home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume24 / gnuplot3 / part01 next >
Text File  |  1991-10-26  |  54KB  |  1,859 lines

  1. Newsgroups: comp.sources.misc
  2. From: gershon%gr@cs.utah.edu (Elber Gershon)
  3. Subject:  v24i023:  gnuplot3 - interactive function plotting utility, Part01/26
  4. Message-ID: <csm-v24i023=gnuplot3.171920@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 6210c9b40603d7d8dd7763a425c3177d
  6. Date: Sat, 26 Oct 1991 22:20:25 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
  10. Posting-number: Volume 24, Issue 23
  11. Archive-name: gnuplot3/part01
  12. Environment: UNIX, MS-DOS, VMS
  13. Supersedes: gnuplot2: Volume 11, Issue 65-79
  14.  
  15.                     ANNOUNCING GNUPLOT 3.0
  16.  
  17.  What is Gnuplot 3.0?
  18.  --------------------
  19.  
  20. Gnuplot is a command-line driven interactive function plotting utility
  21. for UNIX, MSDOS, and VMS platforms.  The software is copyrighted but
  22. freely distributed (i.e., you don't have to pay for it).  It was
  23. originally intended as graphical program which would allow scientists
  24. and students to visualize mathematical functions and data.  Additions
  25. to this version of the software allow plots of three-dimensional
  26. functions and data files.  Gnuplot supports many different types of
  27. terminals, plotters, and printers and is easily extensible to include
  28. new devices.  [ The "GNU" in Gnuplot is NOT related to the Free
  29. Software Foundation, the naming is just a coincidence (and a long
  30. story). Thus gnuplot is not covered by the Gnu copyleft, but rather
  31. by its own copyright statement, included in all source code files.]
  32.  
  33.  Highlights (compared to 2.02): 
  34.  ------------------------------
  35. Gnuplot now handles surfaces as well. A new command named 'splot' (for
  36. surface plot) has been added for that purpose. A number of new 'set'
  37. options for surfaces have also been added and include: isosamples,
  38. view, contour, cntrparam, mapping and surface.  All tic/label/range
  39. setting for x and y axes were extended for z as well.
  40.  
  41. The size of data file for both curves and surfaces is now independent
  42. of the samples (and iso_samples) variables. Data structures will
  43. automatically be extended to hold the entire data file.
  44.  
  45. Command-line editing and history on most platforms.
  46.  
  47.  Other new features:
  48.  -------------------
  49. New 'errorbars' plot style.
  50. New 'using x:y{:z}' format (NOT COMPATIBLE WITH GNUPLOT 2.02).
  51. New makefile scheme for unix, that supports lots of flavors.
  52. Adjustable display of plot border ('set border').
  53. Set-commands 'x/y/zlabel' can now position the label.
  54. Set-command 'title' can now position the title.
  55. New time display command ('set time').
  56. A 'gnuplot' mode for emacs in the file gnuplot.el.
  57. SGI device was improved.
  58. New option to 'set arrow' called 'nohead'. 
  59. All PostScript devices were rewritten and merged into one (Color
  60.  Postscript is supported). Due to this many of the old postscript
  61.  terminal driver names are not supported; only 'postscript' is
  62.  recognized. Use 'help set terminal postscript' to find out how to get
  63.  your old favorite back, and more.
  64. Many small bug fixes.
  65.  
  66.  New terminal drivers:
  67.  ---------------------
  68. vws, apollo, gpr apollo, dumb, BigFig, Super
  69. VGA, ln03/hplj/hpdj, dxf.
  70.  
  71.  Complete list of device drivers supported:
  72.  ------------------------------------------
  73. aed amiga apollo bigfig cgi dumb dxf dxy eepic epson fig gpr hp26
  74. hp2648 hpgl hpljii imagen iris4d kyo latex pc post qms regis sun t410x
  75. tek unixpc unixplot v384 vws x11
  76.  
  77.  KNOWN BUGS:
  78.  -----------
  79. Some problems with logscale on the y-axis, noticed after release.
  80. Definitely a problem when mixing logscaling and autoscaling on the y
  81. axis. x-axis status unknown. Expect a fix in 3.01. 
  82.  
  83.  ===================================================================
  84.  Where to obtain Gnuplot 3.0:
  85.  ----------------------------
  86.  
  87. In general, Gnuplot 3.0 is available as the file gnuplot3.0.tar.Z.
  88. Please obtain gnuplot from the site nearest you. Many of the major ftp
  89. archives world-wide have already picked up the latest version, so if
  90. you found the old version elsewhere, you might check there.
  91.  
  92.  
  93. USENET users:
  94.  
  95.     GNUPLOT 3.0 was posted to comp.sources.misc.
  96.  
  97.  
  98. NORTH AMERICA:
  99.  
  100.      Anonymous ftp to dartmouth.edu (129.170.16.4)
  101.      Fetch
  102.         pub/gnuplot/gnuplot3.0.tar.Z
  103.      in binary mode.
  104.  
  105.      Users without ftp capability can obtain it through a mail ftp
  106.      server. Send a mail message saying 'help' to
  107.      BITFTP@pucc.princeton.edu for instructions. For a uuencoded
  108.      copy of the gnuplot sources (compressed tar file), send this
  109.      message to BITFTP@pucc.princeton.edu:
  110.          FTP DARTMOUTH.EDU UUENCODE
  111.          USER ANONYMOUS
  112.          CD pub/gnuplot
  113.          BINARY
  114.          GET gnuplot3.0.tar.Z
  115.          QUIT
  116.  
  117.  
  118. AUSTRALIA:
  119.  
  120.      Anonymous ftp to monu1.cc.monash.edu.au (130.194.1.101).
  121.      Fetch pub/gnuplot3.0.tar.Z in binary mode.
  122.  
  123.  
  124. EUROPE:
  125.  
  126.      Anonymous ftp to irisa.irisa.fr (131.254.2.3).
  127.      Fetch pub/gnuplot3.0.tar.Z in binary mode.
  128.  
  129.  ----
  130.  
  131.      DISCLAIMER - This product is not related in any way to
  132.      Pixar or any other commercial venture.
  133.  
  134.  ----
  135.   CONTACTS:
  136.      Please send any questions or comments to
  137.         pixar!info-gnuplot@ucbvax.berkeley.edu.
  138.      To join the above mailing list (or get yourself off), mail to
  139.         pixar!info-gnuplot-request@ucbvax.berkeley.edu.
  140.      Send bug reports and problems to
  141.         pixar!bug-gnuplot@ucbvax.berkeley.edu.
  142.  
  143.                                         -Thomas Williams-
  144. ----------------
  145. #!/bin/sh
  146. # This is a shell archive (produced by shar 3.49)
  147. # To extract the files from this archive, save it to a file, remove
  148. # everything above the "!/bin/sh" line above, and type "sh file_name".
  149. #
  150. # made 10/15/1991 19:23 UTC by gershon@gr.utah.edu
  151. # Source directory /n/lotus/u/grad/gershon/gp
  152. #
  153. # existing files will NOT be overwritten unless -c is specified
  154. #
  155. # This is part 1 of a multipart archive                                    
  156. # do not concatenate these parts, unpack them in order with /bin/sh        
  157. #
  158. # This shar contains:
  159. # length  mode       name
  160. # ------ ---------- ------------------------------------------
  161. #    279 -rw-r--r-- gnuplot/linkopt.tco
  162. #    889 -rw-rw-rw- gnuplot/Copyright
  163. #  63352 -rw-r--r-- gnuplot/setshow.c
  164. #   2406 -rw-r--r-- gnuplot/README
  165. #  17904 -rw-r--r-- gnuplot/help.c
  166. #  51656 -rw-rw-rw- gnuplot/bitmap.c
  167. #   2726 -rw-rw-rw- gnuplot/bitmap.h
  168. #    918 -rw-r--r-- gnuplot/buildvms.com
  169. #  22387 -rw-r--r-- gnuplot/misc.c
  170. #  41345 -rw-rw-rw- gnuplot/contour.c
  171. #    781 -rw-rw-rw- gnuplot/demo/1.dat
  172. #    781 -rw-rw-rw- gnuplot/demo/2.dat
  173. #    781 -rw-rw-rw- gnuplot/demo/3.dat
  174. #   3088 -rw-r--r-- gnuplot/demo/contours.demo
  175. #    712 -rw-rw-rw- gnuplot/demo/controls.demo
  176. #   2065 -rw-rw-rw- gnuplot/demo/electron.demo
  177. #   8538 -rw-rw-rw- gnuplot/demo/glass.dat
  178. #    909 -rw-rw-rw- gnuplot/demo/param.demo
  179. #    965 -rw-rw-rw- gnuplot/demo/polar.demo
  180. #   1045 -rw-rw-rw- gnuplot/demo/simple.demo
  181. #   3111 -rw-r--r-- gnuplot/demo/surface1.demo
  182. #   1359 -rw-r--r-- gnuplot/demo/surface2.demo
  183. #   5568 -rw-rw-rw- gnuplot/demo/using.dat
  184. #    708 -rw-r--r-- gnuplot/demo/using.demo
  185. #   3329 -rw-r--r-- gnuplot/demo/world.cor
  186. #  16720 -rw-rw-rw- gnuplot/demo/world.dat
  187. #   1349 -rw-r--r-- gnuplot/demo/world.demo
  188. #    418 -rw-r--r-- gnuplot/demo/err.dat
  189. #    491 -rw-r--r-- gnuplot/demo/poldat.demo
  190. #   6538 -rw-r--r-- gnuplot/demo/polar.dat
  191. #    867 -rw-r--r-- gnuplot/demo/errorbar.demo
  192. #  20577 -rw-r--r-- gnuplot/demo/antenna.dat
  193. #   1245 -rw-r--r-- gnuplot/demo/all.demo
  194. #   2915 -rw-r--r-- gnuplot/demo/bivariat.demo
  195. #   2363 -rw-r--r-- gnuplot/docs/Makefile
  196. #   3681 -rw-r--r-- gnuplot/docs/README
  197. #   1377 -rw-rw-rw- gnuplot/docs/checkdoc.c
  198. #   2021 -rw-rw-rw- gnuplot/docs/doc2gih.c
  199. #   1471 -rw-rw-rw- gnuplot/docs/doc2hlp.c
  200. #     90 -rw-rw-rw- gnuplot/docs/doc2hlp.com
  201. #   5125 -rw-r--r-- gnuplot/docs/doc2ms.c
  202. #   3718 -rw-r--r-- gnuplot/docs/gnuplot.1
  203. #  90586 -rw-r--r-- gnuplot/docs/gnuplot.doc
  204. #   1594 -rw-r--r-- gnuplot/docs/lasergnu.1
  205. #    570 -rw-r--r-- gnuplot/docs/latextut/Makefile
  206. #     65 -rw-rw-rw- gnuplot/docs/latextut/eg1.plt
  207. #    219 -rw-rw-rw- gnuplot/docs/latextut/eg2.plt
  208. #    781 -rw-rw-rw- gnuplot/docs/latextut/eg3.dat
  209. #    199 -rw-rw-rw- gnuplot/docs/latextut/eg3.plt
  210. #    227 -rw-rw-rw- gnuplot/docs/latextut/eg4.plt
  211. #    331 -rw-rw-rw- gnuplot/docs/latextut/eg5.plt
  212. #    457 -rw-rw-rw- gnuplot/docs/latextut/eg6.plt
  213. #   1677 -rw-r--r-- gnuplot/docs/latextut/header.tex
  214. #  16623 -rw-r--r-- gnuplot/docs/latextut/tutorial.tex
  215. #    550 -rw-r--r-- gnuplot/docs/latextut/linepoint.plt
  216. #    599 -rw-r--r-- gnuplot/docs/titlepage.ms
  217. #   5029 -rw-r--r-- gnuplot/docs/doc2tex.c
  218. #   1027 -rw-r--r-- gnuplot/docs/titlepage.tex
  219. #   2009 -rw-r--r-- gnuplot/docs/toc_entry.sty
  220. #   2688 -rw-r--r-- gnuplot/docs/Makefile.ami
  221. #   2272 -rw-rw-rw- gnuplot/corgraph.asm
  222. #   1979 -rw-rw-rw- gnuplot/corplot.c
  223. #   3799 -rw-rw-rw- gnuplot/eval.c
  224. #   5487 -rw-rw-rw- gnuplot/gnuplot.el
  225. #   8774 -rw-r--r-- gnuplot/gnuplot_x11.c
  226. #    252 -rw-rw-rw- gnuplot/linkopt.tc
  227. #   3801 -rw-r--r-- gnuplot/lasergnu
  228. #    918 -rw-rw-rw- gnuplot/header.mac
  229. #  12274 -rw-r--r-- gnuplot/readline.c
  230. #   1383 -rw-rw-rw- gnuplot/help.h
  231. #   8192 -rw-rw-rw- gnuplot/hrcgraph.asm
  232. #  16092 -rw-r--r-- gnuplot/internal.c
  233. #  85435 -rw-r--r-- gnuplot/command.c
  234. #   1980 -rw-rw-rw- gnuplot/lineproc.mac
  235. #    159 -rw-r--r-- gnuplot/linkopt.msc
  236. #   4014 -rw-r--r-- gnuplot/makefile.tc
  237. #     26 -rw-rw-rw- gnuplot/linkopt.vms
  238. #   7115 -rw-r--r-- gnuplot/term/README
  239. #   2311 -rw-rw-rw- gnuplot/term/aed.trm
  240. #   3598 -rw-rw-rw- gnuplot/term/bigfig.trm
  241. #   4407 -rw-rw-rw- gnuplot/term/cgi.trm
  242. #   2238 -rw-rw-rw- gnuplot/term/dxy.trm
  243. #   7640 -rw-r--r-- gnuplot/term/eepic.trm
  244. #  11330 -rw-rw-rw- gnuplot/term/epson.trm
  245. #   7494 -rw-r--r-- gnuplot/term/fig.trm
  246. #   2262 -rw-rw-rw- gnuplot/term/hp26.trm
  247. #   2113 -rw-rw-rw- gnuplot/term/hp2648.trm
  248. #   2857 -rw-r--r-- gnuplot/term/hpgl.trm
  249. #   8101 -rw-r--r-- gnuplot/term/hpljii.trm
  250. #  25264 -rw-r--r-- gnuplot/term/pc.trm
  251. #   7396 -rw-rw-rw- gnuplot/term/imagen.trm
  252. #   5305 -rw-r--r-- gnuplot/term/iris4d.trm
  253. #   2313 -rw-rw-rw- gnuplot/term/kyo.trm
  254. #  17764 -rw-r--r-- gnuplot/term/latex.trm
  255. #   5063 -rw-rw-rw- gnuplot/term/object.h
  256. #   9281 -rw-r--r-- gnuplot/term/post.trm
  257. #   9980 -rw-r--r-- gnuplot/term/dxf.trm
  258. #   3785 -rw-rw-rw- gnuplot/term/qms.trm
  259. #   2967 -rw-rw-rw- gnuplot/term/regis.trm
  260. #   6147 -rw-rw-rw- gnuplot/term/sun.trm
  261. #   5056 -rw-rw-rw- gnuplot/term/t410x.trm
  262. #   6716 -rw-r--r-- gnuplot/term/tek.trm
  263. #  14242 -rw-r--r-- gnuplot/term/unixpc.trm
  264. #   1929 -rw-rw-rw- gnuplot/term/unixplot.trm
  265. #   2579 -rw-rw-rw- gnuplot/term/v384.trm
  266. #   8014 -rw-r--r-- gnuplot/term/vws.trm
  267. #   2240 -rw-r--r-- gnuplot/term/x11.trm
  268. #  11637 -rw-r--r-- gnuplot/term/gpr.trm
  269. #   6235 -rw-r--r-- gnuplot/term/dumb.trm
  270. #  10991 -rw-r--r-- gnuplot/term/amiga.trm
  271. #  17013 -rw-r--r-- gnuplot/term/apollo.trm
  272. #   1260 -rw-rw-rw- gnuplot/term/impcodes.h
  273. #  10144 -rw-r--r-- gnuplot/parse.c
  274. #   2572 -rw-r--r-- gnuplot/makefile.msc
  275. #   1114 -rw-r--r-- gnuplot/copyright
  276. #  52166 -rw-r--r-- gnuplot/graph3d.c
  277. #   1998 -rw-r--r-- gnuplot/makefile.vms
  278. #  12714 -rw-r--r-- gnuplot/util.c
  279. #  25357 -rw-r--r-- gnuplot/makefile.unx
  280. #   3925 -rw-rw-rw- gnuplot/pcgraph.asm
  281. #   8795 -rw-r--r-- gnuplot/plot.c
  282. #  11940 -rw-r--r-- gnuplot/plot.h
  283. #   2981 -rw-r--r-- gnuplot/README.amiga
  284. #   8676 -rw-r--r-- gnuplot/scanner.c
  285. #   1368 -rw-r--r-- gnuplot/version.c
  286. #   3968 -rw-r--r-- gnuplot/setshow.h
  287. #  15347 -rw-rw-rw- gnuplot/standard.c
  288. #  50685 -rw-r--r-- gnuplot/term.c
  289. #    475 -rw-r--r-- gnuplot/Intergraph.x11
  290. #    232 -rw-rw-rw- gnuplot/linkopt.amg
  291. #   7729 -rw-r--r-- gnuplot/README.Install
  292. #  10762 -rw-r--r-- gnuplot/History
  293. #   1170 -rw-r--r-- gnuplot/README.gnutex
  294. #   1808 -rw-r--r-- gnuplot/makefile.amg
  295. #  42004 -rw-r--r-- gnuplot/graphics.c
  296. #   2916 -rw-r--r-- gnuplot/makefile.ami
  297. #   3953 -rw-r--r-- gnuplot/term.h
  298. #
  299. if test -r _shar_seq_.tmp; then
  300.     echo 'Must unpack archives in sequence!'
  301.     echo Please unpack part `cat _shar_seq_.tmp` next
  302.     exit 1
  303. fi
  304. # ============= gnuplot/linkopt.tco ==============
  305. if test ! -d 'gnuplot'; then
  306.     echo 'x - creating directory gnuplot'
  307.     mkdir 'gnuplot'
  308. fi
  309. if test -f 'gnuplot/linkopt.tco' -a X"$1" != X"-c"; then
  310.     echo 'x - skipping gnuplot/linkopt.tco (File already exists)'
  311.     rm -f _shar_wnt_.tmp
  312. else
  313. > _shar_wnt_.tmp
  314. echo 'x - extracting gnuplot/linkopt.tco (Text)'
  315. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/linkopt.tco' &&
  316. c:\tc\lib\C0l +
  317. /o bitmap command eval graphics graph3d help internal misc parse +
  318. plot scanner setshow standard term util version contour +
  319. /o- egavgaf hercf cgaf attf +
  320. ,gnuplot,gnuplot, +
  321. c:\tc\lib\overlay +
  322. c:\tc\lib\emu +
  323. c:\tc\lib\mathl +
  324. c:\tc\lib\cl +
  325. c:\tc\lib\graphics
  326. SHAR_EOF
  327. chmod 0644 gnuplot/linkopt.tco ||
  328. echo 'restore of gnuplot/linkopt.tco failed'
  329. Wc_c="`wc -c < 'gnuplot/linkopt.tco'`"
  330. test 279 -eq "$Wc_c" ||
  331.     echo 'gnuplot/linkopt.tco: original size 279, current size' "$Wc_c"
  332. rm -f _shar_wnt_.tmp
  333. fi
  334. # ============= gnuplot/Copyright ==============
  335. if test -f 'gnuplot/Copyright' -a X"$1" != X"-c"; then
  336.     echo 'x - skipping gnuplot/Copyright (File already exists)'
  337.     rm -f _shar_wnt_.tmp
  338. else
  339. > _shar_wnt_.tmp
  340. echo 'x - extracting gnuplot/Copyright (Text)'
  341. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/Copyright' &&
  342. /*
  343. X * Copyright (C) 1986, 1987, 1990   Thomas Williams, Colin Kelley
  344. X *
  345. X * Permission to use, copy, and distribute this software and its
  346. X * documentation for any purpose with or without fee is hereby granted, 
  347. X * provided that the above copyright notice appear in all copies and 
  348. X * that both that copyright notice and this permission notice appear 
  349. X * in supporting documentation.
  350. X *
  351. X * Permission to modify the software is granted, but not the right to
  352. X * distribute the modified code.  Modifications are to be distributed 
  353. X * as patches to released version.
  354. X *  
  355. X * This software  is provided "as is" without express or implied warranty.
  356. X * 
  357. X *
  358. X * AUTHORS
  359. X * 
  360. X *   Original Software:
  361. X *     Thomas Williams,  Colin Kelley.
  362. X * 
  363. X *   Gnuplot 2.0 additions:
  364. X *       Russell Lang, Dave Kotz, John Campbell.
  365. X * 
  366. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  367. X * 
  368. X */
  369. SHAR_EOF
  370. chmod 0666 gnuplot/Copyright ||
  371. echo 'restore of gnuplot/Copyright failed'
  372. Wc_c="`wc -c < 'gnuplot/Copyright'`"
  373. test 889 -eq "$Wc_c" ||
  374.     echo 'gnuplot/Copyright: original size 889, current size' "$Wc_c"
  375. rm -f _shar_wnt_.tmp
  376. fi
  377. # ============= gnuplot/setshow.c ==============
  378. if test -f 'gnuplot/setshow.c' -a X"$1" != X"-c"; then
  379.     echo 'x - skipping gnuplot/setshow.c (File already exists)'
  380.     rm -f _shar_wnt_.tmp
  381. else
  382. > _shar_wnt_.tmp
  383. echo 'x - extracting gnuplot/setshow.c (Text)'
  384. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/setshow.c' &&
  385. /* GNUPLOT - setshow.c */
  386. /*
  387. X * Copyright (C) 1986, 1987, 1990, 1991   Thomas Williams, Colin Kelley
  388. X *
  389. X * Permission to use, copy, and distribute this software and its
  390. X * documentation for any purpose with or without fee is hereby granted, 
  391. X * provided that the above copyright notice appear in all copies and 
  392. X * that both that copyright notice and this permission notice appear 
  393. X * in supporting documentation.
  394. X *
  395. X * Permission to modify the software is granted, but not the right to
  396. X * distribute the modified code.  Modifications are to be distributed 
  397. X * as patches to released version.
  398. X *  
  399. X * This software is provided "as is" without express or implied warranty.
  400. X * 
  401. X *
  402. X * AUTHORS
  403. X * 
  404. X *   Original Software:
  405. X *     Thomas Williams,  Colin Kelley.
  406. X * 
  407. X *   Gnuplot 2.0 additions:
  408. X *       Russell Lang, Dave Kotz, John Campbell.
  409. X *
  410. X *   Gnuplot 3.0 additions:
  411. X *       Gershon Elber and many others.
  412. X * 
  413. X * Send your comments or suggestions to 
  414. X *  pixar!info-gnuplot@sun.com.
  415. X * This is a mailing list; to join it send a note to 
  416. X *  pixar!info-gnuplot-request@sun.com.  
  417. X * Send bug reports to
  418. X *  pixar!bug-gnuplot@sun.com.
  419. X */
  420. X
  421. #include <stdio.h>
  422. #include <math.h>
  423. #include "plot.h"
  424. #include "setshow.h"
  425. X
  426. #define DEF_FORMAT   "%g"    /* default format for tic mark labels */
  427. #define SIGNIF (0.01)        /* less than one hundredth of a tic mark */
  428. X
  429. /*
  430. X * global variables to hold status of 'set' options
  431. X *
  432. X */
  433. BOOLEAN            autoscale_r    = TRUE;
  434. BOOLEAN            autoscale_t    = TRUE;
  435. BOOLEAN            autoscale_u    = TRUE;
  436. BOOLEAN            autoscale_v    = TRUE;
  437. BOOLEAN            autoscale_x    = TRUE;
  438. BOOLEAN            autoscale_y    = TRUE;
  439. BOOLEAN            autoscale_z    = TRUE;
  440. BOOLEAN            autoscale_lt    = TRUE;
  441. BOOLEAN            autoscale_lu    = TRUE;
  442. BOOLEAN            autoscale_lv    = TRUE;
  443. BOOLEAN            autoscale_lx    = TRUE;
  444. BOOLEAN            autoscale_ly    = TRUE;
  445. BOOLEAN            autoscale_lz    = TRUE;
  446. BOOLEAN           clip_points    = FALSE;
  447. BOOLEAN           clip_lines1    = TRUE;
  448. BOOLEAN           clip_lines2    = FALSE;
  449. BOOLEAN            draw_border    = TRUE;
  450. BOOLEAN            draw_surface    = TRUE;
  451. BOOLEAN            timedate    = FALSE;
  452. char            dummy_var[MAX_NUM_VAR][MAX_ID_LEN+1] = { "x", "y" };
  453. char            xformat[MAX_ID_LEN+1] = DEF_FORMAT;
  454. char            yformat[MAX_ID_LEN+1] = DEF_FORMAT;
  455. char            zformat[MAX_ID_LEN+1] = DEF_FORMAT;
  456. enum            PLOT_STYLE data_style    = POINTS,
  457. X            func_style    = LINES;
  458. BOOLEAN            grid        = FALSE;
  459. int                key            = -1;    /* default position */
  460. double            key_x, key_y, key_z;    /* user specified position for key */
  461. BOOLEAN            log_x        = FALSE,
  462. X            log_y        = FALSE,
  463. X            log_z        = FALSE;
  464. FILE*            outfile;
  465. char            outstr[MAX_ID_LEN+1] = "STDOUT";
  466. BOOLEAN            parametric    = FALSE;
  467. BOOLEAN            polar        = FALSE;
  468. int            angles_format    = ANGLES_RADIANS;
  469. int            mapping3d    = MAP3D_CARTESIAN;
  470. int            samples        = SAMPLES;
  471. int            iso_samples    = ISO_SAMPLES;
  472. float            xsize        = 1.0;  /* scale factor for size */
  473. float            ysize        = 1.0;  /* scale factor for size */
  474. float            zsize        = 1.0;  /* scale factor for size */
  475. float            surface_rot_z   = 30.0; /* Default 3d transform. */
  476. float            surface_rot_x   = 60.0;
  477. float            surface_scale   = 1.0;
  478. float            surface_zscale  = 1.0;
  479. int            term        = 0;        /* unknown term is 0 */
  480. char            term_options[MAX_ID_LEN+1] = "";
  481. char            title[MAX_LINE_LEN+1] = "";
  482. char            xlabel[MAX_LINE_LEN+1] = "";
  483. char            ylabel[MAX_LINE_LEN+1] = "";
  484. char            zlabel[MAX_LINE_LEN+1] = "";
  485. int            time_xoffset    = 0;
  486. int            time_yoffset    = 0;
  487. int            title_xoffset    = 0;
  488. int            title_yoffset    = 0;
  489. int            xlabel_xoffset    = 0;
  490. int            xlabel_yoffset    = 0;
  491. int            ylabel_xoffset    = 0;
  492. int            ylabel_yoffset    = 0;
  493. int            zlabel_xoffset    = 0;
  494. int            zlabel_yoffset    = 0;
  495. double            rmin        = -0.0,
  496. X            rmax        =  10.0,
  497. X            tmin        = -5.0,
  498. X            tmax        =  5.0,
  499. X            umin        = -5.0,
  500. X            umax        = 5.0,
  501. X            vmin        = -5.0,
  502. X            vmax        = 5.0,
  503. X            xmin        = -10.0,
  504. X            xmax        = 10.0,
  505. X            ymin        = -10.0,
  506. X            ymax        = 10.0,
  507. X            zmin        = -10.0,
  508. X            zmax        = 10.0;
  509. double            loff        = 0.0,
  510. X            roff        = 0.0,
  511. X            toff        = 0.0,
  512. X            boff        = 0.0;
  513. int            draw_contour    = CONTOUR_NONE;
  514. int            contour_pts    = 5;
  515. int            contour_kind    = CONTOUR_KIND_LINEAR;
  516. int            contour_order    = 4;
  517. int            contour_levels    = 5;
  518. double            zero = ZERO;            /* zero threshold, not 0! */
  519. X
  520. BOOLEAN xzeroaxis = TRUE;
  521. BOOLEAN yzeroaxis = TRUE;
  522. X
  523. BOOLEAN xtics = TRUE;
  524. BOOLEAN ytics = TRUE;
  525. BOOLEAN ztics = TRUE;
  526. X
  527. float ticslevel = 0.5;
  528. X
  529. struct ticdef xticdef = {TIC_COMPUTED};
  530. struct ticdef yticdef = {TIC_COMPUTED};
  531. struct ticdef zticdef = {TIC_COMPUTED};
  532. X
  533. BOOLEAN            tic_in        = TRUE;
  534. X
  535. struct text_label *first_label = NULL;
  536. struct arrow_def *first_arrow = NULL;
  537. X
  538. /*** other things we need *****/
  539. extern char *strcpy(),*strcat();
  540. extern int strlen();
  541. extern FILE *popen();
  542. X
  543. /* input data, parsing variables */
  544. extern struct lexical_unit token[];
  545. extern char input_line[];
  546. extern int num_tokens, c_token;
  547. extern BOOLEAN interactive;    /* from plot.c */
  548. X
  549. extern char replot_line[];
  550. extern struct udvt_entry *first_udv;
  551. extern BOOLEAN is_3d_plot;
  552. X
  553. extern double magnitude(),real();
  554. extern struct value *const_express();
  555. X
  556. /******** Local functions ********/
  557. static void set_xyzlabel();
  558. static void set_label();
  559. static void set_nolabel();
  560. static void set_arrow();
  561. static void set_noarrow();
  562. static void load_tics();
  563. static void load_tic_user();
  564. static void free_marklist();
  565. static void load_tic_series();
  566. static void load_offsets();
  567. X
  568. static void show_style(), show_range(), show_zero(), show_border();
  569. static void show_offsets(), show_output(), show_samples(), show_isosamples();
  570. static void show_view(), show_size(), show_title(), show_xlabel();
  571. static void show_angles();
  572. static void show_ylabel(), show_zlabel(), show_xzeroaxis(), show_yzeroaxis();
  573. static void show_label(), show_arrow(), show_grid(), show_key();
  574. static void show_polar(), show_parametric(), show_tics(), show_ticdef();
  575. static void show_time(), show_term(), show_plot(), show_autoscale(), show_clip();
  576. static void show_contour(), show_mapping(), show_format(), show_logscale();
  577. static void show_variables(), show_surface();
  578. static void delete_label();
  579. static int assign_label_tag();
  580. static void delete_arrow();
  581. static int assign_arrow_tag();
  582. static BOOLEAN set_one(), set_two(), set_three();
  583. static BOOLEAN show_one(), show_two();
  584. X
  585. /******** The 'set' command ********/
  586. void
  587. set_command()
  588. {
  589. X    c_token++;
  590. X
  591. X    if (!set_one() && !set_two() && !set_three())
  592. X    int_error(
  593. X    "valid set options:  'angles' '{no}arrow', {no}autoscale', \n\
  594. X    '{no}border', '{no}clip', 'cntrparam', '{no}contour', 'data style', \n\
  595. X    'dummy', 'format', 'function style', '{no}grid', 'isosamples', \n\
  596. X    '{no}key', '{no}label', '{no}logscale', 'mapping', 'offsets', \n\
  597. X    'output', '{no}parametric', '{no}polar', 'rrange', 'samples', \n\
  598. X    'size', '{no}surface', 'terminal', 'tics', 'ticslevel', '{no}time', \n\
  599. X    'title', 'trange', 'urange', 'view', 'vrange', 'xlabel', 'xrange', \n\
  600. X    '{no}xtics', '{no}xzeroaxis', 'ylabel', 'yrange', '{no}ytics', \n\
  601. X    '{no}yzeroaxis', 'zero', '{no}zeroaxis', 'zlabel', 'zrange', \n\
  602. X    '{no}ztics'", c_token);
  603. }
  604. X
  605. /* return TRUE if a command match, FALSE if not */
  606. static BOOLEAN
  607. set_one()
  608. {
  609. X    if (almost_equals(c_token,"ar$row")) {
  610. X        c_token++;
  611. X        set_arrow();
  612. X    }
  613. X    else if (almost_equals(c_token,"noar$row")) {
  614. X        c_token++;
  615. X        set_noarrow();
  616. X    }
  617. X     else if (almost_equals(c_token,"au$toscale")) {
  618. X        c_token++;
  619. X        if (END_OF_COMMAND) {
  620. X           autoscale_r=autoscale_t = autoscale_x = autoscale_y = autoscale_z = TRUE;
  621. X        } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
  622. X           autoscale_x = autoscale_y = TRUE;
  623. X           c_token++;
  624. X        } else if (equals(c_token, "r")) {
  625. X           autoscale_r = TRUE;
  626. X           c_token++;
  627. X        } else if (equals(c_token, "t")) {
  628. X           autoscale_t = TRUE;
  629. X           c_token++;
  630. X        } else if (equals(c_token, "x")) {
  631. X           autoscale_x = TRUE;
  632. X           c_token++;
  633. X        } else if (equals(c_token, "y")) {
  634. X           autoscale_y = TRUE;
  635. X           c_token++;
  636. X        } else if (equals(c_token, "z")) {
  637. X           autoscale_z = TRUE;
  638. X           c_token++;
  639. X        }
  640. X    } 
  641. X    else if (almost_equals(c_token,"noau$toscale")) {
  642. X        c_token++;
  643. X        if (END_OF_COMMAND) {
  644. X           autoscale_r=autoscale_t = autoscale_x = autoscale_y = autoscale_z = FALSE;
  645. X        } else if (equals(c_token, "xy") || equals(c_token, "tyx")) {
  646. X           autoscale_x = autoscale_y = FALSE;
  647. X           c_token++;
  648. X        } else if (equals(c_token, "r")) {
  649. X           autoscale_r = FALSE;
  650. X           c_token++;
  651. X        } else if (equals(c_token, "t")) {
  652. X           autoscale_t = FALSE;
  653. X           c_token++;
  654. X        } else if (equals(c_token, "x")) {
  655. X           autoscale_x = FALSE;
  656. X           c_token++;
  657. X        } else if (equals(c_token, "y")) {
  658. X           autoscale_y = FALSE;
  659. X           c_token++;
  660. X        } else if (equals(c_token, "z")) {
  661. X           autoscale_z = FALSE;
  662. X           c_token++;
  663. X        }
  664. X    } 
  665. X    else if (almost_equals(c_token,"bor$der")) {
  666. X        draw_border = TRUE;
  667. X        c_token++;
  668. X    }
  669. X    else if (almost_equals(c_token,"nobor$der")) {
  670. X        draw_border = FALSE;
  671. X        c_token++;
  672. X    }
  673. X    else if (almost_equals(c_token,"c$lip")) {
  674. X        c_token++;
  675. X        if (END_OF_COMMAND)
  676. X         /* assuming same as points */
  677. X         clip_points = TRUE;
  678. X        else if (almost_equals(c_token, "p$oints"))
  679. X         clip_points = TRUE;
  680. X        else if (almost_equals(c_token, "o$ne"))
  681. X         clip_lines1 = TRUE;
  682. X        else if (almost_equals(c_token, "t$wo"))
  683. X         clip_lines2 = TRUE;
  684. X        else
  685. X         int_error("expecting 'points', 'one', or 'two'", c_token);
  686. X        c_token++;
  687. X    }
  688. X    else if (almost_equals(c_token,"noc$lip")) {
  689. X        c_token++;
  690. X        if (END_OF_COMMAND) {
  691. X           /* same as all three */
  692. X           clip_points = FALSE;
  693. X           clip_lines1 = FALSE;
  694. X           clip_lines2 = FALSE;
  695. X        } else if (almost_equals(c_token, "p$oints"))
  696. X         clip_points = FALSE;
  697. X        else if (almost_equals(c_token, "o$ne"))
  698. X         clip_lines1 = FALSE;
  699. X        else if (almost_equals(c_token, "t$wo"))
  700. X         clip_lines2 = FALSE;
  701. X        else
  702. X         int_error("expecting 'points', 'one', or 'two'", c_token);
  703. X        c_token++;
  704. X    }
  705. X    else if (almost_equals(c_token,"ma$pping3d")) {
  706. X        c_token++;
  707. X        if (END_OF_COMMAND)
  708. X         /* assuming same as points */
  709. X         mapping3d = MAP3D_CARTESIAN;
  710. X        else if (almost_equals(c_token, "ca$rtesian"))
  711. X         mapping3d = MAP3D_CARTESIAN;
  712. X        else if (almost_equals(c_token, "s$pherical"))
  713. X         mapping3d = MAP3D_SPHERICAL;
  714. X        else if (almost_equals(c_token, "cy$lindrical"))
  715. X         mapping3d = MAP3D_CYLINDRICAL;
  716. X        else
  717. X         int_error("expecting 'cartesian', 'spherical', or 'cylindrical'", c_token);
  718. X        c_token++;
  719. X    }
  720. X    else if (almost_equals(c_token,"co$ntour")) {
  721. X        c_token++;
  722. X        if (END_OF_COMMAND)
  723. X         /* assuming same as points */
  724. X         draw_contour = CONTOUR_BASE;
  725. X        else if (almost_equals(c_token, "ba$se"))
  726. X         draw_contour = CONTOUR_BASE;
  727. X        else if (almost_equals(c_token, "s$urface"))
  728. X         draw_contour = CONTOUR_SRF;
  729. X        else if (almost_equals(c_token, "bo$th"))
  730. X         draw_contour = CONTOUR_BOTH;
  731. X        else
  732. X         int_error("expecting 'base', 'surface', or 'both'", c_token);
  733. X        c_token++;
  734. X    }
  735. X    else if (almost_equals(c_token,"noco$ntour")) {
  736. X        c_token++;
  737. X        draw_contour = CONTOUR_NONE;
  738. X    }
  739. X    else if (almost_equals(c_token,"cntrp$aram")) {
  740. X        struct value a;
  741. X
  742. X        c_token++;
  743. X        if (END_OF_COMMAND) {
  744. X         /* assuming same as defaults */
  745. X         contour_pts = 5;
  746. X         contour_kind = CONTOUR_KIND_LINEAR;
  747. X         contour_order = 4;
  748. X         contour_levels = 5;
  749. X        }
  750. X        else if (almost_equals(c_token, "p$oints")) {
  751. X         c_token++;
  752. X         contour_pts = (int) real(const_express(&a));
  753. X        }
  754. X        else if (almost_equals(c_token, "li$near")) {
  755. X         c_token++;
  756. X         contour_kind = CONTOUR_KIND_LINEAR;
  757. X        }
  758. X        else if (almost_equals(c_token, "c$ubicspline")) {
  759. X         c_token++;
  760. X         contour_kind = CONTOUR_KIND_CUBIC_SPL;
  761. X        }
  762. X        else if (almost_equals(c_token, "b$spline")) {
  763. X         c_token++;
  764. X         contour_kind = CONTOUR_KIND_BSPLINE;
  765. X        }
  766. X        else if (almost_equals(c_token, "le$vels")) {
  767. X         c_token++;
  768. X         contour_levels = (int) real(const_express(&a));
  769. X        }
  770. X        else if (almost_equals(c_token, "o$rder")) {
  771. X         int order;
  772. X         c_token++;
  773. X         order = (int) real(const_express(&a));
  774. X         if ( order < 2 || order > 10 )
  775. X             int_error("bspline order must be in [2..10] range.", c_token);
  776. X         contour_order = order;
  777. X        }
  778. X        else
  779. X         int_error("expecting 'linear', 'cubicspline', 'bspline', 'points', 'levels' or 'order'", c_token);
  780. X        c_token++;
  781. X    }
  782. X    else if (almost_equals(c_token,"d$ata")) {
  783. X        c_token++;
  784. X        if (!almost_equals(c_token,"s$tyle"))
  785. X            int_error("expecting keyword 'style'",c_token);
  786. X        data_style = get_style();
  787. X    }
  788. X    else if (almost_equals(c_token,"d$ummy")) {
  789. X        c_token++;
  790. X        if (END_OF_COMMAND)
  791. X            int_error("expecting dummy variable name", c_token);
  792. X        else {
  793. X            if (!equals(c_token,","))
  794. X                copy_str(dummy_var[0],c_token++);
  795. X            if (!END_OF_COMMAND && equals(c_token,",")) {
  796. X                c_token++;
  797. X                if (END_OF_COMMAND)
  798. X                    int_error("expecting second dummy variable name", c_token);
  799. X                copy_str(dummy_var[1],c_token++);
  800. X                }
  801. X        }
  802. X    }
  803. X    else if (almost_equals(c_token,"fo$rmat")) {
  804. X        BOOLEAN setx, sety, setz;
  805. X        c_token++;
  806. X        if (equals(c_token,"x")) {
  807. X            setx = TRUE; sety = setz = FALSE;
  808. X            c_token++;
  809. X        }
  810. X        else if (equals(c_token,"y")) {
  811. X            setx = setz = FALSE; sety = TRUE;
  812. X            c_token++;
  813. X        }
  814. X        else if (equals(c_token,"z")) {
  815. X            setx = sety = FALSE; setz = TRUE;
  816. X            c_token++;
  817. X        }
  818. X        else if (equals(c_token,"xy") || equals(c_token,"yx")) {
  819. X            setx = sety = TRUE; setz = FALSE;
  820. X            c_token++;
  821. X        }
  822. X        else if (isstring(c_token) || END_OF_COMMAND) {
  823. X            /* Assume he wants all */
  824. X            setx = sety = setz = TRUE;
  825. X        }
  826. X        if (END_OF_COMMAND) {
  827. X            if (setx)
  828. X                (void) strcpy(xformat,DEF_FORMAT);
  829. X            if (sety)
  830. X                (void) strcpy(yformat,DEF_FORMAT);
  831. X            if (setz)
  832. X                (void) strcpy(zformat,DEF_FORMAT);
  833. X        }
  834. X        else {
  835. X            if (!isstring(c_token))
  836. X              int_error("expecting format string",c_token);
  837. X            else {
  838. X                if (setx)
  839. X                 quote_str(xformat,c_token);
  840. X                if (sety)
  841. X                 quote_str(yformat,c_token);
  842. X                if (setz)
  843. X                 quote_str(zformat,c_token);
  844. X                c_token++;
  845. X            }
  846. X        }
  847. X    }
  848. X    else if (almost_equals(c_token,"fu$nction")) {
  849. X        c_token++;
  850. X        if (!almost_equals(c_token,"s$tyle"))
  851. X            int_error("expecting keyword 'style'",c_token);
  852. X        func_style = get_style();
  853. X    }
  854. X    else if (almost_equals(c_token,"la$bel")) {
  855. X        c_token++;
  856. X        set_label();
  857. X    }
  858. X    else if (almost_equals(c_token,"nola$bel")) {
  859. X        c_token++;
  860. X        set_nolabel();
  861. X    }
  862. X    else if (almost_equals(c_token,"lo$gscale")) {
  863. X        c_token++;
  864. X        if (END_OF_COMMAND) {
  865. X           log_x = log_y = log_z = TRUE;
  866. X        } else {
  867. X           if (chr_in_str(c_token, 'x'))
  868. X               log_x = TRUE;
  869. X           if (chr_in_str(c_token, 'y'))
  870. X               log_y = TRUE;
  871. X           if (chr_in_str(c_token, 'z'))
  872. X               log_z = TRUE;
  873. X           c_token++;
  874. X        }
  875. X    }
  876. X    else if (almost_equals(c_token,"nolo$gscale")) {
  877. X        c_token++;
  878. X        if (END_OF_COMMAND) {
  879. X        log_x = log_y = log_z = FALSE;
  880. X        } else {
  881. X        if (chr_in_str(c_token, 'x'))
  882. X            log_x = FALSE;
  883. X        if (chr_in_str(c_token, 'y'))
  884. X            log_y = FALSE;
  885. X        if (chr_in_str(c_token, 'z'))
  886. X            log_z = FALSE;
  887. X        c_token++;
  888. X        }
  889. X    } 
  890. X    else if (almost_equals(c_token,"of$fsets")) {
  891. X        c_token++;
  892. X        if (END_OF_COMMAND) {
  893. X            loff = roff = toff = boff = 0.0;  /* Reset offsets */
  894. X        }
  895. X        else {
  896. X            load_offsets (&loff,&roff,&toff,&boff);
  897. X        }
  898. X    }
  899. X    else
  900. X        return(FALSE);    /* no command match */
  901. X    return(TRUE);
  902. }
  903. X
  904. X
  905. /* return TRUE if a command match, FALSE if not */
  906. static BOOLEAN
  907. set_two()
  908. {
  909. X     char testfile[MAX_LINE_LEN+1];
  910. #ifdef unix
  911. X     static BOOLEAN pipe_open = FALSE;
  912. #endif
  913. X
  914. X    if (almost_equals(c_token,"o$utput")) {
  915. X        register FILE *f;
  916. X
  917. X        c_token++;
  918. X        if (term && term_init)
  919. X            (*term_tbl[term].reset)();
  920. X        if (END_OF_COMMAND) {    /* no file specified */
  921. X             UP_redirect (4);
  922. X            if (outfile != stdout) { /* Never close stdout */
  923. #ifdef unix
  924. X                if ( pipe_open ) {
  925. X                    (void) pclose(outfile);
  926. X                    pipe_open = FALSE;
  927. X                } else
  928. #endif
  929. X                    (void) fclose(outfile);
  930. X            }
  931. X            outfile = stdout; /* Don't dup... */
  932. X            term_init = FALSE;
  933. X            (void) strcpy(outstr,"STDOUT");
  934. X        } else if (!isstring(c_token))
  935. X            int_error("expecting filename",c_token);
  936. X        else {
  937. X            quote_str(testfile,c_token);
  938. #ifdef unix
  939. X            if ( *testfile == '|' ) {
  940. X              if ((f = popen(testfile+1,"w")) == (FILE *)NULL)
  941. X                os_error("cannot create pipe; output not changed",c_token);
  942. X              else
  943. X                pipe_open = TRUE;
  944. X            } else
  945. #endif
  946. X              if ((f = fopen(testfile,"w")) == (FILE *)NULL)
  947. X                os_error("cannot open file; output not changed",c_token);
  948. X            if (outfile != stdout) /* Never close stdout */
  949. X                (void) fclose(outfile);
  950. X            outfile = f;
  951. X            term_init = FALSE;
  952. X            outstr[0] = '\'';
  953. X            (void) strcat(strcpy(outstr+1,testfile),"'");
  954. X             UP_redirect (1);
  955. X        }
  956. X        c_token++;
  957. X    }
  958. X    else if (almost_equals(c_token,"tit$le")) {
  959. X        set_xyzlabel(title,&title_xoffset,&title_yoffset);
  960. X    }
  961. X    else if (almost_equals(c_token,"xl$abel")) {
  962. X        set_xyzlabel(xlabel,&xlabel_xoffset,&xlabel_yoffset);
  963. X    }
  964. X    else if (almost_equals(c_token,"yl$abel")) {
  965. X        set_xyzlabel(ylabel,&ylabel_xoffset,&ylabel_yoffset);
  966. X    }
  967. X    else if (almost_equals(c_token,"zl$abel")) {
  968. X        set_xyzlabel(zlabel,&zlabel_xoffset,&zlabel_yoffset);
  969. X    }
  970. X    else if (almost_equals(c_token,"xzero$axis")) {
  971. X        c_token++;
  972. X        xzeroaxis = TRUE;
  973. X    } 
  974. X    else if (almost_equals(c_token,"yzero$axis")) {
  975. X        c_token++;
  976. X        yzeroaxis = TRUE;
  977. X    } 
  978. X    else if (almost_equals(c_token,"zeroa$xis")) {
  979. X        c_token++;
  980. X        yzeroaxis = TRUE;
  981. X        xzeroaxis = TRUE;
  982. X    } 
  983. X    else if (almost_equals(c_token,"noxzero$axis")) {
  984. X        c_token++;
  985. X        xzeroaxis = FALSE;
  986. X    } 
  987. X    else if (almost_equals(c_token,"noyzero$axis")) {
  988. X        c_token++;
  989. X        yzeroaxis = FALSE;
  990. X    } 
  991. X    else if (almost_equals(c_token,"nozero$axis")) {
  992. X        c_token++;
  993. X        xzeroaxis = FALSE;
  994. X        yzeroaxis = FALSE;
  995. X    } 
  996. X    else if (almost_equals(c_token,"par$ametric")) {
  997. X        if (!parametric) {
  998. X           parametric = TRUE;
  999. X           strcpy (dummy_var[0], "t");
  1000. X           strcpy (dummy_var[1], "y");
  1001. X             (void) fprintf(stderr,"\n\tdummy variable is t for curves, u/v for surfaces\n");
  1002. X        }
  1003. X        c_token++;
  1004. X    }
  1005. X    else if (almost_equals(c_token,"nopar$ametric")) {
  1006. X        if (parametric) {
  1007. X           parametric = FALSE;
  1008. X           strcpy (dummy_var[0], "x");
  1009. X           strcpy (dummy_var[1], "y");
  1010. X             (void) fprintf(stderr,"\n\tdummy variable is x for curves, x/y for surfaces\n");
  1011. X        }
  1012. X        c_token++;
  1013. X    }
  1014. X    else if (almost_equals(c_token,"pol$ar")) {
  1015. X        if (!polar) {
  1016. X            polar = TRUE;
  1017. X            if (parametric) {
  1018. X                tmin = 0.0;
  1019. X                tmax = 2*Pi;
  1020. X            } else if (angles_format == ANGLES_DEGREES) {
  1021. X                xmin = 0.0;
  1022. X                xmax = 360.0;
  1023. X            } else {
  1024. X                xmin = 0.0;
  1025. X                xmax = 2*Pi;
  1026. X            }
  1027. X        }
  1028. X        c_token++;
  1029. X    }
  1030. X    else if (almost_equals(c_token,"nopo$lar")) {
  1031. X        if (polar) {
  1032. X            polar = FALSE;
  1033. X            if (parametric) {
  1034. X                tmin = -5.0;
  1035. X                tmax = 5.0;
  1036. X            } else {
  1037. X                xmin = -10.0;
  1038. X                xmax = 10.0;
  1039. X            }
  1040. X        }
  1041. X        c_token++;
  1042. X    }
  1043. X    else if (almost_equals(c_token,"an$gles")) {
  1044. X        c_token++;
  1045. X        if (END_OF_COMMAND) {
  1046. X        /* assuming same as defaults */
  1047. X        angles_format = ANGLES_RADIANS;
  1048. X        }
  1049. X        else if (almost_equals(c_token, "r$adians")) {
  1050. X        angles_format = ANGLES_RADIANS;
  1051. X        c_token++;
  1052. X        }
  1053. X        else if (almost_equals(c_token, "d$egrees")) {
  1054. X        angles_format = ANGLES_DEGREES;
  1055. X        c_token++;
  1056. X        }
  1057. X        else
  1058. X         int_error("expecting 'radians' or 'degrees'", c_token);
  1059. X    }
  1060. X    else if (almost_equals(c_token,"g$rid")) {
  1061. X        grid = TRUE;
  1062. X        c_token++;
  1063. X    }
  1064. X    else if (almost_equals(c_token,"nog$rid")) {
  1065. X        grid = FALSE;
  1066. X        c_token++;
  1067. X    }
  1068. X    else if (almost_equals(c_token,"su$rface")) {
  1069. X        draw_surface = TRUE;
  1070. X        c_token++;
  1071. X    }
  1072. X    else if (almost_equals(c_token,"nosu$rface")) {
  1073. X        draw_surface = FALSE;
  1074. X        c_token++;
  1075. X    }
  1076. X    else if (almost_equals(c_token,"k$ey")) {
  1077. X        struct value a;
  1078. X        c_token++;
  1079. X        if (END_OF_COMMAND) {
  1080. X            key = -1;
  1081. X        } 
  1082. X        else {
  1083. X            key_x = real(const_express(&a));
  1084. X            if (!equals(c_token,","))
  1085. X                int_error("',' expected",c_token);
  1086. X            c_token++;
  1087. X            key_y = real(const_express(&a));
  1088. X            if (equals(c_token,","))
  1089. X            {
  1090. X                    c_token++;
  1091. X                key_z = real(const_express(&a));
  1092. X            }
  1093. X            key = 1;
  1094. X        } 
  1095. X    }
  1096. X    else if (almost_equals(c_token,"nok$ey")) {
  1097. X        key = 0;
  1098. X        c_token++;
  1099. X    }
  1100. X    else if (almost_equals(c_token,"tic$s")) {
  1101. X        tic_in = TRUE;
  1102. X        c_token++;
  1103. X        if (almost_equals(c_token,"i$n")) {
  1104. X            tic_in = TRUE;
  1105. X            c_token++;
  1106. X        }
  1107. X        else if (almost_equals(c_token,"o$ut")) {
  1108. X            tic_in = FALSE;
  1109. X            c_token++;
  1110. X        }
  1111. X    }
  1112. X     else if (almost_equals(c_token,"xt$ics")) {
  1113. X        xtics = TRUE;
  1114. X        c_token++;
  1115. X        if (END_OF_COMMAND) { /* reset to default */
  1116. X           if (xticdef.type == TIC_USER) {
  1117. X              free_marklist(xticdef.def.user);
  1118. X              xticdef.def.user = NULL;
  1119. X           }
  1120. X           xticdef.type = TIC_COMPUTED;
  1121. X        }
  1122. X        else
  1123. X         load_tics(&xticdef);
  1124. X    } 
  1125. X     else if (almost_equals(c_token,"noxt$ics")) {
  1126. X        xtics = FALSE;
  1127. X        c_token++;
  1128. X    } 
  1129. X     else if (almost_equals(c_token,"yt$ics")) {
  1130. X        ytics = TRUE;
  1131. X        c_token++;
  1132. X        if (END_OF_COMMAND) { /* reset to default */
  1133. X           if (yticdef.type == TIC_USER) {
  1134. X              free_marklist(yticdef.def.user);
  1135. X              yticdef.def.user = NULL;
  1136. X           }
  1137. X           yticdef.type = TIC_COMPUTED;
  1138. X        }
  1139. X        else
  1140. X         load_tics(&yticdef);
  1141. X    } 
  1142. X     else if (almost_equals(c_token,"noyt$ics")) {
  1143. X        ytics = FALSE;
  1144. X        c_token++;
  1145. X    } 
  1146. X     else if (almost_equals(c_token,"zt$ics")) {
  1147. X        ztics = TRUE;
  1148. X        c_token++;
  1149. X        if (END_OF_COMMAND) { /* reset to default */
  1150. X           if (zticdef.type == TIC_USER) {
  1151. X              free_marklist(zticdef.def.user);
  1152. X              zticdef.def.user = NULL;
  1153. X           }
  1154. X           zticdef.type = TIC_COMPUTED;
  1155. X        }
  1156. X        else
  1157. X         load_tics(&zticdef);
  1158. X    } 
  1159. X     else if (almost_equals(c_token,"nozt$ics")) {
  1160. X        ztics = FALSE;
  1161. X        c_token++;
  1162. X    } 
  1163. X    else if (almost_equals(c_token,"ticsl$evel")) {
  1164. X        double tlvl;
  1165. X        struct value a;
  1166. X
  1167. X        c_token++;
  1168. X        tlvl = real(const_express(&a));
  1169. X        if (tlvl < 0.0)
  1170. X            int_error("tics level must be > 0; ticslevel unchanged",
  1171. X                c_token);
  1172. X        else {
  1173. X            ticslevel = tlvl;
  1174. X        }
  1175. X    }
  1176. X    else
  1177. X    return(FALSE);    /* no command match */
  1178. X
  1179. X    return(TRUE);
  1180. }
  1181. X
  1182. X
  1183. /* return TRUE if a command match, FALSE if not */
  1184. static BOOLEAN
  1185. set_three()
  1186. {
  1187. X     if (almost_equals(c_token,"sa$mples")) {
  1188. X        register int tsamp;
  1189. X        struct value a;
  1190. X
  1191. X        c_token++;
  1192. X        tsamp = (int)magnitude(const_express(&a));
  1193. X        if (tsamp < 2)
  1194. X            int_error("sampling rate must be > 1; sampling unchanged",
  1195. X                c_token);
  1196. X        else {
  1197. X                extern struct surface_points *first_3dplot;
  1198. X            register struct surface_points *f_3dp = first_3dplot;
  1199. X
  1200. X            first_3dplot = NULL;
  1201. X            sp_free(f_3dp);
  1202. X
  1203. X            samples = tsamp;
  1204. X        }
  1205. X    }
  1206. X    else if (almost_equals(c_token,"isosa$mples")) {
  1207. X        register int tsamp;
  1208. X        struct value a;
  1209. X
  1210. X        c_token++;
  1211. X        tsamp = (int)magnitude(const_express(&a));
  1212. X        if (tsamp < 2)
  1213. X            int_error("sampling rate must be > 1; sampling unchanged",
  1214. X                c_token);
  1215. X        else {
  1216. X                extern struct curve_points *first_plot;
  1217. X                extern struct surface_points *first_3dplot;
  1218. X            register struct curve_points *f_p = first_plot;
  1219. X            register struct surface_points *f_3dp = first_3dplot;
  1220. X
  1221. X            first_plot = NULL;
  1222. X            first_3dplot = NULL;
  1223. X            cp_free(f_p);
  1224. X            sp_free(f_3dp);
  1225. X
  1226. X            iso_samples = tsamp;
  1227. X        }
  1228. X    }
  1229. X    else if (almost_equals(c_token,"si$ze")) {
  1230. X        struct value s;
  1231. X        c_token++;
  1232. X        if (END_OF_COMMAND) {
  1233. X            xsize = 1.0;
  1234. X            ysize = 1.0;
  1235. X        } 
  1236. X        else {
  1237. X                xsize=real(const_express(&s));
  1238. X                if (!equals(c_token,","))
  1239. X                    int_error("',' expected",c_token);
  1240. X                c_token++;
  1241. X                ysize=real(const_express(&s));
  1242. X        } 
  1243. X    } 
  1244. X    else if (almost_equals(c_token,"t$erminal")) {
  1245. X        c_token++;
  1246. X        if (END_OF_COMMAND) {
  1247. X            list_terms();
  1248. X            screen_ok = FALSE;
  1249. X        }
  1250. X        else {
  1251. X            if (term && term_init) {
  1252. X                (*term_tbl[term].reset)();
  1253. X                (void) fflush(outfile);
  1254. X            }
  1255. X            term = set_term(c_token);
  1256. X            c_token++;
  1257. X
  1258. X            /* get optional mode parameters */
  1259. X            if (term)
  1260. X                (*term_tbl[term].options)();
  1261. X            if (interactive && *term_options)
  1262. X                fprintf(stderr,"Options are '%s'\n",term_options);
  1263. X        }
  1264. X    }
  1265. X    else if (almost_equals(c_token,"tim$e")) {
  1266. X        timedate = TRUE;
  1267. X        c_token++;
  1268. X        if (!END_OF_COMMAND) {
  1269. X            struct value a;
  1270. X            int x, y;
  1271. X
  1272. X            /* We have x,y offsets specified */
  1273. X            if (!equals(c_token,","))
  1274. X                time_xoffset = (int)real(const_express(&a));
  1275. X            if (!END_OF_COMMAND && equals(c_token,",")) {
  1276. X                c_token++;
  1277. X                time_yoffset = (int)real(const_express(&a));
  1278. X            }
  1279. X        }
  1280. X    }
  1281. X    else if (almost_equals(c_token,"not$ime")) {
  1282. X        timedate = FALSE;
  1283. X        c_token++;
  1284. X    }
  1285. X    else if (almost_equals(c_token,"rr$ange")) {
  1286. X         BOOLEAN changed;
  1287. X        c_token++;
  1288. X        if (!equals(c_token,"["))
  1289. X            int_error("expecting '['",c_token);
  1290. X        c_token++;
  1291. X        changed = load_range(&rmin,&rmax);
  1292. X        if (!equals(c_token,"]"))
  1293. X          int_error("expecting ']'",c_token);
  1294. X        c_token++;
  1295. X        if (changed)
  1296. X          autoscale_r = FALSE;
  1297. X    }
  1298. X    else if (almost_equals(c_token,"tr$ange")) {
  1299. X         BOOLEAN changed;
  1300. X        c_token++;
  1301. X        if (!equals(c_token,"["))
  1302. X            int_error("expecting '['",c_token);
  1303. X        c_token++;
  1304. X        changed = load_range(&tmin,&tmax);
  1305. X        if (!equals(c_token,"]"))
  1306. X          int_error("expecting ']'",c_token);
  1307. X        c_token++;
  1308. X        if (changed)
  1309. X          autoscale_t = FALSE;
  1310. X    }
  1311. X    else if (almost_equals(c_token,"ur$ange")) {
  1312. X         BOOLEAN changed;
  1313. X        c_token++;
  1314. X        if (!equals(c_token,"["))
  1315. X            int_error("expecting '['",c_token);
  1316. X        c_token++;
  1317. X        changed = load_range(&umin,&umax);
  1318. X        if (!equals(c_token,"]"))
  1319. X          int_error("expecting ']'",c_token);
  1320. X        c_token++;
  1321. X        if (changed)
  1322. X          autoscale_u = FALSE;
  1323. X    }
  1324. X    else if (almost_equals(c_token,"vi$ew")) {
  1325. X        int i;
  1326. X        BOOLEAN was_comma = TRUE;
  1327. X        double local_vals[4];
  1328. X        struct value a;
  1329. X
  1330. X        local_vals[0] = surface_rot_x;
  1331. X        local_vals[1] = surface_rot_z;
  1332. X        local_vals[2] = surface_scale;
  1333. X        local_vals[3] = surface_zscale;
  1334. X        c_token++;
  1335. X        for (i = 0; i < 4 && !(END_OF_COMMAND);) {
  1336. X            if (equals(c_token,",")) {
  1337. X                if (was_comma) i++;
  1338. X                was_comma = TRUE;
  1339. X                c_token++;
  1340. X            }
  1341. X            else {
  1342. X                if (!was_comma)
  1343. X                    int_error("',' expected",c_token);
  1344. X                local_vals[i] = real(const_express(&a));
  1345. X                i++;
  1346. X                was_comma = FALSE;
  1347. X            }
  1348. X        }
  1349. X
  1350. X        if (local_vals[0] < 0 || local_vals[0] > 180)
  1351. X            int_error("rot_x must be in [0:180] degrees range; view unchanged",
  1352. X                  c_token);
  1353. X        if (local_vals[1] < 0 || local_vals[1] > 360)
  1354. X            int_error("rot_z must be in [0:360] degrees range; view unchanged",
  1355. X                  c_token);
  1356. X        if (local_vals[2] < 1e-6)
  1357. X            int_error("scale must be > 0; view unchanged", c_token);
  1358. X        if (local_vals[3] < 1e-6)
  1359. X            int_error("zscale must be > 0; view unchanged", c_token);
  1360. X
  1361. X        surface_rot_x = local_vals[0];
  1362. X        surface_rot_z = local_vals[1];
  1363. X        surface_scale = local_vals[2];
  1364. X        surface_zscale = local_vals[3];
  1365. X    }
  1366. X    else if (almost_equals(c_token,"vr$ange")) {
  1367. X         BOOLEAN changed;
  1368. X        c_token++;
  1369. X        if (!equals(c_token,"["))
  1370. X            int_error("expecting '['",c_token);
  1371. X        c_token++;
  1372. X        changed = load_range(&vmin,&vmax);
  1373. X        if (!equals(c_token,"]"))
  1374. X          int_error("expecting ']'",c_token);
  1375. X        c_token++;
  1376. X        if (changed)
  1377. X          autoscale_v = FALSE;
  1378. X    }
  1379. X    else if (almost_equals(c_token,"xr$ange")) {
  1380. X         BOOLEAN changed;
  1381. X        c_token++;
  1382. X        if (!equals(c_token,"["))
  1383. X            int_error("expecting '['",c_token);
  1384. X        c_token++;
  1385. X        changed = load_range(&xmin,&xmax);
  1386. X        if (!equals(c_token,"]"))
  1387. X          int_error("expecting ']'",c_token);
  1388. X        c_token++;
  1389. X        if (changed)
  1390. X          autoscale_x = FALSE;
  1391. X    }
  1392. X    else if (almost_equals(c_token,"yr$ange")) {
  1393. X         BOOLEAN changed;
  1394. X        c_token++;
  1395. X        if (!equals(c_token,"["))
  1396. X            int_error("expecting '['",c_token);
  1397. X        c_token++;
  1398. X        changed = load_range(&ymin,&ymax);
  1399. X        if (!equals(c_token,"]"))
  1400. X          int_error("expecting ']'",c_token);
  1401. X        c_token++;
  1402. X        if (changed)
  1403. X          autoscale_y = FALSE;
  1404. X    }
  1405. X    else if (almost_equals(c_token,"zr$ange")) {
  1406. X         BOOLEAN changed;
  1407. X        c_token++;
  1408. X        if (!equals(c_token,"["))
  1409. X            int_error("expecting '['",c_token);
  1410. X        c_token++;
  1411. X        changed = load_range(&zmin,&zmax);
  1412. X        if (!equals(c_token,"]"))
  1413. X          int_error("expecting ']'",c_token);
  1414. X        c_token++;
  1415. X        if (changed)
  1416. X          autoscale_z = FALSE;
  1417. X    }
  1418. X    else if (almost_equals(c_token,"z$ero")) {
  1419. X        struct value a;
  1420. X        c_token++;
  1421. X        zero = magnitude(const_express(&a));
  1422. X    }
  1423. X    else
  1424. X        return(FALSE);    /* no command match */
  1425. X    return(TRUE);
  1426. }
  1427. X
  1428. /*********** Support functions for set_command ***********/
  1429. X
  1430. /* process a 'set {x/y/z}label command */
  1431. /* set {x/y/z}label {label_text} {x}{,y} */
  1432. static void set_xyzlabel(str,xpos,ypos)
  1433. char *str;
  1434. int *xpos,*ypos;
  1435. {
  1436. X    c_token++;
  1437. X    if (END_OF_COMMAND) {    /* no label specified */
  1438. X        str[0] = '\0';
  1439. X    } else {
  1440. X        if (isstring(c_token)) {
  1441. X            /* We have string specified - grab it. */
  1442. X            quotel_str(str,c_token);
  1443. X            c_token++;
  1444. X        }
  1445. X        if (!END_OF_COMMAND) {
  1446. X            struct value a;
  1447. X            int x, y;
  1448. X
  1449. X            /* We have x,y offsets specified */
  1450. X            if (!equals(c_token,","))
  1451. X                *xpos = (int)real(const_express(&a));
  1452. X            if (!END_OF_COMMAND && equals(c_token,",")) {
  1453. X                c_token++;
  1454. X                *ypos = (int)real(const_express(&a));
  1455. X            }
  1456. X        }
  1457. X    }
  1458. }
  1459. X
  1460. /* process a 'set label' command */
  1461. /* set label {tag} {label_text} {at x,y} {pos} */
  1462. static void
  1463. set_label()
  1464. {
  1465. X    struct value a;
  1466. X    struct text_label *this_label = NULL;
  1467. X    struct text_label *new_label = NULL;
  1468. X    struct text_label *prev_label = NULL;
  1469. X    double x, y, z;
  1470. X    char text[MAX_LINE_LEN+1];
  1471. X    enum JUSTIFY just;
  1472. X    int tag;
  1473. X    BOOLEAN set_text, set_position, set_just;
  1474. X
  1475. X    /* get tag */
  1476. X    if (!END_OF_COMMAND 
  1477. X       && !isstring(c_token) 
  1478. X       && !equals(c_token, "at")
  1479. X       && !equals(c_token, "left")
  1480. X       && !equals(c_token, "center")
  1481. X       && !equals(c_token, "centre")
  1482. X       && !equals(c_token, "right")) {
  1483. X       /* must be a tag expression! */
  1484. X       tag = (int)real(const_express(&a));
  1485. X       if (tag <= 0)
  1486. X        int_error("tag must be > zero", c_token);
  1487. X    } else
  1488. X     tag = assign_label_tag(); /* default next tag */
  1489. X     
  1490. X    /* get text */
  1491. X    if (!END_OF_COMMAND && isstring(c_token)) {
  1492. X       /* get text */
  1493. X       quotel_str(text, c_token);
  1494. X       c_token++;
  1495. X       set_text = TRUE;
  1496. X    } else {
  1497. X       text[0] = '\0';        /* default no text */
  1498. X       set_text = FALSE;
  1499. X    }
  1500. X     
  1501. X    /* get justification - what the heck, let him put it here */
  1502. X    if (!END_OF_COMMAND && !equals(c_token, "at")) {
  1503. X       if (almost_equals(c_token,"l$eft")) {
  1504. X          just = LEFT;
  1505. X       }
  1506. X       else if (almost_equals(c_token,"c$entre")
  1507. X              || almost_equals(c_token,"c$enter")) {
  1508. X          just = CENTRE;
  1509. X       }
  1510. X       else if (almost_equals(c_token,"r$ight")) {
  1511. X          just = RIGHT;
  1512. X       }
  1513. X       else
  1514. X        int_error("bad syntax in set label", c_token);
  1515. X       c_token++;
  1516. X       set_just = TRUE;
  1517. X    } else {
  1518. X       just = LEFT;            /* default left justified */
  1519. X       set_just = FALSE;
  1520. X    } 
  1521. X
  1522. X    /* get position */
  1523. X    if (!END_OF_COMMAND && equals(c_token, "at")) {
  1524. X       c_token++;
  1525. X       if (END_OF_COMMAND)
  1526. X        int_error("coordinates expected", c_token);
  1527. X       /* get coordinates */
  1528. X       x = real(const_express(&a));
  1529. X       if (!equals(c_token,","))
  1530. X        int_error("',' expected",c_token);
  1531. X       c_token++;
  1532. X       y = real(const_express(&a));
  1533. X       if (equals(c_token,",")) {
  1534. X        c_token++;
  1535. X        z = real(const_express(&a));
  1536. X       }
  1537. X       else
  1538. X            z = 0;
  1539. X       set_position = TRUE;
  1540. X    } else {
  1541. X       x = y = z = 0;            /* default at origin */
  1542. X       set_position = FALSE;
  1543. X    }
  1544. X
  1545. X    /* get justification */
  1546. X    if (!END_OF_COMMAND) {
  1547. X       if (set_just)
  1548. X        int_error("only one justification is allowed", c_token);
  1549. X       if (almost_equals(c_token,"l$eft")) {
  1550. X          just = LEFT;
  1551. X       }
  1552. X       else if (almost_equals(c_token,"c$entre")
  1553. X              || almost_equals(c_token,"c$enter")) {
  1554. X          just = CENTRE;
  1555. X       }
  1556. X       else if (almost_equals(c_token,"r$ight")) {
  1557. X          just = RIGHT;
  1558. X       }
  1559. X       else
  1560. X        int_error("bad syntax in set label", c_token);
  1561. X       c_token++;
  1562. X       set_just = TRUE;
  1563. X    } 
  1564. X
  1565. X    if (!END_OF_COMMAND)
  1566. X     int_error("extraenous or out-of-order arguments in set label", c_token);
  1567. X
  1568. X    /* OK! add label */
  1569. X    if (first_label != NULL) { /* skip to last label */
  1570. X       for (this_label = first_label; this_label != NULL ; 
  1571. X           prev_label = this_label, this_label = this_label->next)
  1572. X        /* is this the label we want? */
  1573. X        if (tag <= this_label->tag)
  1574. X          break;
  1575. X    }
  1576. X    if (this_label != NULL && tag == this_label->tag) {
  1577. X       /* changing the label */
  1578. X       if (set_position) {
  1579. X          this_label->x = x;
  1580. X          this_label->y = y;
  1581. X          this_label->z = z;
  1582. X       }
  1583. X       if (set_text)
  1584. X        (void) strcpy(this_label->text, text);
  1585. X       if (set_just)
  1586. X        this_label->pos = just;
  1587. X    } else {
  1588. X       /* adding the label */
  1589. X       new_label = (struct text_label *) 
  1590. X        alloc ( (unsigned int) sizeof(struct text_label), "label");
  1591. X       if (prev_label != NULL)
  1592. X        prev_label->next = new_label; /* add it to end of list */
  1593. X       else 
  1594. X        first_label = new_label; /* make it start of list */
  1595. X       new_label->tag = tag;
  1596. X       new_label->next = this_label;
  1597. X       new_label->x = x;
  1598. X       new_label->y = y;
  1599. X       new_label->z = z;
  1600. X       (void) strcpy(new_label->text, text);
  1601. X       new_label->pos = just;
  1602. X    }
  1603. }
  1604. X
  1605. /* process 'set nolabel' command */
  1606. /* set nolabel {tag} */
  1607. static void
  1608. set_nolabel()
  1609. {
  1610. X    struct value a;
  1611. X    struct text_label *this_label;
  1612. X    struct text_label *prev_label; 
  1613. X    int tag;
  1614. X
  1615. X    if (END_OF_COMMAND) {
  1616. X       /* delete all labels */
  1617. X       while (first_label != NULL)
  1618. X        delete_label((struct text_label *)NULL,first_label);
  1619. X    }
  1620. X    else {
  1621. X       /* get tag */
  1622. X       tag = (int)real(const_express(&a));
  1623. X       if (!END_OF_COMMAND)
  1624. X        int_error("extraneous arguments to set nolabel", c_token);
  1625. X       for (this_label = first_label, prev_label = NULL;
  1626. X           this_label != NULL;
  1627. X           prev_label = this_label, this_label = this_label->next) {
  1628. X          if (this_label->tag == tag) {
  1629. X             delete_label(prev_label,this_label);
  1630. X             return;        /* exit, our job is done */
  1631. X          }
  1632. X       }
  1633. X       int_error("label not found", c_token);
  1634. X    }
  1635. }
  1636. X
  1637. /* assign a new label tag */
  1638. /* labels are kept sorted by tag number, so this is easy */
  1639. static int                /* the lowest unassigned tag number */
  1640. assign_label_tag()
  1641. {
  1642. X    struct text_label *this_label;
  1643. X    int last = 0;            /* previous tag value */
  1644. X
  1645. X    for (this_label = first_label; this_label != NULL;
  1646. X        this_label = this_label->next)
  1647. X     if (this_label->tag == last+1)
  1648. X       last++;
  1649. X     else
  1650. X       break;
  1651. X    
  1652. X    return (last+1);
  1653. }
  1654. X
  1655. /* delete label from linked list started by first_label.
  1656. X * called with pointers to the previous label (prev) and the 
  1657. X * label to delete (this).
  1658. X * If there is no previous label (the label to delete is
  1659. X * first_label) then call with prev = NULL.
  1660. X */
  1661. static void
  1662. delete_label(prev,this)
  1663. X    struct text_label *prev, *this;
  1664. {
  1665. X    if (this!=NULL)    {        /* there really is something to delete */
  1666. X       if (prev!=NULL)        /* there is a previous label */
  1667. X        prev->next = this->next; 
  1668. X       else                /* this = first_label so change first_label */
  1669. X        first_label = this->next;
  1670. X       free((char *)this);
  1671. X    }
  1672. }
  1673. X
  1674. X
  1675. /* process a 'set arrow' command */
  1676. /* set arrow {tag} {from x,y} {to x,y} {{no}head} */
  1677. static void
  1678. set_arrow()
  1679. {
  1680. X    struct value a;
  1681. X    struct arrow_def *this_arrow = NULL;
  1682. X    struct arrow_def *new_arrow = NULL;
  1683. X    struct arrow_def *prev_arrow = NULL;
  1684. X    double sx, sy, sz;
  1685. X    double ex, ey, ez;
  1686. X    int tag;
  1687. X    BOOLEAN set_start, set_end, head = 1;
  1688. X
  1689. X    /* get tag */
  1690. X    if (!END_OF_COMMAND 
  1691. X       && !equals(c_token, "from")
  1692. X       && !equals(c_token, "to")) {
  1693. X       /* must be a tag expression! */
  1694. X       tag = (int)real(const_express(&a));
  1695. X       if (tag <= 0)
  1696. X        int_error("tag must be > zero", c_token);
  1697. X    } else
  1698. X     tag = assign_arrow_tag(); /* default next tag */
  1699. X     
  1700. X    /* get start position */
  1701. X    if (!END_OF_COMMAND && equals(c_token, "from")) {
  1702. X       c_token++;
  1703. X       if (END_OF_COMMAND)
  1704. X        int_error("start coordinates expected", c_token);
  1705. X       /* get coordinates */
  1706. X       sx = real(const_express(&a));
  1707. X       if (!equals(c_token,","))
  1708. X        int_error("',' expected",c_token);
  1709. X       c_token++;
  1710. X       sy = real(const_express(&a));
  1711. X       if (equals(c_token,",")) {
  1712. X        c_token++;
  1713. X        sz = real(const_express(&a));
  1714. X       }
  1715. X       else
  1716. X           sz = 0;
  1717. X       set_start = TRUE;
  1718. X    } else {
  1719. X       sx = sy = sz = 0;            /* default at origin */
  1720. X       set_start = FALSE;
  1721. X    }
  1722. X
  1723. X    /* get end position */
  1724. X    if (!END_OF_COMMAND && equals(c_token, "to")) {
  1725. X       c_token++;
  1726. X       if (END_OF_COMMAND)
  1727. X        int_error("end coordinates expected", c_token);
  1728. X       /* get coordinates */
  1729. X       ex = real(const_express(&a));
  1730. X       if (!equals(c_token,","))
  1731. X        int_error("',' expected",c_token);
  1732. X       c_token++;
  1733. X       ey = real(const_express(&a));
  1734. X       if (equals(c_token,",")) {
  1735. X        c_token++;
  1736. X        ez = real(const_express(&a));
  1737. X       }
  1738. X       else
  1739. X        ez = 0;
  1740. X       set_end = TRUE;
  1741. X    } else {
  1742. X       ex = ey = ez = 0;            /* default at origin */
  1743. X       set_end = FALSE;
  1744. X    }
  1745. X
  1746. X    /* get start position - what the heck, either order is ok */
  1747. X    if (!END_OF_COMMAND && equals(c_token, "from")) {
  1748. X       if (set_start)
  1749. X        int_error("only one 'from' is allowed", c_token);
  1750. X       c_token++;
  1751. X       if (END_OF_COMMAND)
  1752. X        int_error("start coordinates expected", c_token);
  1753. X       /* get coordinates */
  1754. X       sx = real(const_express(&a));
  1755. X       if (!equals(c_token,","))
  1756. X        int_error("',' expected",c_token);
  1757. X       c_token++;
  1758. X       sy = real(const_express(&a));
  1759. X       if (equals(c_token,",")) {
  1760. X        c_token++;
  1761. X        sz = real(const_express(&a));
  1762. X       }
  1763. X       else
  1764. X           sz = 0;
  1765. X       set_start = TRUE;
  1766. X    }
  1767. X
  1768. X    if (!END_OF_COMMAND && equals(c_token, "nohead")) {
  1769. X       c_token++;
  1770. X           head = 0;
  1771. X    }
  1772. X
  1773. X    if (!END_OF_COMMAND && equals(c_token, "head")) {
  1774. X       c_token++;
  1775. X           head = 1;
  1776. X    }
  1777. X
  1778. X    if (!END_OF_COMMAND)
  1779. X     int_error("extraneous or out-of-order arguments in set arrow", c_token);
  1780. X
  1781. X    /* OK! add arrow */
  1782. X    if (first_arrow != NULL) { /* skip to last arrow */
  1783. X       for (this_arrow = first_arrow; this_arrow != NULL ; 
  1784. X           prev_arrow = this_arrow, this_arrow = this_arrow->next)
  1785. X        /* is this the arrow we want? */
  1786. X        if (tag <= this_arrow->tag)
  1787. X          break;
  1788. X    }
  1789. X    if (this_arrow != NULL && tag == this_arrow->tag) {
  1790. X       /* changing the arrow */
  1791. X       if (set_start) {
  1792. X          this_arrow->sx = sx;
  1793. X          this_arrow->sy = sy;
  1794. X          this_arrow->sz = sz;
  1795. X       }
  1796. X       if (set_end) {
  1797. X          this_arrow->ex = ex;
  1798. X          this_arrow->ey = ey;
  1799. X          this_arrow->ez = ez;
  1800. X       }
  1801. X       this_arrow->head = head;
  1802. X    } else {
  1803. X       /* adding the arrow */
  1804. X       new_arrow = (struct arrow_def *) 
  1805. X        alloc ( (unsigned int) sizeof(struct arrow_def), "arrow");
  1806. X       if (prev_arrow != NULL)
  1807. X        prev_arrow->next = new_arrow; /* add it to end of list */
  1808. X       else 
  1809. X        first_arrow = new_arrow; /* make it start of list */
  1810. X       new_arrow->tag = tag;
  1811. X       new_arrow->next = this_arrow;
  1812. X       new_arrow->sx = sx;
  1813. X       new_arrow->sy = sy;
  1814. X       new_arrow->sz = sz;
  1815. X       new_arrow->ex = ex;
  1816. X       new_arrow->ey = ey;
  1817. X       new_arrow->ez = ez;
  1818. X       new_arrow->head = head;
  1819. X    }
  1820. }
  1821. X
  1822. /* process 'set noarrow' command */
  1823. /* set noarrow {tag} */
  1824. static void
  1825. set_noarrow()
  1826. {
  1827. X    struct value a;
  1828. X    struct arrow_def *this_arrow;
  1829. X    struct arrow_def *prev_arrow; 
  1830. X    int tag;
  1831. X
  1832. X    if (END_OF_COMMAND) {
  1833. X       /* delete all arrows */
  1834. X       while (first_arrow != NULL)
  1835. X        delete_arrow((struct arrow_def *)NULL,first_arrow);
  1836. X    }
  1837. X    else {
  1838. X       /* get tag */
  1839. X       tag = (int)real(const_express(&a));
  1840. X       if (!END_OF_COMMAND)
  1841. X        int_error("extraneous arguments to set noarrow", c_token);
  1842. X       for (this_arrow = first_arrow, prev_arrow = NULL;
  1843. X           this_arrow != NULL;
  1844. SHAR_EOF
  1845. true || echo 'restore of gnuplot/setshow.c failed'
  1846. fi
  1847. echo 'End of  part 1'
  1848. echo 'File gnuplot/setshow.c is continued in part 2'
  1849. echo 2 > _shar_seq_.tmp
  1850. exit 0
  1851.  
  1852. exit 0 # Just in case...
  1853. -- 
  1854. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1855. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1856. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1857. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1858.