diff -urN gnuplot-3.7.1.orig/docs/gnuplot.doc gnuplot-3.7.1/docs/gnuplot.doc --- gnuplot-3.7.1.orig/docs/gnuplot.doc Wed Oct 27 11:10:16 1999 +++ gnuplot-3.7.1/docs/gnuplot.doc Mon Feb 28 16:56:05 2000 @@ -215,7 +215,8 @@ 14. The `call` command: `load` with arguments. - 15. More flexible `range` commands with `reverse` and `writeback` keywords. + 15. More flexible `range` commands with `reverse`, `writeback` and 'restore' + keywords. 16. `set encoding` for multi-lingual encoding. @@ -5821,13 +5822,16 @@ ?commands show xrange ?set xrange ?show xrange +?writeback +?restore ?xrange The `set xrange` command sets the horizontal range that will be displayed. A similar command exists for each of the other axes, as well as for the polar radius r and the parametric variables t, u, and v. Syntax: - set xrange [{{}:{}}] {{no}reverse} {{no}writeback} + set xrange { [{{}:{}}] {{no}reverse} {{no}writeback} } + | restore show xrange where and terms are constants, expressions or an asterisk to set @@ -5847,12 +5851,13 @@ the buffers that would be filled by `set xrange`. This is useful if you wish to plot several functions together but have the range determined by only some of them. The `writeback` operation is performed during the `plot` - execution, so it must be specified before that command. For example, + execution, so it must be specified before that command. To restore + the last saved horizontal range use `set xrange restore`. For example, set xrange [-10:10] set yrange [] writeback plot sin(x) - set noautoscale y + set yrange restore replot x/2 results in a yrange of [-1:1] as found only from the range of sin(x); the diff -urN gnuplot-3.7.1.orig/plot2d.c gnuplot-3.7.1/plot2d.c --- gnuplot-3.7.1.orig/plot2d.c Mon Oct 11 13:18:56 1999 +++ gnuplot-3.7.1/plot2d.c Mon Feb 28 16:55:40 2000 @@ -1272,17 +1272,6 @@ max_array[FIRST_Y_AXIS] = max_array[SECOND_Y_AXIS]; } -#define WRITEBACK(axis,min,max) \ -if(range_flags[axis]&RANGE_WRITEBACK) \ - {if (auto_array[axis]&1) min = min_array[axis]; \ - if (auto_array[axis]&2) max = max_array[axis]; \ - } - - WRITEBACK(FIRST_X_AXIS, xmin, xmax) - WRITEBACK(FIRST_Y_AXIS, ymin, ymax) - WRITEBACK(SECOND_X_AXIS, x2min, x2max) - WRITEBACK(SECOND_Y_AXIS, y2min, y2max) - if (strcmp(term->name, "table") == 0) print_table(first_plot, plot_num); else { @@ -1292,6 +1281,27 @@ do_plot(first_plot, plot_num); END_LEAK_CHECK(); + + /* after do_plot(), min_array[] and max_array[] + contain the plotting range actually used (rounded + to tic marks, not only the min/max data values) + --> save them now for writeback if requested */ + +#define SAVE_WRITEBACK(axis) /* ULIG */ \ + if(range_flags[axis]&RANGE_WRITEBACK) { \ + set_writeback_min(axis,min_array[axis]); \ + set_writeback_max(axis,max_array[axis]); \ + } + SAVE_WRITEBACK(FIRST_X_AXIS) + SAVE_WRITEBACK(FIRST_Y_AXIS) + SAVE_WRITEBACK(FIRST_Z_AXIS) + SAVE_WRITEBACK(SECOND_X_AXIS) + SAVE_WRITEBACK(SECOND_Y_AXIS) + SAVE_WRITEBACK(SECOND_Z_AXIS) + SAVE_WRITEBACK(T_AXIS) + SAVE_WRITEBACK(R_AXIS) + SAVE_WRITEBACK(U_AXIS) + SAVE_WRITEBACK(V_AXIS) } /* if we get here, all went well, so record this line for replot */ diff -urN gnuplot-3.7.1.orig/plot3d.c gnuplot-3.7.1/plot3d.c --- gnuplot-3.7.1.orig/plot3d.c Thu Dec 10 18:30:52 1998 +++ gnuplot-3.7.1/plot3d.c Mon Feb 28 16:55:45 2000 @@ -1441,7 +1441,28 @@ else { START_LEAK_CHECK(); /* assert no memory leaks here ! */ do_3dplot(first_3dplot, plot_num); - END_LEAK_CHECK(); + END_LEAK_CHECK(); + + /* after do_3dplot(), min_array[] and max_array[] + contain the plotting range actually used (rounded + to tic marks, not only the min/max data values) + --> save them now for writeback if requested */ + +#define SAVE_WRITEBACK(axis) \ + if(range_flags[axis]&RANGE_WRITEBACK) { \ + set_writeback_min(axis,min_array[axis]); \ + set_writeback_max(axis,max_array[axis]); \ + } + SAVE_WRITEBACK(FIRST_X_AXIS) + SAVE_WRITEBACK(FIRST_Y_AXIS) + SAVE_WRITEBACK(FIRST_Z_AXIS) + SAVE_WRITEBACK(SECOND_X_AXIS) + SAVE_WRITEBACK(SECOND_Y_AXIS) + SAVE_WRITEBACK(SECOND_Z_AXIS) + SAVE_WRITEBACK(T_AXIS) + SAVE_WRITEBACK(R_AXIS) + SAVE_WRITEBACK(U_AXIS) + SAVE_WRITEBACK(V_AXIS) } /* if we get here, all went well, so record the line for replot */ diff -urN gnuplot-3.7.1.orig/protos.h gnuplot-3.7.1/protos.h --- gnuplot-3.7.1.orig/protos.h Fri Oct 1 11:37:23 1999 +++ gnuplot-3.7.1/protos.h Mon Feb 28 16:55:57 2000 @@ -334,5 +334,13 @@ void clip_put_text __PROTO((unsigned int x, unsigned int y, char *str)); void clip_put_text_just __PROTO((unsigned int x, unsigned int y, char *str, enum JUSTIFY just)); -#include "alloc.h" +/* Prototypes from file "set.c" */ + +double get_writeback_min __PROTO((int axis)); +double get_writeback_max __PROTO((int axis)); +void set_writeback_min __PROTO((int axis, double val)); +void set_writeback_max __PROTO((int axis, double val)); + + +#include "alloc.h" diff -urN gnuplot-3.7.1.orig/set.c gnuplot-3.7.1/set.c --- gnuplot-3.7.1.orig/set.c Thu Aug 19 15:36:35 1999 +++ gnuplot-3.7.1/set.c Mon Feb 28 16:57:13 2000 @@ -187,6 +187,9 @@ double x2max = 10.0; double y2min = -10.0; double y2max = 10.0; +/* ULIG from plot.h: z y x t z2 y2 x2 r u v */ +double writeback_min[AXIS_ARRAY_SIZE] = {-10.0, -10.0, -10.0, -5.0, -10.0, -10.0, -10.0, -0.0, -5.0, -5.0}; +double writeback_max[AXIS_ARRAY_SIZE] = {+10.0, +10.0, +10.0, +5.0, +10.0, +10.0, +10.0, 10.0, +5.0, +5.0}; double loff = 0.0; double roff = 0.0; double toff = 0.0; @@ -503,6 +506,26 @@ x2max = 10.0; y2min = -10.0; y2max = 10.0; + writeback_min[FIRST_Z_AXIS] = zmin; /* ULIG */ + writeback_max[FIRST_Z_AXIS] = zmax; + writeback_min[FIRST_Y_AXIS] = ymin; + writeback_max[FIRST_Y_AXIS] = ymax; + writeback_min[FIRST_X_AXIS] = xmin; + writeback_max[FIRST_X_AXIS] = xmax; + writeback_min[SECOND_Z_AXIS] = zmin; /* no z2min (see plot.h) */ + writeback_max[SECOND_Z_AXIS] = zmax; /* no z2max */ + writeback_min[SECOND_Y_AXIS] = y2min; + writeback_max[SECOND_Y_AXIS] = y2max; + writeback_min[SECOND_X_AXIS] = x2min; + writeback_max[SECOND_X_AXIS] = x2max; + writeback_min[T_AXIS] = tmin; + writeback_max[T_AXIS] = tmax; + writeback_min[R_AXIS] = rmin; + writeback_max[R_AXIS] = rmax; + writeback_min[U_AXIS] = umin; + writeback_max[U_AXIS] = umax; + writeback_min[V_AXIS] = vmin; + writeback_max[V_AXIS] = vmax; memset(range_flags, 0, sizeof(range_flags)); /* all = 0 */ loff = 0.0; @@ -1912,19 +1935,26 @@ /* to save replicated code, define a macro */ #define PROCESS_RANGE(AXIS,STRING, MIN, MAX, AUTO) \ else if (almost_equals(c_token, STRING)) { \ - if (!equals(++c_token,"[")) int_error("expecting '['",c_token); \ - c_token++; \ - AUTO = load_range(AXIS,&MIN,&MAX,AUTO); \ - if (!equals(c_token,"]")) int_error("expecting ']'",c_token); \ - c_token++; \ - if (almost_equals(c_token, "rev$erse")) { \ - ++c_token; range_flags[AXIS] |= RANGE_REVERSE;\ - } else if (almost_equals(c_token, "norev$erse")) { \ - ++c_token; range_flags[AXIS] &= ~RANGE_REVERSE;\ - } if (almost_equals(c_token, "wr$iteback")) { \ - ++c_token; range_flags[AXIS] |= RANGE_WRITEBACK;\ - } else if (almost_equals(c_token, "nowri$teback")) { \ - ++c_token; range_flags[AXIS] &= ~RANGE_WRITEBACK;\ + if(almost_equals(++c_token,"re$store")) { /* ULIG */ \ + c_token++; \ + MIN = get_writeback_min(AXIS); \ + MAX = get_writeback_max(AXIS); \ + AUTO = 0; \ + } else { \ + if (!equals(c_token,"[")) int_error("expecting '[' or 'restore'",c_token); \ + c_token++; \ + AUTO = load_range(AXIS,&MIN,&MAX,AUTO); \ + if (!equals(c_token,"]")) int_error("expecting ']'",c_token); \ + c_token++; \ + if (almost_equals(c_token, "rev$erse")) { \ + ++c_token; range_flags[AXIS] |= RANGE_REVERSE;\ + } else if (almost_equals(c_token, "norev$erse")) { \ + ++c_token; range_flags[AXIS] &= ~RANGE_REVERSE;\ + } if (almost_equals(c_token, "wr$iteback")) { \ + ++c_token; range_flags[AXIS] |= RANGE_WRITEBACK;\ + } else if (almost_equals(c_token, "nowri$teback")) { \ + ++c_token; range_flags[AXIS] &= ~RANGE_WRITEBACK;\ + } \ }} PROCESS_RANGE(R_AXIS, "rr$ange", rmin, rmax, autoscale_r) @@ -2999,6 +3029,10 @@ if (equals(c_token, "*")) { autosc |= 1; c_token++; + } else if (equals(c_token, "?")) { /* ULIG */ + *a = get_writeback_min(axis); + autosc &= 2; + c_token++; } else { GET_NUM_OR_TIME(*a, axis); autosc &= 2; @@ -3011,6 +3045,10 @@ if (equals(c_token, "*")) { autosc |= 2; c_token++; + } else if (equals(c_token, "?")) { /* ULIG */ + *b = get_writeback_max(axis); + autosc &= 1; + c_token++; } else { GET_NUM_OR_TIME(*b, axis); autosc &= 1; @@ -3167,4 +3205,85 @@ #else safe_strncpy(cur_locale, lcl, sizeof(cur_locale)); #endif /* NO_LOCALE_H */ +} + + +/* + * get and set routines for range writeback + * ULIG * + */ + +double rm_log(int axis, double val); + + +double get_writeback_min(axis) +int axis; +{ + /* printf("get min(%d)=%g\n",axis,writeback_min[axis]); */ + return writeback_min[axis]; +} + +double get_writeback_max(axis) +int axis; +{ + /* printf("get max(%d)=%g\n",axis,writeback_min[axis]); */ + return writeback_max[axis]; +} + + +void set_writeback_min(axis, val) +int axis; +double val; +{ + val = rm_log(axis,val); + /* printf("set min(%d)=%g\n",axis,val); */ + writeback_min[axis] = val; +} + +void set_writeback_max(axis, val) +int axis; +double val; +{ + val = rm_log(axis,val); + /* printf("set max(%d)=%g\n",axis,val); */ + writeback_max[axis] = val; +} + +double rm_log(axis, val) +int axis; +double val; +{ + TBOOLEAN islog; + double logbase; + + /* check whether value is in logscale */ + switch( axis ) { + case FIRST_X_AXIS: + logbase = base_log_x; + islog = is_log_x; + break; + case FIRST_Y_AXIS: + logbase = base_log_y; + islog = is_log_y; + break; + case FIRST_Z_AXIS: + logbase = base_log_z; + islog = is_log_z; + break; + case SECOND_X_AXIS: + logbase = base_log_x2; + islog = is_log_x2; + break; + case SECOND_Y_AXIS: + logbase = base_log_y2; + islog = is_log_y2; + break; + default: + islog = FALSE; + } + + if( ! islog ) return val; + + /* remove logscale from value */ + return pow(logbase,val); }