=================================================================== RCS file: /home/cvs/OpenXM_contrib/gnuplot/Attic/set.c,v retrieving revision 1.1.1.2 retrieving revision 1.1.1.3 diff -u -p -r1.1.1.2 -r1.1.1.3 --- OpenXM_contrib/gnuplot/Attic/set.c 2000/01/22 14:16:00 1.1.1.2 +++ OpenXM_contrib/gnuplot/Attic/set.c 2003/09/15 07:09:26 1.1.1.3 @@ -1,5 +1,5 @@ #ifndef lint -static char *RCSid = "$Id: set.c,v 1.1.1.2 2000/01/22 14:16:00 maekawa Exp $"; +static char *RCSid = "$Id: set.c,v 1.1.1.3 2003/09/15 07:09:26 ohara Exp $"; #endif /* GNUPLOT - set.c */ @@ -44,10 +44,8 @@ static char *RCSid = "$Id: set.c,v 1.1.1.2 2000/01/22 #include "stdfn.h" #include "setshow.h" #include "national.h" +#include "alloc.h" -#define DEF_FORMAT "%g" /* default format for tic mark labels */ -#define SIGNIF (0.01) /* less than one hundredth of a tic mark */ - /* * global variables to hold status of 'set' options * @@ -187,6 +185,9 @@ double x2min = -10.0; 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; @@ -198,7 +199,8 @@ int contour_order = 4; int contour_levels = 5; double zero = ZERO; /* zero threshold, not 0! */ int levels_kind = LEVELS_AUTO; -double levels_list[MAX_DISCRETE_LEVELS]; /* storage for z levels to draw contours at */ +double *levels_list; /* storage for z levels to draw contours at */ +int max_levels = 0; /* contour level capacity, before enlarging */ int dgrid3d_row_fineness = 10; int dgrid3d_col_fineness = 10; @@ -503,6 +505,26 @@ void reset_command() 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; @@ -611,6 +633,10 @@ else if (equals(c_token, STRING)) { AUTO = DTRUE else if (almost_equals(c_token, MIN)) { AUTO |= 1; ++c_token; } \ else if (almost_equals(c_token, MAX)) { AUTO |= 2; ++c_token; } + if (max_levels == 0) + levels_list = (double *)gp_alloc((max_levels = 5)*sizeof(double), + "contour levels"); + if (almost_equals(c_token, "ar$row")) { c_token++; set_arrow(); @@ -813,6 +839,10 @@ else if (almost_equals(c_token, MAX)) { AUTO |= 2; if (!equals(c_token, ",")) int_error("expecting comma to separate discrete levels", c_token); c_token++; + if (i == max_levels) + levels_list = gp_realloc(levels_list, + (max_levels += 10)*sizeof(double), + "contour levels"); levels_list[i++] = real(const_express(&a)); } contour_levels = i; @@ -1327,7 +1357,7 @@ else if (almost_equals(c_token, string)) { \ if (autoscale_t) { /* only if user has not set a range manually */ tmin = 0.0; - tmax = 2*Pi / ang2rad; /* 360 if degrees, 2pi if radians */ + tmax = 2 * M_PI / ang2rad; /* 360 if degrees, 2pi if radians */ } } c_token++; @@ -1366,7 +1396,7 @@ else if (almost_equals(c_token, string)) { \ if (polar && autoscale_t) { /* set trange if in polar mode and no explicit range */ tmin = 0; - tmax = 2*Pi/ang2rad; + tmax = 2 * M_PI / ang2rad; } } @@ -1912,19 +1942,26 @@ set_three() /* 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) @@ -2313,7 +2350,7 @@ static void set_label() } else { /* adding the label */ new_label = (struct text_label *) - gp_alloc((unsigned long) sizeof(struct text_label), "label"); + gp_alloc(sizeof(struct text_label), "label"); if (prev_label != NULL) prev_label->next = new_label; /* add it to end of list */ else @@ -2404,9 +2441,8 @@ static void set_arrow() struct arrow_def *prev_arrow = NULL; struct position spos, epos; struct lp_style_type loc_lp; - int axes = FIRST_AXES; int tag; - TBOOLEAN set_start, set_end, head = 1, set_axes = 0, set_line = 0; + TBOOLEAN set_start, set_end, head = 1, set_line = 0; /* Init struct lp_style_type loc_lp */ reset_lp_properties (&loc_lp); @@ -2415,8 +2451,7 @@ static void set_arrow() if (!END_OF_COMMAND && !equals(c_token, "from") && !equals(c_token, "to") - && !equals(c_token, "first") - && !equals(c_token, "second")) { + ) { /* must be a tag expression! */ tag = (int) real(const_express(&a)); if (tag <= 0) @@ -2424,15 +2459,10 @@ static void set_arrow() } else tag = assign_arrow_tag(); /* default next tag */ - if (!END_OF_COMMAND && equals(c_token, "first")) { - ++c_token; - axes = FIRST_AXES; - set_axes = 1; - } else if (!END_OF_COMMAND && equals(c_token, "second")) { - ++c_token; - axes = SECOND_AXES; - set_axes = 1; - } + /* HBB 20001018: removed code here that accepted 'first' or + * 'second' keywords. The resulting variables 'axes' and + * 'set_axes' effected nothing, anyway --> deleted them, too. */ + /* get start position */ if (!END_OF_COMMAND && equals(c_token, "from")) { c_token++; @@ -2472,6 +2502,7 @@ static void set_arrow() get_position(&spos); set_start = TRUE; } + if (!END_OF_COMMAND && equals(c_token, "nohead")) { c_token++; head = 0; @@ -2512,7 +2543,7 @@ static void set_arrow() } else { /* adding the arrow */ new_arrow = (struct arrow_def *) - gp_alloc((unsigned long) sizeof(struct arrow_def), "arrow"); + gp_alloc(sizeof(struct arrow_def), "arrow"); if (prev_arrow != NULL) prev_arrow->next = new_arrow; /* add it to end of list */ else @@ -2558,7 +2589,8 @@ static void set_noarrow() /* assign a new arrow tag */ /* arrows are kept sorted by tag number, so this is easy */ -static int /* the lowest unassigned tag number */ assign_arrow_tag() +static int /* the lowest unassigned tag number */ +assign_arrow_tag() { struct arrow_def *this_arrow; int last = 0; /* previous tag value */ @@ -2637,7 +2669,7 @@ static void set_linestyle() } else { /* adding the linestyle */ new_linestyle = (struct linestyle_def *) - gp_alloc((unsigned long) sizeof(struct linestyle_def), "linestyle"); + gp_alloc(sizeof(struct linestyle_def), "linestyle"); if (prev_linestyle != NULL) prev_linestyle->next = new_linestyle; /* add it to end of list */ else @@ -2679,7 +2711,8 @@ static void set_nolinestyle() /* assign a new linestyle tag */ /* linestyles are kept sorted by tag number, so this is easy */ -static int /* the lowest unassigned tag number */ assign_linestyle_tag() +static int /* the lowest unassigned tag number */ +assign_linestyle_tag() { struct linestyle_def *this; int last = 0; /* previous tag value */ @@ -2746,7 +2779,8 @@ int tag, pointflag; /* ======================================================== */ -enum PLOT_STYLE /* not static; used by command.c */ get_style() +enum PLOT_STYLE /* not static; used by command.c */ +get_style() { register enum PLOT_STYLE ps = LINES; /* HBB: initial value, for 'gcc -W} */ @@ -2826,7 +2860,7 @@ struct ticdef *tdef; while (!END_OF_COMMAND) { /* parse a new ticmark */ - tic = (struct ticmark *) gp_alloc((unsigned long) sizeof(struct ticmark), (char *) NULL); + tic = (struct ticmark *) gp_alloc(sizeof(struct ticmark), (char *) NULL); if (tic == (struct ticmark *) NULL) { free_marklist(list); int_error("out of memory for tic mark", c_token); @@ -2840,7 +2874,7 @@ struct ticdef *tdef; if (isstring(c_token) && (datatype[axis] != TIME || isstring(c_token + 1))) { quote_str(temp_string, c_token, MAX_LINE_LEN); - tic->label = gp_alloc((unsigned long) strlen(temp_string) + 1, "tic label"); + tic->label = gp_alloc(strlen(temp_string) + 1, "tic label"); (void) strcpy(tic->label, temp_string); c_token++; } else @@ -2999,6 +3033,10 @@ TBOOLEAN autosc; 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 +3049,10 @@ TBOOLEAN autosc; 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 +3209,85 @@ char *lcl; #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); }