[comp.sources.amiga] v90i008: plplot 2.6 - C library for making scientific plots, Part07/12

Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (01/15/90)

Submitted-by: Anthony M. Richardson <amr@dukee.egr.duke.edu>
Posting-number: Volume 90, Issue 008
Archive-name: applications/plplot-2.6/part07

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 7 (of 12)."
# Contents:  docs/chapter2.tex include/plplot.h src/plbox.c
#   src/plnxtv.c
# Wrapped by tadguy@xanth on Sun Jan 14 18:11:52 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'docs/chapter2.tex' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'docs/chapter2.tex'\"
else
echo shar: Extracting \"'docs/chapter2.tex'\" \(10944 characters\)
sed "s/^X//" >'docs/chapter2.tex' <<'END_OF_FILE'
X\chapter {Simple Use of PLPLOT} \label{simple}
X
XThe rest of this manual assumes the reader has some familiarity with the
XC programming language.
X
X\section {Notation}
XSeveral of the plotting routines are described in this section.
XThe values passed to or returned by the functions
Xare either of type char, PLINT, PLFLT or pointers to one of these three
Xtypes. PLINT and PLFLT are typedef'ed in plplot.h. PLINT is usually
Xtypedef'ed to the longest available interger type (long). PLFLT is
Xtypedef'ed to either float or double (see your local PLPLOT guru to
Xfind out which!!).
X
X\section {Plotting a Simple Graph}
XWe shall first consider plotting simple graphs showing the dependence
Xof one variable upon another. Such a graph may be composed of several
Xelements:
X\begin{itemize}
X   \item A box which defines the ranges of the variables, perhaps with axes
X         and numeric labels along its edges,
X   \item A set of points or lines within the box showing the functional
X         dependence,
X   \item A set of labels for the variables and a title for the graph.
X\end{itemize}
XIn order to draw such a graph, it is necessary to call at least four of
Xthe PLPLOT functions:
X\begin{enumerate}
X   \item {\tt plstar}, to specify the device you want to plot on,
X   \item {\tt plenv}, to define the range and scale of the graph, and
X                      draw labels, axes, etc.,
X   \item One or more calls to {\tt plline} or {\tt plpoin} to draw
X         lines or points as needed. Other more complex routines include
X         {\tt plbin} and {\tt plhist} to draw histograms, {\tt plerrx} and
X         {\tt plerry} to draw error-bars, \label{draw}
X   \item {\tt plend}, to close the plot.
X\end{enumerate}
XMore than one graph can be drawn on a single set of axes by making
Xrepeated calls to the routines listed in item \ref{draw} above. The routine
X{\tt plstar} needs to be called only once, unless it is desired to switch
Xoutput devices between pages.
X
X\section {Starting PLPLOT} \label{startingup}
XSubroutine {\tt plstar} selects a graphics device or opens a disk file to
Xreceive a plot for later display. If {\tt plstar} is called again during
Xa program, the previously opened file will be closed. When called,
Xthe user is prompted for a number representing the device on which
Xthe plot is to appear. The syntax for {\tt plstar} is:
X
X\name{plstar(nx,ny);}
X\argu{{\tt nx, ny} (PLINT, input)}
X{The number of plots to a page. The page is divided into
X{\tt nx}~$\times$~{\tt ny} subpages, with {\tt nx} in the horizontal
Xdirection, and {\tt ny} in the vertical direction.}
X
XSubpages are useful for placing several graphs on a page, but all
Xsubpages are constrained to be of the same size. For greater flexibility,
Xread page \pageref{viewport} in Section
X\ref{viewport} which discusses viewports.
X
X\section{Defining Plot Scales and Axes}
XThe function {\tt plenv} is used to define the scales and axes for simple
Xgraphs. {\tt plenv} starts a new picture on the next subpage (or a new page
Xif necessary), and defines the ranges of the variables required. The
Xroutine will also draw a box, axes, and numeric labels if requested.
XThe syntax for {\tt plenv} is:
X
X\name{plenv(xmin,xmax,ymin,ymax,just,axis);}
X\argu{{\tt xmin, xmax} (PLFLT, input)}
X{The left and right limits for the horizontal axis.}
X\argu{{\tt ymin, ymax} (PLFLT, input)}
X{The bottom and top limits for the vertical axis.}
X\argu{{\tt just} (PLINT, input)}
X{This should be zero or one. If {\tt just} is one, the scales of the
Xx-axis and
Xy-axis will be the same (in units per millimeter); otherwise the axes are
Xscaled independently. This parameter is useful for ensuring that objects
Xsuch as circles have the correct aspect ratio in the final plot.}
X\argu{{\tt axis} (PLINT, input)}
X{{\tt axis} controls whether a box, tick marks, labels, axes, and/or a
Xgrid are drawn.
X\begin{itemize}
X     \item {\tt axis=-2}: No box or annotation.
X     \item {\tt axis=-1}: Draw box only.
X     \item {\tt axis= 0}: Draw box, labelled with coordinate values around edge.
X     \item {\tt axis= 1}: In addition to box and labels, draw the two axes
X                          X=0 and Y=0.
X     \item {\tt axis= 2}: As for {\tt axis=1}, but also draw a grid at the major tick interval.
X     \item {\tt axis=10}: Logarithmic X axis, linear Y axis.
X     \item {\tt axis=11}: Logarithmic X axis, linear Y axis and draw line Y=0.
X     \item {\tt axis=20}: Linear X axis, logarithmic Y axis.
X     \item {\tt axis=21}: Linear X axis, logarithmic Y axis and draw line X=0.
X     \item {\tt axis=30}: Logarithmic X and Y axes.
X\end{itemize}
X}
X
XNote: Logarithmic axes only affect the appearance of the axes and their
Xlabels, so it is up to the user to compute the logarithms prior to passing
Xthem to {\tt plenv} and any of the other routines. Thus, if a graph has a 3-cycle
Xlogarithmic axis from 1 to 1000, we need to set {\tt xmin}$=\log_{10}1=0.0$,
Xand {\tt xmax}$=\log_{10}1000=3.0$.
X
XFor greater control over the size of the plots, axis labelling and tick
Xintervals, more complex graphs should make use of the functions
X\rou{plvpor}, \rou{plwind}, and \rou{plbox}
Xdescribed in Chapter \ref{reference}.
X
X\section {Labelling the Graph}
XThe function {\tt pllab} may be called after {\tt plenv} to write labels
Xon the x and y axes, and at the top of the picture. All the
Xvariables are character variables or constants. Trailing spaces
Xare removed and the label is centred in the appropriate field.
XThe syntax for {\tt pllab} is:
X
X\name{pllab(xlbl,ylbl,toplbl);}
X\argu{{\tt xlbl} (char *, input)}
X{Pointer to string with label for the X-axis (bottom of graph).}
X\argu{{\tt ylbl} (char *, input)}
X{Pointer to string with label for the Y-axis (left of graph).}
X\argu{{\tt toplbl} (char *, input)}
X{Pointer to string with label for the plot (top of picture).}
X
XMore complex labels can be drawn using the function \rou{plmtex}.
XSee also Section \ref{graph-text} on page
X\pageref{graph-text} for information about the function {\tt plptex} which
Xwrites labels within a graph.
X
X\section {Drawing the Graph}
X
XPLPLOT can draw graphs consisting of points with optional error bars,
Xline segments or histograms. Functions which perform each of these
Xactions may be called after setting up the plotting environment
Xusing {\tt plenv}. All of the following functions draw within the box
Xdefined by {\tt plenv}, and any lines crossing the boundary are clipped.
XFunctions are also provided for drawing surface and contour representations
Xof multi-dimensional functions. These are described in
XChapter \ref{advanced}.
X
X\subsection {Drawing Points}
X{\tt plpoin} and {\tt plsym} mark out {\tt n} points
X{\tt (x[i],y[i])} with the
Xspecified symbol. The routines differ only in the interpretation
Xof the symbol
Xcodes. {\tt plpoin} uses an extended ASCII representation, with the
Xprintable
XASCII codes mapping to the respective characters in the current font, and
Xthe codes from 0-31 mapping to various useful symbols.
XIn {\tt plsym} however,
Xthe code is a Hershey font code number. Example programs are provided
Xwhich display each of the symbols available using these routines.
X
X\name{plpoin(n,x,y,code); {\rm and } plsym(n,x,y,code);}
X\argu{{\tt n} (PLINT, input)}
X{the number of points to plot.}
X\argu{{\tt x, y} (PLFLT *, input)}
X{pointers to arrays of the coordinates of the {\tt n} points.}
X\argu{{\tt code} (PLINT, input)}
X{code number of symbol to draw.}
X
X\subsection {Drawing Lines or Curves}
X
XPLPLOT provides two functions for drawing line graphs.
XAll lines are drawn in
Xthe currently selected color, style and width. See page \pageref{color} in
XSection \ref{color}, page \pageref{style} in Section \ref{style} and
Xpage \pageref{width} in Section \ref{width} for
Xinformation about changing these parameters.
X
X{\tt plline} draws a line or curve. The curve consists of {\tt n-1} line
Xsegments joining the {\tt n} points in the input arrays. For single line
Xsegments, {\tt pljoin} is used to join two points.
X
X\name{plline(n,x,y);}
X\argu{{\tt n} (PLINT, input)}
X{the number of points.}
X\argu{{\tt x, y} (PLFLT *, input)}
X{pointers to arrays with coordinates of the {\tt n} points.}
X
X\name{pljoin(x1,y1,x2,y2);}
X\argu{{\tt x1, y1} (PLFLT, input)}
X{coordinates of the first point.}
X\argu{{\tt x2, y2} (PLFLT, input)}
X{coordinates of the second point.}
X
X\subsection {Writing Text on a Graph} \label {graph-text}
X
X{\tt plptex} allows text to be written within the limits set by
X{\tt plenv}. The reference point of a text string may be located
Xanywhere along an imaginary horizontal line passing through the string
Xat half the height of a capital letter. The parameter "just" specifies
Xwhere along this line the reference point is located. The string is then
Xrotated about the reference point through an angle specified by the
Xparameters {\tt dx} and {\tt dy}, so that the string becomes parallel
Xto a line joining {\tt (x,y)} to {\tt (x+dx,y+dy)}.
X
X\name{plptex(x,y,dx,dy,just,text);}
X\argu{{\tt x, y} (PLFLT, input)}
X{coordinates of the reference point.}
X\argu{{\tt dx, dy} (PLFLT, input)}
X{these specify the angle at which the text is to be printed. The text is
X written parallel to a line joining the points {\tt (x,y)} to
X {\tt (x+dx,y+dy)} on the graph.}
X\argu{{\tt just} (PLFLT, input)}
X{determines justification of the string by specifying which point within
X the string is placed at the reference point {\tt (x,y)}. This parameter
X is a fraction of the distance along the string. Thus if {\tt just=0.0},
X the reference point is at the left-hand edge of the string.
X If {\tt just=0.5}, it is at the center and if {\tt just=1.0}, it is at
X the right-hand edge.}
X\argu{{\tt text} (char *, input)}
X{pointer to the string of characters to be written.}
X
X\subsection {Area Fills}
X
XArea fills are done in
Xthe currently selected color, line style, line width and pattern style.
X
X{\tt plfill} fills a polygon. The polygon consists of {\tt n}
Xvertices which define the polygon.
X
X\name{plfill(n,x,y);}
X\argu{{\tt n} (PLINT, input)}
X{the number of vertices.}
X\argu{{\tt x, y} (PLFLT *, input)}
X{pointers to arrays with coordinates of the {\tt n} vertices.}
X
X
X\subsection {More Complex Graphs (Histograms and Error Bars)}
X
XFunctions \rou{plbin} and \rou{plhist} are provided for
Xdrawing histograms, and functions \rou{plerrx}
Xand \rou{plerry} draw error bars about specified
Xpoints. They are described in detail in Chapter \ref{reference}.
X
X\section {Finishing Up}
X
XBefore the end of the program, ALWAYS call \rou{plend}
Xto close any output plot files and to free up resources.
XFor devices that have separate graphics
Xand text modes, {\tt plend} resets the device to text mode.
X
X\section {In Case of Error}
X
XIf a fatal error is encountered during execution of a PLPLOT routine
Xthen \rou{plexit} is called. This routine prints an error message,
Xdoes resource recovery, calls {\tt pl\_exit} (page~\pageref{plxexit}) 
Xand then exits. The
Xdefault {\tt pl\_exit} routine does nothing, but the user may wish
Xto supply his/her own version of {\tt pl\_exit}.
X
END_OF_FILE
if test 10944 -ne `wc -c <'docs/chapter2.tex'`; then
    echo shar: \"'docs/chapter2.tex'\" unpacked with wrong size!
