home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / GPT34SRC / SETSHOW.C < prev    next >
C/C++ Source or Header  |  1993-05-25  |  79KB  |  3,019 lines

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