/*
 *
 *                     defn.h
 *
 *
 *
 *	The following definations allow for the efficient 
 *	translation of DXY and RD-GL codes to PostScript code
 *
 */


#ifndef VAXC
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#endif

#ifdef VAXC
#include stdlib
#include stdio
#include ctype
#include math
#endif

#define FALSE	0
#define TRUE	1

#define CR	'\015'
#define LF	'\012'
#define SPACE	'\040'

#define SIGNED_NUMERIC  (ungetc(( ch = getc(stream)),stream) != EOF ) &&\
		(((ch >= '0') && (ch <= '9')) || (ch == '-') || (ch == '+') ||\
		(ch <= ' ') || (ch == ',') || (ch == '.') )

/*
 * default parameters for relative character sizes.
 */
#define DEFWIDTH (float)0.75 /* 0.75 % of P2x - P1x for default char width */
#define DEFHEIGHT (float)1.5 /* 1.5 % of P2y - P1y for default char height */

#define CIRCLE	21		/* DXY Circle */
#define RCIRCLE 22		/* DXY Relative Circle */
#define CCIRCLE 23		/* DXY Centered Circle */
#define ACIRCLE 24		/* DXY Arc plus Circle */
#define SCIRCLE 25		/* DXY Segment Circle */
#define RDGLCIRCLE 26		/* RD-GL Circle */

#define TEXT	31
#define MARK	32

#define LINETYPE	41
#define LINESCALE	42
#define LINE_TYPE_SCALE	43

#define ABSOLUTE       100
#define RELATIVE       101

/*
 *      initclip marker  
 */
#define FULLPAGE       -77.0

/*
 *      solid line type (LT instruction without parameter or default)
 */
#define SOLID_LINE    7

/*
 *	Definition of "ch" used in SIGNED_NUMERIC
 */
char	ch;
/*
 *	Files to open if any
 */
FILE	*stream;
FILE    *outfile;
FILE	*fopen();
/*
 *	Plotting Parameters that will contain the necessary PostScript
 *	commands to plot (see dxy2ps.c for the initialisation) and
 *	ps_macros.c for the plotting macros).
 */
char	*MOVE;
char	*RMOVE;
char	*DRAW;
char	*RDRAW;
/*
 *	End of line terminator (RD-GL / HP-GL)
 */
char	EOL;
/*
 *	Define the function getval() which returns a real number.
 */
float	getval();
/*
 * The Scaling points P1 and P2 that are used to divide the plotting area
 * into units convenient for your application.
 */
float   P1x, P1y;     /*  P1 coordinates in plotter units */
float   P2x, P2y;     /*  P2 coordinates in plotter units */
                      /*  P1, P2 location -> from IP instruction          */
float	U1x, U1y;     /*  P1 coordinates in user units */
float	U2x, U2y;     /*  P2 coordinates in user units */
		      /*  -> from SC instruction                        */
                      /*  if (USER_UNIT == 0)   U2x == P2x
						U2y == P2y
						U1x == P1x
						U1y == P1y             */
						
float   defP1x, defP1y;  /* default P1 coordinates in plotter units  */
float   defP2x, defP2y;  /* default P2 coordinates in plotter units  */
			 /* Warning: experience has shown that these */
			 /* values may not match values shown in     */
			 /* manual.                                  */

float   rotP1x, rotP1y;  /* rotated default P1 coordinates in plotter units */ 
float   rotP2x, rotP2y;  /* rotated default P2 coordinates in plotter units */ 

/*      The plotting area of each size of HPGL plotting paper in which
 *      the pen can draw.
 */
float   MaxA4RangeX,      MaxA4RangeY;   /* physical range in mm   */ 
float   MaxA3RangeX,      MaxA3RangeY;
/*
 *      Variables to keep current (depend on paper size) maximum & minimum
 *      plotting range expressed in plotter units
 */
float   maxprX,    maxprY;
float   minprX,    minprY;

/*
 *      The Laser Printer's paper sizes
 */
float   A4Width,   A4Height;   /* A4 size  210 mm by 297 mm   */
float   A3Width,   A3Height;   /* A3 size  297 mm by 420 mm   */ 

/*
 *	Scaling parameters used for translation from DXY and RD-GL
 *	coordinate system to the PostScript coordinate system which
 *	has been defined in millimeters. (See above)
 */
float	SCALE;        /*  program option  */
float	XSCALE;       /*  current x-scale; depend on current units, contents 
			  SCALE  & SCALE_ABS in itself */
float	YSCALE;       /*  current y-scale */

float   XSCALE_ABS;   /*  x-scale depend on program constants */
                      /*  choose for fitting plotter_size picture to
			  laserwriter_size picture,  contents SCALE 
			  in itself  */
float   YSCALE_ABS;
                      /*  if (USER_UNIT == 0)  XSCALE_ABS == XSCALE
					       YSCALE_ABS == YSCALE  */
