version 1.1.1.2, 2000/01/22 14:16:00 |
version 1.1.1.3, 2003/09/15 07:09:26 |
Line 44 static char *RCSid = "$Id$"; |
|
Line 44 static char *RCSid = "$Id$"; |
|
#include "stdfn.h" |
#include "stdfn.h" |
#include "setshow.h" |
#include "setshow.h" |
#include "national.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 |
* global variables to hold status of 'set' options |
* |
* |
Line 187 double x2min = -10.0; |
|
Line 185 double x2min = -10.0; |
|
double x2max = 10.0; |
double x2max = 10.0; |
double y2min = -10.0; |
double y2min = -10.0; |
double y2max = 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 loff = 0.0; |
double roff = 0.0; |
double roff = 0.0; |
double toff = 0.0; |
double toff = 0.0; |
Line 198 int contour_order = 4; |
|
Line 199 int contour_order = 4; |
|
int contour_levels = 5; |
int contour_levels = 5; |
double zero = ZERO; /* zero threshold, not 0! */ |
double zero = ZERO; /* zero threshold, not 0! */ |
int levels_kind = LEVELS_AUTO; |
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_row_fineness = 10; |
int dgrid3d_col_fineness = 10; |
int dgrid3d_col_fineness = 10; |
Line 503 void reset_command() |
|
Line 505 void reset_command() |
|
x2max = 10.0; |
x2max = 10.0; |
y2min = -10.0; |
y2min = -10.0; |
y2max = 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 */ |
memset(range_flags, 0, sizeof(range_flags)); /* all = 0 */ |
|
|
loff = 0.0; |
loff = 0.0; |
Line 611 else if (equals(c_token, STRING)) { AUTO = DTRUE |
|
Line 633 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, MIN)) { AUTO |= 1; ++c_token; } \ |
else if (almost_equals(c_token, MAX)) { AUTO |= 2; ++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")) { |
if (almost_equals(c_token, "ar$row")) { |
c_token++; |
c_token++; |
set_arrow(); |
set_arrow(); |
Line 813 else if (almost_equals(c_token, MAX)) { AUTO |= 2; |
|
Line 839 else if (almost_equals(c_token, MAX)) { AUTO |= 2; |
|
if (!equals(c_token, ",")) |
if (!equals(c_token, ",")) |
int_error("expecting comma to separate discrete levels", c_token); |
int_error("expecting comma to separate discrete levels", c_token); |
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)); |
levels_list[i++] = real(const_express(&a)); |
} |
} |
contour_levels = i; |
contour_levels = i; |
Line 1327 else if (almost_equals(c_token, string)) { \ |
|
Line 1357 else if (almost_equals(c_token, string)) { \ |
|
if (autoscale_t) { |
if (autoscale_t) { |
/* only if user has not set a range manually */ |
/* only if user has not set a range manually */ |
tmin = 0.0; |
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++; |
c_token++; |
Line 1366 else if (almost_equals(c_token, string)) { \ |
|
Line 1396 else if (almost_equals(c_token, string)) { \ |
|
if (polar && autoscale_t) { |
if (polar && autoscale_t) { |
/* set trange if in polar mode and no explicit range */ |
/* set trange if in polar mode and no explicit range */ |
tmin = 0; |
tmin = 0; |
tmax = 2*Pi/ang2rad; |
tmax = 2 * M_PI / ang2rad; |
} |
} |
} |
} |
|
|
|
|
/* to save replicated code, define a macro */ |
/* to save replicated code, define a macro */ |
#define PROCESS_RANGE(AXIS,STRING, MIN, MAX, AUTO) \ |
#define PROCESS_RANGE(AXIS,STRING, MIN, MAX, AUTO) \ |
else if (almost_equals(c_token, STRING)) { \ |
else if (almost_equals(c_token, STRING)) { \ |
if (!equals(++c_token,"[")) int_error("expecting '['",c_token); \ |
if(almost_equals(++c_token,"re$store")) { /* ULIG */ \ |
c_token++; \ |
c_token++; \ |
AUTO = load_range(AXIS,&MIN,&MAX,AUTO); \ |
MIN = get_writeback_min(AXIS); \ |
if (!equals(c_token,"]")) int_error("expecting ']'",c_token); \ |
MAX = get_writeback_max(AXIS); \ |
c_token++; \ |
AUTO = 0; \ |
if (almost_equals(c_token, "rev$erse")) { \ |
} else { \ |
++c_token; range_flags[AXIS] |= RANGE_REVERSE;\ |
if (!equals(c_token,"[")) int_error("expecting '[' or 'restore'",c_token); \ |
} else if (almost_equals(c_token, "norev$erse")) { \ |
c_token++; \ |
++c_token; range_flags[AXIS] &= ~RANGE_REVERSE;\ |
AUTO = load_range(AXIS,&MIN,&MAX,AUTO); \ |
} if (almost_equals(c_token, "wr$iteback")) { \ |
if (!equals(c_token,"]")) int_error("expecting ']'",c_token); \ |
++c_token; range_flags[AXIS] |= RANGE_WRITEBACK;\ |
c_token++; \ |
} else if (almost_equals(c_token, "nowri$teback")) { \ |
if (almost_equals(c_token, "rev$erse")) { \ |
++c_token; range_flags[AXIS] &= ~RANGE_WRITEBACK;\ |
++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) |
PROCESS_RANGE(R_AXIS, "rr$ange", rmin, rmax, autoscale_r) |
Line 2313 static void set_label() |
|
Line 2350 static void set_label() |
|
} else { |
} else { |
/* adding the label */ |
/* adding the label */ |
new_label = (struct text_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) |
if (prev_label != NULL) |
prev_label->next = new_label; /* add it to end of list */ |
prev_label->next = new_label; /* add it to end of list */ |
else |
else |
Line 2404 static void set_arrow() |
|
Line 2441 static void set_arrow() |
|
struct arrow_def *prev_arrow = NULL; |
struct arrow_def *prev_arrow = NULL; |
struct position spos, epos; |
struct position spos, epos; |
struct lp_style_type loc_lp; |
struct lp_style_type loc_lp; |
int axes = FIRST_AXES; |
|
int tag; |
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 */ |
/* Init struct lp_style_type loc_lp */ |
reset_lp_properties (&loc_lp); |
reset_lp_properties (&loc_lp); |
Line 2415 static void set_arrow() |
|
Line 2451 static void set_arrow() |
|
if (!END_OF_COMMAND |
if (!END_OF_COMMAND |
&& !equals(c_token, "from") |
&& !equals(c_token, "from") |
&& !equals(c_token, "to") |
&& !equals(c_token, "to") |
&& !equals(c_token, "first") |
) { |
&& !equals(c_token, "second")) { |
|
/* must be a tag expression! */ |
/* must be a tag expression! */ |
tag = (int) real(const_express(&a)); |
tag = (int) real(const_express(&a)); |
if (tag <= 0) |
if (tag <= 0) |
Line 2424 static void set_arrow() |
|
Line 2459 static void set_arrow() |
|
} else |
} else |
tag = assign_arrow_tag(); /* default next tag */ |
tag = assign_arrow_tag(); /* default next tag */ |
|
|
if (!END_OF_COMMAND && equals(c_token, "first")) { |
/* HBB 20001018: removed code here that accepted 'first' or |
++c_token; |
* 'second' keywords. The resulting variables 'axes' and |
axes = FIRST_AXES; |
* 'set_axes' effected nothing, anyway --> deleted them, too. */ |
set_axes = 1; |
|
} else if (!END_OF_COMMAND && equals(c_token, "second")) { |
|
++c_token; |
|
axes = SECOND_AXES; |
|
set_axes = 1; |
|
} |
|
/* get start position */ |
/* get start position */ |
if (!END_OF_COMMAND && equals(c_token, "from")) { |
if (!END_OF_COMMAND && equals(c_token, "from")) { |
c_token++; |
c_token++; |
Line 2472 static void set_arrow() |
|
Line 2502 static void set_arrow() |
|
get_position(&spos); |
get_position(&spos); |
set_start = TRUE; |
set_start = TRUE; |
} |
} |
|
|
if (!END_OF_COMMAND && equals(c_token, "nohead")) { |
if (!END_OF_COMMAND && equals(c_token, "nohead")) { |
c_token++; |
c_token++; |
head = 0; |
head = 0; |
Line 2512 static void set_arrow() |
|
Line 2543 static void set_arrow() |
|
} else { |
} else { |
/* adding the arrow */ |
/* adding the arrow */ |
new_arrow = (struct arrow_def *) |
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) |
if (prev_arrow != NULL) |
prev_arrow->next = new_arrow; /* add it to end of list */ |
prev_arrow->next = new_arrow; /* add it to end of list */ |
else |
else |
Line 2558 static void set_noarrow() |
|
Line 2589 static void set_noarrow() |
|
|
|
/* assign a new arrow tag */ |
/* assign a new arrow tag */ |
/* arrows are kept sorted by tag number, so this is easy */ |
/* 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; |
struct arrow_def *this_arrow; |
int last = 0; /* previous tag value */ |
int last = 0; /* previous tag value */ |
Line 2637 static void set_linestyle() |
|
Line 2669 static void set_linestyle() |
|
} else { |
} else { |
/* adding the linestyle */ |
/* adding the linestyle */ |
new_linestyle = (struct linestyle_def *) |
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) |
if (prev_linestyle != NULL) |
prev_linestyle->next = new_linestyle; /* add it to end of list */ |
prev_linestyle->next = new_linestyle; /* add it to end of list */ |
else |
else |
Line 2679 static void set_nolinestyle() |
|
Line 2711 static void set_nolinestyle() |
|
|
|
/* assign a new linestyle tag */ |
/* assign a new linestyle tag */ |
/* linestyles are kept sorted by tag number, so this is easy */ |
/* 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; |
struct linestyle_def *this; |
int last = 0; /* previous tag value */ |
int last = 0; /* previous tag value */ |
Line 2746 int tag, pointflag; |
|
Line 2779 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} */ |
register enum PLOT_STYLE ps = LINES; /* HBB: initial value, for 'gcc -W} */ |
|
|
Line 2826 struct ticdef *tdef; |
|
Line 2860 struct ticdef *tdef; |
|
|
|
while (!END_OF_COMMAND) { |
while (!END_OF_COMMAND) { |
/* parse a new ticmark */ |
/* 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) { |
if (tic == (struct ticmark *) NULL) { |
free_marklist(list); |
free_marklist(list); |
int_error("out of memory for tic mark", c_token); |
int_error("out of memory for tic mark", c_token); |
Line 2840 struct ticdef *tdef; |
|
Line 2874 struct ticdef *tdef; |
|
if (isstring(c_token) && |
if (isstring(c_token) && |
(datatype[axis] != TIME || isstring(c_token + 1))) { |
(datatype[axis] != TIME || isstring(c_token + 1))) { |
quote_str(temp_string, c_token, MAX_LINE_LEN); |
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); |
(void) strcpy(tic->label, temp_string); |
c_token++; |
c_token++; |
} else |
} else |
Line 2999 TBOOLEAN autosc; |
|
Line 3033 TBOOLEAN autosc; |
|
if (equals(c_token, "*")) { |
if (equals(c_token, "*")) { |
autosc |= 1; |
autosc |= 1; |
c_token++; |
c_token++; |
|
} else if (equals(c_token, "?")) { /* ULIG */ |
|
*a = get_writeback_min(axis); |
|
autosc &= 2; |
|
c_token++; |
} else { |
} else { |
GET_NUM_OR_TIME(*a, axis); |
GET_NUM_OR_TIME(*a, axis); |
autosc &= 2; |
autosc &= 2; |
Line 3011 TBOOLEAN autosc; |
|
Line 3049 TBOOLEAN autosc; |
|
if (equals(c_token, "*")) { |
if (equals(c_token, "*")) { |
autosc |= 2; |
autosc |= 2; |
c_token++; |
c_token++; |
|
} else if (equals(c_token, "?")) { /* ULIG */ |
|
*b = get_writeback_max(axis); |
|
autosc &= 1; |
|
c_token++; |
} else { |
} else { |
GET_NUM_OR_TIME(*b, axis); |
GET_NUM_OR_TIME(*b, axis); |
autosc &= 1; |
autosc &= 1; |
|
|
#else |
#else |
safe_strncpy(cur_locale, lcl, sizeof(cur_locale)); |
safe_strncpy(cur_locale, lcl, sizeof(cur_locale)); |
#endif /* NO_LOCALE_H */ |
#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); |
} |
} |