home *** CD-ROM | disk | FTP | other *** search
/ Graphics 16,000 / graphics-16000.iso / msdos / viewers / showgl19 / hpgl.h < prev    next >
C/C++ Source or Header  |  1992-08-18  |  10KB  |  275 lines

  1. /* program for reading HPGL files and plotting to the screen */
  2.  
  3. /* copyright 1991 - 1992, Robert C. Becker, Lantern Systems */
  4.  
  5. /* HPGL, HPGL/2, HP, DraftPro are trademarks of the Hewlett-Packard company */
  6.  
  7. #ifdef DEBUG
  8. #define        DB(x)        x    /* debugging tool */
  9. #else
  10. #define        DB(x)
  11. #endif
  12.  
  13. #define        MIN(x,y)    ((x) < (y) ? (x) : (y))
  14. #define        MAX(x,y)    ((x) < (y) ? (y) : (x))
  15.  
  16. #define     SCALEMAX    32767.0        /* initial max scaling value */
  17. #define        SCALEMIN    -32768.0    /* initial min scaling value */
  18.  
  19. #define        RAD_2_DEG    57.2957795    /* degree's per radian */
  20. #define        LABEL_BFR    512        /* size of labeling buffer */
  21. #define        LORG_DEFAULT    1        /* default label origin */
  22.  
  23. #define        PA        0
  24. #define        PR        1
  25. #define        PENUP        0
  26. #define        PENDOWN        1        /* p_status values */
  27. #define        ESC        0x1B        /* start of RS-232 command */
  28. #define        ETX        0x03        /* end of transmission */
  29. #define        TERMCHAR    ';'        /* command termination char */
  30. #define        DEF_CHORD    5.0        /* default chord angle for AA, AR, CI */
  31. #define        MAX_CHORD    180.0        /* maximum chord angle */
  32. #define        MIN_CHORD    0.5        /* minimum chord angle */
  33. #define        DEF_TICK    0.5        /* default tick length */
  34. #define        PG_DELAY    6        /* 6 second delay to gclear () on PGn; instr */
  35.  
  36. #define        SOLID        0        /* solid fill, bidirectional */
  37. #define        SOLID1        1        /* solid fill, unidirectional */
  38. #define        HATCH        2        /* hatched fill */
  39. #define        XHATCH        3        /* cross-hatched fill */
  40. #define        SHADED        4        /* shaded fill */
  41. #define        USERFILL    5        /* user defined fill */
  42.  
  43. #define        DEFAULT_FILL    SOLID        /* default fill type () */
  44.  
  45. #define        MAX_COLORS    16        /* maximum number of colors for pen mapping */
  46.  
  47. #define        ON        1        /* "on" constant */
  48. #define        OFF        0        /* "off" constant */
  49.  
  50. #define        ANG        1        /* angle-type chord lengths */
  51. #define        LENGTH        0        /* length-type chord lengths */
  52.  
  53. #define        CP_XSCALE    1.60        /* CP scale factor to add-in inter-character spacing */
  54. #define        CP_YSCALE    1.60        /* CP scale factor to add in inter-line spacing */
  55.  
  56. #define        DEFAULTUNITS    0        /* hatch & x-hatch fill using default spacings */
  57. #define        PLOTTERUNITS    1        /* hatch & x-hatch fill using plotter units (frozen) */
  58. #define        USERUNITS    2        /* hatch & x-hatch fill using user units (variable) */
  59.  
  60. #define        ANISOTROPIC    0        /* anisotropic scaling */
  61. #define        ISOTROPIC    1        /* isotropic scaling */
  62.  
  63. #define        ABSOLUTE    0        /* absolute coordinates */
  64. #define     RELATIVE    1        /* relative coordinates */
  65. #define        FILLED_ABS    0x10        /* absolute coordinates, filled */
  66. #define        FILLED_REL    0x11        /* relative coordinates, filled */
  67.  
  68. #define        A4_paper    0        /* paper-size index values */
  69. #define        A3_paper    1        /* these correspond to values assigned to option flags */
  70. #define        A2_paper    2        /* used in getargs.c for paper sizes and to the order of */
  71. #define        A1_paper    3        /* elements in the struct paper_size in hpgl.c */
  72. #define        A0_paper    4
  73. #define        A_paper        5
  74. #define        B_paper        6
  75. #define        C_paper        7
  76. #define        D_paper        8
  77. #define        E_paper        9
  78. #define        DRAFTPRO    1        /* HP DraftPro plotter */
  79. #define        F_70        2        /* HP 7470 Emulation flag */
  80. #define        F_75        3        /* HP 7475 Emulation flag */
  81. #define        Debug_flag    1        /* debugging output activation flag */
  82.  
  83. #define        plot_abs(x)        plot_line (x, ABSOLUTE)    /* absolute plotting */
  84. #define        plot_rel(x)        plot_line (x, RELATIVE)    /* relative plotting */
  85. #define        set_acsize(x)        set_csize (x, ABSOLUTE)    /* absolute csize */
  86. #define        set_rcsize(x)        set_csize (x, RELATIVE)    /* relative csize */
  87. #define        label_adir(i)        label_dir (i, ABSOLUTE)    /* absolute label direction */
  88. #define        label_rdir(i)        label_dir (i, RELATIVE)    /* relative label direction */
  89. #define        print_string(x)        print_error (x, 1)    /* print string to stdout */
  90. #define        print_noinstr(x)    print_error (x, 0)    /* instruction not implimented */
  91. #define        edge_rect_abs(x)    draw_rect (x, ABSOLUTE)        /* edge rectangle absolute */
  92. #define        edge_rect_rel(x)    draw_rect (x, RELATIVE)        /* edge rectangle relative */
  93. #define        filled_rect_abs(x)    draw_rect (x, FILLED_ABS)    /* filled rectangle absolute */
  94. #define        filled_rect_rel(x)    draw_rect (x, FILLED_REL)    /* filled rectancle relative */
  95. #define        arc_3pt_abs(x)        arc_3pt (x, ABSOLUTE)        /* 3-point arc, absolute */
  96. #define        arc_3pt_rel(x)        arc_3pt (x, RELATIVE)        /* 3-point arc, relative */
  97. #define        input_p1p2abs(x)    input_p1p2 (x, ABSOLUTE)    /* IP instruction */
  98. #define        input_p1p2rel(x)    input_p1p2 (x, RELATIVE)    /* IR instruction */
  99. #define        abs_arc(x)        draw_arc (x, ABSOLUTE)        /* absolute arc */
  100. #define        rel_arc(x)        draw_arc (x, RELATIVE)        /* relative arc */
  101. #define        set_window(x1,x2,y1,y2)    set_scale (x1, x2, y1, y2)    /* anisotropic scaling function */
  102.  
  103. struct options        /* structure for command line arguments */
  104.     {
  105.     int paper;    /* type of paper used */
  106.     int video;    /* video adapter: CGA, EGA, VGA, or auto select */
  107.     int plotter;    /* plotter type: normal (origin in lower-left corner) or draft pro (origin at center) */
  108.     int debug;    /* debugging output flag */
  109.     FILE *infile;    /* file handle for input source */
  110.     };
  111.  
  112.  
  113. struct cplot
  114.     {
  115.     double x, y, ldir, dvdir;    /* (x,y) position, label direction, DV label direction (degrees) */
  116.     int dv;        /* label stacking direction code */
  117.     int lorg;    /* label origin code */
  118.     };        /* (x,y) for location of last start of line or last position moved to by
  119.                PA, PR, PU, PD instruction */
  120.  
  121. struct csizes
  122.     {
  123.     double csize_x, csize_y, slant, acsize_x, acsize_y,
  124.         rcsize_x, rcsize_y, csize_basis;
  125.     int cscale_mode;
  126.     };
  127. /* csize_x, csize_y:   character sizes in GDU's units
  128.    slant:              character slant (tan (slant_angle) )
  129.    rcsize_x, rcsize_y: relative csize storage
  130.    acsize_x, acsize_y: absolute csize storage
  131.    csize_basis:        relative char size for screen plot (relative to A-size paper)
  132.    cscale_mode:        0 for absolute sizes, 1 for relative sizes
  133. */
  134.  
  135. struct paper_size
  136.     {
  137.     double ipxmin, ipymin, ipxmax, ipymax,
  138.         psxdef, psydef, ipxsize, ipysize;
  139.     double ip1x, ip1y, ip2x, ip2y;
  140.     double csize_basis;
  141.     };
  142.  
  143. /* ipxmax, ipymax:   maximum values for IP coordinates
  144.    psxdef, psydef:   default values for PS (plot size)
  145.    ipxsize, ipysize: size of page in IP units (1000th's of an inch)
  146.    ip1x, ip1y:       initial lower left corner IP coordinates
  147.    ip2x, ip2y:       initial upper right corner IP coordinates
  148.    csize_basis:      char size basis scaling (relative to diagonal 
  149.                      distance across A-size paper):
  150.                      basis = A-size diagonal / this-size diagonal.
  151. */
  152.  
  153. struct win_corners
  154.     {
  155.     double x1, y1, x2, y2;
  156.     };
  157.  
  158. /* user unit window corners: (x1, y1) = lower right; (x2, y2) = upper left */
  159.  
  160. struct clip_border
  161.     {
  162.     int xmin, xmax, ymin, ymax;
  163.     };
  164.  
  165. /* clip border in pixel units */
  166.  
  167.  
  168. #ifndef NO_VIDEO    /* do not define this block when NO_VIDEO is defined */
  169.  
  170. #ifndef ADAPTER_CODES
  171.  
  172. #define NOGRAPHICS    0    /* no supported graphics modes available */
  173. #define CGA        1    /* CGA */
  174. #define CGAM        2    /* CGA Monochrome */
  175. #define MEGA        0x83    /* EGA monochrome */
  176. #define CEGA        4    /* EGA color */
  177. #define PGC        5    /* PGC: not supported */
  178. #define MVGA        0x86    /* VGA monochrome */
  179. #define CVGA        7    /* VGA color */
  180. #define EMCGA        8    /* MCGA w/EGA color display */
  181. #define MMCGA        0x89    /* Mono MCGA */
  182. #define CMCGA        0x0A    /* Color MCGA */
  183. #define ATT        0x0B    /* ATT PC6300:  no DEB present */
  184. #define    ATT_DEB        0x0C    /* ATT PC6300: with DEB present */
  185. #define HGC        0x8D    /* Hercules graphics card */
  186. #define HGCPLUS        0x8E    /* Hercules Plus card */
  187. #define INCOLOR        0x0F    /* Hercules InColor card */
  188. #define Num_Adapters    16    /* total # of adapters in this list */
  189.  
  190. struct video_type__
  191.     {
  192.     unsigned type;
  193.     struct _vid_x_parm_ *vid_mode;
  194.     char *display;
  195.     };
  196.  
  197. #define ADAPTER_CODES
  198. #endif
  199.  
  200. #ifndef VID_RTN_DEFT
  201.  
  202. struct video_display        /* returned structure for video_test () */
  203.     {
  204.     unsigned disp_a;
  205.     struct _vid_x_parm_ *vid_mode_a;
  206.     char *display_a;
  207.     unsigned disp_b;
  208.     struct _vid_x_parm_ *vid_mode_b;
  209.     char *display_b;
  210.     };
  211.  
  212. #define     VID_RTN_DEFT    /* video_test return structure defined */
  213. #endif
  214.  
  215. struct video_display *video_test ( void );
  216.  
  217. #endif
  218.  
  219.  
  220. struct options *getargs ( int, char ** );
  221.  
  222. void arc_3pt ( FILE *, int );
  223. void begin_plot ( FILE * );
  224. void calc_ticksize ( double, double );
  225. void char_plot ( FILE * );
  226. void calc_csize ( double, double, int );
  227. void chord_t ( FILE * );
  228. void circle ( FILE * );
  229. void define_path ( FILE * );
  230. void draw_arc ( FILE *, int );
  231. void draw_rect ( FILE *, int );
  232. void draw_wedge ( FILE * );
  233. void draw_xtick ( void );
  234. void draw_ytick ( void );
  235. void extra_space ( double, double );
  236. void fill_type ( FILE *, int );
  237. void fix_hatch ();
  238. void get_anchor ( double *, double * );
  239. int get_val ( FILE *, double * );
  240. int get_xy ( FILE *, double *, double * );
  241. void init_fills ( void );
  242. void initialize ( FILE * );
  243. void label_dir ( FILE *, int );
  244. void label_graph ( FILE * );
  245. void label_origin ( FILE * );
  246. void label_term ( FILE * );
  247. void line_pattern ( FILE * );
  248. void new_plot ( void );
  249. void page_adv ( FILE * );
  250. int plotted_on ( int );
  251. void plotter_units ( double *, double * );
  252. void print_error ( char *, int );
  253. void recalc_csize ( void );
  254. void recalc_ticksize ( void );
  255. void set_anchor ( double, double, int );
  256. void set_clip (double, double, double, double );
  257. void set_csize ( FILE *, int );
  258. void set_scale ( double, double, double, double );
  259. void set_slant ( FILE * );
  260. void symbol_mark ( unsigned char );
  261. void tick_length ( FILE * );
  262. void twait ( FILE *, int );
  263. void user_units (double *, double *);
  264. void velocity_sel ( FILE * );
  265. void xparent_data ( FILE * );
  266.  
  267. /*    media ranges (maximum plotting range) */
  268. /*    paper size    Xmax        Ymax         size */
  269. /*    ANSI A        10365        7962        8.5 x 11 in. */
  270. /*    ANSI B        16640        10365        11 x 17 in. */
  271. /*    ISO A4        11040        7721        210 x 297 mm */
  272. /*    ISO A3        16153        11040        297 x 420 mm */
  273.  
  274.  
  275.