home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / os2 / hpgl312.zip / HP2XX.H < prev    next >
C/C++ Source or Header  |  1993-04-18  |  9KB  |  344 lines

  1. /*
  2.    Copyright (c) 1991 - 1993 Heinz W. Werntges.  All rights reserved.
  3.    Distributed by Free Software Foundation, Inc.
  4.  
  5. This file is part of HP2xx.
  6.  
  7. HP2xx is distributed in the hope that it will be useful, but
  8. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  9. to anyone for the consequences of using it or for whether it serves any
  10. particular purpose or works at all, unless he says so in writing.  Refer
  11. to the GNU General Public License, Version 2 or later, for full details.
  12.  
  13. Everyone is granted permission to copy, modify and redistribute
  14. HP2xx, but only under the conditions described in the GNU General Public
  15. License.  A copy of this license is supposed to have been
  16. given to you along with HP2xx so you can know your rights and
  17. responsibilities.  It should be in a file named COPYING.  Among other
  18. things, the copyright notice and this notice must be preserved on all
  19. copies.
  20.  
  21. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  22. */
  23.  
  24. /** hp2xx.h: Header for Project "hp2xx"
  25.  **
  26.  ** 91/01/13  V 1.00  HWW  Originating
  27.  ** 91/01/19  V 1.01  HWW  Reorganized
  28.  ** 91/01/31  V 1.02  HWW  Tested on SUN; some flags added
  29.  ** 91/02/15  V 1.03  HWW  SUN release; stdlib.h supported
  30.  ** 91/02/18  V 1.04  HWW  plot_picbuf() is macro; new type: HPGL_Pt
  31.  ** 91/06/18  V 1.05  HWW  New PAR elements; ANSI_C supported
  32.  ** 91/06/15  V 1.06  HWW  VGA options added (PC only)
  33.  ** 91/06/20  V 1.07  HWW  Rotation added
  34.  ** 91/09/08  V 1.08  HWW  ATARI 32K format added
  35.  ** 91/10/09  V 1.08a HWW  ATARI 32K format: modified
  36.  ** 91/10/14  V 1.09  HWW  ATARI: PAC format with compression now,
  37.  **                 hwtools.h: excerpt incorporated
  38.  ** 91/10/20  V 1.09b HWW  PAC (compression) removed; atari --> pic (renamed)
  39.  ** 91/10/25  V 1.10  HWW  VAX_C: M_PI added
  40.  ** 91/11/20  V 1.11  HWW  SPn; support
  41.  ** 91/12/22  V 1.11b HWW  Some redefs in PS part
  42.  ** 92/01/11  V 1.12  HWW  Norbert Meyer's ATARI portability changes built in
  43.  ** 92/01/26  V 1.12a HWW  Some prototypes added
  44.  ** 92/01/31  V 1.12c HWW  M_PI def changed ; SUNVIEW etc. + comments added
  45.  ** 92/02/06  V 1.12d HWW  arcs(), circles() added
  46.  ** 92/02/19  V 1.13c HWW  LB etc. supported
  47.  ** 92/02/21  V 1.14a HWW  PG supported
  48.  ** 92/05/06  V 1.14b HWW  Log files & color supported (starting)
  49.  ** 92/05/19  V 2.00a HWW  Color supported
  50.  ** 92/05/28  V 2.00b HWW  Some prototypes changed/added
  51.  ** 92/06/09  V 2.00c HWW  debugged (GNU)
  52.  ** 92/10/15  V 2.01a HWW  LineType added
  53.  ** 92/11/08  V 2.01c HWW  page --> first_page, last_page; GNU --> DJ_GR
  54.  ** 92/12/13  V 2.02a HWW  truesize flag added; colors renamed
  55.  ** 93/04/13  V 2.10a HWW  User-serviceable parts & redundant prototypes
  56.  **               removed
  57.  **/
  58.  
  59.  
  60. /**
  61.  ** Working with Pure C (the official descendant of Borland's
  62.  ** Turbo C for Atari computers)
  63.  **/
  64.  
  65. #ifdef __PUREC__ /* __PUREC__ is pre-defined by the Pure-C  compiler */
  66. #ifndef PURE_C
  67. #define PURE_C
  68. #endif
  69. #endif
  70.  
  71. /**
  72.  ** Automatic definition of obsolete symbol by Turbo-C and Pure-C:
  73.  **/
  74.  
  75. #ifdef __TURBOC__
  76.  
  77. #ifndef TURBO_C
  78. #define TURBO_C
  79. #endif
  80.  
  81. #endif
  82.  
  83.  
  84.  
  85. #ifdef GNU
  86. #define   getch getkey
  87. #endif
  88.  
  89.  
  90. #ifndef M_PI
  91. #define M_PI    3.141592654    /* Some machines don't know PI */
  92. #endif
  93.  
  94. #ifndef EOF
  95. #define EOF (-1)
  96. #endif
  97.  
  98. #ifndef    MIN
  99. #define MIN(x,y)  ((x)<(y) ? (x) : (y))
  100. #endif
  101.  
  102. #ifndef    MAX
  103. #define MAX(x,y)  ((x)<(y) ? (y) : (x))
  104. #endif
  105.  
  106.  
  107. #define    TRUE    1
  108. #define    FALSE    0
  109. #define ERROR (-1)
  110.  
  111. #define    ESC    '\033'
  112. #define    CR    '\015'
  113. #define    FF    '\014'
  114. #define    LF    '\012'
  115. #define    BEL    '\007'
  116.  
  117. #define    MAX_LB_LEN    150    /* Max num of chars per label    */
  118.  
  119.  
  120. #ifndef VOID
  121. #ifdef    __STDC__
  122. #define    VOID    void
  123. #else
  124. #define    VOID    char
  125. #endif
  126. #endif    /* ifndef VOID */
  127.  
  128. /* #endif */
  129.  
  130.  
  131.  
  132. /**
  133.  ** Color codes used within hp2xx
  134.  **/
  135.  
  136. #define    xxBackground    0
  137. #define    xxForeground    1
  138. #define    xxRed        2
  139. #define    xxGreen        3
  140. #define    xxBlue        4
  141. #define    xxCyan        5
  142. #define    xxMagenta    6
  143. #define    xxYellow    7
  144.  
  145.  
  146. /**
  147.  ** Misc. typedefs
  148.  **/
  149.  
  150. typedef unsigned char    Byte;
  151.  
  152.  
  153. /**
  154.  ** A bag for many options and internally needed data to be passed
  155.  ** to various functions.
  156.  **/
  157.  
  158. typedef struct {
  159.     int    dpi_x, dpi_y, first_page, last_page,
  160.         pen, pensize[9], maxpensize, is_color, truesize,
  161.         quiet, init_p, formfeed, specials, vga_width;
  162.     int    pencolor[9], maxcolor;
  163.     Byte    Clut[16][3];
  164.     double    xoff, yoff, x0, x1, y0, y1, width, height,
  165.         aspectfactor, rotation;
  166.     char    *outfile, *swapfile, *logfile, *mode;
  167.     Byte    vga_mode;
  168. } PAR;
  169.  
  170.  
  171.  
  172. /**
  173.  ** This struct handles a single row of our raster picture buffer
  174.  **/
  175.  
  176. typedef    struct Row {
  177.     Byte        *buf;    /* Ptr to actual data buffer which holds the bits    */
  178.     int        index;    /* Index of this row. Unique for each row. Ordered    */
  179.     struct Row    *prev, *next;    /* Rows are elements of a double-linked list    */
  180. } RowBuf;
  181.  
  182.  
  183. /**
  184.  ** Struct holding the whole raster picture
  185.  **/
  186.  
  187. typedef    struct {
  188.             /* Number of rows / columns / bytes per row    */
  189.     int    nr, nc, nb;
  190.             /* Depth: Number of bit planes (1 to 4)        */
  191.     int    depth;
  192.             /* Swapfile handle                */
  193.     FILE    *sd;
  194.             /* Array pointer of all rows            */
  195.     RowBuf    *row;
  196. } PicBuf;
  197.  
  198.  
  199. typedef    struct {
  200.     float    x,y;
  201. } HPGL_Pt;
  202.  
  203.  
  204. typedef enum {
  205.     NOP, MOVE_TO, DRAW_TO, PLOT_AT, SET_PEN
  206. } PlotCmd;
  207.  
  208.  
  209. /**
  210.  ** Line types: No pattern number = solid line, 0 = dot at end coordinates,
  211.  **        != 0: various patterns, consisting of
  212.  **            l)ong lines, s)hort lines, d)ots and g)aps.
  213.  **        < 0:  adaptive line types (ada)
  214.  **        > 0:  fixed line types (fix)
  215.  **
  216.  ** NOTE: See HP-GL manuals for details
  217.  **/
  218.  
  219. typedef    enum
  220. {
  221.     LT_lgsgs_ada    = -6,
  222.     LT_lgs_ada    = -5,
  223.     LT_lgd_ada    = -4,
  224.     LT_ls_ada    = -3,
  225.     LT_l_ada    = -2,
  226.     LT_d_ada    = -1,
  227.  
  228.     LT_plot_at    =  0,
  229.                 /* Line patterns:    */
  230.     LT_d_fix    =  1,    /*    .         */
  231.     LT_l_fix    =  2,    /*    -----         */
  232.     LT_ls_fix    =  3,    /*    -------     */
  233.     LT_lgd_fix    =  4,    /*    ------- .    */
  234.     LT_lgs_fix    =  5,    /*    ------- -    */
  235.     LT_lgsgs_fix    =  6,    /*    ----- - -    */
  236.  
  237.     LT_solid    =  7,
  238.     LT_default    =  7
  239. }
  240.     LineType;
  241.  
  242.  
  243.  
  244. #define    FLAGSTATE(flag)        (flag) ? "ON" : "off"
  245.  
  246.  
  247. #if defined(TURBO_C) || defined (GNU)
  248. #define    READ_BIN    "rb"
  249. #define    WRITE_BIN    "w+b"
  250. #else
  251. #define    READ_BIN    "r"
  252. #define    WRITE_BIN    "w+"
  253. #endif
  254.  
  255.  
  256. /**
  257.  ** Prototypes:
  258.  **/
  259.  
  260. void    SilentWait    (void);
  261. void    Wait        (void);
  262.  
  263. void    HPcoord_to_dotcoord
  264.             (HPGL_Pt *, DevPt *);
  265. void    init_HPGL    (FILE *, PAR *);
  266. void    reset_HPGL    (void);
  267. void    evaluate_HPGL    (PAR *, DevPt *);
  268. void    read_HPGL    (PAR *, FILE *, FILE *, DevPt *);
  269.  
  270. void    read_ESC_cmd    (FILE *);
  271. int    read_float    (float *, FILE *);
  272. void    read_HPGL_cmd    (int,    FILE *);
  273. void    read_string    (char *,FILE *);
  274. void    read_symbol_char(FILE *);
  275.  
  276. void    lines        (int,    FILE *);
  277. void    arcs        (int,    FILE *);
  278. void    circles        (FILE *);
  279. void    ax_ticks    (int);
  280.  
  281. void    plot_user_char    (FILE *);
  282.  
  283. void    Pen_action_to_tmpfile    (PlotCmd, HPGL_Pt *, int);
  284. void    PlotCmd_to_tmpfile    (PlotCmd);
  285. void    HPGL_Pt_to_tmpfile    (HPGL_Pt *);
  286. int    PlotCmd_from_tmpfile    (void);
  287. void    HPGL_Pt_from_tmpfile    (HPGL_Pt *);
  288.  
  289. void    to_ATARI    (PAR *, FILE *);
  290. void    to_mftex    (PAR *, FILE *, int);
  291. void    to_eps        (PAR *, FILE *);
  292.  
  293. PicBuf    *allocate_PicBuf(DevPt *, PAR *);
  294. void    free_PicBuf    (PicBuf *, char *);
  295. void    tmpfile_to_PicBuf(PicBuf*, PAR *, FILE *);
  296. void    line_PicBuf    (PicBuf *, DevPt *, DevPt *, PAR *);
  297. int    index_from_PicBuf(PicBuf*, DevPt *);
  298. int    index_from_RowBuf(RowBuf*, int, PicBuf *);
  299. RowBuf    *get_RowBuf    (PicBuf*, int);
  300.  
  301. void    PicBuf_to_PCL    (PicBuf *, PAR *);
  302. void    PicBuf_to_PCX    (PicBuf *, PAR *);
  303.  
  304. Byte    get_byte_IMG    (int, int, PicBuf *);
  305. int    vert_rep_IMG    (int, PicBuf *);
  306. int    empty_SR_IMG    (int, int, PicBuf *);
  307. int    full_SR_IMG    (int, int, PicBuf *);
  308. int    PR_IMG        (int, int, PicBuf *);
  309. void    write_byte_IMG    (Byte, PicBuf *, PAR *, FILE *);
  310. void    write_VR_IMG    (Byte, PicBuf *, PAR *, FILE *);
  311. void    write_PR_IMG    (Byte, Byte, Byte, PicBuf *, PAR *, FILE *);
  312. void    write_empty_SR_IMG    (Byte, PicBuf *, PAR *, FILE *);
  313. void    write_full_SR_IMG    (Byte, PicBuf *, PAR *, FILE *);
  314. void    write_BS_IMG    (Byte, PicBuf *, PAR *, FILE *);
  315. void    PicBuf_to_IMG    (PicBuf *, PAR *);
  316.  
  317. void    PicBuf_to_PBM    (PicBuf *, PAR *);
  318.  
  319. void    PicBuf_to_ILBM    (PicBuf *, PAR *);
  320.  
  321. #ifdef PIC_PAC
  322. int    Init_PIC_files    (char *, FILE **, int, int, int);
  323. void    PicBuf_to_PIC    (PicBuf *, PAR *);
  324. void    RowBuf_to_PIC    (RowBuf *, int, FILE **);
  325.  
  326. int    Screenpos_PAC    (int *, int *, int);
  327. int    Pack_PAC    (Byte *, Byte, Byte, Byte, int, FILE *);
  328. void    Analyze_PAC    (Byte *, Byte *, Byte *, Byte *);
  329. void    Screen_for_PAC    (PicBuf *, Byte *, int, int);
  330. void    Name_PAC    (char *, char *, int, int, int);
  331. void    PicBuf_to_PAC    (PicBuf *, PAR *);
  332. #endif    /* PIC_PAC */
  333.  
  334. void    PicBuf_to_AMIGA    (PicBuf *, PAR *);
  335. void    PicBuf_to_ATARI    (PicBuf *, PAR *);
  336. void    PicBuf_to_DJ_GR    (PicBuf *, PAR *);
  337. void    PicBuf_to_Dummy    (void);
  338. void    PicBuf_to_PM    (PicBuf *, PAR *);
  339. void    PicBuf_to_Sunview(PicBuf *, PAR *);
  340. void    PicBuf_to_UIS    (PicBuf *, PAR *);
  341. void    PicBuf_to_VGA    (PicBuf *, PAR *);
  342. void    PicBuf_to_X11    (PicBuf *, PAR *);
  343.  
  344.