home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / Gnuplot / Source / setshow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-02  |  73.6 KB  |  3,008 lines

  1. static char *RCSid = "$Id: setshow.c%v 3.38.2.74 1993/02/19 00:57:30 woo Exp woo $";
  2.  
  3.  
  4. /* GNUPLOT - setshow.c */
  5. /*
  6.  * Copyright (C) 1986 - 1993   Thomas Williams, Colin Kelley
  7.  *
  8.  * Permission to use, copy, and distribute this software and its
  9.  * documentation for any purpose with or without fee is hereby granted, 
  10.  * provided that the above copyright notice appear in all copies and 
  11.  * that both that copyright notice and this permission notice appear 
  12.  * in supporting documentation.
  13.  *
  14.  * Permission to modify the software is granted, but not the right to
  15.  * distribute the modified code.  Modifications are to be distributed 
  16.  * as patches to released version.
  17.  *  
  18.  * This software is provided "as is" without express or implied warranty.
  19.  * 
  20.  *
  21.  * AUTHORS
  22.  * 
  23.  *   Original Software:
  24.  *     Thomas Williams,  Colin Kelley.
  25.  * 
  26.  *   Gnuplot 2.0 additions:
  27.  *       Russell Lang, Dave Kotz, John Campbell.
  28.  *
  29.  *   Gnuplot 3.0 additions:
  30.  *       Gershon Elber and many others.
  31.  *
  32.  * 19 September 1992  Lawrence Crowl  (crowl@cs.orst.edu)
  33.  * Added user-specified bases for log scaling.
  34.  * 
  35.  * Send your comments or suggestions to 
  36.  *  info-gnuplot@dartmouth.edu.
  37.  * This is a mailing list; to join it send a note to 
  38.  *  info-gnuplot-request@dartmouth.edu.  
  39.  * Send bug reports to
  40.  *  bug-gnuplot@dartmouth.edu.
  41.  */
  42.  
  43. #include <stdio.h>
  44. #include <math.h>
  45. #include "plot.h"
  46. #include "setshow.h"
  47.  
  48. #define DEF_FORMAT   "%g"    /* default format for tic mark labels */
  49. #define SIGNIF (0.01)        /* less than one hundredth of a tic mark */
  50.  
  51. /*
  52.  * global variables to hold status of 'set' options
  53.  *
  54.  */
  55. TBOOLEAN            autoscale_r    = TRUE;
  56. TBOOLEAN            autoscale_t    = TRUE;
  57. TBOOLEAN            autoscale_u    = TRUE;
  58. TBOOLEAN            autoscale_v    = TRUE;
  59. TBOOLEAN            autoscale_x    = TRUE;
  60. TBOOLEAN            autoscale_y    = TRUE;
  61. TBOOLEAN            autoscale_z    = TRUE;
  62. TBOOLEAN            autoscale_lt    = TRUE;
  63. TBOOLEAN            autoscale_lu    = TRUE;
  64. TBOOLEAN            autoscale_lv    = TRUE;
  65. TBOOLEAN            autoscale_lx    = TRUE;
  66. TBOOLEAN            autoscale_ly    = TRUE;
  67. TBOOLEAN            autoscale_lz    = TRUE;
  68. double            boxwidth = -1.0; /* box width (automatic) */
  69. TBOOLEAN           clip_points    = FALSE;
  70. TBOOLEAN           clip_lines1    = TRUE;
  71. TBOOLEAN           clip_lines2    = FALSE;
  72. TBOOLEAN            draw_border    = TRUE;
  73. TBOOLEAN            draw_surface    = TRUE;
  74. TBOOLEAN            timedate    = FALSE;
  75. char            dummy_var[MAX_NUM_VAR][MAX_ID_LEN+1] = { "x", "y" };
  76. char            xformat[MAX_ID_LEN+1] = DEF_FORMAT;
  77. char            yformat[MAX_ID_LEN+1] = DEF_FORMAT;
  78. char            zformat[MAX_ID_LEN+1] = DEF_FORMAT;
  79. enum            PLOT_STYLE data_style    = POINTSTYLE,
  80.             func_style    = LINES;
  81. TBOOLEAN            grid        = FALSE;
  82. int                key            = -1;    /* default position */
  83. double            key_x, key_y, key_z;    /* user specified position for key */
  84. TBOOLEAN            is_log_x    = FALSE,
  85.             is_log_y    = FALSE,
  86.             is_log_z    = FALSE;
  87. double            base_log_x    = 0.0,
  88.             base_log_y    = 0.0,
  89.             base_log_z    = 0.0;
  90. double            log_base_log_x    = 0.0,
  91.             log_base_log_y    = 0.0,
  92.             log_base_log_z    = 0.0;
  93. FILE*            outfile;
  94. char            outstr[MAX_ID_LEN+1] = "STDOUT";
  95. TBOOLEAN            parametric    = FALSE;
  96. TBOOLEAN            polar        = FALSE;
  97. TBOOLEAN            hidden3d    = FALSE;
  98. TBOOLEAN            label_contours    = TRUE; /* different linestyles are used for contours when set */
  99. int            angles_format    = ANGLES_RADIANS;
  100. int            mapping3d    = MAP3D_CARTESIAN;
  101. int            samples        = SAMPLES; /* samples is always equal to samples_1 */
  102. int            samples_1    = SAMPLES;
  103. int            samples_2    = SAMPLES;
  104. int            iso_samples_1    = ISO_SAMPLES;
  105. int            iso_samples_2    = ISO_SAMPLES;
  106. float            xsize        = 1.0;  /* scale factor for size */
  107. float            ysize        = 1.0;  /* scale factor for size */
  108. float            zsize        = 1.0;  /* scale factor for size */
  109. float            surface_rot_z   = 30.0; /* Default 3d transform. */
  110. float            surface_rot_x   = 60.0;
  111. float            surface_scale   = 1.0;
  112. float            surface_zscale  = 1.0;
  113. int            term        = 0;        /* unknown term is 0 */
  114. char            term_options[MAX_LINE_LEN+1] = "";
  115. char            title[MAX_LINE_LEN+1] = "";
  116. char            xlabel[MAX_LINE_LEN+1] = "";
  117. char            ylabel[MAX_LINE_LEN+1] = "";
  118. char            zlabel[MAX_LINE_LEN+1] = "";
  119. int            time_xoffset    = 0;
  120. int            time_yoffset    = 0;
  121. int            title_xoffset    = 0;
  122. int            title_yoffset    = 0;
  123. int            xlabel_xoffset    = 0;
  124. int            xlabel_yoffset    = 0;
  125. int            ylabel_xoffset    = 0;
  126. int            ylabel_yoffset    = 0;
  127. int            zlabel_xoffset    = 0;
  128. int            zlabel_yoffset    = 0;
  129. double            rmin        = -0.0,
  130.             rmax        =  10.0,
  131.             tmin        = -5.0,
  132.             tmax        =  5.0,
  133.             umin        = -5.0,
  134.             umax        = 5.0,
  135.             vmin        = -5.0,
  136.             vmax        = 5.0,
  137.             xmin        = -10.0,
  138.             xmax        = 10.0,
  139.             ymin        = -10.0,
  140.             ymax        = 10.0,
  141.             zmin        = -10.0,
  142.             zmax        = 10.0;
  143. double            loff        = 0.0,
  144.             roff        = 0.0,
  145.             toff        = 0.0,
  146.             boff        = 0.0;
  147. int            draw_contour    = CONTOUR_NONE;
  148. int            contour_pts    = 5;
  149. int            contour_kind    = CONTOUR_KIND_LINEAR;
  150. int            contour_order    = 4;
  151. int            contour_levels    = 5;
  152. double            zero = ZERO;            /* zero threshold, not 0! */
  153. int            levels_kind = LEVELS_AUTO;
  154. double        levels_list[MAX_DISCRETE_LEVELS];  /* storage for z levels to draw contours at */
  155.  
  156. int            dgrid3d_row_fineness = 10;
  157. int            dgrid3d_col_fineness = 10;
  158. int            dgrid3d_norm_value = 1;
  159. TBOOLEAN            dgrid3d = FALSE;
  160.  
  161. TBOOLEAN xzeroaxis = TRUE;
  162. TBOOLEAN yzeroaxis = TRUE;
  163.  
  164. TBOOLEAN xtics = TRUE;
  165. TBOOLEAN ytics = TRUE;
  166. TBOOLEAN ztics = TRUE;
  167.  
  168. float ticslevel = 0.5;
  169.  
  170. struct ticdef xticdef = {TIC_COMPUTED};
  171. struct ticdef yticdef = {TIC_COMPUTED};
  172. struct ticdef zticdef = {TIC_COMPUTED};
  173.  
  174. TBOOLEAN            tic_in        = TRUE;
  175.  
  176. struct text_label *first_label = NULL;
  177. struct arrow_def *first_arrow = NULL;
  178.  
  179. /*** other things we need *****/
  180. #ifdef _Windows
  181. #include <string.h>
  182. #else
  183. #if !defined(ATARI) && !defined (AMIGA_SC_6_1)
  184. extern char *strcpy(),*strcat();
  185. extern int strlen();
  186. #endif
  187. #endif
  188.  
  189. #if defined(unix) || defined(PIPES)
  190. extern FILE *popen();
  191. #endif
  192.  
  193. /* input data, parsing variables */
  194. extern struct lexical_unit token[];
  195. extern char input_line[];
  196. extern int num_tokens, c_token;
  197. extern TBOOLEAN interactive;    /* from plot.c */
  198.  
  199. extern char replot_line[];
  200. extern struct udvt_entry *first_udv;
  201. extern TBOOLEAN is_3d_plot;
  202.  
  203. extern double magnitude(),real();
  204. extern struct value *const_express();
  205.  
  206. #ifdef _Windows
  207. extern FILE * open_printer();
  208. extern void close_printer();
  209. #endif
  210.  
  211. /******** Local functions ********/
  212. static void set_xyzlabel();
  213. static void set_label();
  214. static void set_nolabel();
  215. static void set_arrow();
  216. static void set_noarrow();
  217. static void load_tics();
  218. static void load_tic_user();
  219. static void free_marklist();
  220. static void load_tic_series();
  221. static void load_offsets();
  222.  
  223. static void show_style(), show_range(), show_zero(), show_border(), show_dgrid3d();
  224. static void show_offsets(), show_output(), show_samples(), show_isosamples();
  225. static void show_view(), show_size(), show_title(), show_xlabel();
  226. static void show_angles(), show_boxwidth();
  227. static void show_ylabel(), show_zlabel(), show_xzeroaxis(), show_yzeroaxis();
  228. static void show_label(), show_arrow(), show_grid(), show_key();
  229. static void show_polar(), show_parametric(), show_tics(), show_ticdef();
  230. static void show_time(), show_term(), show_plot(), show_autoscale(), show_clip();
  231. static void show_contour(), show_mapping(), show_format(), show_logscale();
  232. static void show_variables(), show_surface(), show_hidden3d(), show_label_contours();
  233. static void delete_label();
  234. static int assign_label_tag();
  235. static void delete_arrow();
  236. static int assign_arrow_tag();
  237. static TBOOLEAN set_one(), set_two(), set_three();
  238. static TBOOLEAN show_one(), show_two();
  239.  
  240. /******** The 'set' command ********/
  241. void
  242. set_command()
  243. {
  244.     c_token++;
  245.  
  246.     if (!set_one() && !set_two() && !set_three())
  247.     int_error(
  248.     "valid set options:  'angles' '{no}arrow', {no}autoscale', \n\
  249.     '{no}border', 'boxwidth', '{no}clabel', '{no}clip', 'cntrparam', \n\
  250.         '{no}contour', 'data style', '{no}dgrid3d', 'dummy', 'format', \n\
  251.         'function style', '{no}grid', '{no}hidden3d', 'isosamples', '{no}key', \n\
  252.     '{no}label', '{no}logscale', 'mapping', 'offsets', 'output', \n\
  253.     '{no}parametric', '{no}polar', 'rrange', 'samples', 'size', \n\
  254.     '{no}surface', 'terminal', 'tics', 'ticslevel', '{no}time', 'title', \n\
  255.     'trange', 'urange', 'view', 'vrange', 'xlabel', 'xrange', '{no}xtics', \n\
  256.     'xmtics', 'xdtics', '{no}xzeroaxis', 'ylabel', 'yrange', '{no}ytics', \n\
  257.     'ymtics', 'ydtics', '{no}yzeroaxis', 'zero', '{no}zeroaxis', 'zlabel', \n\
  258.     'zrange', '{no}ztics', 'zmtics', 'zdtics'", c_token);
  259. }
  260.  
  261. /* return TRUE if a command match, FALSE if not */
  262. static TBOOLEAN
  263. set_one()
  264. {
  265.     if (almost_equals(c_token,"ar$row")) {
  266.         c_token++;
  267.         set_arrow();
  268.     }
  269.     else if (almost_equals(c_token,"noar$row")) {
  270.         c_token++;
  271.         set_noarrow();
  272.     }
  273.      else if (almost_equals(c_token,"au$toscale")) {
  274.         c_token++;
  275.         if (END_OF_COMMAND) {
  276.            autoscale_r=autoscale_t = autoscale_x = autoscale_y = autoscale_z = TRUE;
  277.         } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
  278.            autoscale_x = autoscale_y = TRUE;
  279.            c_token++;
  280.         } else if (equals(c_token, "r")) {
  281.            autoscale_r = TRUE;
  282.            c_token++;
  283.         } else if (equals(c_token, "t")) {
  284.            autoscale_t = TRUE;
  285.            c_token++;
  286.         } else if (equals(c_token, "x")) {
  287.            autoscale_x = TRUE;
  288.            c_token++;
  289.         } else if (equals(c_token, "y")) {
  290.            autoscale_y = TRUE;
  291.            c_token++;
  292.         } else if (equals(c_token, "z")) {
  293.            autoscale_z = TRUE;
  294.            c_token++;
  295.         }
  296.     } 
  297.     else if (almost_equals(c_token,"noau$toscale")) {
  298.         c_token++;
  299.         if (END_OF_COMMAND) {
  300.            autoscale_r=autoscale_t = autoscale_x = autoscale_y = autoscale_z = FALSE;
  301.         } else if (equals(c_token, "xy") || equals(c_token, "tyx")) {
  302.            autoscale_x = autoscale_y = FALSE;
  303.            c_token++;
  304.         } else if (equals(c_token, "r")) {
  305.            autoscale_r = FALSE;
  306.            c_token++;
  307.         } else if (equals(c_token, "t")) {
  308.            autoscale_t = FALSE;
  309.            c_token++;
  310.         } else if (equals(c_token, "x")) {
  311.            autoscale_x = FALSE;
  312.            c_token++;
  313.         } else if (equals(c_token, "y")) {
  314.            autoscale_y = FALSE;
  315.            c_token++;
  316.         } else if (equals(c_token, "z")) {
  317.            autoscale_z = FALSE;
  318.            c_token++;
  319.         }
  320.     } 
  321.     else if (almost_equals(c_token,"bor$der")) {
  322.         draw_border = TRUE;
  323.         c_token++;
  324.     }
  325.     else if (almost_equals(c_token,"nobor$der")) {
  326.         draw_border = FALSE;
  327.         c_token++;
  328.     }
  329.     else if (almost_equals(c_token,"box$width")) {
  330.         struct value a;
  331.         c_token++;
  332.         if (END_OF_COMMAND)
  333.             boxwidth = -1.0;
  334.         else
  335.             boxwidth = magnitude(const_express(&a));
  336.     }
  337.     else if (almost_equals(c_token,"c$lip")) {
  338.         c_token++;
  339.         if (END_OF_COMMAND)
  340.          /* assuming same as points */
  341.          clip_points = TRUE;
  342.         else if (almost_equals(c_token, "p$oints"))
  343.          clip_points = TRUE;
  344.         else if (almost_equals(c_token, "o$ne"))
  345.          clip_lines1 = TRUE;
  346.         else if (almost_equals(c_token, "t$wo"))
  347.          clip_lines2 = TRUE;
  348.         else
  349.          int_error("expecting 'points', 'one', or 'two'", c_token);
  350.         c_token++;
  351.     }
  352.     else if (almost_equals(c_token,"noc$lip")) {
  353.         c_token++;
  354.         if (END_OF_COMMAND) {
  355.            /* same as all three */
  356.            clip_points = FALSE;
  357.            clip_lines1 = FALSE;
  358.            clip_lines2 = FALSE;
  359.         } else if (almost_equals(c_token, "p$oints"))
  360.          clip_points = FALSE;
  361.         else if (almost_equals(c_token, "o$ne"))
  362.          clip_lines1 = FALSE;
  363.         else if (almost_equals(c_token, "t$wo"))
  364.          clip_lines2 = FALSE;
  365.         else
  366.          int_error("expecting 'points', 'one', or 'two'", c_token);
  367.         c_token++;
  368.     }
  369.     else if (almost_equals(c_token,"hi$dden3d")) {
  370. #ifdef LITE
  371.         printf(" Hidden Line Removal Not Supported in LITE version\n");
  372. #else
  373.         hidden3d = TRUE;
  374. #endif /* LITE */
  375.         c_token++;
  376.     }
  377.     else if (almost_equals(c_token,"nohi$dden3d")) {
  378. #ifdef LITE
  379.         printf(" Hidden Line Removal Not Supported in LITE version\n");
  380. #else
  381.         hidden3d = FALSE;
  382. #endif /* LITE */
  383.         c_token++;
  384.     }
  385.      else if (almost_equals(c_token,"cla$bel")) {
  386.          label_contours = TRUE;
  387.          c_token++;
  388.      }
  389.      else if (almost_equals(c_token,"nocla$bel")) {
  390.          label_contours = FALSE;
  391.          c_token++;
  392.       }
  393.     else if (almost_equals(c_token,"ma$pping3d")) {
  394.         c_token++;
  395.         if (END_OF_COMMAND)
  396.          /* assuming same as points */
  397.          mapping3d = MAP3D_CARTESIAN;
  398.         else if (almost_equals(c_token, "ca$rtesian"))
  399.          mapping3d = MAP3D_CARTESIAN;
  400.         else if (almost_equals(c_token, "s$pherical"))
  401.          mapping3d = MAP3D_SPHERICAL;
  402.         else if (almost_equals(c_token, "cy$lindrical"))
  403.          mapping3d = MAP3D_CYLINDRICAL;
  404.         else
  405.          int_error("expecting 'cartesian', 'spherical', or 'cylindrical'", c_token);
  406.         c_token++;
  407.     }
  408.     else if (almost_equals(c_token,"co$ntour")) {
  409.         c_token++;
  410.         if (END_OF_COMMAND)
  411.          /* assuming same as points */
  412.          draw_contour = CONTOUR_BASE;
  413.         else if (almost_equals(c_token, "ba$se"))
  414.          draw_contour = CONTOUR_BASE;
  415.         else if (almost_equals(c_token, "s$urface"))
  416.          draw_contour = CONTOUR_SRF;
  417.         else if (almost_equals(c_token, "bo$th"))
  418.          draw_contour = CONTOUR_BOTH;
  419.         else
  420.          int_error("expecting 'base', 'surface', or 'both'", c_token);
  421.         c_token++;
  422.     }
  423.     else if (almost_equals(c_token,"noco$ntour")) {
  424.         c_token++;
  425.         draw_contour = CONTOUR_NONE;
  426.     }
  427.     else if (almost_equals(c_token,"cntrp$aram")) {
  428.         struct value a;
  429.  
  430.         c_token++;
  431.         if (END_OF_COMMAND) {
  432.          /* assuming same as defaults */
  433.          contour_pts = 5;
  434.          contour_kind = CONTOUR_KIND_LINEAR;
  435.          contour_order = 4;
  436.          contour_levels = 5;
  437.           levels_kind = LEVELS_AUTO;
  438.         }
  439.         else if (almost_equals(c_token, "p$oints")) {
  440.          c_token++;
  441.          contour_pts = (int) real(const_express(&a));
  442.         }
  443.         else if (almost_equals(c_token, "li$near")) {
  444.          c_token++;
  445.          contour_kind = CONTOUR_KIND_LINEAR;
  446.         }
  447.         else if (almost_equals(c_token, "c$ubicspline")) {
  448.          c_token++;
  449.          contour_kind = CONTOUR_KIND_CUBIC_SPL;
  450.         }
  451.         else if (almost_equals(c_token, "b$spline")) {
  452.          c_token++;
  453.          contour_kind = CONTOUR_KIND_BSPLINE;
  454.         }
  455.  
  456.            else if (almost_equals(c_token, "le$vels")) {
  457.                int i=0;  /* local counter */
  458.                c_token++;
  459.             /*  RKC: I have modified the next two:
  460.              *   to use commas to separate list elements as in xtics
  461.               *   so that incremental lists start,incr[,end]as in "
  462.               */
  463.                if (almost_equals(c_token, "di$screte")) {
  464.                   levels_kind = LEVELS_DISCRETE;
  465.                   c_token++;
  466.                 if(END_OF_COMMAND)
  467.                  int_error("expecting discrete level", c_token);
  468.                 else
  469.                   levels_list[i++] = real(const_express(&a));
  470.                 while(!END_OF_COMMAND){
  471.                   if (!equals(c_token, ","))
  472.                     int_error("expecting comma to separate discrete levels", c_token);
  473.                   c_token++;
  474.                   levels_list[i++] =  real(const_express(&a));
  475.                 }
  476.                   contour_levels = i;
  477.                }
  478.                else if (almost_equals(c_token, "in$cremental")) {
  479.                   levels_kind = LEVELS_INCREMENTAL;
  480.                   c_token++;
  481.                 levels_list[i++] =  real(const_express(&a));
  482.                 if (!equals(c_token, ","))
  483.                   int_error("expecting comma to separate start,incr levels", c_token);
  484.                 c_token++;
  485.                 if((levels_list[i++] = real(const_express(&a)))==0)
  486.                   int_error("increment cannot be 0", c_token);
  487.                  if(!END_OF_COMMAND){
  488.                   if (!equals(c_token, ","))
  489.                     int_error("expecting comma to separate incr,stop levels", c_token);
  490.                   c_token++;
  491.                   contour_levels = real(const_express(&a));
  492.                   contour_levels = (contour_levels-levels_list[0])/levels_list[1];
  493.                 }
  494.                }
  495.                else if (almost_equals(c_token, "au$to")) {
  496.                    levels_kind = LEVELS_AUTO;
  497.                  c_token++;
  498.                  if(!END_OF_COMMAND)
  499.                      contour_levels = (int) real(const_express(&a));
  500.              }
  501.              else {
  502.               if(levels_kind == LEVELS_DISCRETE)
  503.                 int_error("Levels type is discrete, ignoring new number of contour levels", c_token);
  504.                 contour_levels = (int) real(const_express(&a));
  505.             }
  506.          }
  507.         else if (almost_equals(c_token, "o$rder")) {
  508.          int order;
  509.          c_token++;
  510.          order = (int) real(const_express(&a));
  511.          if ( order < 2 || order > 10 )
  512.              int_error("bspline order must be in [2..10] range.", c_token);
  513.          contour_order = order;
  514.         }
  515.         else
  516.          int_error("expecting 'linear', 'cubicspline', 'bspline', 'points', 'levels' or 'order'", c_token);
  517.         c_token++;
  518.     }
  519.     else if (almost_equals(c_token,"da$ta")) {
  520.         c_token++;
  521.         if (!almost_equals(c_token,"s$tyle"))
  522.             int_error("expecting keyword 'style'",c_token);
  523.         data_style = get_style();
  524.     }
  525.     else if (almost_equals(c_token,"dg$rid3d")) {
  526.         int i;
  527.         TBOOLEAN was_comma = TRUE;
  528.         int local_vals[3];
  529.         struct value a;
  530.  
  531.         local_vals[0] = dgrid3d_row_fineness;
  532.         local_vals[1] = dgrid3d_col_fineness;
  533.         local_vals[2] = dgrid3d_norm_value;
  534.         c_token++;
  535.         for (i = 0; i < 3 && !(END_OF_COMMAND);) {
  536.             if (equals(c_token,",")) {
  537.                 if (was_comma) i++;
  538.                 was_comma = TRUE;
  539.                 c_token++;
  540.             }
  541.             else {
  542.                 if (!was_comma)
  543.                     int_error("',' expected",c_token);
  544.                 local_vals[i] = real(const_express(&a));
  545.                 i++;
  546.                 was_comma = FALSE;
  547.             }
  548.         }
  549.  
  550.  
  551.         if (local_vals[0] < 2 || local_vals[0] > 1000)
  552.             int_error("Row size must be in [2:1000] range; size unchanged",
  553.                   c_token);
  554.         if (local_vals[1] < 2 || local_vals[1] > 1000)
  555.             int_error("Col size must be in [2:1000] range; size unchanged",
  556.                   c_token);
  557.         if (local_vals[2] < 1 || local_vals[2] > 100)
  558.             int_error("Norm must be in [1:100] range; norm unchanged", c_token);
  559.  
  560.         dgrid3d_row_fineness = local_vals[0];
  561.         dgrid3d_col_fineness = local_vals[1];
  562.         dgrid3d_norm_value = local_vals[2];
  563.         dgrid3d = TRUE;
  564.     }
  565.     else if (almost_equals(c_token,"nodg$rid3d")) {
  566.         c_token++;
  567.         dgrid3d = FALSE;
  568.     }
  569.     else if (almost_equals(c_token,"du$mmy")) {
  570.         c_token++;
  571.         if (END_OF_COMMAND)
  572.             int_error("expecting dummy variable name", c_token);
  573.         else {
  574.             if (!equals(c_token,","))
  575.                 copy_str(dummy_var[0],c_token++);
  576.             if (!END_OF_COMMAND && equals(c_token,",")) {
  577.                 c_token++;
  578.                 if (END_OF_COMMAND)
  579.                     int_error("expecting second dummy variable name", c_token);
  580.                 copy_str(dummy_var[1],c_token++);
  581.                 }
  582.         }
  583.     }
  584.     else if (almost_equals(c_token,"fo$rmat")) {
  585.         TBOOLEAN setx, sety, setz;
  586.         c_token++;
  587.         if (equals(c_token,"x")) {
  588.             setx = TRUE; sety = setz = FALSE;
  589.             c_token++;
  590.         }
  591.         else if (equals(c_token,"y")) {
  592.             setx = setz = FALSE; sety = TRUE;
  593.             c_token++;
  594.         }
  595.         else if (equals(c_token,"z")) {
  596.             setx = sety = FALSE; setz = TRUE;
  597.             c_token++;
  598.         }
  599.         else if (equals(c_token,"xy") || equals(c_token,"yx")) {
  600.             setx = sety = TRUE; setz = FALSE;
  601.             c_token++;
  602.         }
  603.         else if (isstring(c_token) || END_OF_COMMAND) {
  604.             /* Assume he wants all */
  605.             setx = sety = setz = TRUE;
  606.         }
  607.         if (END_OF_COMMAND) {
  608.             if (setx)
  609.                 (void) strcpy(xformat,DEF_FORMAT);
  610.             if (sety)
  611.                 (void) strcpy(yformat,DEF_FORMAT);
  612.             if (setz)
  613.                 (void) strcpy(zformat,DEF_FORMAT);
  614.         }
  615.         else {
  616.             if (!isstring(c_token))
  617.               int_error("expecting format string",c_token);
  618.             else {
  619.                 if (setx)
  620.                  quote_str(xformat,c_token);
  621.                 if (sety)
  622.                  quote_str(yformat,c_token);
  623.                 if (setz)
  624.                  quote_str(zformat,c_token);
  625.                 c_token++;
  626.             }
  627.         }
  628.     }
  629.     else if (almost_equals(c_token,"fu$nction")) {
  630.         c_token++;
  631.         if (!almost_equals(c_token,"s$tyle"))
  632.             int_error("expecting keyword 'style'",c_token);
  633.         func_style = get_style();
  634.     }
  635.     else if (almost_equals(c_token,"la$bel")) {
  636.         c_token++;
  637.         set_label();
  638.     }
  639.     else if (almost_equals(c_token,"nola$bel")) {
  640.         c_token++;
  641.         set_nolabel();
  642.     }
  643.     else if (almost_equals(c_token,"lo$gscale")) {
  644.         c_token++;
  645.         if (END_OF_COMMAND) {
  646.         is_log_x = is_log_y = is_log_z = TRUE;
  647.         base_log_x = base_log_y = base_log_z = 10.0;
  648.         log_base_log_x = log_base_log_y = log_base_log_z = log(10.0);
  649.         } else {
  650.         TBOOLEAN change_x = FALSE;
  651.         TBOOLEAN change_y = FALSE;
  652.         TBOOLEAN change_z = FALSE;
  653.         if (chr_in_str(c_token, 'x'))
  654.             change_x = TRUE;
  655.         if (chr_in_str(c_token, 'y'))
  656.             change_y = TRUE;
  657.         if (chr_in_str(c_token, 'z'))
  658.             change_z = TRUE;
  659.         c_token++;
  660.                 if (END_OF_COMMAND) {
  661.             if (change_x) {
  662.             is_log_x = TRUE;
  663.             base_log_x = 10.0;
  664.             log_base_log_x = log(10.0);
  665.             }
  666.             if (change_y) {
  667.             is_log_y = TRUE;
  668.             base_log_y = 10.0;
  669.             log_base_log_y = log(10.0);
  670.             }
  671.             if (change_z) {
  672.             is_log_z = TRUE;
  673.             base_log_z = 10.0;
  674.             log_base_log_z = log(10.0);
  675.             }
  676.         } else {
  677.             struct value a;
  678.             double newbase = magnitude(const_express(&a));
  679.             c_token++;
  680.             if (newbase < 1.1)
  681.             int_error("log base must be >= 1.1; logscale unchanged",
  682.                 c_token);
  683.             else {
  684.             if (change_x) {
  685.                 is_log_x = TRUE;
  686.                 base_log_x = newbase;
  687.                 log_base_log_x = log(newbase);
  688.             }
  689.             if (change_y) {
  690.                 is_log_y = TRUE;
  691.                 base_log_y = newbase;
  692.                 log_base_log_y = log(newbase);
  693.             }
  694.             if (change_z) {
  695.                 is_log_z = TRUE;
  696.                 base_log_z = newbase;
  697.                 log_base_log_z = log(newbase);
  698.             }
  699.             }
  700.         }
  701.         }
  702.     }
  703.     else if (almost_equals(c_token,"nolo$gscale")) {
  704.         c_token++;
  705.         if (END_OF_COMMAND) {
  706.         is_log_x = is_log_y = is_log_z = FALSE;
  707.         } else {
  708.         if (chr_in_str(c_token, 'x')) {
  709.             is_log_x = FALSE;
  710.             base_log_x = 0.0;
  711.             log_base_log_x = 0.0;
  712.                 }
  713.         if (chr_in_str(c_token, 'y')) {
  714.             is_log_y = FALSE;
  715.             base_log_y = 0.0;
  716.             log_base_log_y = 0.0;
  717.                 }
  718.         if (chr_in_str(c_token, 'z')) {
  719.             is_log_z = FALSE;
  720.             base_log_z = 0.0;
  721.             log_base_log_z = 0.0;
  722.                 }
  723.         c_token++;
  724.         }
  725.     } 
  726.     else if (almost_equals(c_token,"of$fsets")) {
  727.         c_token++;
  728.         if (END_OF_COMMAND) {
  729.             loff = roff = toff = boff = 0.0;  /* Reset offsets */
  730.         }
  731.         else {
  732.             load_offsets (&loff,&roff,&toff,&boff);
  733.         }
  734.     }
  735.     else
  736.         return(FALSE);    /* no command match */
  737.     return(TRUE);
  738. }
  739.  
  740.  
  741. /* return TRUE if a command match, FALSE if not */
  742. static TBOOLEAN
  743. set_two()
  744. {
  745.      char testfile[MAX_LINE_LEN+1];
  746. #if defined(unix) || defined(PIPES)
  747.      static TBOOLEAN pipe_open = FALSE;
  748. #endif /* unix || PIPES */
  749.  
  750.     if (almost_equals(c_token,"o$utput")) {
  751.         register FILE *f;
  752.  
  753.         c_token++;
  754.         if (term && term_init)
  755.             (*term_tbl[term].reset)();
  756.         if (END_OF_COMMAND) {    /* no file specified */
  757.              UP_redirect (4);
  758.             if (outfile != stdout) { /* Never close stdout */
  759. #if defined(unix) || defined(PIPES)
  760.                 if ( pipe_open ) {
  761.                     (void) pclose(outfile);
  762.                     pipe_open = FALSE;
  763.                 } else
  764. #endif /* unix || PIPES */
  765. #ifdef _Windows
  766.                   if ( !stricmp(outstr,"'PRN'") )
  767.                     close_printer();
  768.                   else
  769. #endif
  770.                     (void) fclose(outfile);
  771.             }
  772.             outfile = stdout; /* Don't dup... */
  773.             term_init = FALSE;
  774.             (void) strcpy(outstr,"STDOUT");
  775.         } else if (!isstring(c_token))
  776.             int_error("expecting filename",c_token);
  777.         else {
  778.             quote_str(testfile,c_token);
  779. #if defined(unix) || defined(PIPES)
  780.             if ( *testfile == '|' ) {
  781.               if ((f = popen(testfile+1,"w")) == (FILE *)NULL)
  782.                 os_error("cannot create pipe; output not changed",c_token);
  783.               else
  784.                 pipe_open = TRUE;
  785.             } else
  786. #endif /* unix || PIPES */
  787. #ifdef _Windows
  788.             if ( !stricmp(outstr,"'PRN'") ) {
  789.                 /* we can't call open_printer() while printer is open, so */
  790.                 close_printer();    /* close printer immediately if open */
  791.                 outfile = stdout;    /* and reset output to stdout */
  792.                 term_init = FALSE;
  793.                 (void) strcpy(outstr,"STDOUT");
  794.             }
  795.             if ( !stricmp(testfile,"PRN") ) {
  796.               if ((f = open_printer()) == (FILE *)NULL)
  797.                 os_error("cannot open printer temporary file; output may have changed",c_token);
  798.             } else
  799. #endif
  800.               if ((f = fopen(testfile,"w")) == (FILE *)NULL)
  801.                 os_error("cannot open file; output not changed",c_token);
  802.             if (outfile != stdout) /* Never close stdout */
  803. #if defined(unix) || defined(PIPES)
  804.                 if( pipe_open ) {
  805.                 (void) pclose(outfile);
  806.                 pipe_open=FALSE;
  807.                 } else
  808. #endif /* unix || PIPES */
  809.                 (void) fclose(outfile);
  810.             outfile = f;
  811.             term_init = FALSE;
  812.             outstr[0] = '\'';
  813.             (void) strcat(strcpy(outstr+1,testfile),"'");
  814.              UP_redirect (1);
  815.         }
  816.         c_token++;
  817.     }
  818.     else if (almost_equals(c_token,"tit$le")) {
  819.         set_xyzlabel(title,&title_xoffset,&title_yoffset);
  820.     }
  821.     else if (almost_equals(c_token,"xl$abel")) {
  822.         set_xyzlabel(xlabel,&xlabel_xoffset,&xlabel_yoffset);
  823.     }
  824.     else if (almost_equals(c_token,"yl$abel")) {
  825.         set_xyzlabel(ylabel,&ylabel_xoffset,&ylabel_yoffset);
  826.     }
  827.     else if (almost_equals(c_token,"zl$abel")) {
  828.         set_xyzlabel(zlabel,&zlabel_xoffset,&zlabel_yoffset);
  829.     }
  830.     else if (almost_equals(c_token,"xzero$axis")) {
  831.         c_token++;
  832.         xzeroaxis = TRUE;
  833.     } 
  834.     else if (almost_equals(c_token,"yzero$axis")) {
  835.         c_token++;
  836.         yzeroaxis = TRUE;
  837.     } 
  838.     else if (almost_equals(c_token,"zeroa$xis")) {
  839.         c_token++;
  840.         yzeroaxis = TRUE;
  841.         xzeroaxis = TRUE;
  842.     } 
  843.     else if (almost_equals(c_token,"noxzero$axis")) {
  844.         c_token++;
  845.         xzeroaxis = FALSE;
  846.     } 
  847.     else if (almost_equals(c_token,"noyzero$axis")) {
  848.         c_token++;
  849.         yzeroaxis = FALSE;
  850.     } 
  851.     else if (almost_equals(c_token,"nozero$axis")) {
  852.         c_token++;
  853.         xzeroaxis = FALSE;
  854.         yzeroaxis = FALSE;
  855.     } 
  856.     else if (almost_equals(c_token,"par$ametric")) {
  857.         if (!parametric) {
  858.            parametric = TRUE;
  859.            strcpy (dummy_var[0], "t");
  860.            strcpy (dummy_var[1], "y");
  861.              (void) fprintf(stderr,"\n\tdummy variable is t for curves, u/v for surfaces\n");
  862.         }
  863.         c_token++;
  864.     }
  865.     else if (almost_equals(c_token,"nopar$ametric")) {
  866.         if (parametric) {
  867.            parametric = FALSE;
  868.            strcpy (dummy_var[0], "x");
  869.            strcpy (dummy_var[1], "y");
  870.              (void) fprintf(stderr,"\n\tdummy variable is x for curves, x/y for surfaces\n");
  871.         }
  872.         c_token++;
  873.     }
  874.     else if (almost_equals(c_token,"pol$ar")) {
  875.         if (!polar) {
  876.             polar = TRUE;
  877.             if (parametric) {
  878.                 tmin = 0.0;
  879.                 tmax = 2*Pi;
  880.             } else if (angles_format == ANGLES_DEGREES) {
  881.                 xmin = 0.0;
  882.                 xmax = 360.0;
  883.             } else {
  884.                 xmin = 0.0;
  885.                 xmax = 2*Pi;
  886.             }
  887.         }
  888.         c_token++;
  889.     }
  890.     else if (almost_equals(c_token,"nopo$lar")) {
  891.         if (polar) {
  892.             polar = FALSE;
  893.             if (parametric) {
  894.                 tmin = -5.0;
  895.                 tmax = 5.0;
  896.             } else {
  897.                 xmin = -10.0;
  898.                 xmax = 10.0;
  899.             }
  900.         }
  901.         c_token++;
  902.     }
  903.     else if (almost_equals(c_token,"an$gles")) {
  904.         c_token++;
  905.         if (END_OF_COMMAND) {
  906.         /* assuming same as defaults */
  907.         angles_format = ANGLES_RADIANS;
  908.         }
  909.         else if (almost_equals(c_token, "r$adians")) {
  910.         angles_format = ANGLES_RADIANS;
  911.         c_token++;
  912.         }
  913.         else if (almost_equals(c_token, "d$egrees")) {
  914.         angles_format = ANGLES_DEGREES;
  915.         c_token++;
  916.         }
  917.         else
  918.          int_error("expecting 'radians' or 'degrees'", c_token);
  919.     }
  920.     else if (almost_equals(c_token,"g$rid")) {
  921.         grid = TRUE;
  922.         c_token++;
  923.     }
  924.     else if (almost_equals(c_token,"nog$rid")) {
  925.         grid = FALSE;
  926.         c_token++;
  927.     }
  928.     else if (almost_equals(c_token,"su$rface")) {
  929.         draw_surface = TRUE;
  930.         c_token++;
  931.     }
  932.     else if (almost_equals(c_token,"nosu$rface")) {
  933.         draw_surface = FALSE;
  934.         c_token++;
  935.     }
  936.     else if (almost_equals(c_token,"k$ey")) {
  937.         struct value a;
  938.         c_token++;
  939.         if (END_OF_COMMAND) {
  940.             key = -1;
  941.         } 
  942.         else {
  943.             key_x = real(const_express(&a));
  944.             if (!equals(c_token,","))
  945.                 int_error("',' expected",c_token);
  946.             c_token++;
  947.             key_y = real(const_express(&a));
  948.             if (equals(c_token,","))
  949.             {
  950.                     c_token++;
  951.                 key_z = real(const_express(&a));
  952.             }
  953.             key = 1;
  954.         } 
  955.     }
  956.     else if (almost_equals(c_token,"nok$ey")) {
  957.         key = 0;
  958.         c_token++;
  959.     }
  960.     else if (almost_equals(c_token,"tic$s")) {
  961.         tic_in = TRUE;
  962.         c_token++;
  963.         if (almost_equals(c_token,"i$n")) {
  964.             tic_in = TRUE;
  965.             c_token++;
  966.         }
  967.         else if (almost_equals(c_token,"o$ut")) {
  968.             tic_in = FALSE;
  969.             c_token++;
  970.         }
  971.     }
  972.      else if (almost_equals(c_token,"xmt$ics")) {
  973.      xtics = TRUE;
  974.      c_token++;
  975.      if(xticdef.type == TIC_USER){
  976.          free_marklist(xticdef.def.user);
  977.          xticdef.def.user = NULL;
  978.      }
  979.     xticdef.type = TIC_MONTH;
  980.      }
  981.      else if (almost_equals(c_token,"xdt$ics")) {
  982.      xtics = TRUE;
  983.      c_token++;
  984.      if(xticdef.type == TIC_USER){
  985.          free_marklist(xticdef.def.user);
  986.          xticdef.def.user = NULL;
  987.      }
  988.     xticdef.type = TIC_DAY;
  989.      }
  990.      else if (almost_equals(c_token,"xt$ics")) {
  991.         xtics = TRUE;
  992.         c_token++;
  993.         if (END_OF_COMMAND) { /* reset to default */
  994.            if (xticdef.type == TIC_USER) {
  995.               free_marklist(xticdef.def.user);
  996.               xticdef.def.user = NULL;
  997.            }
  998.            xticdef.type = TIC_COMPUTED;
  999.         }
  1000.         else
  1001.          load_tics(&xticdef);
  1002.     } 
  1003.      else if (almost_equals(c_token,"noxt$ics")) {
  1004.         xtics = FALSE;
  1005.         c_token++;
  1006.     } 
  1007.      else if (almost_equals(c_token,"ymt$ics")) {
  1008.      ytics = TRUE;
  1009.      c_token++;
  1010.      if(yticdef.type == TIC_USER){
  1011.          free_marklist(yticdef.def.user);
  1012.          yticdef.def.user = NULL;
  1013.      }
  1014.     yticdef.type = TIC_MONTH;
  1015.      }
  1016.      else if (almost_equals(c_token,"ydt$ics")) {
  1017.      ytics = TRUE;
  1018.      c_token++;
  1019.      if(yticdef.type == TIC_USER){
  1020.          free_marklist(yticdef.def.user);
  1021.          yticdef.def.user = NULL;
  1022.      }
  1023.     yticdef.type = TIC_DAY;
  1024.      }
  1025.      else if (almost_equals(c_token,"yt$ics")) {
  1026.         ytics = TRUE;
  1027.         c_token++;
  1028.         if (END_OF_COMMAND) { /* reset to default */
  1029.            if (yticdef.type == TIC_USER) {
  1030.               free_marklist(yticdef.def.user);
  1031.               yticdef.def.user = NULL;
  1032.            }
  1033.            yticdef.type = TIC_COMPUTED;
  1034.         }
  1035.         else
  1036.          load_tics(&yticdef);
  1037.     } 
  1038.      else if (almost_equals(c_token,"noyt$ics")) {
  1039.         ytics = FALSE;
  1040.         c_token++;
  1041.     } 
  1042.      else if (almost_equals(c_token,"zmt$ics")) {
  1043.      ztics = TRUE;
  1044.      c_token++;
  1045.      if(zticdef.type == TIC_USER){
  1046.          free_marklist(zticdef.def.user);
  1047.          zticdef.def.user = NULL;
  1048.      }
  1049.     zticdef.type = TIC_MONTH;
  1050.      }
  1051.      else if (almost_equals(c_token,"zdt$ics")) {
  1052.      ztics = TRUE;
  1053.      c_token++;
  1054.      if(zticdef.type == TIC_USER){
  1055.          free_marklist(zticdef.def.user);
  1056.          zticdef.def.user = NULL;
  1057.      }
  1058.     zticdef.type = TIC_DAY;
  1059.      }
  1060.      else if (almost_equals(c_token,"zt$ics")) {
  1061.         ztics = TRUE;
  1062.         c_token++;
  1063.         if (END_OF_COMMAND) { /* reset to default */
  1064.            if (zticdef.type == TIC_USER) {
  1065.               free_marklist(zticdef.def.user);
  1066.               zticdef.def.user = NULL;
  1067.            }
  1068.            zticdef.type = TIC_COMPUTED;
  1069.         }
  1070.         else
  1071.          load_tics(&zticdef);
  1072.     } 
  1073.      else if (almost_equals(c_token,"nozt$ics")) {
  1074.         ztics = FALSE;
  1075.         c_token++;
  1076.     } 
  1077.     else if (almost_equals(c_token,"ticsl$evel")) {
  1078.         double tlvl;
  1079.         struct value a;
  1080.  
  1081.         c_token++;
  1082.         tlvl = real(const_express(&a));
  1083.         if (tlvl < 0.0)
  1084.             int_error("tics level must be > 0; ticslevel unchanged",
  1085.                 c_token);
  1086.         else {
  1087.             ticslevel = tlvl;
  1088.         }
  1089.     }
  1090.     else
  1091.     return(FALSE);    /* no command match */
  1092.  
  1093.     return(TRUE);
  1094. }
  1095.  
  1096.  
  1097.  
  1098. /* return TRUE if a command match, FALSE if not */
  1099. static TBOOLEAN
  1100. set_three()
  1101. {
  1102.      if (almost_equals(c_token,"sa$mples")) {
  1103.         register int tsamp1, tsamp2;
  1104.         struct value a;
  1105.  
  1106.         c_token++;
  1107.         tsamp1 = (int)magnitude(const_express(&a));
  1108.         tsamp2 = tsamp1;
  1109.         if (!END_OF_COMMAND) {
  1110.             if (!equals(c_token,","))
  1111.                 int_error("',' expected",c_token);
  1112.             c_token++;
  1113.             tsamp2 = (int)magnitude(const_express(&a));
  1114.         }
  1115.         if (tsamp1 < 2 || tsamp2 < 2)
  1116.             int_error("sampling rate must be > 1; sampling unchanged",
  1117.                 c_token);
  1118.         else {
  1119.                 extern struct surface_points *first_3dplot;
  1120.             register struct surface_points *f_3dp = first_3dplot;
  1121.  
  1122.             first_3dplot = NULL;
  1123.             sp_free(f_3dp);
  1124.  
  1125.             samples = tsamp1;
  1126.             samples_1 = tsamp1;
  1127.             samples_2 = tsamp2;
  1128.         }
  1129.     }
  1130.     else if (almost_equals(c_token,"isosa$mples")) {
  1131.         register int tsamp1, tsamp2;
  1132.         struct value a;
  1133.  
  1134.         c_token++;
  1135.         tsamp1 = (int)magnitude(const_express(&a));
  1136.         tsamp2 = tsamp1;
  1137.         if (!END_OF_COMMAND) {
  1138.             if (!equals(c_token,","))
  1139.                 int_error("',' expected",c_token);
  1140.             c_token++;
  1141.             tsamp2 = (int)magnitude(const_express(&a));
  1142.         }
  1143.         if (tsamp1 < 2 || tsamp2 < 2)
  1144.             int_error("sampling rate must be > 1; sampling unchanged",
  1145.                 c_token);
  1146.         else {
  1147.                 extern struct curve_points *first_plot;
  1148.                 extern struct surface_points *first_3dplot;
  1149.             register struct curve_points *f_p = first_plot;
  1150.             register struct surface_points *f_3dp = first_3dplot;
  1151.  
  1152.             first_plot = NULL;
  1153.             first_3dplot = NULL;
  1154.             cp_free(f_p);
  1155.             sp_free(f_3dp);
  1156.  
  1157.             iso_samples_1 = tsamp1;
  1158.             iso_samples_2 = tsamp2;
  1159.         }
  1160.     }
  1161.     else if (almost_equals(c_token,"si$ze")) {
  1162.         struct value s;
  1163.         c_token++;
  1164.         if (END_OF_COMMAND) {
  1165.             xsize = 1.0;
  1166.             ysize = 1.0;
  1167.         } 
  1168.         else {
  1169.                 xsize=real(const_express(&s));
  1170.                 if (!equals(c_token,","))
  1171.                     int_error("',' expected",c_token);
  1172.                 c_token++;
  1173.                 ysize=real(const_express(&s));
  1174.         } 
  1175.     } 
  1176.     else if (almost_equals(c_token,"t$erminal")) {
  1177.         c_token++;
  1178.         if (END_OF_COMMAND) {
  1179.             list_terms();
  1180.             screen_ok = FALSE;
  1181.         }
  1182.         else {
  1183.             if (term && term_init) {
  1184.                 (*term_tbl[term].reset)();
  1185.                 (void) fflush(outfile);
  1186.             }
  1187.             term = set_term(c_token);
  1188.             c_token++;
  1189.  
  1190.             /* get optional mode parameters */
  1191.             if (term)
  1192.                 (*term_tbl[term].options)();
  1193.             if (interactive && *term_options)
  1194.                 fprintf(stderr,"Options are '%s'\n",term_options);
  1195.         }
  1196.     }
  1197.     else if (almost_equals(c_token,"tim$e")) {
  1198.         timedate = TRUE;
  1199.         c_token++;
  1200.         if (!END_OF_COMMAND) {
  1201.             struct value a;
  1202.             int x, y;
  1203.  
  1204.             /* We have x,y offsets specified */
  1205.             if (!equals(c_token,","))
  1206.                 time_xoffset = (int)real(const_express(&a));
  1207.             if (!END_OF_COMMAND && equals(c_token,",")) {
  1208.                 c_token++;
  1209.                 time_yoffset = (int)real(const_express(&a));
  1210.             }
  1211.         }
  1212.     }
  1213.     else if (almost_equals(c_token,"not$ime")) {
  1214.         timedate = FALSE;
  1215.         c_token++;
  1216.     }
  1217.     else if (almost_equals(c_token,"rr$ange")) {
  1218.          TBOOLEAN changed;
  1219.         c_token++;
  1220.         if (!equals(c_token,"["))
  1221.             int_error("expecting '['",c_token);
  1222.         c_token++;
  1223.         changed = load_range(&rmin,&rmax);
  1224.         if (!equals(c_token,"]"))
  1225.           int_error("expecting ']'",c_token);
  1226.         c_token++;
  1227.         if (changed)
  1228.           autoscale_r = FALSE;
  1229.     }
  1230.     else if (almost_equals(c_token,"tr$ange")) {
  1231.          TBOOLEAN changed;
  1232.         c_token++;
  1233.         if (!equals(c_token,"["))
  1234.             int_error("expecting '['",c_token);
  1235.         c_token++;
  1236.         changed = load_range(&tmin,&tmax);
  1237.         if (!equals(c_token,"]"))
  1238.           int_error("expecting ']'",c_token);
  1239.         c_token++;
  1240.         if (changed)
  1241.           autoscale_t = FALSE;
  1242.     }
  1243.     else if (almost_equals(c_token,"ur$ange")) {
  1244.          TBOOLEAN changed;
  1245.         c_token++;
  1246.         if (!equals(c_token,"["))
  1247.             int_error("expecting '['",c_token);
  1248.         c_token++;
  1249.         changed = load_range(&umin,&umax);
  1250.         if (!equals(c_token,"]"))
  1251.           int_error("expecting ']'",c_token);
  1252.         c_token++;
  1253.         if (changed)
  1254.           autoscale_u = FALSE;
  1255.     }
  1256.     else if (almost_equals(c_token,"vi$ew")) {
  1257.         int i;
  1258.         TBOOLEAN was_comma = TRUE;
  1259.         double local_vals[4];
  1260.         struct value a;
  1261.  
  1262.         local_vals[0] = surface_rot_x;
  1263.         local_vals[1] = surface_rot_z;
  1264.         local_vals[2] = surface_scale;
  1265.         local_vals[3] = surface_zscale;
  1266.         c_token++;
  1267.         for (i = 0; i < 4 && !(END_OF_COMMAND);) {
  1268.             if (equals(c_token,",")) {
  1269.                 if (was_comma) i++;
  1270.                 was_comma = TRUE;
  1271.                 c_token++;
  1272.             }
  1273.             else {
  1274.                 if (!was_comma)
  1275.                     int_error("',' expected",c_token);
  1276.                 local_vals[i] = real(const_express(&a));
  1277.                 i++;
  1278.                 was_comma = FALSE;
  1279.             }
  1280.         }
  1281.  
  1282.         if (local_vals[0] < 0 || local_vals[0] > 180)
  1283.             int_error("rot_x must be in [0:180] degrees range; view unchanged",
  1284.                   c_token);
  1285.         if (local_vals[1] < 0 || local_vals[1] > 360)
  1286.             int_error("rot_z must be in [0:360] degrees range; view unchanged",
  1287.                   c_token);
  1288.         if (local_vals[2] < 1e-6)
  1289.             int_error("scale must be > 0; view unchanged", c_token);
  1290.         if (local_vals[3] < 1e-6)
  1291.             int_error("zscale must be > 0; view unchanged", c_token);
  1292.  
  1293.         surface_rot_x = local_vals[0];
  1294.         surface_rot_z = local_vals[1];
  1295.         surface_scale = local_vals[2];
  1296.         surface_zscale = local_vals[3];
  1297.     }
  1298.     else if (almost_equals(c_token,"vr$ange")) {
  1299.          TBOOLEAN changed;
  1300.         c_token++;
  1301.         if (!equals(c_token,"["))
  1302.             int_error("expecting '['",c_token);
  1303.         c_token++;
  1304.         changed = load_range(&vmin,&vmax);
  1305.         if (!equals(c_token,"]"))
  1306.           int_error("expecting ']'",c_token);
  1307.         c_token++;
  1308.         if (changed)
  1309.           autoscale_v = FALSE;
  1310.     }
  1311.     else if (almost_equals(c_token,"xr$ange")) {
  1312.          TBOOLEAN changed;
  1313.         c_token++;
  1314.         if (!equals(c_token,"["))
  1315.             int_error("expecting '['",c_token);
  1316.         c_token++;
  1317.         changed = load_range(&xmin,&xmax);
  1318.         if (!equals(c_token,"]"))
  1319.           int_error("expecting ']'",c_token);
  1320.         c_token++;
  1321.         if (changed)
  1322.           autoscale_x = FALSE;
  1323.     }
  1324.     else if (almost_equals(c_token,"yr$ange")) {
  1325.          TBOOLEAN changed;
  1326.         c_token++;
  1327.         if (!equals(c_token,"["))
  1328.             int_error("expecting '['",c_token);
  1329.         c_token++;
  1330.         changed = load_range(&ymin,&ymax);
  1331.         if (!equals(c_token,"]"))
  1332.           int_error("expecting ']'",c_token);
  1333.         c_token++;
  1334.         if (changed)
  1335.           autoscale_y = FALSE;
  1336.     }
  1337.     else if (almost_equals(c_token,"zr$ange")) {
  1338.          TBOOLEAN changed;
  1339.         c_token++;
  1340.         if (!equals(c_token,"["))
  1341.             int_error("expecting '['",c_token);
  1342.         c_token++;
  1343.         changed = load_range(&zmin,&zmax);
  1344.         if (!equals(c_token,"]"))
  1345.           int_error("expecting ']'",c_token);
  1346.         c_token++;
  1347.         if (changed)
  1348.           autoscale_z = FALSE;
  1349.     }
  1350.     else if (almost_equals(c_token,"z$ero")) {
  1351.         struct value a;
  1352.         c_token++;
  1353.         zero = magnitude(const_express(&a));
  1354.     }
  1355.     else
  1356.         return(FALSE);    /* no command match */
  1357.     return(TRUE);
  1358. }
  1359.  
  1360. /*********** Support functions for set_command ***********/
  1361.  
  1362. /* process a 'set {x/y/z}label command */
  1363. /* set {x/y/z}label {label_text} {x}{,y} */
  1364. static void set_xyzlabel(str,xpos,ypos)
  1365. char *str;
  1366. int *xpos,*ypos;
  1367. {
  1368.     c_token++;
  1369.     if (END_OF_COMMAND) {    /* no label specified */
  1370.         str[0] = '\0';
  1371.     } else {
  1372.         if (isstring(c_token)) {
  1373.             /* We have string specified - grab it. */
  1374.             quotel_str(str,c_token);
  1375.             c_token++;
  1376.         }
  1377.         if (!END_OF_COMMAND) {
  1378.             struct value a;
  1379.             int x, y;
  1380.  
  1381.             /* We have x,y offsets specified */
  1382.             if (!equals(c_token,","))
  1383.                 *xpos = (int)real(const_express(&a));
  1384.             if (!END_OF_COMMAND && equals(c_token,",")) {
  1385.                 c_token++;
  1386.                 *ypos = (int)real(const_express(&a));
  1387.             }
  1388.         }
  1389.     }
  1390. }
  1391.  
  1392. /* process a 'set label' command */
  1393. /* set label {tag} {label_text} {at x,y} {pos} */
  1394. static void
  1395. set_label()
  1396. {
  1397.     struct value a;
  1398.     struct text_label *this_label = NULL;
  1399.     struct text_label *new_label = NULL;
  1400.     struct text_label *prev_label = NULL;
  1401.     double x, y, z;
  1402.     char text[MAX_LINE_LEN+1];
  1403.     enum JUSTIFY just;
  1404.     int tag;
  1405.     TBOOLEAN set_text, set_position, set_just;
  1406.  
  1407.     /* get tag */
  1408.     if (!END_OF_COMMAND 
  1409.        && !isstring(c_token) 
  1410.        && !equals(c_token, "at")
  1411.        && !equals(c_token, "left")
  1412.        && !equals(c_token, "center")
  1413.        && !equals(c_token, "centre")
  1414.        && !equals(c_token, "right")) {
  1415.        /* must be a tag expression! */
  1416.        tag = (int)real(const_express(&a));
  1417.        if (tag <= 0)
  1418.         int_error("tag must be > zero", c_token);
  1419.     } else
  1420.      tag = assign_label_tag(); /* default next tag */
  1421.      
  1422.     /* get text */
  1423.     if (!END_OF_COMMAND && isstring(c_token)) {
  1424.        /* get text */
  1425.        quotel_str(text, c_token);
  1426.        c_token++;
  1427.        set_text = TRUE;
  1428.     } else {
  1429.        text[0] = '\0';        /* default no text */
  1430.        set_text = FALSE;
  1431.     }
  1432.      
  1433.     /* get justification - what the heck, let him put it here */
  1434.     if (!END_OF_COMMAND && !equals(c_token, "at")) {
  1435.        if (almost_equals(c_token,"l$eft")) {
  1436.           just = LEFT;
  1437.        }
  1438.        else if (almost_equals(c_token,"c$entre")
  1439.               || almost_equals(c_token,"c$enter")) {
  1440.           just = CENTRE;
  1441.        }
  1442.        else if (almost_equals(c_token,"r$ight")) {
  1443.           just = RIGHT;
  1444.        }
  1445.        else
  1446.         int_error("bad syntax in set label", c_token);
  1447.        c_token++;
  1448.        set_just = TRUE;
  1449.     } else {
  1450.        just = LEFT;            /* default left justified */
  1451.        set_just = FALSE;
  1452.     } 
  1453.  
  1454.     /* get position */
  1455.     if (!END_OF_COMMAND && equals(c_token, "at")) {
  1456.        c_token++;
  1457.        if (END_OF_COMMAND)
  1458.         int_error("coordinates expected", c_token);
  1459.        /* get coordinates */
  1460.        x = real(const_express(&a));
  1461.        if (!equals(c_token,","))
  1462.         int_error("',' expected",c_token);
  1463.        c_token++;
  1464.        y = real(const_express(&a));
  1465.        if (equals(c_token,",")) {
  1466.         c_token++;
  1467.         z = real(const_express(&a));
  1468.        }
  1469.        else
  1470.             z = 0;
  1471.        set_position = TRUE;
  1472.     } else {
  1473.        x = y = z = 0;            /* default at origin */
  1474.        set_position = FALSE;
  1475.     }
  1476.  
  1477.     /* get justification */
  1478.     if (!END_OF_COMMAND) {
  1479.        if (set_just)
  1480.         int_error("only one justification is allowed", c_token);
  1481.        if (almost_equals(c_token,"l$eft")) {
  1482.           just = LEFT;
  1483.        }
  1484.        else if (almost_equals(c_token,"c$entre")
  1485.               || almost_equals(c_token,"c$enter")) {
  1486.           just = CENTRE;
  1487.        }
  1488.        else if (almost_equals(c_token,"r$ight")) {
  1489.           just = RIGHT;
  1490.        }
  1491.        else
  1492.         int_error("bad syntax in set label", c_token);
  1493.        c_token++;
  1494.        set_just = TRUE;
  1495.     } 
  1496.  
  1497.     if (!END_OF_COMMAND)
  1498.      int_error("extraenous or out-of-order arguments in set label", c_token);
  1499.  
  1500.     /* OK! add label */
  1501.     if (first_label != NULL) { /* skip to last label */
  1502.        for (this_label = first_label; this_label != NULL ; 
  1503.            prev_label = this_label, this_label = this_label->next)
  1504.         /* is this the label we want? */
  1505.         if (tag <= this_label->tag)
  1506.           break;
  1507.     }
  1508.     if (this_label != NULL && tag == this_label->tag) {
  1509.        /* changing the label */
  1510.        if (set_position) {
  1511.           this_label->x = x;
  1512.           this_label->y = y;
  1513.           this_label->z = z;
  1514.        }
  1515.        if (set_text)
  1516.         (void) strcpy(this_label->text, text);
  1517.        if (set_just)
  1518.         this_label->pos = just;
  1519.     } else {
  1520.        /* adding the label */
  1521.        new_label = (struct text_label *) 
  1522.         alloc ( (unsigned long) sizeof(struct text_label), "label");
  1523.        if (prev_label != NULL)
  1524.         prev_label->next = new_label; /* add it to end of list */
  1525.        else 
  1526.         first_label = new_label; /* make it start of list */
  1527.        new_label->tag = tag;
  1528.        new_label->next = this_label;
  1529.        new_label->x = x;
  1530.        new_label->y = y;
  1531.        new_label->z = z;
  1532.        (void) strcpy(new_label->text, text);
  1533.        new_label->pos = just;
  1534.     }
  1535. }
  1536.  
  1537. /* process 'set nolabel' command */
  1538. /* set nolabel {tag} */
  1539. static void
  1540. set_nolabel()
  1541. {
  1542.     struct value a;
  1543.     struct text_label *this_label;
  1544.     struct text_label *prev_label; 
  1545.     int tag;
  1546.  
  1547.     if (END_OF_COMMAND) {
  1548.        /* delete all labels */
  1549.        while (first_label != NULL)
  1550.         delete_label((struct text_label *)NULL,first_label);
  1551.     }
  1552.     else {
  1553.        /* get tag */
  1554.        tag = (int)real(const_express(&a));
  1555.        if (!END_OF_COMMAND)
  1556.         int_error("extraneous arguments to set nolabel", c_token);
  1557.        for (this_label = first_label, prev_label = NULL;
  1558.            this_label != NULL;
  1559.            prev_label = this_label, this_label = this_label->next) {
  1560.           if (this_label->tag == tag) {
  1561.              delete_label(prev_label,this_label);
  1562.              return;        /* exit, our job is done */
  1563.           }
  1564.        }
  1565.        int_error("label not found", c_token);
  1566.     }
  1567. }
  1568.  
  1569. /* assign a new label tag */
  1570. /* labels are kept sorted by tag number, so this is easy */
  1571. static int                /* the lowest unassigned tag number */
  1572. assign_label_tag()
  1573. {
  1574.     struct text_label *this_label;
  1575.     int last = 0;            /* previous tag value */
  1576.  
  1577.     for (this_label = first_label; this_label != NULL;
  1578.         this_label = this_label->next)
  1579.      if (this_label->tag == last+1)
  1580.        last++;
  1581.      else
  1582.        break;
  1583.     
  1584.     return (last+1);
  1585. }
  1586.  
  1587. /* delete label from linked list started by first_label.
  1588.  * called with pointers to the previous label (prev) and the 
  1589.  * label to delete (this).
  1590.  * If there is no previous label (the label to delete is
  1591.  * first_label) then call with prev = NULL.
  1592.  */
  1593. static void
  1594. delete_label(prev,this)
  1595.     struct text_label *prev, *this;
  1596. {
  1597.     if (this!=NULL)    {        /* there really is something to delete */
  1598.        if (prev!=NULL)        /* there is a previous label */
  1599.         prev->next = this->next; 
  1600.        else                /* this = first_label so change first_label */
  1601.         first_label = this->next;
  1602.        free((char *)this);
  1603.     }
  1604. }
  1605.  
  1606.  
  1607. /* process a 'set arrow' command */
  1608. /* set arrow {tag} {from x,y} {to x,y} {{no}head} */
  1609. static void
  1610. set_arrow()
  1611. {
  1612.     struct value a;
  1613.     struct arrow_def *this_arrow = NULL;
  1614.     struct arrow_def *new_arrow = NULL;
  1615.     struct arrow_def *prev_arrow = NULL;
  1616.     double sx, sy, sz;
  1617.     double ex, ey, ez;
  1618.     int tag;
  1619.     TBOOLEAN set_start, set_end, head = 1;
  1620.  
  1621.     /* get tag */
  1622.     if (!END_OF_COMMAND 
  1623.        && !equals(c_token, "from")
  1624.        && !equals(c_token, "to")) {
  1625.        /* must be a tag expression! */
  1626.        tag = (int)real(const_express(&a));
  1627.        if (tag <= 0)
  1628.         int_error("tag must be > zero", c_token);
  1629.     } else
  1630.      tag = assign_arrow_tag(); /* default next tag */
  1631.      
  1632.     /* get start position */
  1633.     if (!END_OF_COMMAND && equals(c_token, "from")) {
  1634.        c_token++;
  1635.        if (END_OF_COMMAND)
  1636.         int_error("start coordinates expected", c_token);
  1637.        /* get coordinates */
  1638.        sx = real(const_express(&a));
  1639.        if (!equals(c_token,","))
  1640.         int_error("',' expected",c_token);
  1641.        c_token++;
  1642.        sy = real(const_express(&a));
  1643.        if (equals(c_token,",")) {
  1644.         c_token++;
  1645.         sz = real(const_express(&a));
  1646.        }
  1647.        else
  1648.            sz = 0;
  1649.        set_start = TRUE;
  1650.     } else {
  1651.        sx = sy = sz = 0;            /* default at origin */
  1652.        set_start = FALSE;
  1653.     }
  1654.  
  1655.     /* get end position */
  1656.     if (!END_OF_COMMAND && equals(c_token, "to")) {
  1657.        c_token++;
  1658.        if (END_OF_COMMAND)
  1659.         int_error("end coordinates expected", c_token);
  1660.        /* get coordinates */
  1661.        ex = real(const_express(&a));
  1662.        if (!equals(c_token,","))
  1663.         int_error("',' expected",c_token);
  1664.        c_token++;
  1665.        ey = real(const_express(&a));
  1666.        if (equals(c_token,",")) {
  1667.         c_token++;
  1668.         ez = real(const_express(&a));
  1669.        }
  1670.        else
  1671.         ez = 0;
  1672.        set_end = TRUE;
  1673.     } else {
  1674.        ex = ey = ez = 0;            /* default at origin */
  1675.        set_end = FALSE;
  1676.     }
  1677.  
  1678.     /* get start position - what the heck, either order is ok */
  1679.     if (!END_OF_COMMAND && equals(c_token, "from")) {
  1680.        if (set_start)
  1681.         int_error("only one 'from' is allowed", c_token);
  1682.        c_token++;
  1683.        if (END_OF_COMMAND)
  1684.         int_error("start coordinates expected", c_token);
  1685.        /* get coordinates */
  1686.        sx = real(const_express(&a));
  1687.        if (!equals(c_token,","))
  1688.         int_error("',' expected",c_token);
  1689.        c_token++;
  1690.        sy = real(const_express(&a));
  1691.        if (equals(c_token,",")) {
  1692.         c_token++;
  1693.         sz = real(const_express(&a));
  1694.        }
  1695.        else
  1696.            sz = 0;
  1697.        set_start = TRUE;
  1698.     }
  1699.  
  1700.     if (!END_OF_COMMAND && equals(c_token, "nohead")) {
  1701.        c_token++;
  1702.            head = 0;
  1703.     }
  1704.  
  1705.     if (!END_OF_COMMAND && equals(c_token, "head")) {
  1706.        c_token++;
  1707.            head = 1;
  1708.     }
  1709.  
  1710.     if (!END_OF_COMMAND)
  1711.      int_error("extraneous or out-of-order arguments in set arrow", c_token);
  1712.  
  1713.     /* OK! add arrow */
  1714.     if (first_arrow != NULL) { /* skip to last arrow */
  1715.        for (this_arrow = first_arrow; this_arrow != NULL ; 
  1716.            prev_arrow = this_arrow, this_arrow = this_arrow->next)
  1717.         /* is this the arrow we want? */
  1718.         if (tag <= this_arrow->tag)
  1719.           break;
  1720.     }
  1721.     if (this_arrow != NULL && tag == this_arrow->tag) {
  1722.        /* changing the arrow */
  1723.        if (set_start) {
  1724.           this_arrow->sx = sx;
  1725.           this_arrow->sy = sy;
  1726.           this_arrow->sz = sz;
  1727.        }
  1728.        if (set_end) {
  1729.           this_arrow->ex = ex;
  1730.           this_arrow->ey = ey;
  1731.           this_arrow->ez = ez;
  1732.        }
  1733.        this_arrow->head = head;
  1734.     } else {
  1735.        /* adding the arrow */
  1736.        new_arrow = (struct arrow_def *) 
  1737.         alloc ( (unsigned long) sizeof(struct arrow_def), "arrow");
  1738.        if (prev_arrow != NULL)
  1739.         prev_arrow->next = new_arrow; /* add it to end of list */
  1740.        else 
  1741.         first_arrow = new_arrow; /* make it start of list */
  1742.        new_arrow->tag = tag;
  1743.        new_arrow->next = this_arrow;
  1744.        new_arrow->sx = sx;
  1745.        new_arrow->sy = sy;
  1746.        new_arrow->sz = sz;
  1747.        new_arrow->ex = ex;
  1748.        new_arrow->ey = ey;
  1749.        new_arrow->ez = ez;
  1750.        new_arrow->head = head;
  1751.     }
  1752. }
  1753.  
  1754. /* process 'set noarrow' command */
  1755. /* set noarrow {tag} */
  1756. static void
  1757. set_noarrow()
  1758. {
  1759.     struct value a;
  1760.     struct arrow_def *this_arrow;
  1761.     struct arrow_def *prev_arrow; 
  1762.     int tag;
  1763.  
  1764.     if (END_OF_COMMAND) {
  1765.        /* delete all arrows */
  1766.        while (first_arrow != NULL)
  1767.         delete_arrow((struct arrow_def *)NULL,first_arrow);
  1768.     }
  1769.     else {
  1770.        /* get tag */
  1771.        tag = (int)real(const_express(&a));
  1772.        if (!END_OF_COMMAND)
  1773.         int_error("extraneous arguments to set noarrow", c_token);
  1774.        for (this_arrow = first_arrow, prev_arrow = NULL;
  1775.            this_arrow != NULL;
  1776.            prev_arrow = this_arrow, this_arrow = this_arrow->next) {
  1777.           if (this_arrow->tag == tag) {
  1778.              delete_arrow(prev_arrow,this_arrow);
  1779.              return;        /* exit, our job is done */
  1780.           }
  1781.        }
  1782.        int_error("arrow not found", c_token);
  1783.     }
  1784. }
  1785.  
  1786. /* assign a new arrow tag */
  1787. /* arrows are kept sorted by tag number, so this is easy */
  1788. static int                /* the lowest unassigned tag number */
  1789. assign_arrow_tag()
  1790. {
  1791.     struct arrow_def *this_arrow;
  1792.     int last = 0;            /* previous tag value */
  1793.  
  1794.     for (this_arrow = first_arrow; this_arrow != NULL;
  1795.         this_arrow = this_arrow->next)
  1796.      if (this_arrow->tag == last+1)
  1797.        last++;
  1798.      else
  1799.        break;
  1800.  
  1801.     return (last+1);
  1802. }
  1803.  
  1804. /* delete arrow from linked list started by first_arrow.
  1805.  * called with pointers to the previous arrow (prev) and the 
  1806.  * arrow to delete (this).
  1807.  * If there is no previous arrow (the arrow to delete is
  1808.  * first_arrow) then call with prev = NULL.
  1809.  */
  1810. static void
  1811. delete_arrow(prev,this)
  1812.     struct arrow_def *prev, *this;
  1813. {
  1814.     if (this!=NULL)    {        /* there really is something to delete */
  1815.        if (prev!=NULL)        /* there is a previous arrow */
  1816.         prev->next = this->next; 
  1817.        else                /* this = first_arrow so change first_arrow */
  1818.         first_arrow = this->next;
  1819.        free((char *)this);
  1820.     }
  1821. }
  1822.  
  1823.  
  1824. enum PLOT_STYLE            /* not static; used by command.c */
  1825. get_style()
  1826. {
  1827. register enum PLOT_STYLE ps;
  1828.  
  1829.     c_token++;
  1830.     if (almost_equals(c_token,"l$ines"))
  1831.         ps = LINES;
  1832.     else if (almost_equals(c_token,"i$mpulses"))
  1833.         ps = IMPULSES;
  1834.     else if (almost_equals(c_token,"p$oints"))
  1835.         ps = POINTSTYLE;
  1836.     else if (almost_equals(c_token,"linesp$oints"))
  1837.         ps = LINESPOINTS;
  1838.     else if (almost_equals(c_token,"d$ots"))
  1839.         ps = DOTS;
  1840.     else if (almost_equals(c_token,"e$rrorbars"))
  1841.         ps = ERRORBARS;
  1842.     else if (almost_equals(c_token,"b$oxes"))
  1843.         ps = BOXES;
  1844.     else if (almost_equals(c_token,"boxer$rorbars"))
  1845.         ps = BOXERROR;
  1846.     else if (almost_equals(c_token,"s$teps"))
  1847.         ps = STEPS;
  1848.     else
  1849.         int_error("expecting 'lines', 'points', 'linespoints', 'dots', 'impulses', \n\
  1850.         'errorbars', 'steps', 'boxes' or 'boxerrorbars'",c_token);
  1851.     c_token++;
  1852.     return(ps);
  1853. }
  1854.  
  1855. /* For set [xy]tics... command*/
  1856. static void
  1857. load_tics(tdef)
  1858.     struct ticdef *tdef;    /* change this ticdef */
  1859. {
  1860.     if (equals(c_token,"(")) { /* set : TIC_USER */
  1861.        c_token++;
  1862.        load_tic_user(tdef);
  1863.     } else {                /* series : TIC_SERIES */
  1864.        load_tic_series(tdef);
  1865.     }
  1866. }
  1867.  
  1868. /* load TIC_USER definition */
  1869. /* (tic[,tic]...)
  1870.  * where tic is ["string"] value
  1871.  * Left paren is already scanned off before entry.
  1872.  */
  1873. static void
  1874. load_tic_user(tdef)
  1875.     struct ticdef *tdef;
  1876. {
  1877.     struct ticmark *list = NULL; /* start of list */
  1878.     struct ticmark *last = NULL; /* end of list */
  1879.     struct ticmark *tic = NULL; /* new ticmark */
  1880.     char temp_string[MAX_LINE_LEN];
  1881.     struct value a;
  1882.  
  1883.     while (!END_OF_COMMAND) {
  1884.        /* parse a new ticmark */
  1885.        tic = (struct ticmark *)alloc((unsigned long)sizeof(struct ticmark), (char *)NULL);
  1886.        if (tic == (struct ticmark *)NULL) {
  1887.           free_marklist(list);
  1888.           int_error("out of memory for tic mark", c_token);
  1889.        }
  1890.  
  1891.        /* has a string with it? */
  1892.        if (isstring(c_token)) {
  1893.           quote_str(temp_string,c_token);
  1894.           tic->label = alloc((unsigned long)strlen(temp_string)+1, "tic label");
  1895.           (void) strcpy(tic->label, temp_string);
  1896.           c_token++;
  1897.        } else
  1898.         tic->label = NULL;
  1899.  
  1900.        /* in any case get the value */
  1901.        tic->position = real(const_express(&a));
  1902.        tic->next = NULL;
  1903.  
  1904.        /* append to list */
  1905.        if (list == NULL)
  1906.         last = list = tic;    /* new list */
  1907.        else {                /* append to list */
  1908.           last->next = tic;
  1909.           last = tic;
  1910.        }
  1911.  
  1912.        /* expect "," or ")" here */
  1913.        if (!END_OF_COMMAND && equals(c_token, ","))
  1914.         c_token++;        /* loop again */
  1915.        else
  1916.         break;            /* hopefully ")" */
  1917.     }
  1918.     
  1919.     if (END_OF_COMMAND || !equals(c_token, ")")) {
  1920.        free_marklist(list);
  1921.        int_error("expecting right parenthesis )", c_token);
  1922.     }
  1923.     c_token++;
  1924.     
  1925.     /* successful list */
  1926.     if (tdef->type == TIC_USER) {
  1927.        /* remove old list */
  1928.         /* VAX Optimiser was stuffing up following line. Turn Optimiser OFF */
  1929.        free_marklist(tdef->def.user);
  1930.        tdef->def.user = NULL;
  1931.     }
  1932.     tdef->type = TIC_USER;
  1933.     tdef->def.user = list;
  1934. }
  1935.  
  1936. static void
  1937. free_marklist(list)
  1938.     struct ticmark *list;
  1939. {
  1940.     register struct ticmark *freeable;
  1941.  
  1942.     while (list != NULL) {
  1943.        freeable = list;
  1944.        list = list->next;
  1945.        if (freeable->label != NULL)
  1946.         free( (char *)freeable->label );
  1947.        free( (char *)freeable );
  1948.     }
  1949. }
  1950.  
  1951. /* load TIC_SERIES definition */
  1952. /* start,incr[,end] */
  1953. static void
  1954. load_tic_series(tdef)
  1955.     struct ticdef *tdef;
  1956. {
  1957.     double start, incr, end;
  1958.     struct value a;
  1959.     int incr_token;
  1960.  
  1961.     start = real(const_express(&a));
  1962.     if (!equals(c_token, ","))
  1963.      int_error("expecting comma to separate start,incr", c_token);
  1964.     c_token++;
  1965.  
  1966.     incr_token = c_token;
  1967.     incr = real(const_express(&a));
  1968.  
  1969.     if (END_OF_COMMAND)
  1970.      end = VERYLARGE;
  1971.     else {
  1972.        if (!equals(c_token, ","))
  1973.         int_error("expecting comma to separate incr,end", c_token);
  1974.        c_token++;
  1975.  
  1976.        end = real(const_express(&a));
  1977.     }
  1978.     if (!END_OF_COMMAND)
  1979.      int_error("tic series is defined by start,increment[,end]", 
  1980.              c_token);
  1981.     
  1982.     if (start < end && incr <= 0)
  1983.      int_error("increment must be positive", incr_token);
  1984.     if (start > end && incr >= 0)
  1985.      int_error("increment must be negative", incr_token);
  1986.     if (start > end) {
  1987.        /* put in order */
  1988.         double numtics;
  1989.         numtics = floor( (end*(1+SIGNIF) - start)/incr );
  1990.         end = start;
  1991.         start = end + numtics*incr;
  1992.         incr = -incr;
  1993. /*
  1994.        double temp = start;
  1995.        start = end;
  1996.        end = temp;
  1997.        incr = -incr;
  1998.  */
  1999.     }
  2000.  
  2001.     if (tdef->type == TIC_USER) {
  2002.        /* remove old list */
  2003.         /* VAX Optimiser was stuffing up following line. Turn Optimiser OFF */
  2004.        free_marklist(tdef->def.user);
  2005.        tdef->def.user = NULL;
  2006.     }
  2007.     tdef->type = TIC_SERIES;
  2008.     tdef->def.series.start = start;
  2009.     tdef->def.series.incr = incr;
  2010.     tdef->def.series.end = end;
  2011. }
  2012.  
  2013. static void
  2014. load_offsets (a, b, c, d)
  2015. double *a,*b, *c, *d;
  2016. {
  2017. struct value t;
  2018.  
  2019.     *a = real (const_express(&t));  /* loff value */
  2020.     c_token++;
  2021.     if (equals(c_token,","))
  2022.         c_token++;
  2023.     if (END_OF_COMMAND) 
  2024.         return;
  2025.  
  2026.     *b = real (const_express(&t));  /* roff value */
  2027.     c_token++;
  2028.     if (equals(c_token,","))
  2029.         c_token++;
  2030.     if (END_OF_COMMAND) 
  2031.         return;
  2032.  
  2033.     *c = real (const_express(&t));  /* toff value */
  2034.     c_token++;
  2035.     if (equals(c_token,","))
  2036.         c_token++;
  2037.     if (END_OF_COMMAND) 
  2038.         return;
  2039.  
  2040.     *d = real (const_express(&t));  /* boff value */
  2041.     c_token++;
  2042. }
  2043.  
  2044.  
  2045. TBOOLEAN                    /* TRUE if a or b were changed */
  2046. load_range(a,b)            /* also used by command.c */
  2047. double *a,*b;
  2048. {
  2049. struct value t;
  2050. TBOOLEAN changed = FALSE;
  2051.  
  2052.     if (equals(c_token,"]"))
  2053.         return(FALSE);
  2054.     if (END_OF_COMMAND) {
  2055.         int_error("starting range value or ':' or 'to' expected",c_token);
  2056.     } else if (!equals(c_token,"to") && !equals(c_token,":"))  {
  2057.         *a = real(const_express(&t));
  2058.         changed = TRUE;
  2059.     }    
  2060.     if (!equals(c_token,"to") && !equals(c_token,":"))
  2061.         int_error("':' or keyword 'to' expected",c_token);
  2062.     c_token++;
  2063.     if (!equals(c_token,"]")) {
  2064.         *b = real(const_express(&t));
  2065.         changed = TRUE;
  2066.      }
  2067.      return(changed);
  2068. }
  2069.  
  2070.  
  2071.  
  2072. /******* The 'show' command *******/
  2073. void
  2074. show_command()
  2075. {
  2076.     c_token++;
  2077.  
  2078.     if (!show_one() && !show_two())
  2079.     int_error(
  2080.     "valid show options:  'action_table', 'all', 'angles', 'arrow', \n\
  2081.     'autoscale', 'border', 'boxwidth', 'clip', 'contour', 'data', \n\
  2082.     'dgrid3d', 'dummy', 'format', 'function', 'grid', 'hidden', 'key', \n\
  2083.     'label', 'logscale', 'mapping',  'offsets', 'output', 'plot', \n\
  2084.     'parametric', 'polar', 'rrange', 'samples', 'isosamples', 'view', \n\
  2085.     'size', 'terminal', 'tics', 'ticslevel', 'time', 'title', 'trange', \n\
  2086.     'urange', 'vrange', 'variables', 'version', \n\
  2087.     'xlabel', 'xrange', '{no}xtics', 'xmtics', 'xdtics', '{no}xzeroaxis',\n\
  2088.     'ylabel', 'yrange', '{no}ytics', 'ymtics', 'ydtics', '{no}yzeroaxis',\n\
  2089.      'zero', '{no}zeroaxis', 'zlabel', 'zrange', '{no}ztics',\n\
  2090.      'zmtics', 'zdtics'", c_token);
  2091.     screen_ok = FALSE;
  2092.     (void) putc('\n',stderr);
  2093. }
  2094.  
  2095. /* return TRUE if a command match, FALSE if not */
  2096. static TBOOLEAN
  2097. show_one()
  2098. {
  2099.     if (almost_equals(c_token,"ac$tion_table") ||
  2100.              equals(c_token,"at") ) {
  2101.         c_token++; 
  2102.         show_at();
  2103.         c_token++;
  2104.     }
  2105.     else if (almost_equals(c_token,"ar$row")) {
  2106.         struct value a;
  2107.         int tag = 0;
  2108.  
  2109.         c_token++;
  2110.         if (!END_OF_COMMAND) {
  2111.            tag = (int)real(const_express(&a));
  2112.            if (tag <= 0)
  2113.             int_error("tag must be > zero", c_token);
  2114.         }
  2115.  
  2116.         (void) putc('\n',stderr);
  2117.         show_arrow(tag);
  2118.     }
  2119.     else if (almost_equals(c_token,"au$toscale")) {
  2120.         (void) putc('\n',stderr);
  2121.         show_autoscale();
  2122.         c_token++;
  2123.     }
  2124.     else if (almost_equals(c_token,"bor$der")) {
  2125.         (void) putc('\n',stderr);
  2126.         show_border();
  2127.         c_token++;
  2128.     }
  2129.     else if (almost_equals(c_token,"box$width")) {
  2130.         (void) putc('\n',stderr);
  2131.         show_boxwidth();
  2132.         c_token++;
  2133.     }
  2134.     else if (almost_equals(c_token,"c$lip")) {
  2135.         (void) putc('\n',stderr);
  2136.         show_clip();
  2137.         c_token++;
  2138.     }
  2139.     else if (almost_equals(c_token,"ma$pping")) {
  2140.         (void) putc('\n',stderr);
  2141.         show_mapping();
  2142.         c_token++;
  2143.     }
  2144.     else if (almost_equals(c_token,"co$ntour")) {
  2145.         (void) putc('\n',stderr);
  2146.         show_contour();
  2147.         c_token++;
  2148.     }
  2149.     else if (almost_equals(c_token,"da$ta")) {
  2150.         c_token++;
  2151.         if (!almost_equals(c_token,"s$tyle"))
  2152.             int_error("expecting keyword 'style'",c_token);
  2153.         (void) putc('\n',stderr);
  2154.         show_style("data",data_style);
  2155.         c_token++;
  2156.     }
  2157.     else if (almost_equals(c_token,"dg$rid3d")) {
  2158.         (void) putc('\n',stderr);
  2159.         show_dgrid3d();
  2160.         c_token++;
  2161.     }
  2162.     else if (almost_equals(c_token,"du$mmy")) {
  2163.           (void) fprintf(stderr,"\n\tdummy variables are \"%s\" and \"%s\"\n",
  2164.                         dummy_var[0], dummy_var[1]);
  2165.         c_token++;
  2166.     }
  2167.     else if (almost_equals(c_token,"fo$rmat")) {
  2168.         show_format();
  2169.         c_token++;
  2170.     }
  2171.     else if (almost_equals(c_token,"fu$nctions")) {
  2172.         c_token++;
  2173.         if (almost_equals(c_token,"s$tyle"))  {
  2174.             (void) putc('\n',stderr);
  2175.             show_style("functions",func_style);
  2176.             c_token++;
  2177.         }
  2178.         else
  2179.             show_functions();
  2180.     }
  2181.     else if (almost_equals(c_token,"lo$gscale")) {
  2182.         (void) putc('\n',stderr);
  2183.         show_logscale();
  2184.         c_token++;
  2185.     }
  2186.     else if (almost_equals(c_token,"of$fsets")) {
  2187.         (void) putc('\n',stderr);
  2188.         show_offsets();
  2189.         c_token++;
  2190.     }
  2191.     else if (almost_equals(c_token,"o$utput")) {
  2192.         (void) putc('\n',stderr);
  2193.         show_output();
  2194.         c_token++;
  2195.     }
  2196.     else if (almost_equals(c_token,"tit$le")) {
  2197.         (void) putc('\n',stderr);
  2198.         show_title();
  2199.         c_token++;
  2200.     }
  2201.     else if (almost_equals(c_token,"xl$abel")) {
  2202.         (void) putc('\n',stderr);
  2203.         show_xlabel();
  2204.         c_token++;
  2205.     }
  2206.     else if (almost_equals(c_token,"yl$abel")) {
  2207.         (void) putc('\n',stderr);
  2208.         show_ylabel();
  2209.         c_token++;
  2210.     }
  2211.     else if (almost_equals(c_token,"zl$abel")) {
  2212.         (void) putc('\n',stderr);
  2213.         show_zlabel();
  2214.         c_token++;
  2215.     }
  2216.     else if (almost_equals(c_token,"xzero$axis")) {
  2217.         (void) putc('\n',stderr);
  2218.         show_xzeroaxis();
  2219.         c_token++;
  2220.     }
  2221.     else if (almost_equals(c_token,"yzero$axis")) {
  2222.         (void) putc('\n',stderr);
  2223.         show_yzeroaxis();
  2224.         c_token++;
  2225.     }
  2226.     else if (almost_equals(c_token,"zeroa$xis")) {
  2227.         (void) putc('\n',stderr);
  2228.         show_xzeroaxis();
  2229.         show_yzeroaxis();
  2230.         c_token++;
  2231.     }
  2232.     else if (almost_equals(c_token,"la$bel")) {
  2233.         struct value a;
  2234.         int tag = 0;
  2235.  
  2236.         c_token++;
  2237.         if (!END_OF_COMMAND) {
  2238.            tag = (int)real(const_express(&a));
  2239.            if (tag <= 0)
  2240.             int_error("tag must be > zero", c_token);
  2241.         }
  2242.  
  2243.         (void) putc('\n',stderr);
  2244.         show_label(tag);
  2245.     }
  2246.     else if (almost_equals(c_token,"g$rid")) {
  2247.         (void) putc('\n',stderr);
  2248.         show_grid();
  2249.         c_token++;
  2250.     }
  2251.     else if (almost_equals(c_token,"k$ey")) {
  2252.         (void) putc('\n',stderr);
  2253.         show_key();
  2254.         c_token++;
  2255.     }
  2256.     else
  2257.         return (FALSE);
  2258.     return TRUE;
  2259. }
  2260.  
  2261. /* return TRUE if a command match, FALSE if not */
  2262. static TBOOLEAN
  2263. show_two()
  2264. {
  2265.     if (almost_equals(c_token,"p$lot")) {
  2266.         (void) putc('\n',stderr);
  2267.         show_plot();
  2268.         c_token++;
  2269.     }
  2270.     else if (almost_equals(c_token,"par$ametric")) {
  2271.         (void) putc('\n',stderr);
  2272.         show_parametric();
  2273.         c_token++;
  2274.     }
  2275.     else if (almost_equals(c_token,"pol$ar")) {
  2276.         (void) putc('\n',stderr);
  2277.         show_polar();
  2278.         c_token++;
  2279.     }
  2280.     else if (almost_equals(c_token,"an$gles")) {
  2281.         (void) putc('\n',stderr);
  2282.         show_angles();
  2283.         c_token++;
  2284.     }
  2285.     else if (almost_equals(c_token,"ti$cs")) {
  2286.         (void) putc('\n',stderr);
  2287.         show_tics(TRUE,TRUE,TRUE);
  2288.         c_token++;
  2289.     }
  2290.     else if (almost_equals(c_token,"tim$e")) {
  2291.         (void) putc('\n',stderr);
  2292.         show_time();
  2293.         c_token++;
  2294.     }
  2295.     else if (almost_equals(c_token,"su$rface")) {
  2296.         (void) putc('\n',stderr);
  2297.         show_surface();
  2298.         c_token++;
  2299.     }
  2300.     else if (almost_equals(c_token,"hi$dden3d")) {
  2301.         (void) putc('\n',stderr);
  2302.         show_hidden3d();
  2303.         c_token++;
  2304.     }
  2305.      else if (almost_equals(c_token,"cla$bel")) {
  2306.          (void) putc('\n',stderr);
  2307.          show_label_contours();
  2308.          c_token++;
  2309.      }
  2310.     else if (almost_equals(c_token,"xti$cs")) {
  2311.         show_tics(TRUE,FALSE,FALSE);
  2312.         c_token++;
  2313.     }
  2314.     else if (almost_equals(c_token,"yti$cs")) {
  2315.         show_tics(FALSE,TRUE,FALSE);
  2316.         c_token++;
  2317.     }
  2318.     else if (almost_equals(c_token,"zti$cs")) {
  2319.         show_tics(FALSE,FALSE,TRUE);
  2320.         c_token++;
  2321.     }
  2322.     else if (almost_equals(c_token,"sa$mples")) {
  2323.         (void) putc('\n',stderr);
  2324.         show_samples();
  2325.         c_token++;
  2326.     }
  2327.     else if (almost_equals(c_token,"isosa$mples")) {
  2328.         (void) putc('\n',stderr);
  2329.         show_isosamples();
  2330.         c_token++;
  2331.     }
  2332.     else if (almost_equals(c_token,"si$ze")) {
  2333.         (void) putc('\n',stderr);
  2334.         show_size();
  2335.         c_token++;
  2336.     }
  2337.     else if (almost_equals(c_token,"t$erminal")) {
  2338.         (void) putc('\n',stderr);
  2339.         show_term();
  2340.         c_token++;
  2341.     }
  2342.     else if (almost_equals(c_token,"rr$ange")) {
  2343.         (void) putc('\n',stderr);
  2344.         show_range('r',rmin,rmax);
  2345.         c_token++;
  2346.     }
  2347.     else if (almost_equals(c_token,"tr$ange")) {
  2348.         (void) putc('\n',stderr);
  2349.         show_range('t',tmin,tmax);
  2350.         c_token++;
  2351.     }
  2352.     else if (almost_equals(c_token,"ur$ange")) {
  2353.         (void) putc('\n',stderr);
  2354.         show_range('u',umin,umax);
  2355.         c_token++;
  2356.     }
  2357.     else if (almost_equals(c_token,"vi$ew")) {
  2358.         (void) putc('\n',stderr);
  2359.         show_view();
  2360.         c_token++;
  2361.     }
  2362.     else if (almost_equals(c_token,"vr$ange")) {
  2363.         (void) putc('\n',stderr);
  2364.         show_range('v',vmin,vmax);
  2365.         c_token++;
  2366.     }
  2367.     else if (almost_equals(c_token,"v$ariables")) {
  2368.         show_variables();
  2369.         c_token++;
  2370.     }
  2371.     else if (almost_equals(c_token,"ve$rsion")) {
  2372.         show_version();
  2373.         c_token++;
  2374.     }
  2375.     else if (almost_equals(c_token,"xr$ange")) {
  2376.         (void) putc('\n',stderr);
  2377.         show_range('x',xmin,xmax);
  2378.         c_token++;
  2379.     }
  2380.     else if (almost_equals(c_token,"yr$ange")) {
  2381.         (void) putc('\n',stderr);
  2382.         show_range('y',ymin,ymax);
  2383.         c_token++;
  2384.     }
  2385.     else if (almost_equals(c_token,"zr$ange")) {
  2386.         (void) putc('\n',stderr);
  2387.         show_range('z',zmin,zmax);
  2388.         c_token++;
  2389.     }
  2390.     else if (almost_equals(c_token,"z$ero")) {
  2391.         (void) putc('\n',stderr);
  2392.         show_zero();
  2393.         c_token++;
  2394.     }
  2395.     else if (almost_equals(c_token,"a$ll")) {
  2396.         c_token++;
  2397.         show_version();
  2398.         show_autoscale();
  2399.         show_border();
  2400.         show_boxwidth();
  2401.         show_clip();
  2402.         show_contour();
  2403.         show_dgrid3d();
  2404.         show_mapping();
  2405.           (void) fprintf(stderr,"\tdummy variables are \"%s\" and \"%s\"\n",
  2406.                         dummy_var[0], dummy_var[1]);
  2407.         show_format();
  2408.         show_style("data",data_style);
  2409.         show_style("functions",func_style);
  2410.         show_grid();
  2411.         show_label(0);
  2412.         show_arrow(0);
  2413.         show_key();
  2414.         show_logscale();
  2415.         show_offsets();
  2416.         show_output();
  2417.         show_parametric();
  2418.         show_polar();
  2419.         show_angles();
  2420.         show_samples();
  2421.         show_isosamples();
  2422.         show_view();
  2423.         show_surface();
  2424. #ifndef LITE
  2425.         show_hidden3d();
  2426. #endif
  2427.         show_size();
  2428.         show_term();
  2429.         show_tics(TRUE,TRUE,TRUE);
  2430.         show_time();
  2431.         if (parametric)
  2432.             if (!is_3d_plot)
  2433.                 show_range('t',tmin,tmax);
  2434.             else {
  2435.                 show_range('u',umin,umax);
  2436.                 show_range('v',vmin,vmax);
  2437.             }
  2438.         if (polar)
  2439.           show_range('r',rmin,rmax);
  2440.         show_range('x',xmin,xmax);
  2441.         show_range('y',ymin,ymax);
  2442.         show_range('z',zmin,zmax);
  2443.         show_title();
  2444.         show_xlabel();
  2445.         show_ylabel();
  2446.         show_zlabel();
  2447.         show_zero();
  2448.         show_plot();
  2449.         show_variables();
  2450.         show_functions();
  2451.         c_token++;
  2452.     }
  2453.     else
  2454.         return (FALSE);
  2455.     return (TRUE);
  2456. }
  2457.  
  2458.  
  2459. /*********** support functions for 'show'  **********/
  2460. static void
  2461. show_style(name,style)
  2462. char name[];
  2463. enum PLOT_STYLE style;
  2464. {
  2465.     fprintf(stderr,"\t%s are plotted with ",name);
  2466.     switch (style) {
  2467.         case LINES: fprintf(stderr,"lines\n"); break;
  2468.         case POINTSTYLE: fprintf(stderr,"points\n"); break;
  2469.         case IMPULSES: fprintf(stderr,"impulses\n"); break;
  2470.         case LINESPOINTS: fprintf(stderr,"linespoints\n"); break;
  2471.         case DOTS: fprintf(stderr,"dots\n"); break;
  2472.         case ERRORBARS: fprintf(stderr,"errorbars\n"); break;
  2473.         case BOXES: fprintf(stderr,"boxes\n"); break;
  2474.         case BOXERROR: fprintf(stderr,"boxerrorbars\n"); break;
  2475.         case STEPS: fprintf(stderr,"steps\n"); break;
  2476.     }
  2477. }
  2478.  
  2479. static void
  2480. show_boxwidth()
  2481. {
  2482.     if (boxwidth<0.0)
  2483.         fprintf(stderr,"\tboxwidth is auto\n");
  2484.     else
  2485.         fprintf(stderr,"\tboxwidth is %g\n",boxwidth);
  2486. }
  2487. static void
  2488. show_dgrid3d()
  2489. {
  2490.     if (dgrid3d)
  2491.         fprintf(stderr,"\tdata grid3d is enabled for mesh of size %dx%d, norm=%d\n",
  2492.             dgrid3d_row_fineness,
  2493.             dgrid3d_col_fineness,
  2494.             dgrid3d_norm_value);
  2495.     else
  2496.         fprintf(stderr,"\tdata grid3d is disabled\n");
  2497. }
  2498.  
  2499. static void
  2500. show_range(name,min,max)
  2501. char name;
  2502. double min,max;
  2503. {
  2504.     fprintf(stderr,"\t%crange is [%g : %g]\n",name,min,max);
  2505. }
  2506.  
  2507. static void
  2508. show_zero()
  2509. {
  2510.     fprintf(stderr,"\tzero is %g\n",zero);
  2511. }
  2512.  
  2513. static void
  2514. show_offsets()
  2515. {
  2516.     fprintf(stderr,"\toffsets are %g, %g, %g, %g\n",loff,roff,toff,boff);
  2517. }
  2518.  
  2519. static void
  2520. show_border()
  2521. {
  2522.     fprintf(stderr,"\tborder is %sdrawn\n", draw_border ? "" : "not ");
  2523. }
  2524.  
  2525. static void
  2526. show_output()
  2527. {
  2528.     fprintf(stderr,"\toutput is sent to %s\n",outstr);
  2529. }
  2530.  
  2531. static void
  2532. show_samples()
  2533. {
  2534.     fprintf(stderr,"\tsampling rate is %d, %d\n",samples_1, samples_2);
  2535. }
  2536.  
  2537. static void
  2538. show_isosamples()
  2539. {
  2540.     fprintf(stderr,"\tiso sampling rate is %d, %d\n",
  2541.         iso_samples_1, iso_samples_2);
  2542. }
  2543.  
  2544. static void
  2545. show_surface()
  2546. {
  2547.     fprintf(stderr,"\tsurface is %sdrawn\n", draw_surface ? "" : "not ");
  2548. }
  2549.  
  2550. static void
  2551. show_hidden3d()
  2552. {
  2553. #ifdef LITE
  2554.     printf(" Hidden Line Removal Not Supported in LITE version\n");
  2555. #else
  2556.     fprintf(stderr,"\thidden surface is %s\n", hidden3d ? "removed" : "drawn");
  2557. #endif /* LITE */
  2558. }
  2559.  
  2560. static void
  2561. show_label_contours()
  2562. {
  2563.     fprintf(stderr,"\tcontour line types are %s\n", label_contours ? "varied & labeled" : "all the same");
  2564. }
  2565.  
  2566. static void
  2567. show_view()
  2568. {
  2569.     fprintf(stderr,"\tview is %g rot_x, %g rot_z, %g scale, %g scale_z\n",
  2570.         surface_rot_x, surface_rot_z, surface_scale, surface_zscale);
  2571. }
  2572.  
  2573. static void
  2574. show_size()
  2575. {
  2576.     fprintf(stderr,"\tsize is scaled by %g,%g\n",xsize,ysize);
  2577. }
  2578.  
  2579. static void
  2580. show_title()
  2581. {
  2582.     fprintf(stderr,"\ttitle is \"%s\", offset at %d, %d\n",
  2583.         title,title_xoffset,title_yoffset);
  2584. }
  2585.  
  2586. static void
  2587. show_xlabel()
  2588. {
  2589.     fprintf(stderr,"\txlabel is \"%s\", offset at %d, %d\n",
  2590.         xlabel,xlabel_xoffset,xlabel_yoffset);
  2591. }
  2592.  
  2593. static void
  2594. show_ylabel()
  2595. {
  2596.     fprintf(stderr,"\tylabel is \"%s\", offset at %d, %d\n",
  2597.         ylabel,ylabel_xoffset,ylabel_yoffset);
  2598. }
  2599. static void
  2600. show_zlabel()
  2601. {
  2602.     fprintf(stderr,"\tzlabel is \"%s\", offset at %d, %d\n",
  2603.         zlabel,zlabel_xoffset,zlabel_yoffset);
  2604. }
  2605.  
  2606. static void
  2607. show_xzeroaxis()
  2608. {
  2609.     fprintf(stderr,"\txzeroaxis is %s\n",(xzeroaxis)? "ON" : "OFF");
  2610. }
  2611.  
  2612. static void
  2613. show_yzeroaxis()
  2614. {
  2615.     fprintf(stderr,"\tyzeroaxis is %s\n",(yzeroaxis)? "ON" : "OFF");
  2616. }
  2617.  
  2618. static void
  2619. show_label(tag)
  2620.     int tag;                /* 0 means show all */
  2621. {
  2622.     struct text_label *this_label;
  2623.     TBOOLEAN showed = FALSE;
  2624.  
  2625.     for (this_label = first_label; this_label != NULL;
  2626.         this_label = this_label->next) {
  2627.        if (tag == 0 || tag == this_label->tag) {
  2628.           showed = TRUE;
  2629.           fprintf(stderr,"\tlabel %d \"%s\" at %g,%g,%g ",
  2630.                 this_label->tag, this_label->text, 
  2631.                 this_label->x, this_label->y, this_label->z);
  2632.           switch(this_label->pos) {
  2633.              case LEFT : {
  2634.                 fprintf(stderr,"left");
  2635.                 break;
  2636.              }
  2637.              case CENTRE : {
  2638.                 fprintf(stderr,"centre");
  2639.                 break;
  2640.              }
  2641.              case RIGHT : {
  2642.                 fprintf(stderr,"right");
  2643.                 break;
  2644.              }
  2645.           }
  2646.           fputc('\n',stderr);
  2647.        }
  2648.     }
  2649.     if (tag > 0 && !showed)
  2650.      int_error("label not found", c_token);
  2651. }
  2652.  
  2653. static void
  2654. show_arrow(tag)
  2655.     int tag;                /* 0 means show all */
  2656. {
  2657.     struct arrow_def *this_arrow;
  2658.     TBOOLEAN showed = FALSE;
  2659.  
  2660.     for (this_arrow = first_arrow; this_arrow != NULL;
  2661.         this_arrow = this_arrow->next) {
  2662.        if (tag == 0 || tag == this_arrow->tag) {
  2663.           showed = TRUE;
  2664.           fprintf(stderr,"\tarrow %d from %g,%g,%g to %g,%g,%g%s\n",
  2665.                 this_arrow->tag, 
  2666.                 this_arrow->sx, this_arrow->sy, this_arrow->sz,
  2667.                 this_arrow->ex, this_arrow->ey, this_arrow->ez,
  2668.                 this_arrow->head ? "" : " (nohead)");
  2669.        }
  2670.     }
  2671.     if (tag > 0 && !showed)
  2672.      int_error("arrow not found", c_token);
  2673. }
  2674.  
  2675. static void
  2676. show_grid()
  2677. {
  2678.     fprintf(stderr,"\tgrid is %s\n",(grid)? "ON" : "OFF");
  2679. }
  2680.  
  2681. static void
  2682. show_key()
  2683. {
  2684.     switch (key) {
  2685.         case -1 : 
  2686.             fprintf(stderr,"\tkey is ON\n");
  2687.             break;
  2688.         case 0 :
  2689.             fprintf(stderr,"\tkey is OFF\n");
  2690.             break;
  2691.         case 1 :
  2692.             fprintf(stderr,"\tkey is at %g,%g,%g\n",key_x,key_y,key_z);
  2693.             break;
  2694.     }
  2695. }
  2696.  
  2697. static void
  2698. show_parametric()
  2699. {
  2700.     fprintf(stderr,"\tparametric is %s\n",(parametric)? "ON" : "OFF");
  2701. }
  2702.  
  2703. static void
  2704. show_polar()
  2705. {
  2706.     fprintf(stderr,"\tpolar is %s\n",(polar)? "ON" : "OFF");
  2707. }
  2708.  
  2709. static void
  2710. show_angles()
  2711. {
  2712.     fprintf(stderr,"\tAngles are in ");
  2713.     switch (angles_format) {
  2714.         case ANGLES_RADIANS:
  2715.             fprintf(stderr, "radians\n");
  2716.         break;
  2717.         case ANGLES_DEGREES:
  2718.             fprintf(stderr, "degrees\n");
  2719.         break;
  2720.     }
  2721. }
  2722.  
  2723.  
  2724. static void
  2725. show_tics(showx, showy, showz)
  2726.     TBOOLEAN showx, showy, showz;
  2727. {
  2728.     fprintf(stderr,"\ttics are %s, ",(tic_in)? "IN" : "OUT");
  2729.     fprintf(stderr,"\tticslevel is %g\n",ticslevel);
  2730.  
  2731.     if (showx)
  2732.      show_ticdef(xtics, 'x', &xticdef);
  2733.     if (showy)
  2734.      show_ticdef(ytics, 'y', &yticdef);
  2735.     if (showz)
  2736.      show_ticdef(ztics, 'z', &zticdef);
  2737.     screen_ok = FALSE;
  2738. }
  2739.  
  2740. /* called by show_tics */
  2741. static void
  2742. show_ticdef(tics, axis, tdef)
  2743.     TBOOLEAN tics;            /* xtics ytics or ztics */
  2744.     char axis;            /* 'x' 'y' or 'z' */
  2745.     struct ticdef *tdef;    /* xticdef yticdef or zticdef */
  2746. {
  2747.     register struct ticmark *t;
  2748.  
  2749.     fprintf(stderr, "\t%c-axis tic labelling is ", axis);
  2750.     if (!tics) {
  2751.        fprintf(stderr, "OFF\n");
  2752.        return;
  2753.     }
  2754.  
  2755.     switch(tdef->type) {
  2756.        case TIC_COMPUTED: {
  2757.           fprintf(stderr, "computed automatically\n");
  2758.           break;
  2759.        }
  2760.         case TIC_MONTH: {
  2761.         fprintf(stderr, "Months computed automatically\n");
  2762.         break;
  2763.        }
  2764.         case TIC_DAY:{
  2765.         fprintf(stderr, "Days computed automatically\n");
  2766.         }
  2767.        case TIC_SERIES: {
  2768.           if (tdef->def.series.end == VERYLARGE)
  2769.             fprintf(stderr, "series from %g by %g\n", 
  2770.                   tdef->def.series.start, tdef->def.series.incr);
  2771.           else
  2772.             fprintf(stderr, "series from %g by %g until %g\n", 
  2773.                   tdef->def.series.start, tdef->def.series.incr, 
  2774.                   tdef->def.series.end);
  2775.           break;
  2776.        }
  2777.        case TIC_USER: {
  2778.           fprintf(stderr, "list (");
  2779.           for (t = tdef->def.user; t != NULL; t=t->next) {
  2780.              if (t->label)
  2781.                fprintf(stderr, "\"%s\" ", t->label);
  2782.              if (t->next)
  2783.                fprintf(stderr, "%g, ", t->position);
  2784.              else
  2785.                fprintf(stderr, "%g", t->position);
  2786.           }
  2787.           fprintf(stderr, ")\n");
  2788.           break;
  2789.        }
  2790.        default: {
  2791.           int_error("unknown ticdef type in show_ticdef()", NO_CARET);
  2792.           /* NOTREACHED */
  2793.        }
  2794.     }
  2795. }
  2796.  
  2797. static void
  2798. show_time()
  2799. {
  2800.     fprintf(stderr,"\ttime is %s, offset at %d, %d\n",
  2801.         (timedate)? "ON" : "OFF",
  2802.         time_xoffset,time_yoffset);
  2803. }
  2804.  
  2805. static void
  2806. show_term()
  2807. {
  2808.     char *str;
  2809.  
  2810.     fprintf(stderr,"\tterminal type is %s %s\n",
  2811.         term_tbl[term].name, term_options);
  2812. }
  2813.  
  2814. static void
  2815. show_plot()
  2816. {
  2817.     fprintf(stderr,"\tlast plot command was: %s\n",replot_line);
  2818. }
  2819.  
  2820. static void
  2821. show_autoscale()
  2822. {
  2823.     fprintf(stderr,"\tautoscaling is ");
  2824.     if (parametric)
  2825.         if (is_3d_plot)
  2826.             fprintf(stderr,"\tt: %s, ",(autoscale_t)? "ON" : "OFF");
  2827.         else
  2828.             fprintf(stderr,"\tu: %s, v: %s, ",
  2829.                         (autoscale_u)? "ON" : "OFF",
  2830.                         (autoscale_v)? "ON" : "OFF");
  2831.     else fprintf(stderr,"\t");
  2832.  
  2833.     if (polar) fprintf(stderr,"r: %s, ",(autoscale_r)? "ON" : "OFF");
  2834.     fprintf(stderr,"x: %s, ",(autoscale_x)? "ON" : "OFF");
  2835.     fprintf(stderr,"y: %s, ",(autoscale_y)? "ON" : "OFF");
  2836.     fprintf(stderr,"z: %s\n",(autoscale_z)? "ON" : "OFF");
  2837. }
  2838.  
  2839. static void
  2840. show_clip()
  2841. {
  2842.     fprintf(stderr,"\tpoint clip is %s\n",(clip_points)? "ON" : "OFF");
  2843.  
  2844.     if (clip_lines1)
  2845.       fprintf(stderr,
  2846.          "\tdrawing and clipping lines between inrange and outrange points\n");
  2847.     else
  2848.       fprintf(stderr,
  2849.          "\tnot drawing lines between inrange and outrange points\n");
  2850.  
  2851.     if (clip_lines2)
  2852.       fprintf(stderr,
  2853.          "\tdrawing and clipping lines between two outrange points\n");
  2854.     else
  2855.       fprintf(stderr,
  2856.          "\tnot drawing lines between two outrange points\n");
  2857. }
  2858.  
  2859. static void
  2860. show_mapping()
  2861. {
  2862.     fprintf(stderr,"\tmapping for 3-d data is ");
  2863.  
  2864.     switch (mapping3d) {
  2865.         case MAP3D_CARTESIAN:
  2866.             fprintf(stderr,"cartesian\n");
  2867.             break;
  2868.         case MAP3D_SPHERICAL:
  2869.             fprintf(stderr,"spherical\n");
  2870.             break;
  2871.         case MAP3D_CYLINDRICAL:
  2872.             fprintf(stderr,"cylindrical\n");
  2873.             break;
  2874.     }
  2875. }
  2876.  
  2877. static void
  2878. show_contour()
  2879. {
  2880.     fprintf(stderr,"\tcontour for surfaces are %s",
  2881.         (draw_contour)? "drawn" : "not drawn\n");
  2882.  
  2883.     if (draw_contour) {
  2884.             fprintf(stderr, " in %d levels on ", contour_levels);
  2885.         switch (draw_contour) {
  2886.             case CONTOUR_BASE:
  2887.                 fprintf(stderr,"grid base\n");
  2888.                 break;
  2889.             case CONTOUR_SRF:
  2890.                 fprintf(stderr,"surface\n");
  2891.                 break;
  2892.             case CONTOUR_BOTH:
  2893.                 fprintf(stderr,"grid base and surface\n");
  2894.                 break;
  2895.         }
  2896.         switch (contour_kind) {
  2897.             case CONTOUR_KIND_LINEAR:
  2898.                 fprintf(stderr,"\t\tas linear segments\n");
  2899.                 break;
  2900.             case CONTOUR_KIND_CUBIC_SPL:
  2901.                 fprintf(stderr,"\t\tas cubic spline interpolation segments with %d pts\n",
  2902.                     contour_pts);
  2903.                 break;
  2904.             case CONTOUR_KIND_BSPLINE:
  2905.                 fprintf(stderr,"\t\tas bspline approximation segments of order %d with %d pts\n",
  2906.                     contour_order, contour_pts);
  2907.                 break;
  2908.         }
  2909.         switch (levels_kind) {
  2910.             int i;
  2911.             case LEVELS_AUTO:
  2912.                 fprintf(stderr,"\t\t%d automatic levels\n", contour_levels);
  2913.                 break;
  2914.             case LEVELS_DISCRETE:
  2915.                 fprintf(stderr,"\t\t%d discrete levels at ", contour_levels);
  2916.                         fprintf(stderr, "%g", levels_list[0]);
  2917.                 for(i = 1; i < contour_levels; i++)
  2918.                     fprintf(stderr,",%g ", levels_list[i]);
  2919.                 fprintf(stderr,"\n");
  2920.                 break;
  2921.             case LEVELS_INCREMENTAL:
  2922.                 fprintf(stderr,"\t\t%d incremental levels starting at %g, step %g, end %g\n",
  2923.                     contour_levels, levels_list[0], levels_list[1],
  2924.                     levels_list[0]+contour_levels*levels_list[1]);
  2925.                 break;
  2926.         }
  2927.         fprintf(stderr,"\t\tcontour line types are %s\n", label_contours ? "varied" : "all the same");
  2928.     }
  2929. }
  2930.  
  2931. static void
  2932. show_format()
  2933. {
  2934.     fprintf(stderr, "\ttic format is x-axis: \"%s\", y-axis: \"%s\", z-axis: \"%s\"\n",
  2935.         xformat, yformat, zformat);
  2936. }
  2937.  
  2938. static void
  2939. show_logscale()
  2940. {
  2941.     char *p;
  2942.  
  2943.     if (is_log_x) {
  2944.         fprintf(stderr,"\tlogscaling x (base %g)", base_log_x);
  2945.         if (is_log_y && is_log_z)
  2946.             fprintf(stderr,", y (base %g) and z (base %g)\n",
  2947.                 base_log_y, base_log_z);
  2948.         else if (is_log_y)
  2949.             fprintf(stderr," and y (base %g)\n", base_log_y);
  2950.         else if (is_log_z)
  2951.             fprintf(stderr," and z (base %g)\n", base_log_z);
  2952.         else
  2953.             fprintf(stderr," only\n");
  2954.     } else if (is_log_y) {
  2955.         fprintf(stderr,"\tlogscaling y (base %g)", base_log_y);
  2956.         if (is_log_z)
  2957.             fprintf(stderr," and z (base %g)\n", base_log_z);
  2958.         else
  2959.             fprintf(stderr," only\n");
  2960.     } else if (is_log_z) {
  2961.         fprintf(stderr,"\tlogscaling z (base %g) only\n", base_log_z);
  2962.     } else {
  2963.         fprintf(stderr,"\tno logscaling\n");
  2964.     }
  2965. }
  2966.  
  2967. static void
  2968. show_variables()
  2969. {
  2970. register struct udvt_entry *udv = first_udv;
  2971. int len;
  2972.  
  2973.     fprintf(stderr,"\n\tVariables:\n");
  2974.     while (udv) {
  2975.          len = instring(udv->udv_name, ' ');
  2976.         fprintf(stderr,"\t%-*s ",len,udv->udv_name);
  2977.         if (udv->udv_undef)
  2978.             fputs("is undefined\n",stderr);
  2979.         else {
  2980.             fputs("= ",stderr);
  2981.             disp_value(stderr,&(udv->udv_value));
  2982.             (void) putc('\n',stderr);
  2983.         }
  2984.         udv = udv->next_udv;
  2985.     }
  2986. }
  2987.  
  2988. char *authors[] = {"Thomas Williams","Colin Kelley"}; /* primary */
  2989. void                /* used by plot.c */
  2990. show_version()
  2991. {
  2992. extern char version[];
  2993. extern char patchlevel[];
  2994. extern char date[];
  2995. extern char copyright[];
  2996. extern char bug_email[];
  2997. int x;
  2998. long time();
  2999.  
  3000.     x = time((long *)NULL) & 1;
  3001.     fprintf(stderr,"\n\t%s\n\t%sversion \n\t%s\n",
  3002.         PROGRAM, OS, version); 
  3003.     fprintf(stderr,"\tpatchlevel %s\n",patchlevel);
  3004.      fprintf(stderr, "\tlast modified %s\n", date);
  3005.     fprintf(stderr,"\n\t%s   %s, %s\n", copyright,authors[x],authors[1-x]);
  3006.     fprintf(stderr, "\n\tSend bugs and comments to %s\n", bug_email);
  3007. }
  3008.