fi
# end of 'docs/chapter2.tex'
fi
if test -f 'include/plplot.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'include/plplot.h'\"
else
echo shar: Extracting \"'include/plplot.h'\" \(13579 characters\)
sed "s/^X//" >'include/plplot.h' <<'END_OF_FILE'
X/* This header file contains all of the function prototypes and
X   machine dependent defines */
X
X/* We need to know where the fonts are located, so set these. */
X#ifdef AMIGA
X  #define SSTRKFONT  "PLFONTS:plstnd.fnt"
X  #define SFONTINDX  "PLFONTS:plstnd.idx"
X  #define SFONTLKUP  "PLFONTS:plstnd.lkp"
X  #define XSTRKFONT  "PLFONTS:plxtnd.fnt"
X  #define XFONTINDX  "PLFONTS:plxtnd.idx"
X  #define XFONTLKUP  "PLFONTS:plxtnd.lkp"
X#endif
X
X/* plfontld.c is the only file that uses these defines. So if you
X   move the fonts, just change these and recompile plfontld.c */
X#ifdef unix
X  #define SSTRKFONT  "/home/dukee2/amr/newplp/fonts/plstnd.fnt" 
X  #define SFONTINDX  "/home/dukee2/amr/newplp/fonts/plstnd.idx"
X  #define SFONTLKUP  "/home/dukee2/amr/newplp/fonts/plstnd.lkp"
X  #define XSTRKFONT  "/home/dukee2/amr/newplp/fonts/plxtnd.fnt"
X  #define XFONTINDX  "/home/dukee2/amr/newplp/fonts/plxtnd.idx"
X  #define XFONTLKUP  "/home/dukee2/amr/newplp/fonts/plxtnd.lkp"
X#endif
X
X/* If PLDBL is defined all floating point variables will be of type double */
X#ifdef PLDBL
X   typedef double PLFLT;
X#else
X   typedef float PLFLT;
X#endif
X
X/* You'd better leave this as is. I haven't gotten around to seeing
X   if things will work with short's. I doubt that they will. */
Xtypedef long PLINT;
X
X#ifdef LATTICE_50
X   #define PLSTDC             1
X#endif
X
X#ifdef __STDC__
X   #define PLSTDC             1
X#endif
X
X/* We need a signed char type. Manx doesn't support signed char but
X   fortunately treats char as signed. */
X#ifndef AZTEC_C 
X   typedef signed char SCHAR;
X#else
X   typedef char        SCHAR;
X#endif
X
X/* Let's try to get around some ANSI/non-ANSI problems with typedef's */
X/* PLPLOT needs a signed char type to work. Some compilers don't
X   recognize the signed char keywords however. */
X#ifdef PLSTDC
X   typedef void        VOID;
X#else
X   typedef char        VOID;
X#endif
X
X#ifdef PLSTDC
X   #define PLARGS(a)  a       /* Use function prototypes. */
X#else
X   #define PLARGS(a)  ()
X#endif
X
X#ifdef NOPROTS
X   #undef PLARGS
X   #define PLARGS(a) ()
X#endif
X
X#ifndef max
X   #define max(a,b)     ((a)>(b) ? (a) : (b))
X   #define min(a,b)     ((a)<(b) ? (a) : (b))
X   #define abs(a)       ((a)<0 ? -(a) : (a))
X#endif
X
X#define round(a)   (PLINT)((a)<0. ? ((a)-.5) : ((a)+.5))
X
X/* All of the void type declarations are made first. */
Xvoid pladv PLARGS((PLINT page));
Xvoid plbeg PLARGS((PLINT dev, PLINT nx, PLINT ny));
Xvoid plbin PLARGS((PLINT nbin, PLFLT *x, PLFLT *y, PLINT centre));
Xvoid plbox PLARGS((char *xopt, PLFLT xtick, PLINT nxsub, char *yopt, \
X                   PLFLT ytick, PLINT nysub));
Xvoid plccal PLARGS((PLFLT *pts, PLINT nx, PLINT ny, PLFLT zlev, \
X                    PLINT ix, PLINT iy, PLINT ixg, PLINT iyg, PLFLT *dist));
Xvoid plclr PLARGS((void));
Xvoid plcntr PLARGS((PLFLT *points, PLINT nx, PLINT ny, PLINT kx, PLINT lx, \
X                    PLINT ky, PLINT ly, PLFLT zlev, PLINT *iscan, \
X                    PLINT *ixstor, PLINT *iystor, PLINT nstor, \
X                    void (*tr)(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty)));
Xvoid plcol PLARGS((PLINT color));
Xvoid plcont PLARGS((PLFLT *z, PLINT nx, PLINT ny, PLINT kx, PLINT lx, \
X                    PLINT ky, PLINT ly, PLFLT *clevel, PLINT nlevel, \
X                    void (*tr)()));
Xvoid pldeco PLARGS((short **symbol, PLINT *length, char *text));
Xvoid pldtik PLARGS((PLFLT vmin, PLFLT vmax, PLFLT *tick, PLINT *nsubt, \
X                    PLINT *mode, PLINT *prec));
Xvoid plend PLARGS((void));
Xvoid plenv PLARGS((PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, \
X                   PLINT just, PLINT axis));
Xvoid plerrx PLARGS((PLINT n, PLFLT *xmin, PLFLT *xmax, PLFLT *y));
Xvoid plerry PLARGS((PLINT n, PLFLT *x, PLFLT *ymin, PLFLT *ymax));
Xvoid plerx1 PLARGS((PLFLT xmin, PLFLT xmax, PLFLT y));
Xvoid plery1 PLARGS((PLFLT x, PLFLT ymin, PLFLT ymax));
Xvoid plexit PLARGS((char *msg));
Xvoid plfill PLARGS((PLINT n, PLFLT *x, PLFLT *y));
Xvoid plfont PLARGS((PLINT ifont));
Xvoid plfontld PLARGS((PLINT fnt));
Xvoid plfontrel PLARGS((void));
Xvoid plform PLARGS((PLFLT value, PLINT mode, PLINT prec, char *result));
Xvoid plgra PLARGS((void));
Xvoid plgspa PLARGS((PLFLT *xmin, PLFLT *xmax, PLFLT *ymin, PLFLT *ymax));
Xvoid plhist PLARGS((PLINT n, PLFLT *data, PLFLT datmin, PLFLT datmax, \
X                    PLINT nbin, PLINT oldwin));
Xvoid plhrsh PLARGS((PLINT ch, PLINT x, PLINT y));
Xvoid pljoin PLARGS((PLFLT x1, PLFLT y1, PLFLT x2, PLFLT y2));
Xvoid pllab PLARGS((char *xlabel, char *ylabel, char *tlabel));
Xvoid pllclp PLARGS((PLINT x1, PLINT y1, PLINT x2, PLINT y2));
Xvoid plline PLARGS((PLINT n, PLFLT *x, PLFLT *y));
Xvoid pllsty PLARGS((PLINT line));
Xvoid plmtex PLARGS((char *side, PLFLT disp, PLFLT pos, PLFLT just, \
X                    char *text));
Xvoid plpat PLARGS((PLINT n, PLINT *inc, PLINT *del));
Xvoid plpoi1 PLARGS((PLFLT x, PLFLT y, PLINT code));
Xvoid plpoin PLARGS((PLINT n, PLFLT *x, PLFLT *y, PLINT code));
Xvoid plprec PLARGS((PLINT setp, PLINT prec));
Xvoid plpsty PLARGS((PLINT patt));
Xvoid plptex PLARGS((PLFLT x, PLFLT y, PLFLT dx, PLFLT dy, PLFLT just, \
X                    char *text));
Xvoid plr135 PLARGS((PLINT *ix, PLINT *iy, PLINT isens));
Xvoid plr45 PLARGS((PLINT *ix, PLINT *iy, PLINT isens));
Xvoid plschr PLARGS((PLFLT dep, PLFLT scale));
Xvoid plselect PLARGS((PLINT ori, char *file));
Xvoid plsetup PLARGS((PLFLT xdpi, PLFLT ydpi, PLINT xw, PLINT yw));
Xvoid plsmaj PLARGS((PLFLT def, PLFLT scale));
Xvoid plsmin PLARGS((PLFLT def, PLFLT scale));
Xvoid plssym PLARGS((PLFLT def, PLFLT scale));
Xvoid plstar PLARGS((PLINT nx, PLINT ny));
Xvoid plstik PLARGS((PLFLT mx, PLFLT my, PLFLT dx, PLFLT dy));
Xvoid plstr PLARGS((PLINT base, PLFLT *xform, PLINT refx, PLINT refy, \
X                  char *string));
Xvoid plstyl PLARGS((PLINT nels, PLINT *mk, PLINT *sp));
Xvoid plsvpa PLARGS((PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax));
Xvoid plsym PLARGS((PLINT n, PLFLT *x, PLFLT *y, PLINT code));
Xvoid plsym1 PLARGS((PLFLT x, PLFLT y, PLINT code));
Xvoid pltext PLARGS((void));
Xvoid plupd PLARGS((void));
Xvoid plvpor PLARGS((PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax));
Xvoid plvsta PLARGS((void));
Xvoid plwid PLARGS((PLINT pwid));
Xvoid plwind PLARGS((PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax));
Xvoid plxtik PLARGS((PLINT x, PLINT y, PLINT below, PLINT above));
Xvoid plxybx PLARGS((char *opt, char *label, PLFLT wx1, PLFLT wy1, \
X                    PLFLT wx2, PLFLT wy2, PLFLT vmin, PLFLT vmax, \
X                    PLFLT tick, PLINT nsub, PLINT nolast));
Xvoid plxytx PLARGS((PLFLT wx1, PLFLT wy1, PLFLT wx2, PLFLT wy2, \
X                    PLFLT disp, PLFLT pos, PLFLT just, char *text));
Xvoid plytik PLARGS((PLINT x, PLINT y, PLINT left, PLINT right));
Xvoid plzbx PLARGS((char *opt, char *label, PLINT right, PLFLT dx, PLFLT dy, \
X                   PLFLT wx, PLFLT wy1, PLFLT wy2, PLFLT vmin, PLFLT vmax, \
X                   PLFLT tick, PLINT nsub));
Xvoid plztx PLARGS((char *opt, PLFLT dx, PLFLT dy, PLFLT wx, PLFLT wy1, \
X                   PLFLT wy2, PLFLT disp, PLFLT pos, PLFLT just, char *t));
X
X/* 3-D routine types*/
Xvoid pl3cut PLARGS((PLINT sx1, PLINT sy1, PLINT sx2, PLINT sy2, PLINT su1, \
X                    PLINT sv1, PLINT su2, PLINT sv2, PLINT *cx, PLINT *cy));
Xvoid plbox3 PLARGS((char *xopt, char *xlabel, PLFLT xtick, PLINT nsubx, \
X                    char *yopt, char *ylabel, PLFLT ytick, PLINT nsuby, \
X                    char *zopt, char *zlabel, PLFLT ztick, PLINT nsubz));
Xvoid plgrid3 PLARGS((PLFLT tick));
Xvoid plmesh PLARGS((PLFLT *x, PLFLT *y, PLFLT *z, PLINT ly, \
X                      PLINT nx, PLINT ny, PLINT opt));
Xvoid plnxtv PLARGS((PLINT *u, PLINT *v, PLINT n, PLINT init));
Xvoid plot3d PLARGS((PLFLT *x, PLFLT *y, PLFLT *z, PLINT ly, \
X                      PLINT nx, PLINT ny, PLINT opt, PLINT side));
Xvoid plside3 PLARGS((PLFLT *x, PLFLT *y, PLFLT *z, PLINT ly, PLINT nx, \
X                       PLINT ny, PLINT opt));
Xvoid plt3zz PLARGS((PLINT xstar0, PLINT ystar0, PLINT dx, PLINT dy, \
X                      PLINT flg0, PLINT init, PLFLT *x, PLFLT *y, PLFLT *z, \
X                      PLINT ly, PLINT nx, PLINT ny, PLINT *u, PLINT *v));
Xvoid plw3d PLARGS((PLFLT basex, PLFLT basey, PLFLT height, PLFLT xmin0, \
X                     PLFLT xmax0, PLFLT ymin0, PLFLT ymax0, PLFLT zmin0, \
X                     PLFLT zmax0, PLFLT alt, PLFLT az));
X
X/* The novice plplot user will not need to call the following functions */
Xvoid cleanup PLARGS((void));
Xvoid genlin PLARGS((PLINT x1, PLINT y1, PLINT x2, PLINT y2));
Xvoid movphy PLARGS((PLINT x, PLINT y));
Xvoid draphy PLARGS((PLINT x, PLINT y));
Xvoid movwor PLARGS((PLFLT x, PLFLT y));
Xvoid drawor PLARGS((PLFLT x, PLFLT y));
Xvoid setphy PLARGS((PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax));
Xvoid setpxl PLARGS((PLFLT xpmm0, PLFLT ypmm0));
Xvoid setsub PLARGS((void));
Xvoid xform PLARGS((PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty));
X/* stuff in global.c */
Xvoid glev PLARGS((PLINT *n));
Xvoid slev PLARGS((PLINT n));
Xvoid gbase PLARGS((PLFLT *x, PLFLT *y, PLFLT *xc, PLFLT *yc));
Xvoid sbase PLARGS((PLFLT x, PLFLT y, PLFLT xc, PLFLT yc));
Xvoid gnms PLARGS((PLINT *n));
Xvoid snms PLARGS((PLINT n));
Xvoid gdev PLARGS((PLINT *dev, PLINT *term, PLINT *gra));
Xvoid sdev PLARGS((PLINT dev, PLINT term, PLINT gra));
Xvoid smod PLARGS((PLINT term));
Xvoid gcurr PLARGS((PLINT *ix, PLINT *iy));
Xvoid scurr PLARGS((PLINT ix, PLINT iy));
Xvoid gdom PLARGS((PLFLT *xmin, PLFLT *xmax, PLFLT *ymin, PLFLT *ymax));
Xvoid sdom PLARGS((PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax));
Xvoid grange PLARGS((PLFLT *zscl, PLFLT *zmin, PLFLT *zmax));
Xvoid srange PLARGS((PLFLT zscl, PLFLT zmin, PLFLT zmax));
Xvoid gw3wc PLARGS((PLFLT *dxx, PLFLT *dxy, PLFLT *dyx, PLFLT *dyy, PLFLT *dyz));
Xvoid sw3wc PLARGS((PLFLT dxx, PLFLT dxy, PLFLT dyx, PLFLT dyy, PLFLT dyz));
Xvoid gvpp PLARGS((PLINT *ixmin, PLINT *ixmax, PLINT *iymin, PLINT *iymax));
Xvoid svpp PLARGS((PLINT ixmin, PLINT ixmax, PLINT iymin, PLINT iymax));
Xvoid gspp PLARGS((PLINT *ixmin, PLINT *ixmax, PLINT *iymin, PLINT *iymax));
Xvoid sspp PLARGS((PLINT ixmin, PLINT ixmax, PLINT iymin, PLINT iymax));
Xvoid gclp PLARGS((PLINT *ixmin, PLINT *ixmax, PLINT *iymin, PLINT *iymax));
Xvoid sclp PLARGS((PLINT ixmin, PLINT ixmax, PLINT iymin, PLINT iymax));
Xvoid gphy PLARGS((PLINT *ixmin, PLINT *ixmax, PLINT *iymin, PLINT *iymax));
Xvoid sphy PLARGS((PLINT ixmin, PLINT ixmax, PLINT iymin, PLINT iymax));
Xvoid gsub PLARGS((PLINT *nx, PLINT *ny, PLINT *cs));
Xvoid ssub PLARGS((PLINT nx, PLINT ny, PLINT cs));
Xvoid gumpix PLARGS((PLINT *ix, PLINT *iy));
Xvoid sumpix PLARGS((PLINT ix, PLINT iy));
Xvoid gatt PLARGS((PLINT *ifnt, PLINT *icol));
Xvoid satt PLARGS((PLINT ifnt, PLINT icol));
Xvoid gcol PLARGS((PLINT *icol));
Xvoid scol PLARGS((PLINT icol));
Xvoid gwid PLARGS((PLINT *pwid));
Xvoid swid PLARGS((PLINT pwid));
Xvoid gspd PLARGS((PLFLT *xmin, PLFLT *xmax, PLFLT *ymin, PLFLT *ymax));
Xvoid sspd PLARGS((PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax));
Xvoid gvpd PLARGS((PLFLT *xmin, PLFLT *xmax, PLFLT *ymin, PLFLT *ymax));
Xvoid svpd PLARGS((PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax));
Xvoid gvpw PLARGS((PLFLT *xmin, PLFLT *xmax, PLFLT *ymin, PLFLT *ymax));
Xvoid svpw PLARGS((PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax));
Xvoid gpixmm PLARGS((PLFLT *x, PLFLT *y));
Xvoid spixmm PLARGS((PLFLT x, PLFLT y));
Xvoid gwp PLARGS((PLFLT *xscl, PLFLT *xoff, PLFLT *yscl, PLFLT *yoff));
Xvoid swp PLARGS((PLFLT xscl, PLFLT xoff, PLFLT yscl, PLFLT yoff));
Xvoid gwm PLARGS((PLFLT *xscl, PLFLT *xoff, PLFLT *yscl, PLFLT *yoff));
Xvoid swm PLARGS((PLFLT xscl, PLFLT xoff, PLFLT yscl, PLFLT yoff));
Xvoid gdp PLARGS((PLFLT *xscl, PLFLT *xoff, PLFLT *yscl, PLFLT *yoff));
Xvoid sdp PLARGS((PLFLT xscl, PLFLT xoff, PLFLT yscl, PLFLT yoff));
Xvoid gmp PLARGS((PLFLT *xscl, PLFLT *xoff, PLFLT *yscl,PLFLT *yoff));
Xvoid smp PLARGS((PLFLT xscl, PLFLT xoff, PLFLT yscl, PLFLT yoff));
Xvoid gchr PLARGS((PLFLT *def, PLFLT *ht));
Xvoid schr PLARGS((PLFLT def, PLFLT ht));
Xvoid gsym PLARGS((PLFLT *def, PLFLT *ht));
Xvoid ssym PLARGS((PLFLT def, PLFLT ht));
Xvoid gmaj PLARGS((PLFLT *def, PLFLT *ht));
Xvoid smaj PLARGS((PLFLT def, PLFLT ht));
Xvoid gmin PLARGS((PLFLT *def, PLFLT *ht));
Xvoid smin PLARGS((PLFLT def, PLFLT ht));
X
X/* Functions that return floats */
XPLFLT plstrl PLARGS((char *string));
X/* Stuff in fcnvrt.c */
XPLFLT dcmmx PLARGS((PLFLT x));
XPLFLT dcmmy PLARGS((PLFLT y));
XPLFLT dcscx PLARGS((PLFLT x));
XPLFLT dcscy PLARGS((PLFLT y));
XPLFLT mmdcx PLARGS((PLFLT x));
XPLFLT mmdcy PLARGS((PLFLT y));
XPLFLT scdcx PLARGS((PLFLT x));
XPLFLT scdcy PLARGS((PLFLT y));
XPLFLT wcmmx PLARGS((PLFLT x));
XPLFLT wcmmy PLARGS((PLFLT y));
XPLFLT w3wcx PLARGS((PLFLT x, PLFLT y, PLFLT z));
XPLFLT w3wcy PLARGS((PLFLT x, PLFLT y, PLFLT z));
X
X/* Functions returning PLINTs */
XPLINT plabv PLARGS((PLINT px, PLINT py, PLINT sx1, PLINT sy1, PLINT sx2, PLINT sy2));
XPLINT plcvec PLARGS((PLINT ch, signed char **xygrid));
XPLINT stindex PLARGS((char *str1, char *str2));
XPLINT strpos PLARGS((char *str, char chr));
XPLINT stsearch PLARGS((char *str, char chr));
X/* This stuff is all in icnvrt.c */
XPLINT dcpcx PLARGS((PLFLT x));
XPLINT dcpcy PLARGS((PLFLT y));
XPLINT mmpcx PLARGS((PLFLT x));
XPLINT mmpcy PLARGS((PLFLT y));
XPLINT wcpcx PLARGS((PLFLT x));
XPLINT wcpcy PLARGS((PLFLT y));
X
X/* Device independent routines */
Xvoid grsetup PLARGS((void));
Xvoid grselect PLARGS((void));
Xvoid grbeg PLARGS((PLINT dev));
Xvoid grclr PLARGS((void));
Xvoid grpage PLARGS((void));
Xvoid grcol PLARGS((void));
Xvoid grwid PLARGS((void));
Xvoid grinit PLARGS((void));
Xvoid grgra PLARGS((void));
Xvoid grline PLARGS((PLINT x1, PLINT y1, PLINT x2, PLINT y2));
Xvoid grtext PLARGS((void));
Xvoid grtidy PLARGS((void));
END_OF_FILE
if test 13579 -ne `wc -c <'include/plplot.h'`; then
    echo shar: \"'include/plplot.h'\" unpacked with wrong size!
