|
From: <jun...@so...> - 2006-04-07 17:34:56
|
The ratio-corrected box is seemed be centerd on the page. This change looks good for ploting just one graph, but it becomses practically impossible to put some ratio-corrected graphs on the positions which I want. Thus, I made some patches to controll this centering behavior by using the sign of the ysize. There may be some problem, but please check. Jun *** gadgets.c.org Sat Apr 8 02:20:01 2006 --- gadgets.c Sat Apr 8 02:21:02 2006 *************** *** 75,80 **** --- 75,81 ---- float xoffset = 0.0; /* x origin */ float yoffset = 0.0; /* y origin */ float aspect_ratio = 0.0; /* don't attempt to force it */ + TBOOLEAN centering_in_ratio = TRUE; /* centering in ratio plot */ /* space between left edge and plot_bounds.xleft in chars (-1: computed) */ float lmargin = -1; *** gadgets.h.org Sat Apr 8 02:21:51 2006 --- gadgets.h Sat Apr 8 02:22:12 2006 *************** *** 304,310 **** extern float xoffset; /* x origin setting */ extern float yoffset; /* y origin setting */ extern float aspect_ratio; /* 1.0 for square */ ! /* plot border autosizing overrides, in characters (-1: autosize) */ extern float lmargin, bmargin, rmargin, tmargin; --- 304,310 ---- extern float xoffset; /* x origin setting */ extern float yoffset; /* y origin setting */ extern float aspect_ratio; /* 1.0 for square */ ! extern TBOOLEAN centering_in_ratio; /* TRUE */ /* plot border autosizing overrides, in characters (-1: autosize) */ extern float lmargin, bmargin, rmargin, tmargin; *** set.c.org Sat Apr 8 02:20:08 2006 --- set.c Sat Apr 8 02:21:15 2006 *************** *** 3468,3476 **** } } } ! if (xsize <= 0 || ysize <=0) { xsize = ysize = 1.0; int_error(NO_CARET,"Illegal value for size"); } } --- 3468,3485 ---- } } } ! if ((aspect_ratio ==0.0) && (xsize <= 0 || ysize <=0)) { xsize = ysize = 1.0; int_error(NO_CARET,"Illegal value for size"); + } else if ( xsize == 0.0 || ysize == 0.0 ) { + xsize = ysize = 1.0; + centering_in_ratio = TRUE; + int_error(NO_CARET,"Illegal value for size"); + } else if ( ysize > 0 ) { + centering_in_ratio = TRUE; + } else if ( ysize < 0 ) { + ysize = -ysize; + centering_in_ratio = FALSE; } } *** graphics.c.org Sat Apr 8 02:20:15 2006 --- graphics.c Sat Apr 8 02:21:20 2006 *************** *** 899,910 **** --- 899,915 ---- if (current > required) { /* too tall */ + if (centering_in_ratio) { + /* centering */ int height = plot_bounds.ytop - plot_bounds.ybot; plot_bounds.ytop = plot_bounds.ybot + required * (plot_bounds.xright - plot_bounds.xleft); height -= (plot_bounds.ytop - plot_bounds.ybot); height /= 2; plot_bounds.ytop += height; plot_bounds.ybot += height; + } else { + plot_bounds.ytop = plot_bounds.ybot + required * (plot_bounds.xright - plot_bounds.xleft); + } } else { int width = plot_bounds.xright - plot_bounds.xleft; plot_bounds.xright = plot_bounds.xleft + (plot_bounds.ytop - plot_bounds.ybot) / required; |