float   Xshift;       /*  distance between plotter and user defined origins */
float   Yshift;     
/*
 *      Tick lengths ( specified as a percentage of the horizontal and
 *      vertical distances between the scaling points P1 and P2 ).
 *      urTICK    - upward and right-side portions of the tick marks  
 *      dlTICK    - downward and left-side portions of the tick marks
 */
float   urTICK;
float   dlTICK;
/*
 *      Carriage-return point using with CP & LB instructions
 */
float   CR_point_X;
float   CR_point_Y;
/*
 *      Current line specification
 */
int     LINE_STYLE;    /*  0 - 6   */
float   LINE_LENGTH;   /*  length of line pattern in % of P1 P2 distance */
/*
 *	PostScript Coordinate parameters
 */
float	lastXmove;      /* using in closepath PS instruction      */
float	lastYmove;      /* -> plotps.c  &  end_draw.c             */ 

float	absX;           /* absolute coordinates on output chart, in mm  */ 
float	absY;

float	xval;           /* in plotdot.c  */
float	yval;

float	xoffset;        /* x & y offset on output chart calculated from */
float   yoffset;        /* xprzes, yprzes and program constants         */

float   xprzes;         /* program options   */
float   yprzes;
/*
 *	Extra parameters
 */
/*
 *      Parameters for discribing font
 */
char	        *font;    /* font name -> avaliable fonts are in selectfont.c */
float   	char_angle;
float   	char_height;
float   	char_width;
float   	char_space;
float           char_tan;      /* tangent of the angle -> see SL  */
#define char_slant  (float)(chHfact * char_height * char_tan)
int             SR_bad;   /* flag to change relative char size after IP instr */
float           rel_WIDTH;  /* current relative char width factor eg. percentage
                               of P2x, P1x distance                           */
float           rel_HEIGHT; /*current relative char height factor eg. percentage
                               of P2y, P1y distance                           */

/*       
 *      Next two parameters are introduced to make best match of HPGL & PS
 *      char sizes (the reason is character definition in PS)
 */
/*
 *      factor for char_width parameter to match char size in PS char definition
 */
float   chWfact;
/*
 *      factor for char_height parameter
 */
float   chHfact;

char	symbol;   /* holds current char in symbol (SYMBOLX == TRUE) mode */ 

int	dcount;   /* keeps number of drawn lines after newpath has been 
		     established --> plotps.c, end_draw.c
                   */
/*
 *	Degree radian conversion parameter ie: deg_rad = asin(1) / 90.0;
 *	( Defined in dxy2ps.c or rdgl2ps.c )
 */
float	deg_rad;

float   rad_deg;
/*
 *	Line / pen size parameter (max 8 sizes)
 */
float	pen_size[8];
/*
 *	Paper size (ie A3 or A4) and Mode (HPGL or DXY) for original plot
 */
char	*PaperSize;
char	*Mode;
/*
 *	Flags
 */
int	DEBUG;          /* send to output some additional error
			   and warning messages                */
int	ENCAPSULATED;	/* generate Encapsulated PostScript    */
int     MANUAL_FEED;    /* manual feed on/off                  */
int	LANDSCAPE;      /* output format  */
int	DRAW_FLAG;      /* 1 - newpath has already been open   */
			/* 0 - last path has been closed       */
int	PLOTABS;        /* plotting mode  1 - absolute         */
			/*                0 - relative         */ 
int	PENDOWN;        /* pen down flag                       */
int	SETDOT; 	/* HP-GL commands only - line type instr LT0    */
int	SYMBOLX;	/* HP-GL commands only  - symbol mode instr SM  */
int     ONE_TIME;       /* some PS commands are included in IN instruction
			   implementation must be proccesd only one time  */
int     USER_UNITS;     /* in SC instruction
                           0 - scaling off
			   1 - scaling on        */
int	PROP_SPACE;	/* Use proportional spacing */
int	RELCHAR;	/* Relative character size flag */
int     A4_OUT;         /* Laser Writer paper size: A4/A3, default A4  */
int     CURR_LB_PT;     /* after IP instruction following by no 
			   PA, PR, PU, PD, CP instruction, plotter adjusts
			   current point for LB instruction to following
			   coordinates:
			   absX = 0.0 in new coordinate system;
			   absY = physically the "old" absY;
			   IP sets CURR_LB_PT to FALSE;
			   any of PA, PR, PU, PD, CP, LB instruction
			   sets CURR_LB_PT to TRUE;
                        */
 
/*
 *      Fill Type instruction parameters
 */
int     FILL_TYPE;
float   FILL_SPACING;      /* always in plotter unit  */
int     FILL_ANGLE;

/*
 *      Pen Thickness instruction
 */
float   PEN_THICKNESS;     /* always in mm */

/*
 *      plotter resolution in [plotter unit/mm]
 */
float   RESOLUTION;

/*
 *      coordinate system rotation state
 */
int     ROTATE_STATE;