fi
# end of 'include/plplot.h'
fi
if test -f 'src/plbox.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/plbox.c'\"
else
echo shar: Extracting \"'src/plbox.c'\" \(11587 characters\)
sed "s/^X//" >'src/plbox.c' <<'END_OF_FILE'
X/* This draws a box around the current viewport. XOPT and YOPT are */
X/* character strings which define the box as follows: */
X
X/* A: Draw axis (X is horizontal line Y=0, Y is vertical line X=0) */
X/* B: Draw bottom (X) or left (Y) edge of frame */
X/* C: Draw top (X) or right (Y) edge of frame */
X/* G: Draws a grid at the major tick interval */
X/* I: Inverts tick marks */
X/* L: Logarithmic axes, major ticks at decades, minor ticks at units */
X/* N: Write numeric label at conventional location */
X/* M: Write numeric label at unconventional location */
X/* T: Draw major tick marks */
X/* S: Draw minor tick marks */
X/* V: (for Y only) Label vertically */
X
X/* xtick, ytick are the major tick intervals required, zero for  */
X/*              automatic selection */
X/* nxsub, nysub are the number of subtick intervals in a major tick */
X/*              interval */
X
X#include "plplot.h"
X#include <stdio.h>
X#include <math.h>
X#ifdef PLSTDC
X#include <string.h>
X#else
Xextern char *strcat();
Xextern char *strcpy();
X#endif
X
X#define betw(c,a,b) ((a<=c && c<=b) || (b<=c && c<=a))
X
Xstatic PLFLT xlog[8] = {0.301030, 0.477121, 0.602060, 0.698970,
X                        0.778151, 0.845098, 0.903090, 0.954243};
X
Xvoid plbox(xopt,xtick,nxsub,yopt,ytick,nysub)
Xchar *xopt, *yopt;
XPLFLT xtick, ytick;
XPLINT nxsub, nysub;
X{
X      static char string[40];
X      char strtmp[4];
X      PLINT lax,lbx,lcx,lgx,lix,llx,lmx,lnx,lsx,ltx;
X      PLINT lay,lby,lcy,lgy,liy,lly,lmy,lny,lsy,lty,lvy;
X      PLINT xmajor, xminor, ymajor, yminor, xmode, xprec;
X      PLINT ymode, yprec;
X      PLINT i, i1x, i2x, i3x, i4x, i1y, i2y, i3y, i4y, it0;
X      PLINT nxsub1, nysub1;
X      PLINT lxmin, lxmax, lymin, lymax;
X      PLINT pxmin, pxmax, pymin, pymax;
X      PLINT vppxmi, vppxma, vppymi, vppyma;
X      PLINT level;
X      PLFLT xpmm, ypmm, defmaj, defmin, htmaj, htmin;
X      PLFLT xtick1, ytick1, vpwxmi, vpwxma, vpwymi, vpwyma;
X      PLFLT pos, tn, tp, temp;
X
X      glev(&level);
X      if (level<3) plexit("Please set up window before calling plbox.");
X
X      /* Open  the clip limits to the subpage limits */
X      gclp(&lxmin,&lxmax,&lymin,&lymax);
X      gphy(&pxmin,&pxmax,&pymin,&pymax);
X      sclp(pxmin,pxmax,pymin,pymax);
X
X      gvpp(&vppxmi,&vppxma,&vppymi,&vppyma);
X
X      /* Tick and subtick sizes in device coords */
X      gpixmm(&xpmm,&ypmm);
X      gmaj(&defmaj,&htmaj);
X      gmin(&defmin,&htmin);
X
X      xmajor=max(round(htmaj*ypmm),1);
X      ymajor=max(round(htmaj*xpmm),1);
X      xminor=max(round(htmin*ypmm),1);
X      yminor=max(round(htmin*xpmm),1);
X
X      xtick1=xtick;
X      nxsub1=nxsub;
X      ytick1=ytick;
X      nysub1=nysub;
X
X      lax=stsearch(xopt,'a');
X      lbx=stsearch(xopt,'b');
X      lcx=stsearch(xopt,'c');
X      lgx=stsearch(xopt,'g');
X      lix=stsearch(xopt,'i');
X      llx=stsearch(xopt,'l');
X      lmx=stsearch(xopt,'m');
X      lnx=stsearch(xopt,'n');
X      lsx=stsearch(xopt,'s');
X      ltx=stsearch(xopt,'t');
X
X      lay=stsearch(yopt,'a');
X      lby=stsearch(yopt,'b');
X      lcy=stsearch(yopt,'c');
X      lgy=stsearch(yopt,'g');
X      liy=stsearch(yopt,'i');
X      lly=stsearch(yopt,'l');
X      lmy=stsearch(yopt,'m');
X      lny=stsearch(yopt,'n');
X      lsy=stsearch(yopt,'s');
X      lty=stsearch(yopt,'t');
X      lvy=stsearch(yopt,'v');
X
X      gvpw(&vpwxmi,&vpwxma,&vpwymi,&vpwyma);
X
X      lax=lax && (vpwymi*vpwyma<0.0) && !llx;
X      lay=lay && (vpwxmi*vpwxma<0.0) && !lly;
X      if (llx) xtick1=1.0;
X      if (lly) ytick1=1.0;
X      if (ltx || lgx)
X          pldtik(vpwxmi,vpwxma,&xtick1,&nxsub1,&xmode,&xprec);
X      if (lty || lgy)
X          pldtik(vpwymi,vpwyma,&ytick1,&nysub1,&ymode,&yprec);
X
X      /* Set up tick variables */
X      if (lix) {
X        i1x=xminor;
X        i2x=0;
X        i3x=xmajor;
X        i4x=0;
X      }
X      else {
X        i1x=0;
X        i2x=xminor;
X        i3x=0;
X        i4x=xmajor;
X      }
X
X      if (liy) {
X        i1y=yminor;
X        i2y=0;
X        i3y=ymajor;
X        i4y=0;
X      }
X      else {
X        i1y=0;
X        i2y=yminor;
X        i3y=0;
X        i4y=ymajor;
X      }
X
X
X      /* Draw the bottom edge of the box */
X      if (lbx) {
X        movphy(vppxmi,vppymi);
X        if (ltx) {
X          tp=xtick1*floor(vpwxmi/xtick1);
X          for(;;) {
X             tn=tp+xtick1;
X             if (lsx) {
X               if (llx) {
X                 for(i=0; i<=7;i++){
X                   temp=tp+xlog[i];
X                   if (betw(temp,vpwxmi,vpwxma))
X                        plxtik(wcpcx(temp),vppymi,i1x,i2x);
X                 }
X               }
X               else {
X                 for ( i=1;i<=nxsub1-1;i++) {
X                   temp=tp+i*(tn-tp)/nxsub1;
X                   if (betw(temp,vpwxmi,vpwxma))
X                        plxtik(wcpcx(temp),vppymi,i1x,i2x);
X                 }
X               }
X             }
X             if (!betw(tn,vpwxmi,vpwxma))
X               break;
X             plxtik(wcpcx(tn),vppymi,i3x,i4x);
X             tp=tn;
X          }
X        }
X        draphy(vppxma,vppymi);
X      }
X
X      /* Draw right-hand edge of box */
X      if (lcy) {
X        movphy(vppxma,vppymi);
X        if (lty) {
X          tp=ytick1*floor(vpwymi/ytick1);
X          for(;;) {
X             tn=tp+ytick1;
X             if (lsy) {
X               if (lly) {
X                 for(i=0;i<=7;i++) {
X                   temp=tp+xlog[i];
X                   if (betw(temp,vpwymi,vpwyma))
X                        plytik(vppxma,wcpcy(temp),i2y,i1y);
X                 }
X               }
X               else {
X                 for(i=1;i<=nysub1-1;i++) {
X                   temp=tp+i*(tn-tp)/nysub1;
X                   if (betw(temp,vpwymi,vpwyma))
X                        plytik(vppxma,wcpcy(temp),i2y,i1y);
X                 }
X               }
X             }
X             if (!betw(tn,vpwymi,vpwyma))
X                break;
X             plytik(vppxma,wcpcy(tn),i4y,i3y);
X             tp=tn;
X          }
X        }
X        draphy(vppxma,vppyma);
X      }
X
X      /* Draw the top edge of the box */
X      if (lcx) {
X        movphy(vppxma,vppyma);
X        if (ltx) {
X          tp=xtick1*(floor(vpwxma/xtick1)+1);
X          for(;;) {
X             tn=tp-xtick1;
X             if (lsx) {
X               if (llx) {
X                 for(i=7;i>=0;i--) {
X                   temp=tn+xlog[i];
X                   if (betw(temp,vpwxmi,vpwxma))
X                        plxtik(wcpcx(temp),vppyma,i2x,i1x);
X                 }
X               }
X               else {
X                 for(i=nxsub1-1;i>=1;i--) {
X                   temp=tn+i*(tp-tn)/nxsub1;
X                   if (betw(temp,vpwxmi,vpwxma))
X                        plxtik(wcpcx(temp),vppyma,i2x,i1x);
X                 }
X               }
X             }
X             if (!betw(tn,vpwxmi,vpwxma))
X               break;
X             plxtik(wcpcx(tn),vppyma,i4x,i3x);
X             tp=tn;
X          }
X        }
X        draphy(vppxmi,vppyma);
X      }
X
X      /* Draw left-hand edge of box */
X      if (lby) {
X        movphy(vppxmi,vppyma);
X        if (lty) {
X          tp=ytick1*(floor(vpwyma/ytick1)+1);
X          for(;;) {
X             tn=tp-ytick1;
X             if (lsy) {
X               if (lly) {
X                 for(i=7;i>=0;i--) {
X                   temp=tn+xlog[i];
X                   if (betw(temp,vpwymi,vpwyma))
X                        plytik(vppxmi,wcpcy(temp),i1y,i2y);
X                 }
X               }
X               else {
X                 for(i=nysub1-1;i>=1;i--) {
X                   temp=tn+i*(tp-tn)/nysub1;
X                   if (betw(temp,vpwymi,vpwyma))
X                        plytik(vppxmi,wcpcy(temp),i1y,i2y);
X                 }
X               }
X             }
X             if (!betw(tn,vpwymi,vpwyma))
X               break;
X             plytik(vppxmi,wcpcy(tn),i3y,i4y);
X             tp=tn;
X          }
X        }
X        draphy(vppxmi,vppymi);
X      }
X
X      /* Draw the horizontal axis */
X      if (lax) {
X        it0=wcpcy((PLFLT)0.0);
X        movphy(vppxmi,it0);
X        if (ltx) {
X          tp=xtick1*floor(vpwxmi/xtick1);
X          for(;;) {
X             tn=tp+xtick1;
X             if (lsx) {
X               if (llx) {
X                 for(i=0;i<=7;i++) {
X                   temp=tp+xlog[i];
X                   if (betw(temp,vpwxmi,vpwxma))
X                        plxtik(wcpcx(temp),it0,xminor,xminor);
X                 }
X               }
X               else {
X                 for(i=1;i<=nxsub1-1;i++) {
X                   temp=tp+i*(tn-tp)/nxsub1;
X                   if (betw(temp,vpwxmi,vpwxma))
X                        plxtik(wcpcx(temp),it0,xminor,xminor);
X                 }
X               }
X             }
X             if (!betw(tn,vpwxmi,vpwxma))
X               break;
X             plxtik(wcpcx(tn),it0,xmajor,xmajor);
X             tp=tn;
X          }
X        }
X        draphy(vppxma,it0);
X      }
X
X      /* Draw the vertical axis */
X      if (lay) {
X        it0=wcpcx((PLFLT)0.0);
X        movphy(it0,vppymi);
X        if (lty) {
X          tp=ytick1*floor(vpwymi/ytick1);
X          for(;;) {
X             tn=tp+ytick1;
X             if (lsy) {
X               if (lly) {
X                 for(i=0;i<=7;i++) {
X                   temp=tp+xlog[i];
X                   if (betw(temp,vpwymi,vpwyma))
X                      plytik(it0,wcpcy(temp),yminor,yminor);
X                 }
X               }
X               else {
X                 for(i=1;i<=nysub1-1;i++) {
X                   temp=tp+i*(tn-tp)/nysub1;
X                   if (betw(temp,vpwymi,vpwyma))
X                        plytik(it0,wcpcy(temp),yminor,yminor);
X                 }
X               }
X             }
X             if (!betw(tn,vpwymi,vpwyma))
X               break;
X             plytik(it0,wcpcy(tn),ymajor,ymajor);
X             tp=tn;
X          }
X        }
X        draphy(it0,vppyma);
X      }
X
X      /* Draw grid in x direction */
X      if (lgx) {
X        tp=xtick1*(1.+floor(vpwxmi/xtick1+.5));
X        for(tn=tp; betw(tn+xtick1/2.,vpwxmi,vpwxma); tn+=xtick1)
X           pljoin(tn,vpwymi,tn,vpwyma);
X      }
X
X      /* Draw grid in y direction */
X      if (lgy) {
X        tp=ytick1*(1.+floor(vpwymi/ytick1+.5));
X        for(tn=tp; betw(tn+ytick1/2.,vpwymi,vpwyma); tn+=ytick1)
X           pljoin(vpwxmi,tn,vpwxma,tn);
X      }
X
X      /* Write horizontal label(s) */
X      if ((lmx || lnx) && ltx) {
X        tp=xtick1*(1.+floor(vpwxmi/xtick1));
X        for(tn=tp; betw(tn,vpwxmi,vpwxma); tn+=xtick1) {
X          if (!llx)
X            plform(tn,xmode,xprec,string);
X          else {
X            sprintf(strtmp,"%-d",round(tn));
X            strcpy(string,"10#u");
X            strcat(string,strtmp);
X          }
X          pos=(tn-vpwxmi)/(vpwxma-vpwxmi);
X          if (lnx) plmtex("b",(PLFLT)1.5,pos,(PLFLT)0.5,string);
X          if (lmx) plmtex("t",(PLFLT)1.5,pos,(PLFLT)0.5,string);
X        }
X      }
X
X      /* Write vertical label(s) */
X      if ((lmy || lny) && lty) {
X        tp=ytick1*(1.+floor(vpwymi/ytick1));
X        for(tn=tp; betw(tn,vpwymi,vpwyma); tn+=ytick1) {
X          if (!lly)
X            plform(tn,ymode,yprec,string);
X          else {
X            sprintf(strtmp,"%-d",round(tn));
X            strcpy(string,"10#u");
X            strcat(string,strtmp);
X          }
X          pos=(tn-vpwymi)/(vpwyma-vpwymi);
X          if (lny) {
X            if (lvy)
X              plmtex("lv",(PLFLT)0.5,pos,(PLFLT)1.0,string);
X            else
X              plmtex("l",(PLFLT)1.5,pos,(PLFLT)0.5,string);
X          }
X          if (lmy) {
X            if (lvy)
X              plmtex("rv",(PLFLT)0.5,pos,(PLFLT)0.0,string);
X            else
X              plmtex("r",(PLFLT)1.5,pos,(PLFLT)0.5,string);
X          }
X        }
X      }
X      /* Restore the clip limits to viewport edge */
X      sclp(lxmin,lxmax,lymin,lymax);
X}
END_OF_FILE
if test 11587 -ne `wc -c <'src/plbox.c'`; then
    echo shar: \"'src/plbox.c'\" unpacked with wrong size!
