- Main Page
- Modules
- Data Structures
- Files

# hpgsreader.h

Go to the documentation of this file.

    00001 /***********************************************************************
    00002  *                                                                     *
    00003  * $Id: hpgsreader.h 489 2009-02-11 14:10:30Z softadm $
    00004  *                                                                     *
    00005  * hpgs - HPGl Script, a hpgl/2 interpreter, which uses a Postscript   *
    00006  *        API for rendering a scene and thus renders to a variety of   *
    00007  *        devices and fileformats.                                     *
    00008  *                                                                     *
    00009  * (C) 2004-2009 ev-i Informationstechnologie GmbH  http://www.ev-i.at *
    00010  *                                                                     *
    00011  * Author: Wolfgang Glas                                               *
    00012  *                                                                     *
    00013  *  hpgs is free software; you can redistribute it and/or              *
    00014  * modify it under the terms of the GNU Lesser General Public          *
    00015  * License as published by the Free Software Foundation; either        *
    00016  * version 2.1 of the License, or (at your option) any later version.  *
    00017  *                                                                     *
    00018  * hpgs is distributed in the hope that it will be useful,             *
    00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of      *
    00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   *
    00021  * Lesser General Public License for more details.                     *
    00022  *                                                                     *
    00023  * You should have received a copy of the GNU Lesser General Public    *
    00024  * License along with this library; if not, write to the               *
    00025  * Free Software  Foundation, Inc., 59 Temple Place, Suite 330,        *
    00026  * Boston, MA  02111-1307  USA                                         *
    00027  *                                                                     *
    00028  ***********************************************************************
    00029  *                                                                     *
    00030  * Private subroutines used by the hpgs_reader.                        *
    00031  *                                                                     *
    00032  ***********************************************************************/
    00033
    00034 #ifndef __HPGS_READER_H__
    00035 #define __HPGS_READER_H__
    00036
    00037 #include <hpgs.h>
    00038
    00039 #ifdef __cplusplus
    00040 extern "C" {
    00041 #endif
    00042
    00051 #define MM_TO_PT (72.0 / 25.4)
    00052 #define HP_TO_PT (72.0 / (25.4 * 40.0))
    00053
    00054 #define MAKE_COMMAND(a,b) (((int)(a) << 8) + (b))
    00055
    00056 #define AA_CMD  MAKE_COMMAND('A','A')
    00057 #define AC_CMD  MAKE_COMMAND('A','C')
    00058 #define AD_CMD  MAKE_COMMAND('A','D')
    00059 #define AR_CMD  MAKE_COMMAND('A','R')
    00060 #define AT_CMD  MAKE_COMMAND('A','T')
    00061 #define BP_CMD  MAKE_COMMAND('B','P')
    00062 #define BR_CMD  MAKE_COMMAND('B','R')
    00063 #define BZ_CMD  MAKE_COMMAND('B','Z')
    00064 #define CI_CMD  MAKE_COMMAND('C','I')
    00065 #define CO_CMD  MAKE_COMMAND('C','O')
    00066 #define CP_CMD  MAKE_COMMAND('C','P')
    00067 #define CR_CMD  MAKE_COMMAND('C','R')
    00068 #define DI_CMD  MAKE_COMMAND('D','I')
    00069 #define DR_CMD  MAKE_COMMAND('D','R')
    00070 #define DT_CMD  MAKE_COMMAND('D','T')
    00071 #define DV_CMD  MAKE_COMMAND('D','V')
    00072 #define EA_CMD  MAKE_COMMAND('E','A')
    00073 #define EP_CMD  MAKE_COMMAND('E','P')
    00074 #define ER_CMD  MAKE_COMMAND('E','R')
    00075 #define ES_CMD  MAKE_COMMAND('E','S')
    00076 #define EW_CMD  MAKE_COMMAND('E','W')
    00077 #define FP_CMD  MAKE_COMMAND('F','P')
    00078 #define FR_CMD  MAKE_COMMAND('F','R')
    00079 #define FT_CMD  MAKE_COMMAND('F','T')
    00080 #define IN_CMD  MAKE_COMMAND('I','N')
    00081 #define IP_CMD  MAKE_COMMAND('I','P')
    00082 #define IR_CMD  MAKE_COMMAND('I','R')
    00083 #define IW_CMD  MAKE_COMMAND('I','W')
    00084 #define LA_CMD  MAKE_COMMAND('L','A')
    00085 #define LB_CMD  MAKE_COMMAND('L','B')
    00086 #define LO_CMD  MAKE_COMMAND('L','O')
    00087 #define LT_CMD  MAKE_COMMAND('L','T')
    00088 #define MC_CMD  MAKE_COMMAND('M','C')
    00089 #define MG_CMD  MAKE_COMMAND('M','G')
    00090 #define NP_CMD  MAKE_COMMAND('N','P')
    00091 #define PA_CMD  MAKE_COMMAND('P','A')
    00092 #define PC_CMD  MAKE_COMMAND('P','C')
    00093 #define PD_CMD  MAKE_COMMAND('P','D')
    00094 #define PE_CMD  MAKE_COMMAND('P','E')
    00095 #define PG_CMD  MAKE_COMMAND('P','G')
    00096 #define PM_CMD  MAKE_COMMAND('P','M')
    00097 #define PP_CMD  MAKE_COMMAND('P','P')
    00098 #define PR_CMD  MAKE_COMMAND('P','R')
    00099 #define PS_CMD  MAKE_COMMAND('P','S')
    00100 #define PU_CMD  MAKE_COMMAND('P','U')
    00101 #define PW_CMD  MAKE_COMMAND('P','W')
    00102 #define RA_CMD  MAKE_COMMAND('R','A')
    00103 #define RO_CMD  MAKE_COMMAND('R','O')
    00104 #define RR_CMD  MAKE_COMMAND('R','R')
    00105 #define RT_CMD  MAKE_COMMAND('R','T')
    00106 #define SA_CMD  MAKE_COMMAND('S','A')
    00107 #define SC_CMD  MAKE_COMMAND('S','C')
    00108 #define SD_CMD  MAKE_COMMAND('S','D')
    00109 #define SI_CMD  MAKE_COMMAND('S','I')
    00110 #define SL_CMD  MAKE_COMMAND('S','L')
    00111 #define SM_CMD  MAKE_COMMAND('S','M')
    00112 #define SP_CMD  MAKE_COMMAND('S','P')
    00113 #define SR_CMD  MAKE_COMMAND('S','R')
    00114 #define SS_CMD  MAKE_COMMAND('S','S')
    00115 #define TR_CMD  MAKE_COMMAND('T','R')
    00116 #define UL_CMD  MAKE_COMMAND('U','L')
    00117 #define WG_CMD  MAKE_COMMAND('W','G')
    00118 #define WU_CMD  MAKE_COMMAND('W','U')
    00119
    00124 typedef struct hpgs_reader_poly_point_st hpgs_reader_poly_point;
    00125
    00131 struct hpgs_reader_poly_point_st
    00132 {
    00133   hpgs_point p;
    00134   int flag;
    00135 };
    00136
    00137 typedef struct hpgs_reader_pcl_palette_st hpgs_reader_pcl_palette;
    00138
    00143 struct hpgs_reader_pcl_palette_st
    00144 {
    00145   hpgs_palette_color colors[256];
    00146   hpgs_palette_color last_color;
    00148   int cid_space;
    00149   int cid_enc;
    00150   int cid_bpi;
    00151   int cid_bpc[3];
    00152 };
    00153
    00160 struct hpgs_reader_st
    00161 {
    00162   hpgs_istream *in;
    00163   hpgs_device *device;
    00164   hpgs_device *plotsize_device;
    00166   int current_page;
    00168   int verbosity;
    00170   double lw_factor;
    00171
    00173   double x_size,y_size; /*@} */
    00176   double frame_x,frame_y; /*@} */
    00177   hpgs_point P1;
    00178   hpgs_point P2;
    00179   hpgs_point delta_P;
    00180   int rotation;
    00182
    00184   int sc_type;
    00185   double sc_xmin;
    00186   double sc_xmax;
    00187   double sc_ymin;
    00188   double sc_ymax;
    00189   double sc_left;
    00190   double sc_bottom;
    00193   int rop3;
    00194   hpgs_bool src_transparency;
    00195   hpgs_bool pattern_transparency;
    00197   hpgs_matrix world_matrix;
    00200   double world_scale;
    00202   hpgs_matrix page_matrix;
    00206   double page_scale;
    00208   hpgs_matrix total_matrix;
    00210   double total_scale;
    00212   int page_mode;
    00214   double page_width;
    00215   double page_height;
    00216   double page_angle;
    00217   double page_border;
    00219   hpgs_bbox page_bbox;
    00220   hpgs_bbox content_bbox;
    00222   void *page_asset_ctxt;
    00223   hpgs_reader_asset_func_t page_asset_func;
    00225   void *frame_asset_ctxt;
    00226   hpgs_reader_asset_func_t frame_asset_func;
    00228
    00230   int   linetype_nsegs[17];
    00231   float linetype_segs[17][20];
    00234
    00236   int npens;
    00237   double *pen_widths;
    00238   hpgs_color *pen_colors;
    00241   hpgs_color min_color;
    00242   hpgs_color max_color;
    00244
    00246   char label_term;
    00247   int  label_term_ignore;
    00250   int polygon_mode;
    00252
    00254   hpgs_reader_poly_point *poly_buffer;
    00255   int poly_buffer_size;
    00256   int poly_buffer_alloc_size;
    00259   int polygon_open;
    00260   int pen_width_relative;
    00261   int pen_down;
    00262   int current_pen;
    00263   int current_linetype;
    00264   int absolute_plotting;
    00265   int have_current_point;
    00266   hpgs_point current_point;
    00268   hpgs_point first_path_point;
    00269   hpgs_point min_path_point;
    00270   hpgs_point max_path_point;
    00271   hpgs_point anchor_point;
    00273   int current_ft;
    00274   double ft3_angle;
    00275   double ft3_spacing;
    00276   double ft4_angle;
    00277   double ft4_spacing;
    00278   double ft10_level;
    00280
    00282   int default_encoding;
    00283   int default_face;
    00284   int default_spacing;
    00285   double default_pitch;
    00286   double default_height;
    00287   int default_posture;
    00288   int default_weight;
    00291
    00293   int alternate_encoding;
    00294   int alternate_face;
    00295   int alternate_spacing;
    00296   double alternate_pitch;
    00297   double alternate_height;
    00298   int alternate_posture;
    00299   int alternate_weight;
    00302   int alternate_font;
    00304
    00306   hpgs_point cr_point;
    00307   hpgs_point current_char_size;
    00308   hpgs_point current_extra_space;
    00309   double current_slant;
    00310   int current_label_origin;
    00311   int current_text_path;
    00312   int current_text_line;
    00313   double current_label_angle;
    00316   double pcl_scale;
    00317   double pcl_hmi;
    00318   double pcl_vmi;
    00319   hpgs_point pcl_point;
    00321   hpgs_reader_pcl_palette **pcl_palettes;
    00322   size_t pcl_n_palettes;
    00323   int pcl_i_palette;
    00325   int pcl_pattern;
    00326   hpgs_palette_color pcl_foreground_color;
    00328   int pcl_raster_mode;
    00330   int pcl_raster_presentation;
    00331   int pcl_raster_src_width;
    00332   int pcl_raster_src_height;
    00333   int pcl_raster_dest_width;
    00334   int pcl_raster_dest_height;
    00335   int pcl_raster_res;
    00336   int pcl_raster_compression;
    00337   int pcl_raster_y_offset;
    00338   int pcl_raster_plane;
    00339   int pcl_raster_line;
    00341   unsigned char *pcl_raster_data[8];
    00342   int pcl_raster_data_size;
    00343   int pcl_raster_planes;
    00346   hpgs_image *pcl_image;
    00348   // The filename for dumped pcl images.
    00349   int png_dump_count;
    00350   char *png_dump_filename;
    00352   int clipsave_depth;
    00354   int last_byte;
    00355   int bytes_ignored;
    00356   int eoc;
    00357   hpgs_bool interrupted;
    00358 };
    00359
    00360 HPGS_INTERNAL_API int hpgs_reader_check_param_end(hpgs_reader *reader);
    00361
    00368 HPGS_INTERNAL_API int hpgs_reader_read_pcl_int(hpgs_reader *reader, int *x, int *sign);
    00369
    00376 HPGS_INTERNAL_API int hpgs_reader_read_int(hpgs_reader *reader, int *x);
    00377
    00384 HPGS_INTERNAL_API int hpgs_reader_read_double(hpgs_reader *reader, double *x);
    00385 HPGS_INTERNAL_API int hpgs_reader_read_point(hpgs_reader *reader, hpgs_point *p, int xform);
    00386
    00393 HPGS_INTERNAL_API int hpgs_reader_read_new_string(hpgs_reader *reader, char *str);
    00394 HPGS_INTERNAL_API int hpgs_reader_read_label_string(hpgs_reader *reader, char *str);
    00395
    00396 HPGS_INTERNAL_API void hpgs_reader_set_page_matrix (hpgs_reader *reader, const hpgs_bbox *bb);
    00397 HPGS_INTERNAL_API void hpgs_reader_set_default_transformation (hpgs_reader *reader);
    00398 HPGS_INTERNAL_API void hpgs_reader_set_default_state (hpgs_reader *reader);
    00399 HPGS_INTERNAL_API void hpgs_reader_set_defaults (hpgs_reader *reader);
    00400 HPGS_INTERNAL_API int hpgs_reader_set_plotsize (hpgs_reader *reader, double xs, double ys);
    00401 HPGS_INTERNAL_API int hpgs_reader_showpage (hpgs_reader *reader, int ipage);
    00402
    00403 HPGS_INTERNAL_API void hpgs_reader_set_std_pen_colors(hpgs_reader *reader,
    00404                                                       int i0, int n);
    00405
    00406 HPGS_INTERNAL_API int hpgs_reader_checkpath(hpgs_reader *reader);
    00407
    00408 HPGS_INTERNAL_API int hpgs_reader_moveto(hpgs_reader *reader, hpgs_point *p);
    00409 HPGS_INTERNAL_API int hpgs_reader_lineto(hpgs_reader *reader, hpgs_point *p);
    00410 HPGS_INTERNAL_API int hpgs_reader_curveto(hpgs_reader *reader,
    00411                                          hpgs_point *p1, hpgs_point *p2, hpgs_point *p3);
    00412 HPGS_INTERNAL_API int hpgs_reader_stroke(hpgs_reader *reader);
    00413 HPGS_INTERNAL_API int hpgs_reader_fill(hpgs_reader *reader, hpgs_bool winding);
    00414 HPGS_INTERNAL_API int hpgs_reader_closepath(hpgs_reader *reader);
    00415
    00416 HPGS_INTERNAL_API int hpgs_reader_do_setpen(hpgs_reader *reader, int pen);
    00417
    00422 HPGS_INTERNAL_API int hpgs_device_setrgb_all(hpgs_device *dev, const hpgs_color *rgb);
    00423
    00424 HPGS_INTERNAL_API int hpgs_reader_label(hpgs_reader *reader,
    00425                                         const char *str, int str_len,
    00426                                         int face,
    00427                                         int encoding,
    00428                                         int posture,
    00429                                         int weight,
    00430                                         const hpgs_point *left_vec,
    00431                                         const hpgs_point *up_vec,
    00432                                         const hpgs_point *space_vec);
    00433
    00434 HPGS_INTERNAL_API int hpgs_device_label(hpgs_device *dev,
    00435                                         hpgs_point *pos,
    00436                                         const char *str, int str_len,
    00437                                         int face,
    00438                                         const char *encoding,
    00439                                         int posture,
    00440                                         int weight,
    00441                                         const hpgs_point *left_vec,
    00442                                         const hpgs_point *up_vec,
    00443                                         const hpgs_point *space_vec);
    00444
    00445 typedef int (*hpgs_reader_hpglcmd_func_t)(hpgs_reader *reader);
    00446
    00447 HPGS_INTERNAL_API int hpgs_reader_do_PCL(hpgs_reader *reader, hpgs_bool take_pos);
    00448 HPGS_INTERNAL_API int hpgs_reader_do_PJL(hpgs_reader *reader);
    00449
    00450 HPGS_INTERNAL_API int hpgs_reader_push_pcl_palette (hpgs_reader *reader);
    00451 HPGS_INTERNAL_API int hpgs_reader_pop_pcl_palette (hpgs_reader *reader);
    00452
    00453 HPGS_INTERNAL_API int hpgs_reader_do_AA(hpgs_reader *reader);
    00454 HPGS_INTERNAL_API int hpgs_reader_do_AC(hpgs_reader *reader);
    00455 HPGS_INTERNAL_API int hpgs_reader_do_AD(hpgs_reader *reader);
    00456 HPGS_INTERNAL_API int hpgs_reader_do_AR(hpgs_reader *reader);
    00457 HPGS_INTERNAL_API int hpgs_reader_do_AT(hpgs_reader *reader);
    00458 HPGS_INTERNAL_API int hpgs_reader_do_BP(hpgs_reader *reader);
    00459 HPGS_INTERNAL_API int hpgs_reader_do_BR(hpgs_reader *reader);
    00460 HPGS_INTERNAL_API int hpgs_reader_do_BZ(hpgs_reader *reader);
    00461 HPGS_INTERNAL_API int hpgs_reader_do_CI(hpgs_reader *reader);
    00462 HPGS_INTERNAL_API int hpgs_reader_do_CO(hpgs_reader *reader);
    00463 HPGS_INTERNAL_API int hpgs_reader_do_CP(hpgs_reader *reader);
    00464 HPGS_INTERNAL_API int hpgs_reader_do_CR(hpgs_reader *reader);
    00465 HPGS_INTERNAL_API int hpgs_reader_do_DI(hpgs_reader *reader);
    00466 HPGS_INTERNAL_API int hpgs_reader_do_DR(hpgs_reader *reader);
    00467 HPGS_INTERNAL_API int hpgs_reader_do_DT(hpgs_reader *reader);
    00468 HPGS_INTERNAL_API int hpgs_reader_do_DV(hpgs_reader *reader);
    00469 HPGS_INTERNAL_API int hpgs_reader_do_EA(hpgs_reader *reader);
    00470 HPGS_INTERNAL_API int hpgs_reader_do_EP(hpgs_reader *reader);
    00471 HPGS_INTERNAL_API int hpgs_reader_do_ER(hpgs_reader *reader);
    00472 HPGS_INTERNAL_API int hpgs_reader_do_ES(hpgs_reader *reader);
    00473 HPGS_INTERNAL_API int hpgs_reader_do_EW(hpgs_reader *reader);
    00474 HPGS_INTERNAL_API int hpgs_reader_do_FP(hpgs_reader *reader);
    00475 HPGS_INTERNAL_API int hpgs_reader_do_FR(hpgs_reader *reader);
    00476 HPGS_INTERNAL_API int hpgs_reader_do_FT(hpgs_reader *reader);
    00477 HPGS_INTERNAL_API int hpgs_reader_do_IN(hpgs_reader *reader);
    00478 HPGS_INTERNAL_API int hpgs_reader_do_IP(hpgs_reader *reader);
    00479 HPGS_INTERNAL_API int hpgs_reader_do_IR(hpgs_reader *reader);
    00480 HPGS_INTERNAL_API int hpgs_reader_do_IW(hpgs_reader *reader);
    00481 HPGS_INTERNAL_API int hpgs_reader_do_LA(hpgs_reader *reader);
    00482 HPGS_INTERNAL_API int hpgs_reader_do_LB(hpgs_reader *reader);
    00483 HPGS_INTERNAL_API int hpgs_reader_do_LO(hpgs_reader *reader);
    00484 HPGS_INTERNAL_API int hpgs_reader_do_LT(hpgs_reader *reader);
    00485 HPGS_INTERNAL_API int hpgs_reader_do_MC(hpgs_reader *reader);
    00486 HPGS_INTERNAL_API int hpgs_reader_do_MG(hpgs_reader *reader);
    00487 HPGS_INTERNAL_API int hpgs_reader_do_NP(hpgs_reader *reader);
    00488 HPGS_INTERNAL_API int hpgs_reader_do_PC(hpgs_reader *reader);
    00489 HPGS_INTERNAL_API int hpgs_reader_do_PA(hpgs_reader *reader);
    00490 HPGS_INTERNAL_API int hpgs_reader_do_PD(hpgs_reader *reader);
    00491 HPGS_INTERNAL_API int hpgs_reader_do_PE(hpgs_reader *reader);
    00492 HPGS_INTERNAL_API int hpgs_reader_do_PG(hpgs_reader *reader);
    00493 HPGS_INTERNAL_API int hpgs_reader_do_PM(hpgs_reader *reader);
    00494 HPGS_INTERNAL_API int hpgs_reader_do_PP(hpgs_reader *reader);
    00495 HPGS_INTERNAL_API int hpgs_reader_do_PR(hpgs_reader *reader);
    00496 HPGS_INTERNAL_API int hpgs_reader_do_PS(hpgs_reader *reader);
    00497 HPGS_INTERNAL_API int hpgs_reader_do_PU(hpgs_reader *reader);
    00498 HPGS_INTERNAL_API int hpgs_reader_do_PW(hpgs_reader *reader);
    00499 HPGS_INTERNAL_API int hpgs_reader_do_RA(hpgs_reader *reader);
    00500 HPGS_INTERNAL_API int hpgs_reader_do_RO(hpgs_reader *reader);
    00501 HPGS_INTERNAL_API int hpgs_reader_do_RR(hpgs_reader *reader);
    00502 HPGS_INTERNAL_API int hpgs_reader_do_RT(hpgs_reader *reader);
    00503 HPGS_INTERNAL_API int hpgs_reader_do_SA(hpgs_reader *reader);
    00504 HPGS_INTERNAL_API int hpgs_reader_do_SC(hpgs_reader *reader);
    00505 HPGS_INTERNAL_API int hpgs_reader_do_SD(hpgs_reader *reader);
    00506 HPGS_INTERNAL_API int hpgs_reader_do_SI(hpgs_reader *reader);
    00507 HPGS_INTERNAL_API int hpgs_reader_do_SL(hpgs_reader *reader);
    00508 HPGS_INTERNAL_API int hpgs_reader_do_SM(hpgs_reader *reader);
    00509 HPGS_INTERNAL_API int hpgs_reader_do_SP(hpgs_reader *reader);
    00510 HPGS_INTERNAL_API int hpgs_reader_do_SR(hpgs_reader *reader);
    00511 HPGS_INTERNAL_API int hpgs_reader_do_SS(hpgs_reader *reader);
    00512 HPGS_INTERNAL_API int hpgs_reader_do_TR(hpgs_reader *reader);
    00513 HPGS_INTERNAL_API int hpgs_reader_do_UL(hpgs_reader *reader);
    00514 HPGS_INTERNAL_API int hpgs_reader_do_WG(hpgs_reader *reader);
    00515 HPGS_INTERNAL_API int hpgs_reader_do_WU(hpgs_reader *reader);
    00516  /* end of group reader */
    00518
    00519 #ifdef __cplusplus
    00520 } // end of extern "C"
    00521 #endif
    00522
    00523 #endif // ! __HPGS_READER_H__