home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / psgraph / part01 / psgraph.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-06  |  8.2 KB  |  266 lines

  1. /* $Header: psgraph.h,v 1.8 92/08/04 17:55:13 mogul Exp $ */
  2.  
  3. /*
  4.  *               Copyright 1989, 1992 Digital Equipment Corporation
  5.  *                          All Rights Reserved
  6.  * 
  7.  * 
  8.  * Permission to use, copy, and modify this software and its documentation
  9.  * is hereby granted only under the following terms and conditions.  Both
  10.  * the above copyright notice and this permission notice must appear in
  11.  * all copies of the software, derivative works or modified versions, and
  12.  * any portions threof, and both notices must appear in supporting
  13.  * documentation.
  14.  * 
  15.  * Users of this software agree to the terms and conditions set forth
  16.  * herein, and hereby grant back to Digital a non-exclusive, unrestricted,
  17.  * royalty-free right and license under any changes, enhancements or
  18.  * extensions made to the core functions of the software, including but
  19.  * not limited to those affording compatibility with other hardware or
  20.  * software environments, but excluding applications which incorporate
  21.  * this software.  Users further agree to use their best efforts to return
  22.  * to Digital any such changes, enhancements or extensions that they make
  23.  * and inform Digital of noteworthy uses of this software.  Correspondence
  24.  * should be provided to Digital at:
  25.  * 
  26.  *                       Director of Licensing
  27.  *                       Western Research Laboratory
  28.  *                       Digital Equipment Corporation
  29.  *                       250 University Avenue
  30.  *                       Palo Alto, California  94301  
  31.  * 
  32.  * This software may be distributed (but not offered for sale or
  33.  * transferred for compensation) to third parties, provided such third
  34.  * parties agree to abide by the terms and conditions of this notice.
  35.  * 
  36.  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS
  37.  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
  38.  * WARRANTIES OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL
  39.  * EQUIPMENT CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  40.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  41.  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  42.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  43.  * PERFORMANCE OF THIS SOFTWARE.
  44.  */
  45.  
  46. /* 
  47.  * psgraph.h - Definitions for psgraph
  48.  * 
  49.  * Author:    Christopher A. Kent
  50.  *         Western Research Laboratory
  51.  *         Digital Equipment Corporation
  52.  * Date:    Wed Jan  4 1989
  53.  */
  54.  
  55. /*
  56.  * $Log:    psgraph.h,v $
  57.  * Revision 1.8  92/08/04  17:55:13  mogul
  58.  * undo RCS botch
  59.  * 
  60.  * Revision 1.7  1992/07/08  16:43:46  mogul
  61.  * Stupid Ul tricks.
  62.  * (math.h doesn't declare copysign() as returning double)
  63.  *
  64.  * Revision 1.6  92/07/08  15:50:32  mogul
  65.  * PROLOG can now be defined in Makefile.
  66.  * 
  67.  * Revision 1.5  1992/04/02  00:45:01  kent
  68.  * Changes to handle lots of points; when using dataticks, the axis
  69.  * routines could get too big and overflow the operand stack. As
  70.  * a result, the output PostScript code is even uglier.
  71.  *
  72.  * Revision 1.4  1992/04/01  23:28:24  kent
  73.  *  Added datalabel verb, fixed a bug in handling blank input lines.
  74.  *
  75.  * Revision 1.3  1992/03/31  00:07:39  kent
  76.  * Added markerscale verb.
  77.  *
  78.  * Revision 1.2  1992/03/30  23:54:25  kent
  79.  * Added halfopen, halfticks grid styles, range frames, and gray.
  80.  *
  81.  * Revision 1.1  1992/03/20  21:29:05  kent
  82.  * Initial revision
  83.  *
  84.  * Revision 1.10  92/02/21  17:13:23  mogul
  85.  * Added Digital license info
  86.  * 
  87.  * Revision 1.9  91/02/04  16:48:11  mogul
  88.  * Fixed text, marker colors
  89.  * 
  90.  * Revision 1.8  90/12/11  20:42:27  reid
  91.  * Added new enum type members for LINEWIDTH and LINECOLOR
  92.  * 
  93.  * Revision 1.7  89/01/27  15:59:38  kent
  94.  * Need to get the prolog from the standard place!
  95.  * 
  96.  * Revision 1.6  89/01/10  18:20:01  kent
  97.  * Moved marker code to prolog, added error checking and messages.
  98.  * 
  99.  * Revision 1.5  89/01/09  22:18:49  kent
  100.  * Added log scales.
  101.  * 
  102.  * Revision 1.4  89/01/04  18:12:35  kent
  103.  * Added -p flag to specify alternate prologue file.
  104.  * 
  105.  * Revision 1.3  89/01/04  17:29:47  kent
  106.  * Made command line arguments override compiled-in defaults for
  107.  * all plots in a run, not just the first one. 
  108.  * 
  109.  * Revision 1.2  89/01/04  15:22:10  kent
  110.  * Massive renaming. No functional change.
  111.  * 
  112.  * Revision 1.1  89/01/04  13:58:10  kent
  113.  * Initial revision
  114.  * 
  115.  */
  116.  
  117. #include <ctype.h>
  118. #include <math.h>
  119.  
  120. #ifdef    ultrix
  121. extern double copysign();    /* grrrr */
  122. #endif    ultrix
  123.  
  124. typedef    char    bool;
  125. #define    TRUE    1
  126. #define    FALSE    0
  127.  
  128. #define TOKENINC    16
  129. #define ARGC    16
  130. #define EOS    '\0'
  131.  
  132. #ifndef    PROLOG
  133. #define    PROLOG    "/usr/local/lib/ps/psgraph.pro"
  134. #endif    PROLOG
  135.  
  136. #define    TEXTFONT    "Times-Roman10"
  137.  
  138. #define    MIN(a,b)    ((a)<(b)?(a):(b))
  139. #define    MAX(a,b)    ((a)>(b)?(a):(b))
  140.  
  141. typedef enum {IDENT, LOG10}        tform_t;
  142. typedef enum {NONE,OPEN,TICKS,FULL,HALFOPEN,HALFTICKS}    grid_t;
  143. typedef    enum {NORTH, SOUTH, EAST, WEST}    dir_t;
  144.  
  145. typedef struct _title {
  146.     char    *title;        /* title string    */
  147.     char    *font;        /* font for the title */
  148. } title_t;
  149.  
  150. typedef struct _arg {        /* plot-specific parameters that can also be
  151.                  * specified on the command line */
  152.     bool    breakAfterLabel;/* automatic break after input label */
  153.     float    center;        /* center point of baseline */
  154. } arg_t;
  155.  
  156. typedef struct _axis {        /* axis-specific parameters */
  157.     bool    minflag;    /* TRUE=>minimum specified explicitly    */
  158.     bool    maxflag;    /* TRUE=>maximum specified explicitly    */
  159.     bool    distf;        /* TRUE=>user-supplied grid spacing    */
  160.     bool    tickflag;    /* TRUE=>user supplied tick positions    */
  161.     bool    rangeframe;    /* TRUE=>axis only covers data range    */
  162.     bool    datatick;    /* TRUE=>ticks at real datapoints    */
  163.     bool    datalabel;    /* TRUE=>labels at real datapoints    */
  164.     float    tick;        /* user-supplied tick spacing        */
  165.     float    tickgray;    /* percent gray in which to draw ticks  */
  166.     grid_t    gridtype;    /* grid type in this dimension        */
  167.     bool    halfgrid;    /* don't draw a full frame for this axis*/
  168.     float    axisgray;    /* percent gray in which to draw axis   */
  169.     tform_t    tform;        /* transformation type            */
  170.     float    min, max;    /* data minimum and maximum        */
  171.     int    intervals;    /* number of intervals on axis        */
  172.     float    pmin, pmax;    /* computed plot minimum and maximum    */
  173.     float    distp;        /* computed distance between grid lines    */
  174.     float    gmin, gmax;    /* min and max to use on the grid    */
  175.         float    lgmin, lgmax;    /* log of gmin, gmax for log scales    */
  176.     float    distg;        /* grid spacing to actually use        */
  177.     float    dist;        /* grid line spacing            */
  178.     float    offset;        /* displacement                */
  179.     float    size;        /* grid size in inches            */
  180.     char    *label;        /* label to place on the axis        */
  181.     char    *font;        /* font to label axis in        */
  182. } axis_t;
  183.  
  184. typedef struct _limit {        /* axis limit argument */
  185.     tform_t    tform;        /* transformation type            */
  186.     bool    minflag;    /* TRUE=>minimum specified explicitly    */
  187.     bool    maxflag;    /* TRUE=>maximum specified explicitly    */
  188.     bool    distf;        /* TRUE=>user-supplied grid spacing    */
  189.     float    min, max;    /* data minimum and maximum        */
  190.     float    dist;        /* grid line spacing            */
  191. } limit_t;
  192.  
  193. typedef enum tokenType {    /* internalized graph tokens */
  194.     POINT, BREAK, LINETYPE, LINECOLOR, LINEWIDTH, MARKER, MARKERGRAY,
  195.     MARKERSCALE, FONT, TEXT, SPLINE, TRANS, IGNORE
  196. } type_t;
  197. typedef struct _token {
  198.     type_t    type;
  199.     float    val[2];
  200.     int    ival;
  201.     char    *label;
  202. }token_t;
  203. #define xval val[0]
  204. #define yval val[1]
  205.  
  206. typedef struct _fontName {    /* the chain of fonts that were used */
  207.     char *name;
  208.     struct _fontName *next;
  209. }fontName_t;
  210.  
  211. arg_t    Args;            /* command-line arguments override defaults */
  212. char    *Prolog;
  213. grid_t    GridType;
  214. bool    HalfGrid;
  215. float    Height;
  216. bool    Preview;
  217. float    Xoffset;
  218. float    Yoffset;
  219. bool    TransposeAxes;
  220. float    Width;
  221. limit_t    Xlim, Ylim;
  222.  
  223. bool    BreakAfterLabel;    /* plot-specific values */
  224. float    ClipDist;
  225. bool    DoAxisLabels;
  226. int    PointSize;
  227. char    *TextFont;
  228. float    TickLen;
  229. float    Tick2Len;
  230. bool    TransparentLabels;
  231. float    Xcenter;
  232. axis_t    AxisArgs[2];
  233.  
  234. char    **File;            /* global state */
  235. int    Files;
  236. int    CurrentPage;
  237. float    MinX, MinY, MaxX, MaxY;
  238. float    minX, minY, maxX, maxY;
  239. char    *LineType;
  240. char    *LineColor;
  241. char    *LineWidth;
  242. bool    UseSpline;
  243. title_t    Title;
  244. token_t    *Token;
  245. int    SizeofToken, NumTokens;
  246. char    *UseMarker;
  247. fontName_t    *FontList;
  248. fontName_t    *CurrentFont;
  249. char    *TextColor;
  250. char    *MarkColor;
  251. int    CurrentTemp;
  252. bool    TempOpen;
  253. int    LinesInTemp;
  254.  
  255. #define    Xaxis    AxisArgs[0]
  256. #define    Yaxis    AxisArgs[1]
  257.  
  258. char    *newstr();
  259. grid_t    gridval();
  260. float    sx(), sy(), SX(), SY();
  261. float    plotx(), ploty();
  262. float    ipow();
  263. char    *calloc(), *malloc(), *realloc();
  264. double    atof();
  265.  
  266.