home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-26 | 52.9 KB | 1,859 lines |
- Newsgroups: comp.sources.misc
- From: gershon%gr@cs.utah.edu (Elber Gershon)
- Subject: v24i023: gnuplot3 - interactive function plotting utility, Part01/26
- Message-ID: <csm-v24i023=gnuplot3.171920@sparky.IMD.Sterling.COM>
- X-Md4-Signature: 6210c9b40603d7d8dd7763a425c3177d
- Date: Sat, 26 Oct 1991 22:20:25 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
- Posting-number: Volume 24, Issue 23
- Archive-name: gnuplot3/part01
- Environment: UNIX, MS-DOS, VMS
- Supersedes: gnuplot2: Volume 11, Issue 65-79
-
- ANNOUNCING GNUPLOT 3.0
-
- What is Gnuplot 3.0?
- --------------------
-
- Gnuplot is a command-line driven interactive function plotting utility
- for UNIX, MSDOS, and VMS platforms. The software is copyrighted but
- freely distributed (i.e., you don't have to pay for it). It was
- originally intended as graphical program which would allow scientists
- and students to visualize mathematical functions and data. Additions
- to this version of the software allow plots of three-dimensional
- functions and data files. Gnuplot supports many different types of
- terminals, plotters, and printers and is easily extensible to include
- new devices. [ The "GNU" in Gnuplot is NOT related to the Free
- Software Foundation, the naming is just a coincidence (and a long
- story). Thus gnuplot is not covered by the Gnu copyleft, but rather
- by its own copyright statement, included in all source code files.]
-
- Highlights (compared to 2.02):
- ------------------------------
- Gnuplot now handles surfaces as well. A new command named 'splot' (for
- surface plot) has been added for that purpose. A number of new 'set'
- options for surfaces have also been added and include: isosamples,
- view, contour, cntrparam, mapping and surface. All tic/label/range
- setting for x and y axes were extended for z as well.
-
- The size of data file for both curves and surfaces is now independent
- of the samples (and iso_samples) variables. Data structures will
- automatically be extended to hold the entire data file.
-
- Command-line editing and history on most platforms.
-
- Other new features:
- -------------------
- New 'errorbars' plot style.
- New 'using x:y{:z}' format (NOT COMPATIBLE WITH GNUPLOT 2.02).
- New makefile scheme for unix, that supports lots of flavors.
- Adjustable display of plot border ('set border').
- Set-commands 'x/y/zlabel' can now position the label.
- Set-command 'title' can now position the title.
- New time display command ('set time').
- A 'gnuplot' mode for emacs in the file gnuplot.el.
- SGI device was improved.
- New option to 'set arrow' called 'nohead'.
- All PostScript devices were rewritten and merged into one (Color
- Postscript is supported). Due to this many of the old postscript
- terminal driver names are not supported; only 'postscript' is
- recognized. Use 'help set terminal postscript' to find out how to get
- your old favorite back, and more.
- Many small bug fixes.
-
- New terminal drivers:
- ---------------------
- vws, apollo, gpr apollo, dumb, BigFig, Super
- VGA, ln03/hplj/hpdj, dxf.
-
- Complete list of device drivers supported:
- ------------------------------------------
- aed amiga apollo bigfig cgi dumb dxf dxy eepic epson fig gpr hp26
- hp2648 hpgl hpljii imagen iris4d kyo latex pc post qms regis sun t410x
- tek unixpc unixplot v384 vws x11
-
- KNOWN BUGS:
- -----------
- Some problems with logscale on the y-axis, noticed after release.
- Definitely a problem when mixing logscaling and autoscaling on the y
- axis. x-axis status unknown. Expect a fix in 3.01.
-
- ===================================================================
- Where to obtain Gnuplot 3.0:
- ----------------------------
-
- In general, Gnuplot 3.0 is available as the file gnuplot3.0.tar.Z.
- Please obtain gnuplot from the site nearest you. Many of the major ftp
- archives world-wide have already picked up the latest version, so if
- you found the old version elsewhere, you might check there.
-
-
- USENET users:
-
- GNUPLOT 3.0 was posted to comp.sources.misc.
-
-
- NORTH AMERICA:
-
- Anonymous ftp to dartmouth.edu (129.170.16.4)
- Fetch
- pub/gnuplot/gnuplot3.0.tar.Z
- in binary mode.
-
- Users without ftp capability can obtain it through a mail ftp
- server. Send a mail message saying 'help' to
- BITFTP@pucc.princeton.edu for instructions. For a uuencoded
- copy of the gnuplot sources (compressed tar file), send this
- message to BITFTP@pucc.princeton.edu:
- FTP DARTMOUTH.EDU UUENCODE
- USER ANONYMOUS
- CD pub/gnuplot
- BINARY
- GET gnuplot3.0.tar.Z
- QUIT
-
-
- AUSTRALIA:
-
- Anonymous ftp to monu1.cc.monash.edu.au (130.194.1.101).
- Fetch pub/gnuplot3.0.tar.Z in binary mode.
-
-
- EUROPE:
-
- Anonymous ftp to irisa.irisa.fr (131.254.2.3).
- Fetch pub/gnuplot3.0.tar.Z in binary mode.
-
- ----
-
- DISCLAIMER - This product is not related in any way to
- Pixar or any other commercial venture.
-
- ----
- CONTACTS:
- Please send any questions or comments to
- pixar!info-gnuplot@ucbvax.berkeley.edu.
- To join the above mailing list (or get yourself off), mail to
- pixar!info-gnuplot-request@ucbvax.berkeley.edu.
- Send bug reports and problems to
- pixar!bug-gnuplot@ucbvax.berkeley.edu.
-
- -Thomas Williams-
- ----------------
- #!/bin/sh
- # This is a shell archive (produced by shar 3.49)
- # To extract the files from this archive, save it to a file, remove
- # everything above the "!/bin/sh" line above, and type "sh file_name".
- #
- # made 10/15/1991 19:23 UTC by gershon@gr.utah.edu
- # Source directory /n/lotus/u/grad/gershon/gp
- #
- # existing files will NOT be overwritten unless -c is specified
- #
- # This is part 1 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 279 -rw-r--r-- gnuplot/linkopt.tco
- # 889 -rw-rw-rw- gnuplot/Copyright
- # 63352 -rw-r--r-- gnuplot/setshow.c
- # 2406 -rw-r--r-- gnuplot/README
- # 17904 -rw-r--r-- gnuplot/help.c
- # 51656 -rw-rw-rw- gnuplot/bitmap.c
- # 2726 -rw-rw-rw- gnuplot/bitmap.h
- # 918 -rw-r--r-- gnuplot/buildvms.com
- # 22387 -rw-r--r-- gnuplot/misc.c
- # 41345 -rw-rw-rw- gnuplot/contour.c
- # 781 -rw-rw-rw- gnuplot/demo/1.dat
- # 781 -rw-rw-rw- gnuplot/demo/2.dat
- # 781 -rw-rw-rw- gnuplot/demo/3.dat
- # 3088 -rw-r--r-- gnuplot/demo/contours.demo
- # 712 -rw-rw-rw- gnuplot/demo/controls.demo
- # 2065 -rw-rw-rw- gnuplot/demo/electron.demo
- # 8538 -rw-rw-rw- gnuplot/demo/glass.dat
- # 909 -rw-rw-rw- gnuplot/demo/param.demo
- # 965 -rw-rw-rw- gnuplot/demo/polar.demo
- # 1045 -rw-rw-rw- gnuplot/demo/simple.demo
- # 3111 -rw-r--r-- gnuplot/demo/surface1.demo
- # 1359 -rw-r--r-- gnuplot/demo/surface2.demo
- # 5568 -rw-rw-rw- gnuplot/demo/using.dat
- # 708 -rw-r--r-- gnuplot/demo/using.demo
- # 3329 -rw-r--r-- gnuplot/demo/world.cor
- # 16720 -rw-rw-rw- gnuplot/demo/world.dat
- # 1349 -rw-r--r-- gnuplot/demo/world.demo
- # 418 -rw-r--r-- gnuplot/demo/err.dat
- # 491 -rw-r--r-- gnuplot/demo/poldat.demo
- # 6538 -rw-r--r-- gnuplot/demo/polar.dat
- # 867 -rw-r--r-- gnuplot/demo/errorbar.demo
- # 20577 -rw-r--r-- gnuplot/demo/antenna.dat
- # 1245 -rw-r--r-- gnuplot/demo/all.demo
- # 2915 -rw-r--r-- gnuplot/demo/bivariat.demo
- # 2363 -rw-r--r-- gnuplot/docs/Makefile
- # 3681 -rw-r--r-- gnuplot/docs/README
- # 1377 -rw-rw-rw- gnuplot/docs/checkdoc.c
- # 2021 -rw-rw-rw- gnuplot/docs/doc2gih.c
- # 1471 -rw-rw-rw- gnuplot/docs/doc2hlp.c
- # 90 -rw-rw-rw- gnuplot/docs/doc2hlp.com
- # 5125 -rw-r--r-- gnuplot/docs/doc2ms.c
- # 3718 -rw-r--r-- gnuplot/docs/gnuplot.1
- # 90586 -rw-r--r-- gnuplot/docs/gnuplot.doc
- # 1594 -rw-r--r-- gnuplot/docs/lasergnu.1
- # 570 -rw-r--r-- gnuplot/docs/latextut/Makefile
- # 65 -rw-rw-rw- gnuplot/docs/latextut/eg1.plt
- # 219 -rw-rw-rw- gnuplot/docs/latextut/eg2.plt
- # 781 -rw-rw-rw- gnuplot/docs/latextut/eg3.dat
- # 199 -rw-rw-rw- gnuplot/docs/latextut/eg3.plt
- # 227 -rw-rw-rw- gnuplot/docs/latextut/eg4.plt
- # 331 -rw-rw-rw- gnuplot/docs/latextut/eg5.plt
- # 457 -rw-rw-rw- gnuplot/docs/latextut/eg6.plt
- # 1677 -rw-r--r-- gnuplot/docs/latextut/header.tex
- # 16623 -rw-r--r-- gnuplot/docs/latextut/tutorial.tex
- # 550 -rw-r--r-- gnuplot/docs/latextut/linepoint.plt
- # 599 -rw-r--r-- gnuplot/docs/titlepage.ms
- # 5029 -rw-r--r-- gnuplot/docs/doc2tex.c
- # 1027 -rw-r--r-- gnuplot/docs/titlepage.tex
- # 2009 -rw-r--r-- gnuplot/docs/toc_entry.sty
- # 2688 -rw-r--r-- gnuplot/docs/Makefile.ami
- # 2272 -rw-rw-rw- gnuplot/corgraph.asm
- # 1979 -rw-rw-rw- gnuplot/corplot.c
- # 3799 -rw-rw-rw- gnuplot/eval.c
- # 5487 -rw-rw-rw- gnuplot/gnuplot.el
- # 8774 -rw-r--r-- gnuplot/gnuplot_x11.c
- # 252 -rw-rw-rw- gnuplot/linkopt.tc
- # 3801 -rw-r--r-- gnuplot/lasergnu
- # 918 -rw-rw-rw- gnuplot/header.mac
- # 12274 -rw-r--r-- gnuplot/readline.c
- # 1383 -rw-rw-rw- gnuplot/help.h
- # 8192 -rw-rw-rw- gnuplot/hrcgraph.asm
- # 16092 -rw-r--r-- gnuplot/internal.c
- # 85435 -rw-r--r-- gnuplot/command.c
- # 1980 -rw-rw-rw- gnuplot/lineproc.mac
- # 159 -rw-r--r-- gnuplot/linkopt.msc
- # 4014 -rw-r--r-- gnuplot/makefile.tc
- # 26 -rw-rw-rw- gnuplot/linkopt.vms
- # 7115 -rw-r--r-- gnuplot/term/README
- # 2311 -rw-rw-rw- gnuplot/term/aed.trm
- # 3598 -rw-rw-rw- gnuplot/term/bigfig.trm
- # 4407 -rw-rw-rw- gnuplot/term/cgi.trm
- # 2238 -rw-rw-rw- gnuplot/term/dxy.trm
- # 7640 -rw-r--r-- gnuplot/term/eepic.trm
- # 11330 -rw-rw-rw- gnuplot/term/epson.trm
- # 7494 -rw-r--r-- gnuplot/term/fig.trm
- # 2262 -rw-rw-rw- gnuplot/term/hp26.trm
- # 2113 -rw-rw-rw- gnuplot/term/hp2648.trm
- # 2857 -rw-r--r-- gnuplot/term/hpgl.trm
- # 8101 -rw-r--r-- gnuplot/term/hpljii.trm
- # 25264 -rw-r--r-- gnuplot/term/pc.trm
- # 7396 -rw-rw-rw- gnuplot/term/imagen.trm
- # 5305 -rw-r--r-- gnuplot/term/iris4d.trm
- # 2313 -rw-rw-rw- gnuplot/term/kyo.trm
- # 17764 -rw-r--r-- gnuplot/term/latex.trm
- # 5063 -rw-rw-rw- gnuplot/term/object.h
- # 9281 -rw-r--r-- gnuplot/term/post.trm
- # 9980 -rw-r--r-- gnuplot/term/dxf.trm
- # 3785 -rw-rw-rw- gnuplot/term/qms.trm
- # 2967 -rw-rw-rw- gnuplot/term/regis.trm
- # 6147 -rw-rw-rw- gnuplot/term/sun.trm
- # 5056 -rw-rw-rw- gnuplot/term/t410x.trm
- # 6716 -rw-r--r-- gnuplot/term/tek.trm
- # 14242 -rw-r--r-- gnuplot/term/unixpc.trm
- # 1929 -rw-rw-rw- gnuplot/term/unixplot.trm
- # 2579 -rw-rw-rw- gnuplot/term/v384.trm
- # 8014 -rw-r--r-- gnuplot/term/vws.trm
- # 2240 -rw-r--r-- gnuplot/term/x11.trm
- # 11637 -rw-r--r-- gnuplot/term/gpr.trm
- # 6235 -rw-r--r-- gnuplot/term/dumb.trm
- # 10991 -rw-r--r-- gnuplot/term/amiga.trm
- # 17013 -rw-r--r-- gnuplot/term/apollo.trm
- # 1260 -rw-rw-rw- gnuplot/term/impcodes.h
- # 10144 -rw-r--r-- gnuplot/parse.c
- # 2572 -rw-r--r-- gnuplot/makefile.msc
- # 1114 -rw-r--r-- gnuplot/copyright
- # 52166 -rw-r--r-- gnuplot/graph3d.c
- # 1998 -rw-r--r-- gnuplot/makefile.vms
- # 12714 -rw-r--r-- gnuplot/util.c
- # 25357 -rw-r--r-- gnuplot/makefile.unx
- # 3925 -rw-rw-rw- gnuplot/pcgraph.asm
- # 8795 -rw-r--r-- gnuplot/plot.c
- # 11940 -rw-r--r-- gnuplot/plot.h
- # 2981 -rw-r--r-- gnuplot/README.amiga
- # 8676 -rw-r--r-- gnuplot/scanner.c
- # 1368 -rw-r--r-- gnuplot/version.c
- # 3968 -rw-r--r-- gnuplot/setshow.h
- # 15347 -rw-rw-rw- gnuplot/standard.c
- # 50685 -rw-r--r-- gnuplot/term.c
- # 475 -rw-r--r-- gnuplot/Intergraph.x11
- # 232 -rw-rw-rw- gnuplot/linkopt.amg
- # 7729 -rw-r--r-- gnuplot/README.Install
- # 10762 -rw-r--r-- gnuplot/History
- # 1170 -rw-r--r-- gnuplot/README.gnutex
- # 1808 -rw-r--r-- gnuplot/makefile.amg
- # 42004 -rw-r--r-- gnuplot/graphics.c
- # 2916 -rw-r--r-- gnuplot/makefile.ami
- # 3953 -rw-r--r-- gnuplot/term.h
- #
- if test -r _shar_seq_.tmp; then
- echo 'Must unpack archives in sequence!'
- echo Please unpack part `cat _shar_seq_.tmp` next
- exit 1
- fi
- # ============= gnuplot/linkopt.tco ==============
- if test ! -d 'gnuplot'; then
- echo 'x - creating directory gnuplot'
- mkdir 'gnuplot'
- fi
- if test -f 'gnuplot/linkopt.tco' -a X"$1" != X"-c"; then
- echo 'x - skipping gnuplot/linkopt.tco (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting gnuplot/linkopt.tco (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/linkopt.tco' &&
- c:\tc\lib\C0l +
- /o bitmap command eval graphics graph3d help internal misc parse +
- plot scanner setshow standard term util version contour +
- /o- egavgaf hercf cgaf attf +
- ,gnuplot,gnuplot, +
- c:\tc\lib\overlay +
- c:\tc\lib\emu +
- c:\tc\lib\mathl +
- c:\tc\lib\cl +
- c:\tc\lib\graphics
- SHAR_EOF
- chmod 0644 gnuplot/linkopt.tco ||
- echo 'restore of gnuplot/linkopt.tco failed'
- Wc_c="`wc -c < 'gnuplot/linkopt.tco'`"
- test 279 -eq "$Wc_c" ||
- echo 'gnuplot/linkopt.tco: original size 279, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= gnuplot/Copyright ==============
- if test -f 'gnuplot/Copyright' -a X"$1" != X"-c"; then
- echo 'x - skipping gnuplot/Copyright (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting gnuplot/Copyright (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/Copyright' &&
- /*
- X * Copyright (C) 1986, 1987, 1990 Thomas Williams, Colin Kelley
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X *
- X * AUTHORS
- X *
- X * Original Software:
- X * Thomas Williams, Colin Kelley.
- X *
- X * Gnuplot 2.0 additions:
- X * Russell Lang, Dave Kotz, John Campbell.
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- SHAR_EOF
- chmod 0666 gnuplot/Copyright ||
- echo 'restore of gnuplot/Copyright failed'
- Wc_c="`wc -c < 'gnuplot/Copyright'`"
- test 889 -eq "$Wc_c" ||
- echo 'gnuplot/Copyright: original size 889, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= gnuplot/setshow.c ==============
- if test -f 'gnuplot/setshow.c' -a X"$1" != X"-c"; then
- echo 'x - skipping gnuplot/setshow.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting gnuplot/setshow.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/setshow.c' &&
- /* GNUPLOT - setshow.c */
- /*
- X * Copyright (C) 1986, 1987, 1990, 1991 Thomas Williams, Colin Kelley
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X *
- X * AUTHORS
- X *
- X * Original Software:
- X * Thomas Williams, Colin Kelley.
- X *
- X * Gnuplot 2.0 additions:
- X * Russell Lang, Dave Kotz, John Campbell.
- X *
- X * Gnuplot 3.0 additions:
- X * Gershon Elber and many others.
- X *
- X * Send your comments or suggestions to
- X * pixar!info-gnuplot@sun.com.
- X * This is a mailing list; to join it send a note to
- X * pixar!info-gnuplot-request@sun.com.
- X * Send bug reports to
- X * pixar!bug-gnuplot@sun.com.
- X */
- X
- #include <stdio.h>
- #include <math.h>
- #include "plot.h"
- #include "setshow.h"
- X
- #define DEF_FORMAT "%g" /* default format for tic mark labels */
- #define SIGNIF (0.01) /* less than one hundredth of a tic mark */
- X
- /*
- X * global variables to hold status of 'set' options
- X *
- X */
- BOOLEAN autoscale_r = TRUE;
- BOOLEAN autoscale_t = TRUE;
- BOOLEAN autoscale_u = TRUE;
- BOOLEAN autoscale_v = TRUE;
- BOOLEAN autoscale_x = TRUE;
- BOOLEAN autoscale_y = TRUE;
- BOOLEAN autoscale_z = TRUE;
- BOOLEAN autoscale_lt = TRUE;
- BOOLEAN autoscale_lu = TRUE;
- BOOLEAN autoscale_lv = TRUE;
- BOOLEAN autoscale_lx = TRUE;
- BOOLEAN autoscale_ly = TRUE;
- BOOLEAN autoscale_lz = TRUE;
- BOOLEAN clip_points = FALSE;
- BOOLEAN clip_lines1 = TRUE;
- BOOLEAN clip_lines2 = FALSE;
- BOOLEAN draw_border = TRUE;
- BOOLEAN draw_surface = TRUE;
- BOOLEAN timedate = FALSE;
- char dummy_var[MAX_NUM_VAR][MAX_ID_LEN+1] = { "x", "y" };
- char xformat[MAX_ID_LEN+1] = DEF_FORMAT;
- char yformat[MAX_ID_LEN+1] = DEF_FORMAT;
- char zformat[MAX_ID_LEN+1] = DEF_FORMAT;
- enum PLOT_STYLE data_style = POINTS,
- X func_style = LINES;
- BOOLEAN grid = FALSE;
- int key = -1; /* default position */
- double key_x, key_y, key_z; /* user specified position for key */
- BOOLEAN log_x = FALSE,
- X log_y = FALSE,
- X log_z = FALSE;
- FILE* outfile;
- char outstr[MAX_ID_LEN+1] = "STDOUT";
- BOOLEAN parametric = FALSE;
- BOOLEAN polar = FALSE;
- int angles_format = ANGLES_RADIANS;
- int mapping3d = MAP3D_CARTESIAN;
- int samples = SAMPLES;
- int iso_samples = ISO_SAMPLES;
- float xsize = 1.0; /* scale factor for size */
- float ysize = 1.0; /* scale factor for size */
- float zsize = 1.0; /* scale factor for size */
- float surface_rot_z = 30.0; /* Default 3d transform. */
- float surface_rot_x = 60.0;
- float surface_scale = 1.0;
- float surface_zscale = 1.0;
- int term = 0; /* unknown term is 0 */
- char term_options[MAX_ID_LEN+1] = "";
- char title[MAX_LINE_LEN+1] = "";
- char xlabel[MAX_LINE_LEN+1] = "";
- char ylabel[MAX_LINE_LEN+1] = "";
- char zlabel[MAX_LINE_LEN+1] = "";
- int time_xoffset = 0;
- int time_yoffset = 0;
- int title_xoffset = 0;
- int title_yoffset = 0;
- int xlabel_xoffset = 0;
- int xlabel_yoffset = 0;
- int ylabel_xoffset = 0;
- int ylabel_yoffset = 0;
- int zlabel_xoffset = 0;
- int zlabel_yoffset = 0;
- double rmin = -0.0,
- X rmax = 10.0,
- X tmin = -5.0,
- X tmax = 5.0,
- X umin = -5.0,
- X umax = 5.0,
- X vmin = -5.0,
- X vmax = 5.0,
- X xmin = -10.0,
- X xmax = 10.0,
- X ymin = -10.0,
- X ymax = 10.0,
- X zmin = -10.0,
- X zmax = 10.0;
- double loff = 0.0,
- X roff = 0.0,
- X toff = 0.0,
- X boff = 0.0;
- int draw_contour = CONTOUR_NONE;
- int contour_pts = 5;
- int contour_kind = CONTOUR_KIND_LINEAR;
- int contour_order = 4;
- int contour_levels = 5;
- double zero = ZERO; /* zero threshold, not 0! */
- X
- BOOLEAN xzeroaxis = TRUE;
- BOOLEAN yzeroaxis = TRUE;
- X
- BOOLEAN xtics = TRUE;
- BOOLEAN ytics = TRUE;
- BOOLEAN ztics = TRUE;
- X
- float ticslevel = 0.5;
- X
- struct ticdef xticdef = {TIC_COMPUTED};
- struct ticdef yticdef = {TIC_COMPUTED};
- struct ticdef zticdef = {TIC_COMPUTED};
- X
- BOOLEAN tic_in = TRUE;
- X
- struct text_label *first_label = NULL;
- struct arrow_def *first_arrow = NULL;
- X
- /*** other things we need *****/
- extern char *strcpy(),*strcat();
- extern int strlen();
- extern FILE *popen();
- X
- /* input data, parsing variables */
- extern struct lexical_unit token[];
- extern char input_line[];
- extern int num_tokens, c_token;
- extern BOOLEAN interactive; /* from plot.c */
- X
- extern char replot_line[];
- extern struct udvt_entry *first_udv;
- extern BOOLEAN is_3d_plot;
- X
- extern double magnitude(),real();
- extern struct value *const_express();
- X
- /******** Local functions ********/
- static void set_xyzlabel();
- static void set_label();
- static void set_nolabel();
- static void set_arrow();
- static void set_noarrow();
- static void load_tics();
- static void load_tic_user();
- static void free_marklist();
- static void load_tic_series();
- static void load_offsets();
- X
- static void show_style(), show_range(), show_zero(), show_border();
- static void show_offsets(), show_output(), show_samples(), show_isosamples();
- static void show_view(), show_size(), show_title(), show_xlabel();
- static void show_angles();
- static void show_ylabel(), show_zlabel(), show_xzeroaxis(), show_yzeroaxis();
- static void show_label(), show_arrow(), show_grid(), show_key();
- static void show_polar(), show_parametric(), show_tics(), show_ticdef();
- static void show_time(), show_term(), show_plot(), show_autoscale(), show_clip();
- static void show_contour(), show_mapping(), show_format(), show_logscale();
- static void show_variables(), show_surface();
- static void delete_label();
- static int assign_label_tag();
- static void delete_arrow();
- static int assign_arrow_tag();
- static BOOLEAN set_one(), set_two(), set_three();
- static BOOLEAN show_one(), show_two();
- X
- /******** The 'set' command ********/
- void
- set_command()
- {
- X c_token++;
- X
- X if (!set_one() && !set_two() && !set_three())
- X int_error(
- X "valid set options: 'angles' '{no}arrow', {no}autoscale', \n\
- X '{no}border', '{no}clip', 'cntrparam', '{no}contour', 'data style', \n\
- X 'dummy', 'format', 'function style', '{no}grid', 'isosamples', \n\
- X '{no}key', '{no}label', '{no}logscale', 'mapping', 'offsets', \n\
- X 'output', '{no}parametric', '{no}polar', 'rrange', 'samples', \n\
- X 'size', '{no}surface', 'terminal', 'tics', 'ticslevel', '{no}time', \n\
- X 'title', 'trange', 'urange', 'view', 'vrange', 'xlabel', 'xrange', \n\
- X '{no}xtics', '{no}xzeroaxis', 'ylabel', 'yrange', '{no}ytics', \n\
- X '{no}yzeroaxis', 'zero', '{no}zeroaxis', 'zlabel', 'zrange', \n\
- X '{no}ztics'", c_token);
- }
- X
- /* return TRUE if a command match, FALSE if not */
- static BOOLEAN
- set_one()
- {
- X if (almost_equals(c_token,"ar$row")) {
- X c_token++;
- X set_arrow();
- X }
- X else if (almost_equals(c_token,"noar$row")) {
- X c_token++;
- X set_noarrow();
- X }
- X else if (almost_equals(c_token,"au$toscale")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X autoscale_r=autoscale_t = autoscale_x = autoscale_y = autoscale_z = TRUE;
- X } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
- X autoscale_x = autoscale_y = TRUE;
- X c_token++;
- X } else if (equals(c_token, "r")) {
- X autoscale_r = TRUE;
- X c_token++;
- X } else if (equals(c_token, "t")) {
- X autoscale_t = TRUE;
- X c_token++;
- X } else if (equals(c_token, "x")) {
- X autoscale_x = TRUE;
- X c_token++;
- X } else if (equals(c_token, "y")) {
- X autoscale_y = TRUE;
- X c_token++;
- X } else if (equals(c_token, "z")) {
- X autoscale_z = TRUE;
- X c_token++;
- X }
- X }
- X else if (almost_equals(c_token,"noau$toscale")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X autoscale_r=autoscale_t = autoscale_x = autoscale_y = autoscale_z = FALSE;
- X } else if (equals(c_token, "xy") || equals(c_token, "tyx")) {
- X autoscale_x = autoscale_y = FALSE;
- X c_token++;
- X } else if (equals(c_token, "r")) {
- X autoscale_r = FALSE;
- X c_token++;
- X } else if (equals(c_token, "t")) {
- X autoscale_t = FALSE;
- X c_token++;
- X } else if (equals(c_token, "x")) {
- X autoscale_x = FALSE;
- X c_token++;
- X } else if (equals(c_token, "y")) {
- X autoscale_y = FALSE;
- X c_token++;
- X } else if (equals(c_token, "z")) {
- X autoscale_z = FALSE;
- X c_token++;
- X }
- X }
- X else if (almost_equals(c_token,"bor$der")) {
- X draw_border = TRUE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"nobor$der")) {
- X draw_border = FALSE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"c$lip")) {
- X c_token++;
- X if (END_OF_COMMAND)
- X /* assuming same as points */
- X clip_points = TRUE;
- X else if (almost_equals(c_token, "p$oints"))
- X clip_points = TRUE;
- X else if (almost_equals(c_token, "o$ne"))
- X clip_lines1 = TRUE;
- X else if (almost_equals(c_token, "t$wo"))
- X clip_lines2 = TRUE;
- X else
- X int_error("expecting 'points', 'one', or 'two'", c_token);
- X c_token++;
- X }
- X else if (almost_equals(c_token,"noc$lip")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X /* same as all three */
- X clip_points = FALSE;
- X clip_lines1 = FALSE;
- X clip_lines2 = FALSE;
- X } else if (almost_equals(c_token, "p$oints"))
- X clip_points = FALSE;
- X else if (almost_equals(c_token, "o$ne"))
- X clip_lines1 = FALSE;
- X else if (almost_equals(c_token, "t$wo"))
- X clip_lines2 = FALSE;
- X else
- X int_error("expecting 'points', 'one', or 'two'", c_token);
- X c_token++;
- X }
- X else if (almost_equals(c_token,"ma$pping3d")) {
- X c_token++;
- X if (END_OF_COMMAND)
- X /* assuming same as points */
- X mapping3d = MAP3D_CARTESIAN;
- X else if (almost_equals(c_token, "ca$rtesian"))
- X mapping3d = MAP3D_CARTESIAN;
- X else if (almost_equals(c_token, "s$pherical"))
- X mapping3d = MAP3D_SPHERICAL;
- X else if (almost_equals(c_token, "cy$lindrical"))
- X mapping3d = MAP3D_CYLINDRICAL;
- X else
- X int_error("expecting 'cartesian', 'spherical', or 'cylindrical'", c_token);
- X c_token++;
- X }
- X else if (almost_equals(c_token,"co$ntour")) {
- X c_token++;
- X if (END_OF_COMMAND)
- X /* assuming same as points */
- X draw_contour = CONTOUR_BASE;
- X else if (almost_equals(c_token, "ba$se"))
- X draw_contour = CONTOUR_BASE;
- X else if (almost_equals(c_token, "s$urface"))
- X draw_contour = CONTOUR_SRF;
- X else if (almost_equals(c_token, "bo$th"))
- X draw_contour = CONTOUR_BOTH;
- X else
- X int_error("expecting 'base', 'surface', or 'both'", c_token);
- X c_token++;
- X }
- X else if (almost_equals(c_token,"noco$ntour")) {
- X c_token++;
- X draw_contour = CONTOUR_NONE;
- X }
- X else if (almost_equals(c_token,"cntrp$aram")) {
- X struct value a;
- X
- X c_token++;
- X if (END_OF_COMMAND) {
- X /* assuming same as defaults */
- X contour_pts = 5;
- X contour_kind = CONTOUR_KIND_LINEAR;
- X contour_order = 4;
- X contour_levels = 5;
- X }
- X else if (almost_equals(c_token, "p$oints")) {
- X c_token++;
- X contour_pts = (int) real(const_express(&a));
- X }
- X else if (almost_equals(c_token, "li$near")) {
- X c_token++;
- X contour_kind = CONTOUR_KIND_LINEAR;
- X }
- X else if (almost_equals(c_token, "c$ubicspline")) {
- X c_token++;
- X contour_kind = CONTOUR_KIND_CUBIC_SPL;
- X }
- X else if (almost_equals(c_token, "b$spline")) {
- X c_token++;
- X contour_kind = CONTOUR_KIND_BSPLINE;
- X }
- X else if (almost_equals(c_token, "le$vels")) {
- X c_token++;
- X contour_levels = (int) real(const_express(&a));
- X }
- X else if (almost_equals(c_token, "o$rder")) {
- X int order;
- X c_token++;
- X order = (int) real(const_express(&a));
- X if ( order < 2 || order > 10 )
- X int_error("bspline order must be in [2..10] range.", c_token);
- X contour_order = order;
- X }
- X else
- X int_error("expecting 'linear', 'cubicspline', 'bspline', 'points', 'levels' or 'order'", c_token);
- X c_token++;
- X }
- X else if (almost_equals(c_token,"d$ata")) {
- X c_token++;
- X if (!almost_equals(c_token,"s$tyle"))
- X int_error("expecting keyword 'style'",c_token);
- X data_style = get_style();
- X }
- X else if (almost_equals(c_token,"d$ummy")) {
- X c_token++;
- X if (END_OF_COMMAND)
- X int_error("expecting dummy variable name", c_token);
- X else {
- X if (!equals(c_token,","))
- X copy_str(dummy_var[0],c_token++);
- X if (!END_OF_COMMAND && equals(c_token,",")) {
- X c_token++;
- X if (END_OF_COMMAND)
- X int_error("expecting second dummy variable name", c_token);
- X copy_str(dummy_var[1],c_token++);
- X }
- X }
- X }
- X else if (almost_equals(c_token,"fo$rmat")) {
- X BOOLEAN setx, sety, setz;
- X c_token++;
- X if (equals(c_token,"x")) {
- X setx = TRUE; sety = setz = FALSE;
- X c_token++;
- X }
- X else if (equals(c_token,"y")) {
- X setx = setz = FALSE; sety = TRUE;
- X c_token++;
- X }
- X else if (equals(c_token,"z")) {
- X setx = sety = FALSE; setz = TRUE;
- X c_token++;
- X }
- X else if (equals(c_token,"xy") || equals(c_token,"yx")) {
- X setx = sety = TRUE; setz = FALSE;
- X c_token++;
- X }
- X else if (isstring(c_token) || END_OF_COMMAND) {
- X /* Assume he wants all */
- X setx = sety = setz = TRUE;
- X }
- X if (END_OF_COMMAND) {
- X if (setx)
- X (void) strcpy(xformat,DEF_FORMAT);
- X if (sety)
- X (void) strcpy(yformat,DEF_FORMAT);
- X if (setz)
- X (void) strcpy(zformat,DEF_FORMAT);
- X }
- X else {
- X if (!isstring(c_token))
- X int_error("expecting format string",c_token);
- X else {
- X if (setx)
- X quote_str(xformat,c_token);
- X if (sety)
- X quote_str(yformat,c_token);
- X if (setz)
- X quote_str(zformat,c_token);
- X c_token++;
- X }
- X }
- X }
- X else if (almost_equals(c_token,"fu$nction")) {
- X c_token++;
- X if (!almost_equals(c_token,"s$tyle"))
- X int_error("expecting keyword 'style'",c_token);
- X func_style = get_style();
- X }
- X else if (almost_equals(c_token,"la$bel")) {
- X c_token++;
- X set_label();
- X }
- X else if (almost_equals(c_token,"nola$bel")) {
- X c_token++;
- X set_nolabel();
- X }
- X else if (almost_equals(c_token,"lo$gscale")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X log_x = log_y = log_z = TRUE;
- X } else {
- X if (chr_in_str(c_token, 'x'))
- X log_x = TRUE;
- X if (chr_in_str(c_token, 'y'))
- X log_y = TRUE;
- X if (chr_in_str(c_token, 'z'))
- X log_z = TRUE;
- X c_token++;
- X }
- X }
- X else if (almost_equals(c_token,"nolo$gscale")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X log_x = log_y = log_z = FALSE;
- X } else {
- X if (chr_in_str(c_token, 'x'))
- X log_x = FALSE;
- X if (chr_in_str(c_token, 'y'))
- X log_y = FALSE;
- X if (chr_in_str(c_token, 'z'))
- X log_z = FALSE;
- X c_token++;
- X }
- X }
- X else if (almost_equals(c_token,"of$fsets")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X loff = roff = toff = boff = 0.0; /* Reset offsets */
- X }
- X else {
- X load_offsets (&loff,&roff,&toff,&boff);
- X }
- X }
- X else
- X return(FALSE); /* no command match */
- X return(TRUE);
- }
- X
- X
- /* return TRUE if a command match, FALSE if not */
- static BOOLEAN
- set_two()
- {
- X char testfile[MAX_LINE_LEN+1];
- #ifdef unix
- X static BOOLEAN pipe_open = FALSE;
- #endif
- X
- X if (almost_equals(c_token,"o$utput")) {
- X register FILE *f;
- X
- X c_token++;
- X if (term && term_init)
- X (*term_tbl[term].reset)();
- X if (END_OF_COMMAND) { /* no file specified */
- X UP_redirect (4);
- X if (outfile != stdout) { /* Never close stdout */
- #ifdef unix
- X if ( pipe_open ) {
- X (void) pclose(outfile);
- X pipe_open = FALSE;
- X } else
- #endif
- X (void) fclose(outfile);
- X }
- X outfile = stdout; /* Don't dup... */
- X term_init = FALSE;
- X (void) strcpy(outstr,"STDOUT");
- X } else if (!isstring(c_token))
- X int_error("expecting filename",c_token);
- X else {
- X quote_str(testfile,c_token);
- #ifdef unix
- X if ( *testfile == '|' ) {
- X if ((f = popen(testfile+1,"w")) == (FILE *)NULL)
- X os_error("cannot create pipe; output not changed",c_token);
- X else
- X pipe_open = TRUE;
- X } else
- #endif
- X if ((f = fopen(testfile,"w")) == (FILE *)NULL)
- X os_error("cannot open file; output not changed",c_token);
- X if (outfile != stdout) /* Never close stdout */
- X (void) fclose(outfile);
- X outfile = f;
- X term_init = FALSE;
- X outstr[0] = '\'';
- X (void) strcat(strcpy(outstr+1,testfile),"'");
- X UP_redirect (1);
- X }
- X c_token++;
- X }
- X else if (almost_equals(c_token,"tit$le")) {
- X set_xyzlabel(title,&title_xoffset,&title_yoffset);
- X }
- X else if (almost_equals(c_token,"xl$abel")) {
- X set_xyzlabel(xlabel,&xlabel_xoffset,&xlabel_yoffset);
- X }
- X else if (almost_equals(c_token,"yl$abel")) {
- X set_xyzlabel(ylabel,&ylabel_xoffset,&ylabel_yoffset);
- X }
- X else if (almost_equals(c_token,"zl$abel")) {
- X set_xyzlabel(zlabel,&zlabel_xoffset,&zlabel_yoffset);
- X }
- X else if (almost_equals(c_token,"xzero$axis")) {
- X c_token++;
- X xzeroaxis = TRUE;
- X }
- X else if (almost_equals(c_token,"yzero$axis")) {
- X c_token++;
- X yzeroaxis = TRUE;
- X }
- X else if (almost_equals(c_token,"zeroa$xis")) {
- X c_token++;
- X yzeroaxis = TRUE;
- X xzeroaxis = TRUE;
- X }
- X else if (almost_equals(c_token,"noxzero$axis")) {
- X c_token++;
- X xzeroaxis = FALSE;
- X }
- X else if (almost_equals(c_token,"noyzero$axis")) {
- X c_token++;
- X yzeroaxis = FALSE;
- X }
- X else if (almost_equals(c_token,"nozero$axis")) {
- X c_token++;
- X xzeroaxis = FALSE;
- X yzeroaxis = FALSE;
- X }
- X else if (almost_equals(c_token,"par$ametric")) {
- X if (!parametric) {
- X parametric = TRUE;
- X strcpy (dummy_var[0], "t");
- X strcpy (dummy_var[1], "y");
- X (void) fprintf(stderr,"\n\tdummy variable is t for curves, u/v for surfaces\n");
- X }
- X c_token++;
- X }
- X else if (almost_equals(c_token,"nopar$ametric")) {
- X if (parametric) {
- X parametric = FALSE;
- X strcpy (dummy_var[0], "x");
- X strcpy (dummy_var[1], "y");
- X (void) fprintf(stderr,"\n\tdummy variable is x for curves, x/y for surfaces\n");
- X }
- X c_token++;
- X }
- X else if (almost_equals(c_token,"pol$ar")) {
- X if (!polar) {
- X polar = TRUE;
- X if (parametric) {
- X tmin = 0.0;
- X tmax = 2*Pi;
- X } else if (angles_format == ANGLES_DEGREES) {
- X xmin = 0.0;
- X xmax = 360.0;
- X } else {
- X xmin = 0.0;
- X xmax = 2*Pi;
- X }
- X }
- X c_token++;
- X }
- X else if (almost_equals(c_token,"nopo$lar")) {
- X if (polar) {
- X polar = FALSE;
- X if (parametric) {
- X tmin = -5.0;
- X tmax = 5.0;
- X } else {
- X xmin = -10.0;
- X xmax = 10.0;
- X }
- X }
- X c_token++;
- X }
- X else if (almost_equals(c_token,"an$gles")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X /* assuming same as defaults */
- X angles_format = ANGLES_RADIANS;
- X }
- X else if (almost_equals(c_token, "r$adians")) {
- X angles_format = ANGLES_RADIANS;
- X c_token++;
- X }
- X else if (almost_equals(c_token, "d$egrees")) {
- X angles_format = ANGLES_DEGREES;
- X c_token++;
- X }
- X else
- X int_error("expecting 'radians' or 'degrees'", c_token);
- X }
- X else if (almost_equals(c_token,"g$rid")) {
- X grid = TRUE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"nog$rid")) {
- X grid = FALSE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"su$rface")) {
- X draw_surface = TRUE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"nosu$rface")) {
- X draw_surface = FALSE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"k$ey")) {
- X struct value a;
- X c_token++;
- X if (END_OF_COMMAND) {
- X key = -1;
- X }
- X else {
- X key_x = real(const_express(&a));
- X if (!equals(c_token,","))
- X int_error("',' expected",c_token);
- X c_token++;
- X key_y = real(const_express(&a));
- X if (equals(c_token,","))
- X {
- X c_token++;
- X key_z = real(const_express(&a));
- X }
- X key = 1;
- X }
- X }
- X else if (almost_equals(c_token,"nok$ey")) {
- X key = 0;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"tic$s")) {
- X tic_in = TRUE;
- X c_token++;
- X if (almost_equals(c_token,"i$n")) {
- X tic_in = TRUE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"o$ut")) {
- X tic_in = FALSE;
- X c_token++;
- X }
- X }
- X else if (almost_equals(c_token,"xt$ics")) {
- X xtics = TRUE;
- X c_token++;
- X if (END_OF_COMMAND) { /* reset to default */
- X if (xticdef.type == TIC_USER) {
- X free_marklist(xticdef.def.user);
- X xticdef.def.user = NULL;
- X }
- X xticdef.type = TIC_COMPUTED;
- X }
- X else
- X load_tics(&xticdef);
- X }
- X else if (almost_equals(c_token,"noxt$ics")) {
- X xtics = FALSE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"yt$ics")) {
- X ytics = TRUE;
- X c_token++;
- X if (END_OF_COMMAND) { /* reset to default */
- X if (yticdef.type == TIC_USER) {
- X free_marklist(yticdef.def.user);
- X yticdef.def.user = NULL;
- X }
- X yticdef.type = TIC_COMPUTED;
- X }
- X else
- X load_tics(&yticdef);
- X }
- X else if (almost_equals(c_token,"noyt$ics")) {
- X ytics = FALSE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"zt$ics")) {
- X ztics = TRUE;
- X c_token++;
- X if (END_OF_COMMAND) { /* reset to default */
- X if (zticdef.type == TIC_USER) {
- X free_marklist(zticdef.def.user);
- X zticdef.def.user = NULL;
- X }
- X zticdef.type = TIC_COMPUTED;
- X }
- X else
- X load_tics(&zticdef);
- X }
- X else if (almost_equals(c_token,"nozt$ics")) {
- X ztics = FALSE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"ticsl$evel")) {
- X double tlvl;
- X struct value a;
- X
- X c_token++;
- X tlvl = real(const_express(&a));
- X if (tlvl < 0.0)
- X int_error("tics level must be > 0; ticslevel unchanged",
- X c_token);
- X else {
- X ticslevel = tlvl;
- X }
- X }
- X else
- X return(FALSE); /* no command match */
- X
- X return(TRUE);
- }
- X
- X
- X
- /* return TRUE if a command match, FALSE if not */
- static BOOLEAN
- set_three()
- {
- X if (almost_equals(c_token,"sa$mples")) {
- X register int tsamp;
- X struct value a;
- X
- X c_token++;
- X tsamp = (int)magnitude(const_express(&a));
- X if (tsamp < 2)
- X int_error("sampling rate must be > 1; sampling unchanged",
- X c_token);
- X else {
- X extern struct surface_points *first_3dplot;
- X register struct surface_points *f_3dp = first_3dplot;
- X
- X first_3dplot = NULL;
- X sp_free(f_3dp);
- X
- X samples = tsamp;
- X }
- X }
- X else if (almost_equals(c_token,"isosa$mples")) {
- X register int tsamp;
- X struct value a;
- X
- X c_token++;
- X tsamp = (int)magnitude(const_express(&a));
- X if (tsamp < 2)
- X int_error("sampling rate must be > 1; sampling unchanged",
- X c_token);
- X else {
- X extern struct curve_points *first_plot;
- X extern struct surface_points *first_3dplot;
- X register struct curve_points *f_p = first_plot;
- X register struct surface_points *f_3dp = first_3dplot;
- X
- X first_plot = NULL;
- X first_3dplot = NULL;
- X cp_free(f_p);
- X sp_free(f_3dp);
- X
- X iso_samples = tsamp;
- X }
- X }
- X else if (almost_equals(c_token,"si$ze")) {
- X struct value s;
- X c_token++;
- X if (END_OF_COMMAND) {
- X xsize = 1.0;
- X ysize = 1.0;
- X }
- X else {
- X xsize=real(const_express(&s));
- X if (!equals(c_token,","))
- X int_error("',' expected",c_token);
- X c_token++;
- X ysize=real(const_express(&s));
- X }
- X }
- X else if (almost_equals(c_token,"t$erminal")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X list_terms();
- X screen_ok = FALSE;
- X }
- X else {
- X if (term && term_init) {
- X (*term_tbl[term].reset)();
- X (void) fflush(outfile);
- X }
- X term = set_term(c_token);
- X c_token++;
- X
- X /* get optional mode parameters */
- X if (term)
- X (*term_tbl[term].options)();
- X if (interactive && *term_options)
- X fprintf(stderr,"Options are '%s'\n",term_options);
- X }
- X }
- X else if (almost_equals(c_token,"tim$e")) {
- X timedate = TRUE;
- X c_token++;
- X if (!END_OF_COMMAND) {
- X struct value a;
- X int x, y;
- X
- X /* We have x,y offsets specified */
- X if (!equals(c_token,","))
- X time_xoffset = (int)real(const_express(&a));
- X if (!END_OF_COMMAND && equals(c_token,",")) {
- X c_token++;
- X time_yoffset = (int)real(const_express(&a));
- X }
- X }
- X }
- X else if (almost_equals(c_token,"not$ime")) {
- X timedate = FALSE;
- X c_token++;
- X }
- X else if (almost_equals(c_token,"rr$ange")) {
- X BOOLEAN changed;
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X changed = load_range(&rmin,&rmax);
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X if (changed)
- X autoscale_r = FALSE;
- X }
- X else if (almost_equals(c_token,"tr$ange")) {
- X BOOLEAN changed;
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X changed = load_range(&tmin,&tmax);
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X if (changed)
- X autoscale_t = FALSE;
- X }
- X else if (almost_equals(c_token,"ur$ange")) {
- X BOOLEAN changed;
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X changed = load_range(&umin,&umax);
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X if (changed)
- X autoscale_u = FALSE;
- X }
- X else if (almost_equals(c_token,"vi$ew")) {
- X int i;
- X BOOLEAN was_comma = TRUE;
- X double local_vals[4];
- X struct value a;
- X
- X local_vals[0] = surface_rot_x;
- X local_vals[1] = surface_rot_z;
- X local_vals[2] = surface_scale;
- X local_vals[3] = surface_zscale;
- X c_token++;
- X for (i = 0; i < 4 && !(END_OF_COMMAND);) {
- X if (equals(c_token,",")) {
- X if (was_comma) i++;
- X was_comma = TRUE;
- X c_token++;
- X }
- X else {
- X if (!was_comma)
- X int_error("',' expected",c_token);
- X local_vals[i] = real(const_express(&a));
- X i++;
- X was_comma = FALSE;
- X }
- X }
- X
- X if (local_vals[0] < 0 || local_vals[0] > 180)
- X int_error("rot_x must be in [0:180] degrees range; view unchanged",
- X c_token);
- X if (local_vals[1] < 0 || local_vals[1] > 360)
- X int_error("rot_z must be in [0:360] degrees range; view unchanged",
- X c_token);
- X if (local_vals[2] < 1e-6)
- X int_error("scale must be > 0; view unchanged", c_token);
- X if (local_vals[3] < 1e-6)
- X int_error("zscale must be > 0; view unchanged", c_token);
- X
- X surface_rot_x = local_vals[0];
- X surface_rot_z = local_vals[1];
- X surface_scale = local_vals[2];
- X surface_zscale = local_vals[3];
- X }
- X else if (almost_equals(c_token,"vr$ange")) {
- X BOOLEAN changed;
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X changed = load_range(&vmin,&vmax);
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X if (changed)
- X autoscale_v = FALSE;
- X }
- X else if (almost_equals(c_token,"xr$ange")) {
- X BOOLEAN changed;
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X changed = load_range(&xmin,&xmax);
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X if (changed)
- X autoscale_x = FALSE;
- X }
- X else if (almost_equals(c_token,"yr$ange")) {
- X BOOLEAN changed;
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X changed = load_range(&ymin,&ymax);
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X if (changed)
- X autoscale_y = FALSE;
- X }
- X else if (almost_equals(c_token,"zr$ange")) {
- X BOOLEAN changed;
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X changed = load_range(&zmin,&zmax);
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X if (changed)
- X autoscale_z = FALSE;
- X }
- X else if (almost_equals(c_token,"z$ero")) {
- X struct value a;
- X c_token++;
- X zero = magnitude(const_express(&a));
- X }
- X else
- X return(FALSE); /* no command match */
- X return(TRUE);
- }
- X
- /*********** Support functions for set_command ***********/
- X
- /* process a 'set {x/y/z}label command */
- /* set {x/y/z}label {label_text} {x}{,y} */
- static void set_xyzlabel(str,xpos,ypos)
- char *str;
- int *xpos,*ypos;
- {
- X c_token++;
- X if (END_OF_COMMAND) { /* no label specified */
- X str[0] = '\0';
- X } else {
- X if (isstring(c_token)) {
- X /* We have string specified - grab it. */
- X quotel_str(str,c_token);
- X c_token++;
- X }
- X if (!END_OF_COMMAND) {
- X struct value a;
- X int x, y;
- X
- X /* We have x,y offsets specified */
- X if (!equals(c_token,","))
- X *xpos = (int)real(const_express(&a));
- X if (!END_OF_COMMAND && equals(c_token,",")) {
- X c_token++;
- X *ypos = (int)real(const_express(&a));
- X }
- X }
- X }
- }
- X
- /* process a 'set label' command */
- /* set label {tag} {label_text} {at x,y} {pos} */
- static void
- set_label()
- {
- X struct value a;
- X struct text_label *this_label = NULL;
- X struct text_label *new_label = NULL;
- X struct text_label *prev_label = NULL;
- X double x, y, z;
- X char text[MAX_LINE_LEN+1];
- X enum JUSTIFY just;
- X int tag;
- X BOOLEAN set_text, set_position, set_just;
- X
- X /* get tag */
- X if (!END_OF_COMMAND
- X && !isstring(c_token)
- X && !equals(c_token, "at")
- X && !equals(c_token, "left")
- X && !equals(c_token, "center")
- X && !equals(c_token, "centre")
- X && !equals(c_token, "right")) {
- X /* must be a tag expression! */
- X tag = (int)real(const_express(&a));
- X if (tag <= 0)
- X int_error("tag must be > zero", c_token);
- X } else
- X tag = assign_label_tag(); /* default next tag */
- X
- X /* get text */
- X if (!END_OF_COMMAND && isstring(c_token)) {
- X /* get text */
- X quotel_str(text, c_token);
- X c_token++;
- X set_text = TRUE;
- X } else {
- X text[0] = '\0'; /* default no text */
- X set_text = FALSE;
- X }
- X
- X /* get justification - what the heck, let him put it here */
- X if (!END_OF_COMMAND && !equals(c_token, "at")) {
- X if (almost_equals(c_token,"l$eft")) {
- X just = LEFT;
- X }
- X else if (almost_equals(c_token,"c$entre")
- X || almost_equals(c_token,"c$enter")) {
- X just = CENTRE;
- X }
- X else if (almost_equals(c_token,"r$ight")) {
- X just = RIGHT;
- X }
- X else
- X int_error("bad syntax in set label", c_token);
- X c_token++;
- X set_just = TRUE;
- X } else {
- X just = LEFT; /* default left justified */
- X set_just = FALSE;
- X }
- X
- X /* get position */
- X if (!END_OF_COMMAND && equals(c_token, "at")) {
- X c_token++;
- X if (END_OF_COMMAND)
- X int_error("coordinates expected", c_token);
- X /* get coordinates */
- X x = real(const_express(&a));
- X if (!equals(c_token,","))
- X int_error("',' expected",c_token);
- X c_token++;
- X y = real(const_express(&a));
- X if (equals(c_token,",")) {
- X c_token++;
- X z = real(const_express(&a));
- X }
- X else
- X z = 0;
- X set_position = TRUE;
- X } else {
- X x = y = z = 0; /* default at origin */
- X set_position = FALSE;
- X }
- X
- X /* get justification */
- X if (!END_OF_COMMAND) {
- X if (set_just)
- X int_error("only one justification is allowed", c_token);
- X if (almost_equals(c_token,"l$eft")) {
- X just = LEFT;
- X }
- X else if (almost_equals(c_token,"c$entre")
- X || almost_equals(c_token,"c$enter")) {
- X just = CENTRE;
- X }
- X else if (almost_equals(c_token,"r$ight")) {
- X just = RIGHT;
- X }
- X else
- X int_error("bad syntax in set label", c_token);
- X c_token++;
- X set_just = TRUE;
- X }
- X
- X if (!END_OF_COMMAND)
- X int_error("extraenous or out-of-order arguments in set label", c_token);
- X
- X /* OK! add label */
- X if (first_label != NULL) { /* skip to last label */
- X for (this_label = first_label; this_label != NULL ;
- X prev_label = this_label, this_label = this_label->next)
- X /* is this the label we want? */
- X if (tag <= this_label->tag)
- X break;
- X }
- X if (this_label != NULL && tag == this_label->tag) {
- X /* changing the label */
- X if (set_position) {
- X this_label->x = x;
- X this_label->y = y;
- X this_label->z = z;
- X }
- X if (set_text)
- X (void) strcpy(this_label->text, text);
- X if (set_just)
- X this_label->pos = just;
- X } else {
- X /* adding the label */
- X new_label = (struct text_label *)
- X alloc ( (unsigned int) sizeof(struct text_label), "label");
- X if (prev_label != NULL)
- X prev_label->next = new_label; /* add it to end of list */
- X else
- X first_label = new_label; /* make it start of list */
- X new_label->tag = tag;
- X new_label->next = this_label;
- X new_label->x = x;
- X new_label->y = y;
- X new_label->z = z;
- X (void) strcpy(new_label->text, text);
- X new_label->pos = just;
- X }
- }
- X
- /* process 'set nolabel' command */
- /* set nolabel {tag} */
- static void
- set_nolabel()
- {
- X struct value a;
- X struct text_label *this_label;
- X struct text_label *prev_label;
- X int tag;
- X
- X if (END_OF_COMMAND) {
- X /* delete all labels */
- X while (first_label != NULL)
- X delete_label((struct text_label *)NULL,first_label);
- X }
- X else {
- X /* get tag */
- X tag = (int)real(const_express(&a));
- X if (!END_OF_COMMAND)
- X int_error("extraneous arguments to set nolabel", c_token);
- X for (this_label = first_label, prev_label = NULL;
- X this_label != NULL;
- X prev_label = this_label, this_label = this_label->next) {
- X if (this_label->tag == tag) {
- X delete_label(prev_label,this_label);
- X return; /* exit, our job is done */
- X }
- X }
- X int_error("label not found", c_token);
- X }
- }
- X
- /* assign a new label tag */
- /* labels are kept sorted by tag number, so this is easy */
- static int /* the lowest unassigned tag number */
- assign_label_tag()
- {
- X struct text_label *this_label;
- X int last = 0; /* previous tag value */
- X
- X for (this_label = first_label; this_label != NULL;
- X this_label = this_label->next)
- X if (this_label->tag == last+1)
- X last++;
- X else
- X break;
- X
- X return (last+1);
- }
- X
- /* delete label from linked list started by first_label.
- X * called with pointers to the previous label (prev) and the
- X * label to delete (this).
- X * If there is no previous label (the label to delete is
- X * first_label) then call with prev = NULL.
- X */
- static void
- delete_label(prev,this)
- X struct text_label *prev, *this;
- {
- X if (this!=NULL) { /* there really is something to delete */
- X if (prev!=NULL) /* there is a previous label */
- X prev->next = this->next;
- X else /* this = first_label so change first_label */
- X first_label = this->next;
- X free((char *)this);
- X }
- }
- X
- X
- /* process a 'set arrow' command */
- /* set arrow {tag} {from x,y} {to x,y} {{no}head} */
- static void
- set_arrow()
- {
- X struct value a;
- X struct arrow_def *this_arrow = NULL;
- X struct arrow_def *new_arrow = NULL;
- X struct arrow_def *prev_arrow = NULL;
- X double sx, sy, sz;
- X double ex, ey, ez;
- X int tag;
- X BOOLEAN set_start, set_end, head = 1;
- X
- X /* get tag */
- X if (!END_OF_COMMAND
- X && !equals(c_token, "from")
- X && !equals(c_token, "to")) {
- X /* must be a tag expression! */
- X tag = (int)real(const_express(&a));
- X if (tag <= 0)
- X int_error("tag must be > zero", c_token);
- X } else
- X tag = assign_arrow_tag(); /* default next tag */
- X
- X /* get start position */
- X if (!END_OF_COMMAND && equals(c_token, "from")) {
- X c_token++;
- X if (END_OF_COMMAND)
- X int_error("start coordinates expected", c_token);
- X /* get coordinates */
- X sx = real(const_express(&a));
- X if (!equals(c_token,","))
- X int_error("',' expected",c_token);
- X c_token++;
- X sy = real(const_express(&a));
- X if (equals(c_token,",")) {
- X c_token++;
- X sz = real(const_express(&a));
- X }
- X else
- X sz = 0;
- X set_start = TRUE;
- X } else {
- X sx = sy = sz = 0; /* default at origin */
- X set_start = FALSE;
- X }
- X
- X /* get end position */
- X if (!END_OF_COMMAND && equals(c_token, "to")) {
- X c_token++;
- X if (END_OF_COMMAND)
- X int_error("end coordinates expected", c_token);
- X /* get coordinates */
- X ex = real(const_express(&a));
- X if (!equals(c_token,","))
- X int_error("',' expected",c_token);
- X c_token++;
- X ey = real(const_express(&a));
- X if (equals(c_token,",")) {
- X c_token++;
- X ez = real(const_express(&a));
- X }
- X else
- X ez = 0;
- X set_end = TRUE;
- X } else {
- X ex = ey = ez = 0; /* default at origin */
- X set_end = FALSE;
- X }
- X
- X /* get start position - what the heck, either order is ok */
- X if (!END_OF_COMMAND && equals(c_token, "from")) {
- X if (set_start)
- X int_error("only one 'from' is allowed", c_token);
- X c_token++;
- X if (END_OF_COMMAND)
- X int_error("start coordinates expected", c_token);
- X /* get coordinates */
- X sx = real(const_express(&a));
- X if (!equals(c_token,","))
- X int_error("',' expected",c_token);
- X c_token++;
- X sy = real(const_express(&a));
- X if (equals(c_token,",")) {
- X c_token++;
- X sz = real(const_express(&a));
- X }
- X else
- X sz = 0;
- X set_start = TRUE;
- X }
- X
- X if (!END_OF_COMMAND && equals(c_token, "nohead")) {
- X c_token++;
- X head = 0;
- X }
- X
- X if (!END_OF_COMMAND && equals(c_token, "head")) {
- X c_token++;
- X head = 1;
- X }
- X
- X if (!END_OF_COMMAND)
- X int_error("extraneous or out-of-order arguments in set arrow", c_token);
- X
- X /* OK! add arrow */
- X if (first_arrow != NULL) { /* skip to last arrow */
- X for (this_arrow = first_arrow; this_arrow != NULL ;
- X prev_arrow = this_arrow, this_arrow = this_arrow->next)
- X /* is this the arrow we want? */
- X if (tag <= this_arrow->tag)
- X break;
- X }
- X if (this_arrow != NULL && tag == this_arrow->tag) {
- X /* changing the arrow */
- X if (set_start) {
- X this_arrow->sx = sx;
- X this_arrow->sy = sy;
- X this_arrow->sz = sz;
- X }
- X if (set_end) {
- X this_arrow->ex = ex;
- X this_arrow->ey = ey;
- X this_arrow->ez = ez;
- X }
- X this_arrow->head = head;
- X } else {
- X /* adding the arrow */
- X new_arrow = (struct arrow_def *)
- X alloc ( (unsigned int) sizeof(struct arrow_def), "arrow");
- X if (prev_arrow != NULL)
- X prev_arrow->next = new_arrow; /* add it to end of list */
- X else
- X first_arrow = new_arrow; /* make it start of list */
- X new_arrow->tag = tag;
- X new_arrow->next = this_arrow;
- X new_arrow->sx = sx;
- X new_arrow->sy = sy;
- X new_arrow->sz = sz;
- X new_arrow->ex = ex;
- X new_arrow->ey = ey;
- X new_arrow->ez = ez;
- X new_arrow->head = head;
- X }
- }
- X
- /* process 'set noarrow' command */
- /* set noarrow {tag} */
- static void
- set_noarrow()
- {
- X struct value a;
- X struct arrow_def *this_arrow;
- X struct arrow_def *prev_arrow;
- X int tag;
- X
- X if (END_OF_COMMAND) {
- X /* delete all arrows */
- X while (first_arrow != NULL)
- X delete_arrow((struct arrow_def *)NULL,first_arrow);
- X }
- X else {
- X /* get tag */
- X tag = (int)real(const_express(&a));
- X if (!END_OF_COMMAND)
- X int_error("extraneous arguments to set noarrow", c_token);
- X for (this_arrow = first_arrow, prev_arrow = NULL;
- X this_arrow != NULL;
- SHAR_EOF
- true || echo 'restore of gnuplot/setshow.c failed'
- fi
- echo 'End of part 1'
- echo 'File gnuplot/setshow.c is continued in part 2'
- echo 2 > _shar_seq_.tmp
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-