home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / GRAPHICS / SHOWGL10.ZIP / HPGL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-19  |  6.7 KB  |  183 lines

  1. /* program for reading HPGL files and plotting to the screen */
  2.  
  3. /* copyright 1991, 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        ON        1        /* "on" constant */
  46. #define        OFF        0        /* "off" constant */
  47.  
  48. #define        ANG        1        /* angle-type chord lengths */
  49. #define        LENGTH        0        /* length-type chord lengths */
  50.  
  51. #define        CP_XSCALE    1.60        /* CP scale factor to add-in inter-character spacing */
  52. #define        CP_YSCALE    1.60        /* CP scale factor to add in inter-line spacing */
  53.  
  54. #define        DEFAULTUNITS    0        /* hatch & x-hatch fill using default spacings */
  55. #define        PLOTTERUNITS    1        /* hatch & x-hatch fill using plotter units (frozen) */
  56. #define        USERUNITS    2        /* hatch & x-hatch fill using user units (variable) */
  57.  
  58. #define        ANISOTROPIC    0        /* anisotropic scaling */
  59. #define        ISOTROPIC    1        /* isotropic scaling */
  60.  
  61. #define        A4_paper    0        /* paper-size index values */
  62. #define        A3_paper    1        /* these correspond to values assigned to option flags */
  63. #define        A2_paper    2        /* used in getargs.c for paper sizes and to the order of */
  64. #define        A1_paper    3        /* elements in the struct paper_size in hpgl.c */
  65. #define        A0_paper    4
  66. #define        A_paper        5
  67. #define        B_paper        6
  68. #define        C_paper        7
  69. #define        D_paper        8
  70. #define        E_paper        9
  71. #define        DRAFTPRO    1        /* HP DraftPro plotter */
  72.  
  73. #define        plot_abs(x)        plot_line (x, 0)    /* absolute plotting */
  74. #define        plot_rel(x)        plot_line (x, 1)    /* relative plotting */
  75. #define        set_acsize(x)        set_csize (x, 0)    /* absolute csize */
  76. #define        set_rcsize(x)        set_csize (x, 1)    /* relative csize */
  77. #define        label_adir(i)        label_dir (i, 0)    /* absolute label direction */
  78. #define        label_rdir(i)        label_dir (i, 1)    /* relative label direction */
  79. #define        print_string(x)        print_error (x, 1)    /* print string to stderr */
  80. #define        print_noinstr(x)    print_error (x, 0)    /* instruction not implimented */
  81. #define        edge_rect_abs(x)    draw_rect (x, 0)    /* edge rectangle absolute */
  82. #define        edge_rect_rel(x)    draw_rect (x, 1)    /* edge rectangle relative */
  83. #define        filled_rect_abs(x)    draw_rect (x, 0x10)    /* filled rectangle absolute */
  84. #define        filled_rect_rel(x)    draw_rect (x, 0x11)    /* filled rectancle relative */
  85. #define        arc_3pt_abs(x)        arc_3pt (x, 0)        /* 3-point arc, absolute */
  86. #define        arc_3pt_rel(x)        arc_3pt (x, 1)        /* 3-point arc, relative */
  87. #define        input_p1p2abs(x)    input_p1p2 (x, 0)    /* IP instruction */
  88. #define        input_p1p2rel(x)    input_p1p2 (x, 1)    /* IR instruction */
  89. #define        abs_arc(x)        draw_arc (x, 0)        /* absolute arc */
  90. #define        rel_arc(x)        draw_arc (x, 1)        /* relative arc */
  91. #define        set_window(x1,x2,y1,y2)    set_scale (x1, x2, y1, y2, 0)    /* anisotropic scaling function */
  92. #define        set_show(x1,x2,y1,y2)    set_scale (x1, x2, y1, y2, 1)    /* isotropic scaling function */
  93.  
  94. struct options        /* structure for command line arguments */
  95.     {
  96.     int paper;
  97.     int video;
  98.     int plotter;
  99.     FILE *infile;
  100.     };
  101.  
  102.  
  103. struct cplot
  104.     {
  105.     double x, y, ldir, dvdir;    /* (x,y) position, label direction, DV label direction (degrees) */
  106.     int dv;        /* label stacking direction code */
  107.     int lorg;    /* label origin code */
  108.     };        /* (x,y) for location of last start of line or last position moved to by
  109.                PA, PR, PU, PD instruction */
  110.  
  111. struct csizes
  112.     {
  113.     double csize_x, csize_y, slant, rcsize_x, rcsize_y;
  114.     int cscale_mode;
  115.     };
  116. /* csize_x, csize_y:   character sizes in GDU's units
  117.    slant:              character slant (tan (slant_angle) )
  118.    rcsize_x, rcsize_y: relative csize storage
  119.    cscale_mode:        0 for absolute sizes, 1 for relative sizes
  120. */
  121.  
  122. struct paper_size
  123.     {
  124.     double ipxmin, ipymin, ipxmax, ipymax, 
  125.         psxdef, psydef, ipxsize, ipysize;
  126.     double ip1x, ip1y, ip2x, ip2y;
  127.     };
  128.  
  129. /* ipxmax, ipymax:   maximum values for IP coordinates
  130.    psxdef, psydef:   default values for PS (plot size)
  131.    ipxsize, ipysize: size of page in IP units (1000th's of an inch)
  132.    ip1x, ip1y:       initial lower left corner IP coordinates
  133.    ip2x, ip2y:       initial upper right corner IP coordinates
  134. */
  135.  
  136. struct options *getargs ( int, char ** );
  137.  
  138. void arc_3pt ( FILE *, int );
  139. void begin_plot ( FILE * );
  140. void calc_ticksize ( double, double );
  141. void char_plot ( FILE * );
  142. void calc_csize ( double, double, int );
  143. void chord_t ( FILE * );
  144. void circle ( FILE * );
  145. void define_path ( FILE * );
  146. void draw_arc ( FILE *, int );
  147. void draw_rect ( FILE *, int );
  148. void draw_wedge ( FILE * );
  149. void draw_xtick ( void );
  150. void draw_ytick ( void );
  151. void extra_space ( double, double );
  152. void fill_type ( FILE *, int );
  153. void fix_hatch ();
  154. void get_anchor ( double *, double * );
  155. int get_val ( FILE *, double * );
  156. int get_xy ( FILE *, double *, double * );
  157. void init_fills ( void );
  158. void initialize ( FILE * );
  159. void label_dir ( FILE *, int );
  160. void label_graph ( FILE * );
  161. void label_origin ( FILE * );
  162. void label_term ( FILE * );
  163. void line_pattern ( FILE * );
  164. void new_plot ( void );
  165. void page_adv ( FILE * );
  166. int plotted_on ( int );
  167. void plotter_units ( double *, double * );
  168. void print_error ( char *, int );
  169. void set_csize ( FILE *, int );
  170. void set_scale ( double, double, double, double, int );
  171. void set_slant ( FILE * );
  172. void symbol_mark ( unsigned char );
  173. void tick_length ( FILE * );
  174. void twait ( FILE *, int );
  175. void velocity_sel ( FILE * );
  176.  
  177. /*    media ranges (maximum plotting range) */
  178. /*    paper size    Xmax        Ymax         size */
  179. /*    ANSI A        10365        7962        8.5 x 11 in. */
  180. /*    ANSI B        16640        10365        11 x 17 in. */
  181. /*    ISO A4        11040        7721        210 x 297 mm */
  182. /*    ISO A3        16153        11040        297 x 420 mm */
  183.