fi
# end of 'src/plbox.c'
fi
if test -f 'src/plnxtv.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/plnxtv.c'\"
else
echo shar: Extracting \"'src/plnxtv.c'\" \(16101 characters\)
sed "s/^X//" >'src/plnxtv.c' <<'END_OF_FILE'
X/* Draws the next view of a 3-d plot. The physical coordinates of */
X/* the points for the next view are placed in the n points of arrays  */
X/* u and v. The silhouette found so far is stored in the heap as a */
X/* set of m peak points. */
X
X#include "plplot.h"
X#include "declare.h"
X#include <stdio.h>
X#ifdef PLSTDC
X#include <stdlib.h>
X#else
Xextern char *malloc();
Xextern char *realloc();
Xextern void free();
X#endif
X
XPLINT pl3mode=0;                 /* 0 3d solid; 1 mesh plot */
XPLINT pl3upv=1;                  /* 1 update view; 0 no update */
XPLINT *oldhiview;
XPLINT *oldloview;
X
X/* This routine now dynamically allocates the memory it needs for hidden */
X/* line removal.  Memory is allocated in blocks of 2*BINC*sizeof(PLINT) */
X/* bytes.  Large values of BINC give better performance but also */
X/* allocate more memory than is needed. If your 3D plots are very */
X/* "spiky" or you are working with very large matrices then you will */
X/* probably want to increase BINC. */
X
X#define  BINC      50
X
Xstatic PLINT *newhiview;
Xstatic PLINT *newloview;
Xstatic PLINT mhi, xxhi, newhisize;
Xstatic PLINT mlo, xxlo, newlosize;
X
Xvoid plnxtv(u, v, n, init)
XPLINT *u, *v, n, init;
X{
X   void plnxtvhi(), plnxtvlo();
X
X   plnxtvhi(u,v,n,init);
X
X   if(pl3mode)
X      plnxtvlo(u,v,n,init);
X}
X
Xstatic void plnxtvhi(u,v,n,init)
XPLINT *u, *v, n, init;
X{
X      PLINT i, j, first;
X      PLINT sx1, sx2, sy1, sy2;
X      PLINT su1, su2, sv1, sv2;
X      PLINT cx, cy, px, py;
X      PLINT seg, ptold, lstold, pthi, pnewhi, newhi, change, ochange;
X      void savehipoint(), swaphiview();
X
X      first = 1;
X      pnewhi = 0;
X
X      /* For the initial set of points, just display them and store them as */
X      /* the peak points. */
X
X      if (init == 1) {
X         /* heap not yet allocated so ... */
X         if(!( oldhiview = (PLINT *)malloc(2*n*sizeof(PLINT))))
X            plexit("Out of memory.");
X         movphy(u[0],v[0]);
X         oldhiview[0] = u[0];
X         oldhiview[1] = v[0];
X         for (i=1; i<n; i++){
X           draphy(u[i],v[i]);
X           oldhiview[2*i] = u[i];
X           oldhiview[2*i+1] = v[i];
X         }
X         mhi = n;
X         return;
X      }
X
X      /* Otherwise, we need to consider hidden-line removal problem. We scan */
X      /* over the points in both the old (i.e. oldhiview[]) and */
X      /* new (i.e. u[] and v[]) arrays in order of increasing x coordinate. */
X      /* At each stage, we find the line segment in the other array (if one */
X      /* exists) that straddles the x coordinate of the point. We */
X      /* have to determine if the point lies above or below the line segment, */
X      /* and to check if the below/above status has changed since the last */
X      /* point. */
X
X      /* If pl3upv = 0 we do not update the view, this is useful for drawing */
X      /* lines on the graph after we are done plotting points.  Hidden line */
X      /* removal is still done, but the view is not updated. */
X      xxhi = 0;
X      i = 0;
X      j = 0;
X      if(pl3upv != 0) {
X         newhisize = 2*(mhi+BINC);
X         if(!( newhiview = (PLINT *)malloc(newhisize*sizeof(PLINT)))) {
X            free((VOID *)oldhiview);
X            plexit("Out of memory.");
X         }
X      }
X
X      /* (oldhiview[2*i], oldhiview[2*i]) is the i'th point in the old array */
X      /* (u[j], v[j])           is the j'th point in the new array */
X
X      while (i < mhi || j < n) {
X
X        /* The coordinates of the point under consideration are (px,py). */
X        /* The line segment joins (sx1,sy1) to (sx2,sy2). */
X
X        /* "ptold" is true if the point lies in the old array. We set it */
X        /*  by comparing the x coordinates of the i'th old point */
X        /*  and the j'th new point, being careful if we have fallen past */
X        /*  the edges. Having found the point, load up the point and */
X        /*  segment coordinates appropriately. */
X
X        ptold = ((oldhiview[2*i] < u[j] && i<mhi) || j>= n);
X        if (ptold) {
X          px = oldhiview[2*i];
X          py = oldhiview[2*i+1];
X          seg = j>0 && j<n;
X          if (seg) {
X            sx1 = u[j-1];
X            sy1 = v[j-1];
X            sx2 = u[j];
X            sy2 = v[j];
X          }
X        }
X        else {
X          px = u[j];
X          py = v[j];
X          seg = i>0 && i<mhi;
X          if (seg) {
X            sx1 = oldhiview[2*(i-1)];
X            sy1 = oldhiview[2*(i-1)+1];
X            sx2 = oldhiview[2*i];
X            sy2 = oldhiview[2*i+1];
X          }
X        }
X
X        /* Now determine if the point is higher than the segment, using the */
X        /* logical function "above". We also need to know if it is */
X        /* the old view or the new view that is higher. "newhi" is set true */
X        /* if the new view is higher than the old */
X
X        if(seg)
X            pthi = plabv(px,py,sx1,sy1,sx2,sy2);
X        else
X            pthi = 1;
X
X        newhi = (ptold && !pthi) || (!ptold && pthi);
X        change = (newhi && !pnewhi) || (!newhi && pnewhi);
X
X        /* There is a new intersection point to put in the peak array if the */
X        /* state of "newhi" changes */
X
X        if (first) {
X          movphy(px,py);
X          first = 0;
X          lstold = ptold;
X          savehipoint(px,py);
X          pthi = 0;
X          ochange = 0;
X        }
X        else if (change) {
X          /* Take care of special cases at end of arrays.  If pl3upv */
X          /* is 0 the endpoints are not connected to the old view. */
X          if (pl3upv==0 && ((!ptold && j==0)||(ptold && i==0))) {
X            movphy(px,py);
X            lstold = ptold;
X            pthi = 0;
X            ochange = 0;
X          }
X          else if (pl3upv==0 && ((!ptold && i>=mhi)||(ptold && j>=n))) {
X            movphy(px,py);
X            lstold = ptold;
X            pthi = 0;
X            ochange = 0;
X          }
X          /* If pl3upv is not 0 then we do want to connect the current line */
X          /* with the previous view at the endpoints.  */
X          /* Also find intersection point with old view. */
X          else  {
X            if (i == 0) {
X              sx1 = oldhiview[0];
X              sy1 = -1;
X              sx2 = oldhiview[0];
X              sy2 = oldhiview[1];
X            }
X            else if (i >= mhi) {
X              sx1 = oldhiview[2*(mhi-1)];
X              sy1 = oldhiview[2*(mhi-1)+1];
X              sx2 = oldhiview[2*(mhi-1)];
X              sy2 = -1;
X            }
X            else {
X              sx1 = oldhiview[2*(i-1)];
X              sy1 = oldhiview[2*(i-1)+1];
X              sx2 = oldhiview[2*i];
X              sy2 = oldhiview[2*i+1];
X            }
X
X            if (j == 0) {
X              su1 = u[0];
X              sv1 = -1;
X              su2 = u[0];
X              sv2 = v[0];
X            }
X            else if (j >= n) {
X              su1 = u[n-1];
X              sv1 = v[n-1];
X              su2 = u[n];
X              sv2 = -1;
X            }
X            else  {
X              su1 = u[j-1];
X              sv1 = v[j-1];
X              su2 = u[j];
X              sv2 = v[j];
X            }
X
X            /* Determine the intersection */
X            pl3cut(sx1,sy1,sx2,sy2,su1,sv1,su2,sv2,&cx,&cy);
X            if (cx == px && cy == py)  {
X              if (lstold && !ochange)
X                movphy(px,py);
X              else
X                draphy(px,py);
X
X              savehipoint(px,py);
X              lstold = 1;
X              pthi = 0;
X            }
X            else {
X              if (lstold && !ochange)
X                 movphy(cx,cy);
X              else
X                 draphy(cx,cy);
X
X              lstold = 1;
X              savehipoint(cx,cy);
X            }
X            ochange =1;
X          }
X        }
X
X        /* If point is high then draw plot to point and update view. */
X        if (pthi) {
X          if (lstold && ptold)
X            movphy(px,py);
X          else
X            draphy(px,py);
X
X          savehipoint(px,py);
X          lstold = ptold;
X          ochange = 0;
X        }
X
X        pnewhi = newhi;
X
X        if (ptold)
X          i = i+1;
X        else
X          j = j+1;
X      }
X
X      /* Set oldhiview */
X      swaphiview();
X}
X
Xstatic void savehipoint(px, py)
XPLINT px, py;
X{
X   PLINT *temp;
X
X   if(pl3upv == 0)
X      return;
X   if( xxhi >= newhisize )  {
X      /* allocate additional space */
X      newhisize += 2*BINC;
X      if(!(temp = (PLINT *)realloc((VOID *)newhiview,newhisize*sizeof(PLINT)))) {
X         free((VOID *)oldhiview);
X         free((VOID *)newhiview);
X         plexit("Out of memory.");
X      }
X      newhiview = temp;
X   }
X
X   newhiview[xxhi] = px;
X   xxhi++;
X   newhiview[xxhi] = py;
X   xxhi++;
X}
X
Xstatic void swaphiview()
X{
X   if(pl3upv != 0) {
X     mhi = xxhi/2;
X     free((VOID *)oldhiview);
X     oldhiview = newhiview;
X   }
X}
X
Xstatic void plnxtvlo(u,v,n,init)
XPLINT *u, *v, n, init;
X{
X      PLINT i, j, first;
X      PLINT sx1, sx2, sy1, sy2;
X      PLINT su1, su2, sv1, sv2;
X      PLINT cx, cy, px, py;
X      PLINT seg, ptold, lstold, ptlo, pnewlo, newlo, change, ochange;
X      void savelopoint(), swaploview();
X
X      first = 1;
X      pnewlo = 0;
X
X      /* For the initial set of points, just display them and store them as */
X      /* the peak points. */
X
X      if (init == 1) {
X         /* heap not yet allocated so ... */
X         if(!( oldloview = (PLINT *)malloc(2*n*sizeof(PLINT))))
X            plexit("Out of memory.");
X         movphy(u[0],v[0]);
X         oldloview[0] = u[0];
X         oldloview[1] = v[0];
X         for (i=1; i<n; i++){
X           draphy(u[i],v[i]);
X           oldloview[2*i] = u[i];
X           oldloview[2*i+1] = v[i];
X         }
X         mlo = n;
X         return;
X      }
X
X      /* Otherwise, we need to consider hidden-line removal problem. We scan */
X      /* over the points in both the old (i.e. oldloview[]) and */
X      /* new (i.e. u[] and v[]) arrays in order of increasing x coordinate. */
X      /* At each stage, we find the line segment in the other array (if one */
X      /* exists) that straddles the x coordinate of the point. We */
X      /* have to determine if the point lies above or below the line segment, */
X      /* and to check if the below/above status has changed since the last */
X      /* point. */
X
X      /* If pl3upv = 0 we do not update the view, this is useful for drawing */
X      /* lines on the graph after we are done plotting points.  Hidden line */
X      /* removal is still done, but the view is not updated. */
X      xxlo = 0;
X      i = 0;
X      j = 0;
X      if(pl3upv != 0) {
X         newlosize = 2*(mlo+BINC);
X         if(!( newloview = (PLINT *)malloc(newlosize*sizeof(PLINT)))) {
X            free((VOID *)oldloview);
X            plexit("Out of memory.");
X         }
X      }
X
X      /* (oldloview[2*i], oldloview[2*i]) is the i'th point in the old array */
X      /* (u[j], v[j])           is the j'th point in the new array */
X
X      while (i < mlo || j < n) {
X
X        /* The coordinates of the point under consideration are (px,py). */
X        /* The line segment joins (sx1,sy1) to (sx2,sy2). */
X
X        /* "ptold" is true if the point lies in the old array. We set it */
X        /*  by comparing the x coordinates of the i'th old point */
X        /*  and the j'th new point, being careful if we have fallen past */
X        /*  the edges. Having found the point, load up the point and */
X        /*  segment coordinates appropriately. */
X
X        ptold = ((oldloview[2*i] < u[j] && i<mlo) || j>= n);
X        if (ptold) {
X          px = oldloview[2*i];
X          py = oldloview[2*i+1];
X          seg = j>0 && j<n;
X          if (seg) {
X            sx1 = u[j-1];
X            sy1 = v[j-1];
X            sx2 = u[j];
X            sy2 = v[j];
X          }
X        }
X        else {
X          px = u[j];
X          py = v[j];
X          seg = i>0 && i<mlo;
X          if (seg) {
X            sx1 = oldloview[2*(i-1)];
X            sy1 = oldloview[2*(i-1)+1];
X            sx2 = oldloview[2*i];
X            sy2 = oldloview[2*i+1];
X          }
X        }
X
X        /* Now determine if the point is lower than the segment, using the */
X        /* logical function "above". We also need to know if it is */
X        /* the old view or the new view that is lower. "newlo" is set true */
X        /* if the new view is lower than the old */
X
X        if(seg)
X            ptlo = !plabv(px,py,sx1,sy1,sx2,sy2);
X        else
X            ptlo = 1;
X
X        newlo = (ptold && !ptlo) || (!ptold && ptlo);
X        change = (newlo && !pnewlo) || (!newlo && pnewlo);
X
X        /* There is a new intersection point to put in the peak array if the */
X        /* state of "newlo" changes */
X
X        if (first) {
X          movphy(px,py);
X          first = 0;
X          lstold = ptold;
X          savelopoint(px,py);
X          ptlo = 0;
X          ochange = 0;
X        }
X        else if (change) {
X          /* Take care of special cases at end of arrays.  If pl3upv */
X          /* is 0 the endpoints are not connected to the old view. */
X          if (pl3upv==0 && ((!ptold && j==0)||(ptold && i==0))) {
X            movphy(px,py);
X            lstold = ptold;
X            ptlo = 0;
X            ochange = 0;
X          }
X          else if (pl3upv==0 && ((!ptold && i>=mlo)||(ptold && j>=n))) {
X            movphy(px,py);
X            lstold = ptold;
X            ptlo = 0;
X            ochange = 0;
X          }
X          /* If pl3upv is not 0 then we do want to connect the current line */
X          /* with the previous view at the endpoints.  */
X          /* Also find intersection point with old view. */
X          else  {
X            if (i == 0) {
X              sx1 = oldloview[0];
X              sy1 = 100000;
X              sx2 = oldloview[0];
X              sy2 = oldloview[1];
X            }
X            else if (i >= mlo) {
X              sx1 = oldloview[2*(mlo-1)];
X              sy1 = oldloview[2*(mlo-1)+1];
X              sx2 = oldloview[2*(mlo-1)];
X              sy2 = 100000;
X            }
X            else {
X              sx1 = oldloview[2*(i-1)];
X              sy1 = oldloview[2*(i-1)+1];
X              sx2 = oldloview[2*i];
X              sy2 = oldloview[2*i+1];
X            }
X
X            if (j == 0) {
X              su1 = u[0];
X              sv1 = 100000;
X              su2 = u[0];
X              sv2 = v[0];
X            }
X            else if (j >= n) {
X              su1 = u[n-1];
X              sv1 = v[n-1];
X              su2 = u[n];
X              sv2 = 100000;
X            }
X            else  {
X              su1 = u[j-1];
X              sv1 = v[j-1];
X              su2 = u[j];
X              sv2 = v[j];
X            }
X
X            /* Determine the intersection */
X            pl3cut(sx1,sy1,sx2,sy2,su1,sv1,su2,sv2,&cx,&cy);
X            if (cx == px && cy == py)  {
X              if (lstold && !ochange)
X                movphy(px,py);
X              else
X                draphy(px,py);
X
X              savelopoint(px,py);
X              lstold = 1;
X              ptlo = 0;
X            }
X            else {
X              if (lstold && !ochange)
X                 movphy(cx,cy);
X              else
X                 draphy(cx,cy);
X
X              lstold = 1;
X              savelopoint(cx,cy);
X            }
X            ochange =1;
X          }
X        }
X
X        /* If point is low then draw plot to point and update view. */
X        if (ptlo) {
X          if (lstold && ptold)
X            movphy(px,py);
X          else
X            draphy(px,py);
X
X          savelopoint(px,py);
X          lstold = ptold;
X          ochange = 0;
X        }
X
X        pnewlo = newlo;
X
X        if (ptold)
X          i = i+1;
X        else
X          j = j+1;
X      }
X
X      /* Set oldloview */
X      swaploview();
X}
X
Xstatic void savelopoint(px, py)
XPLINT px, py;
X{
X   PLINT *temp;
X
X   if(pl3upv == 0)
X      return;
X   if( xxlo >= newlosize )  {
X      /* allocate additional space */
X      newlosize += 2*BINC;
X      if(!(temp = (PLINT *)realloc((VOID *)newloview,newlosize*sizeof(PLINT)))) {
X         free((VOID *)oldloview);
X         free((VOID *)newloview);
X         plexit("Out of memory.");
X      }
X      newloview = temp;
X   }
X
X   newloview[xxlo] = px;
X   xxlo++;
X   newloview[xxlo] = py;
X   xxlo++;
X}
X
Xstatic void swaploview()
X{
X   if(pl3upv != 0) {
X     mlo = xxlo/2;
X     free((VOID *)oldloview);
X     oldloview = newloview;
X   }
X}
X
X
X
END_OF_FILE
if test 16101 -ne `wc -c <'src/plnxtv.c'`; then
    echo shar: \"'src/plnxtv.c'\" unpacked with wrong size!
fi
# end of 'src/plnxtv.c'
fi
echo shar: End of archive 7 \(of 12\).
cp /dev/null ark7isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 12 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Submissions to comp.sources.amiga and comp.binaries.amiga should be sent to:
	amiga@cs.odu.edu	
or	amiga@xanth.cs.odu.edu	( obsolescent mailers may need this address )
or	...!uunet!xanth!amiga	( very obsolescent mailers need this address )

Comments, questions, and suggestions s should be addressed to ``amiga-request''
(only use ``amiga'' for submissions) at the above addresses.