home *** CD-ROM | disk | FTP | other *** search
/ Der Mediaplex Sampler - Die 6 von Plex / 6_v_plex.zip / 6_v_plex / DISK2 / MULTI_04 / SHOWGL15.ZIP / HPGL.H < prev    next >
C/C++ Source or Header  |  1991-12-27  |  8KB  |  241 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        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        A4_paper    0        /* paper-size index values */
  64. #define        A3_paper    1        /* these correspond to values assigned to option flags */
  65. #define        A2_paper    2        /* used in getargs.c for paper sizes and to the order of */
  66. #define        A1_paper    3        /* elements in the struct paper_size in hpgl.c */
  67. #define        A0_paper    4
  68. #define        A_paper        5
  69. #define        B_paper        6
  70. #define        C_paper        7
  71. #define        D_paper        8
  72. #define        E_paper        9
  73. #define        DRAFTPRO    1        /* HP DraftPro plotter */
  74. #define        Debug_flag    1        /* debugging output activation flag */
  75.  
  76. #define        plot_abs(x)        plot_line (x, 0)    /* absolute plotting */
  77. #define        plot_rel(x)        plot_line (x, 1)    /* relative plotting */
  78. #define        set_acsize(x)        set_csize (x, 0)    /* absolute csize */
  79. #define        set_rcsize(x)        set_csize (x, 1)    /* relative csize */
  80. #define        label_adir(i)        label_dir (i, 0)    /* absolute label direction */
  81. #define        label_rdir(i)        label_dir (i, 1)    /* relative label direction */
  82. #define        print_string(x)        print_error (x, 1)    /* print string to stderr */
  83. #define        print_noinstr(x)    print_error (x, 0)    /* instruction not implimented */
  84. #define        edge_rect_abs(x)    draw_rect (x, 0)    /* edge rectangle absolute */
  85. #define        edge_rect_rel(x)    draw_rect (x, 1)    /* edge rectangle relative */
  86. #define        filled_rect_abs(x)    draw_rect (x, 0x10)    /* filled rectangle absolute */
  87. #define        filled_rect_rel(x)    draw_rect (x, 0x11)    /* filled rectancle relative */
  88. #define        arc_3pt_abs(x)        arc_3pt (x, 0)        /* 3-point arc, absolute */
  89. #define        arc_3pt_rel(x)        arc_3pt (x, 1)        /* 3-point arc, relative */
  90. #define        input_p1p2abs(x)    input_p1p2 (x, 0)    /* IP instruction */
  91. #define        input_p1p2rel(x)    input_p1p2 (x, 1)    /* IR instruction */
  92. #define        abs_arc(x)        draw_arc (x, 0)        /* absolute arc */
  93. #define        rel_arc(x)        draw_arc (x, 1)        /* relative arc */
  94. #define        set_window(x1,x2,y1,y2)    set_scale (x1, x2, y1, y2, 0)    /* anisotropic scaling function */
  95. #define        set_show(x1,x2,y1,y2)    set_scale (x1, x2, y1, y2, 1)    /* isotropic scaling function */
  96.  
  97. struct options        /* structure for command line arguments */
  98.     {
  99.     int paper;
  100.     int video;
  101.     int plotter;
  102.     int debug;
  103.     FILE *infile;
  104.     };
  105.  
  106.  
  107. struct cplot
  108.     {
  109.     double x, y, ldir, dvdir;    /* (x,y) position, label direction, DV label direction (degrees) */
  110.     int dv;        /* label stacking direction code */
  111.     int lorg;    /* label origin code */
  112.     };        /* (x,y) for location of last start of line or last position moved to by
  113.                PA, PR, PU, PD instruction */
  114.  
  115. struct csizes
  116.     {
  117.     double csize_x, csize_y, slant, rcsize_x, rcsize_y;
  118.     int cscale_mode;
  119.     };
  120. /* csize_x, csize_y:   character sizes in GDU's units
  121.    slant:              character slant (tan (slant_angle) )
  122.    rcsize_x, rcsize_y: relative csize storage
  123.    cscale_mode:        0 for absolute sizes, 1 for relative sizes
  124. */
  125.  
  126. struct paper_size
  127.     {
  128.     double ipxmin, ipymin, ipxmax, ipymax, 
  129.         psxdef, psydef, ipxsize, ipysize;
  130.     double ip1x, ip1y, ip2x, ip2y;
  131.     };
  132.  
  133. /* ipxmax, ipymax:   maximum values for IP coordinates
  134.    psxdef, psydef:   default values for PS (plot size)
  135.    ipxsize, ipysize: size of page in IP units (1000th's of an inch)
  136.    ip1x, ip1y:       initial lower left corner IP coordinates
  137.    ip2x, ip2y:       initial upper right corner IP coordinates
  138. */
  139.  
  140. #ifndef NO_VIDEO    /* do not define this block when NO_VIDEO is defined */
  141.  
  142. #ifndef ADAPTER_CODES
  143.  
  144. #define NOGRAPHICS    0    /* no supported graphics modes available */
  145. #define CGA        1    /* CGA */
  146. #define CGAM        2    /* CGA Monochrome */
  147. #define MEGA        0x83    /* EGA monochrome */
  148. #define CEGA        4    /* EGA color */
  149. #define PGC        5    /* PGC: not supported */
  150. #define MVGA        0x86    /* VGA monochrome */
  151. #define CVGA        7    /* VGA color */
  152. #define EMCGA        8    /* MCGA w/EGA color display */
  153. #define MMCGA        0x89    /* Mono MCGA */
  154. #define CMCGA        0x0A    /* Color MCGA */
  155. #define ATT        0x0B    /* ATT PC6300:  no DEB present */
  156. #define    ATT_DEB        0x0C    /* ATT PC6300: with DEB present */
  157. #define HGC        0x8D    /* Hercules graphics card */
  158. #define HGCPLUS        0x8E    /* Hercules Plus card */
  159. #define INCOLOR        0x0F    /* Hercules InColor card */
  160. #define Num_Adapters    16    /* total # of adapters in this list */
  161.  
  162. struct video_type__
  163.     {
  164.     unsigned type;
  165.     struct _vid_x_parm_ *vid_mode;
  166.     char *display;
  167.     };
  168.  
  169. #define ADAPTER_CODES
  170. #endif
  171.  
  172. #ifndef VID_RTN_DEFT
  173.  
  174. struct video_display        /* returned structure for video_test () */
  175.     {
  176.     unsigned disp_a;
  177.     struct _vid_x_parm_ *vid_mode_a;
  178.     char *display_a;
  179.     unsigned disp_b;
  180.     struct _vid_x_parm_ *vid_mode_b;
  181.     char *display_b;
  182.     };
  183.  
  184. #define     VID_RTN_DEFT    /* video_test return structure defined */
  185. #endif
  186.  
  187. struct video_display *video_test ( void );
  188.  
  189. #endif
  190.  
  191.  
  192. struct options *getargs ( int, char ** );
  193.  
  194. void arc_3pt ( FILE *, int );
  195. void begin_plot ( FILE * );
  196. void calc_ticksize ( double, double );
  197. void char_plot ( FILE * );
  198. void calc_csize ( double, double, int );
  199. void chord_t ( FILE * );
  200. void circle ( FILE * );
  201. void define_path ( FILE * );
  202. void draw_arc ( FILE *, int );
  203. void draw_rect ( FILE *, int );
  204. void draw_wedge ( FILE * );
  205. void draw_xtick ( void );
  206. void draw_ytick ( void );
  207. void extra_space ( double, double );
  208. void fill_type ( FILE *, int );
  209. void fix_hatch ();
  210. void get_anchor ( double *, double * );
  211. int get_val ( FILE *, double * );
  212. int get_xy ( FILE *, double *, double * );
  213. void init_fills ( void );
  214. void initialize ( FILE * );
  215. void label_dir ( FILE *, int );
  216. void label_graph ( FILE * );
  217. void label_origin ( FILE * );
  218. void label_term ( FILE * );
  219. void line_pattern ( FILE * );
  220. void new_plot ( void );
  221. void page_adv ( FILE * );
  222. int plotted_on ( int );
  223. void plotter_units ( double *, double * );
  224. void print_error ( char *, int );
  225. void set_csize ( FILE *, int );
  226. void set_scale ( double, double, double, double, int );
  227. void set_slant ( FILE * );
  228. void symbol_mark ( unsigned char );
  229. void tick_length ( FILE * );
  230. void twait ( FILE *, int );
  231. void velocity_sel ( FILE * );
  232.  
  233. /*    media ranges (maximum plotting range) */
  234. /*    paper size    Xmax        Ymax         size */
  235. /*    ANSI A        10365        7962        8.5 x 11 in. */
  236. /*    ANSI B        16640        10365        11 x 17 in. */
  237. /*    ISO A4        11040        7721        210 x 297 mm */
  238. /*    ISO A3        16153        11040        297 x 420 mm */
  239.  
  240.  
  241.