#include "gp_axis.h" #include AXIS axis_array[AXIS_ARRAY_SIZE] = AXIS_ARRAY_INITIALIZER(DEFAULT_AXIS_STRUCT); void dummy(){ int k=4; } /*{{{ dbl_raise() used by set_tics */ /* FIXME HBB 20000426: is this really useful? */ static double dbl_raise(x, y) double x; int y; { register int i = abs(y); double val = 1.0; while (--i >= 0) val *= x; if (y < 0) return (1.0 / val); return (val); } /*}}} */ /*{{{ set_tic() */ /* the guide parameter was intended to allow the number of tics * to depend on the relative sizes of the plot and the font. * It is the approximate upper limit on number of tics allowed. * But it did not go down well with the users. * A value of 20 gives the same behaviour as 3.5, so that is * hardwired into the calls to here. Maybe we will restore it * to the automatic calculation one day */ double set_tic(l10, guide) double l10; int guide; { double xnorm, tics, posns; int fl = (int) floor(l10); xnorm = pow(10.0, l10 - fl); /* approx number of decades */ posns = guide / xnorm; /* approx number of tic posns per decade */ if (posns > 40) tics = 0.05; /* eg 0, .05, .10, ... */ else if (posns > 20) tics = 0.1; /* eg 0, .1, .2, ... */ else if (posns > 10) tics = 0.2; /* eg 0,0.2,0.4,... */ else if (posns > 4) tics = 0.5; /* 0,0.5,1, */ else if (posns > 1) tics = 1; /* 0,1,2,.... */ else if (posns > 0.5) tics = 2; /* 0, 2, 4, 6 */ else /* getting desperate... the ceil is to make sure we * go over rather than under - eg plot [-10:10] x*x * gives a range of about 99.999 - tics=xnorm gives * tics at 0, 99.99 and 109.98 - BAD ! * This way, inaccuracy the other way will round * up (eg 0->100.0001 => tics at 0 and 101 * I think latter is better than former */ tics = ceil(xnorm); return (tics * dbl_raise(10.0, fl)); } /* this is used in a few places all over the code: undo logscaling of * a given range if necessary. If checkrange is TRUE, will int_error() if * range is invalid */ void axis_unlog_interval(axis, min, max, checkrange) AXIS_INDEX axis; double *min, *max; TBOOLEAN checkrange; { if (axis_array[axis].log) { if (checkrange && (*min<= 0.0 || *max <= 0.0))printf(" axis_unlog_interval : range must be > 0 !! \n"); /*int_error(NO_CARET, "%s range must be greater than 0 for log scale", axis_defaults[axis].name);*/ *min = (*min<=0) ? -VERYLARGE : AXIS_DO_LOG(axis,*min); *max = (*max<=0) ? -VERYLARGE : AXIS_DO_LOG(axis,*max); } } /*}}} */