/* This file is part of the GNU plotutils package. Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc. The GNU plotutils package is free software. You may redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software foundation; either version 2, or (at your option) any later version. The GNU plotutils package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU plotutils package; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor, Boston, MA 02110-1301, USA. */ /* This is "plotter.h", the public header file for the C++ Plotter class provided by GNU libplotter, a shared class library for 2-dimensional vector graphics. This file should be included by any code that uses the Plotter class. If the Plotter class was installed without X Window System support, be sure to do "#define X_DISPLAY_MISSING" before including this file. From the base Plotter class, the BitmapPlotter, MetaPlotter, TekPlotter, ReGISPlotter, HPGLPlotter, FigPlotter, CGMPlotter, PSPlotter, AIPlotter, SVGPlotter, GIFPlotter, PNMPlotter, PNGPlotter, and XDrawablePlotter classes are derived. The PNMPlotter and PNGPlotter classes are derived from the BitmapPlotter class, the PCLPlotter class is derived from the HPGLPlotter class, and the XPlotter class is derived from the XDrawablePlotter class. */ /* If NOT_LIBPLOTTER is defined, this file magically becomes an internal header file used in GNU libplot, the C version of libplotter. libplot has its own public header file, called "plot.h". */ /* Implementation note: In libplot, a Plotter is a typedef'd structure rather than a class instance. Because of the need to support both libplot and libplotter, i.e. C and C++, all data members of derived Plotter classes are declared in this file twice: once in the Plotter structure (for C), and once in each derived class declaration (for C++). */ #ifndef _PLOTTER_H_ #define _PLOTTER_H_ 1 /***********************************************************************/ /* Version of GNU libplot/libplotter which this header file accompanies. This information is included beginning with version 4.0. The PL_LIBPLOT_VER_STRING macro is compiled into the library, as `pl_libplot_ver'. The PL_LIBPLOT_VER macro is not compiled into it. Both are available to applications that include this header file. */ #define PL_LIBPLOT_VER_STRING "4.4" #define PL_LIBPLOT_VER 404 extern const char pl_libplot_ver[8]; /* need room for 99.99aa */ /***********************************************************************/ /* If we're supporting X, include X-related header files needed by the class definition. */ #ifndef X_DISPLAY_MISSING #include #include #endif /* not X_DISPLAY_MISSING */ /* Include stdio and iostream support if this is libplotter rather than libplot. */ #ifndef NOT_LIBPLOTTER #include #include using namespace std; #endif /* THE GLOBAL VARIABLES IN GNU LIBPLOTTER */ /* There are two; both are user-settable error handlers. */ #ifndef NOT_LIBPLOTTER extern int (*pl_libplotter_warning_handler) (const char *msg); extern int (*pl_libplotter_error_handler) (const char *msg); #endif /***********************************************************************/ /* Structures for points. */ typedef struct { double x, y; } plPoint; typedef struct { int x, y; } plIntPoint; /* Structures for paths, as painted by any Plotter. */ /* Normally, a simple path is a sequence of contiguous line segments, circular arc segments, elliptic arc segments, quadratic Bezier segments, or cubic Bezier segments. All Plotters support line segments, but many Plotters don't support the other types of segment. Some Plotters also support (closed) simple paths that are single circles, ellipses, or "boxes" (rectangles aligned with the coordinate axes). A simple path that is a sequence of segments is represented internally as a list of plPathSegments. Each contains a single endpoint (x,y), and specifies how to get there (e.g., via a pen-up motion, which is used for the first point in a path, or via a line segment, or a curve defined by control points). A well-formed simple path of this `segment list' type has the form: { moveto { line | arc | ellarc | quad | cubic }* { closepath }? } */ /* Allowed values for the path segment type field. */ typedef enum { S_MOVETO, S_LINE, S_ARC, S_ELLARC, S_QUAD, S_CUBIC, S_CLOSEPATH } plPathSegmentType; /* Structure for a path segment. */ typedef struct { plPathSegmentType type; plPoint p; /* endpoint of segment */ plPoint pc; /* intermediate control point (if any) */ plPoint pd; /* additional control point (S_CUBIC only) */ } plPathSegment; /* Allowed values for the path type field in a plPath (see below). */ typedef enum { PATH_SEGMENT_LIST, /* the default kind */ PATH_CIRCLE, PATH_ELLIPSE, PATH_BOX /* supported by some Plotters */ } plPathType; /* Structure for a simple path. The default kind of simple path is a list of segments. However, a simple path may also be a circle, ellipse, or box, which some Plotter support as primitive drawing elements, at least under some circumstances. Other Plotters automatically flatten these built-in primitives into segment lists. The advisory `primitive' flag is set to `true' to indicate that a segment list is in fact such a flattened object. */ typedef struct { plPathType type; /* PATH_{SEGMENT_LIST,CIRCLE,ELLIPSE,BOX} */ double llx, lly, urx, ury; /* bounding box */ /* simple path of segment list type */ plPathSegment *segments; /* list of path segments */ int num_segments; /* number of segments in list */ int segments_len; /* length of buffer for list storage (bytes) */ bool primitive; /* advisory (see above; some Plotters use it)*/ /* simple path of built-in primitive type (circle/ellipse/box) */ plPoint pc; /* CIRCLE/ELLIPSE: center */ double radius; /* CIRCLE: radius */ double rx, ry; /* ELLIPSE: semi-axes */ double angle; /* ELLIPSE: angle of first axis */ plPoint p0, p1; /* BOX: opposite vertices */ bool clockwise; /* CIRCLE/ELLIPSE/BOX: clockwise? */ } plPath; /* An integer counterpart to plPathSegment, used by some Plotters during the mapping of segment-list paths to the device frame. This shouldn't be defined here, since it's so Plotter-specific. */ typedef struct { plPathSegmentType type; plIntPoint p; /* endpoint of segment */ plIntPoint pc; /* intermediate control point (if any) */ plIntPoint pd; /* additional control point (S_CUBIC only) */ double angle; /* subtended angle (for S_ARC, if used) */ } plIntPathSegment; /* Values for the parameters `allowed_{arc|ellarc|quad|cubic}_scaling' of any Plotter. Those parameters specify which sorts of user frame -> device frame affine transformation are allowed, if an arc or Bezier that is part of a path is to be placed in the path buffer's segment list as a single segment, rather than approximated as a polyline. These are also the possible values for the parameters allowed_{circle|ellipse|box}_scaling' of any Plotter, which specify whether any circle/ellipse/box should be placed in the path buffer as a primitive, rather than split into arc segments or line segments and placed in the segment list. The reason for extensively parametrizing the internal operation of any Plotter (i.e. restricting what gets placed in its path buffer) is that for many Plotters, the Plotter-specific operation _paint_path(), which is called by endpath(), can't handle arbitrary drawing primitives, because the Plotter's output format doesn't support them. The values AS_UNIFORM and AS_AXES_PRESERVED aren't used for Beziers, but they're used for the other primitives. Also, insofar as ellipses go, a value of AS_AXES_PRESERVED for the allowed scaling is intepreted as meaning that not only should the affine map preserve coordinate axes, but the ellipse itself, to be placed in the path buffer, should have its major and minor axes aligned with the coordinate axes. See g_ellipse.c. */ typedef enum { AS_NONE, /* primitive not supported at all */ AS_UNIFORM, /* supported only if transf. is uniform */ AS_AXES_PRESERVED, /* supported only if transf. preserves axes */ AS_ANY /* supported irrespective of transformation */ } plScalingType; /**********************************************************************/ /* Structures for colors (we don't fully distinguish between 24-bit color and 48-bit color, though we should). */ /* RGB */ typedef struct { int red; int green; int blue; } plColor; /* BitmapPlotters (including PNMPlotters and PNGPlotters, which are derived) and GIFPlotters use the libxmi scan-conversion library, which is compiled into libplot/libplotter. libxmi writes into a pixmap that is made up of the following type of pixel. We use a struct containing a union, so that the compiled-in libxmi can be used both by GIF Plotters (in which pixel values are color indices) and by BitmapPlotters (in which pixel values are 24-bit RGB values). We distinguish them by the `type' field. */ #define MI_PIXEL_TYPE struct \ { \ unsigned char type; \ union \ { \ unsigned char index; \ unsigned char rgb[3]; \ } u; \ } /* values for the `type' field */ #define MI_PIXEL_INDEX_TYPE 0 #define MI_PIXEL_RGB_TYPE 1 #define MI_SAME_PIXEL(pixel1,pixel2) \ (((pixel1).type == MI_PIXEL_INDEX_TYPE \ && (pixel2).type == MI_PIXEL_INDEX_TYPE \ && (pixel1).u.index == (pixel2).u.index) \ || \ ((pixel1).type == MI_PIXEL_RGB_TYPE \ && (pixel2).type == MI_PIXEL_RGB_TYPE \ && (pixel1).u.rgb[0] == (pixel2).u.rgb[0] \ && (pixel1).u.rgb[1] == (pixel2).u.rgb[1] \ && (pixel1).u.rgb[2] == (pixel2).u.rgb[2])) /**********************************************************************/ /* Structure used for characterizing a page type (e.g. "letter", "a4"; see our database of known page types in g_pagetype.h). Any Plotter includes a pointer to one of these. For all `physical' Plotters, i.e. those with a page type determined by the PAGESIZE parameter, we map the window that the user specifies by invoking space(), to a viewport whose default size is fixed and Plotter-independent. E.g., for any Plotter for which PAGESIZE is "letter", the default viewport is a square of size 8.0in x 8.0in. All physical Plotters position this default viewport at the center of the page, except that HPGLPlotters don't know exactly where the origin of the device coordinate system is. PCLPlotters do, though, when they're emitting HP-GL/2 code (there's a field in the struct that specifies that, see below). See comments in g_pagetype.h. */ typedef struct { const char *name; /* official name, e.g. "a" */ const char *alt_name; /* alternative name if any, e.g. "letter" */ const char *fig_name; /* name used in Fig format (case-sensitive) */ bool metric; /* metric vs. Imperial, advisory only */ double xsize, ysize; /* width, height in inches */ double default_viewport_size; /* size of default square viewport, in inches*/ double pcl_hpgl2_xorigin; /* origin for HP-GL/2-in-PCL5 plotting */ double pcl_hpgl2_yorigin; double hpgl2_plot_length; /* plot length (for HP-GL/2 roll plotters) */ } plPageData; /* Structure in which the user->NDC and user->device affine coordinate transformations are stored. Any drawing state includes one of these structures. The user->NDC transformation is a bit more fundamental, since it's used as an attribute of all objects that get drawn. The user->device transformation is the product of the user->NDC transformation and the NDC->device transformation (stored in the Plotter itself, since it never changes after being initialized at Plotter creation time). The reason we precompute the user->device transformation and store it here is that we use it so frequently. */ typedef struct { /* the user->NDC transformation */ double m_user_to_ndc[6]; /* 1. a linear transformation (4 elements) */ /* 2. a translation (2 elements) */ /* the user->device transformation, precomputed for convenience */ double m[6]; /* data on user->device map, also precomputed for convenience */ bool uniform; /* transf. scaling is uniform? */ bool axes_preserved; /* transf. preserves axis directions? */ bool nonreflection; /* transf. doesn't involve a reflection? */ } plTransform; /**********************************************************************/ /* Drawing state structure. Includes drawing attributes, and the state of any uncompleted path object. When open, i.e., when drawing a page of graphics, any Plotter maintains a stack of these things. Many of the data members are device-dependent, i.e., specific to individual derived Plotter classes, but it's more efficient to keep them here, in a single structure. The device-independent data members are listed first. */ typedef struct plDrawStateStruct { /***************** DEVICE-INDEPENDENT PART ***************************/ /* graphics cursor position */ plPoint pos; /* graphics cursor position in user space */ /* affine transformation from user coordinates to normalized device coordinates, and also to actual device coordinates (precomputed) */ plTransform transform; /* see definition of structure above */ /* the compound path being drawn, if any */ plPath *path; /* simple path being drawn */ plPath **paths; /* previously drawn simple paths */ int num_paths; /* number of previously drawn simple paths */ plPoint start_point; /* starting point (used by closepath()) */ /* modal drawing attributes */ /* 1. path-related attributes */ const char *fill_rule; /* fill rule */ int fill_rule_type; /* one of PL_FILL_*, determined by fill rule */ const char *line_mode; /* line mode */ int line_type; /* one of PL_L_*, determined by line mode */ bool points_are_connected; /* if not set, path displayed as points */ const char *cap_mode; /* cap mode */ int cap_type; /* one of PL_CAP_*, determined by cap mode */ const char *join_mode; /* join mode */ int join_type; /* one of PL_JOIN_*, determined by join mode */ double miter_limit; /* miter limit for line joins */ double line_width; /* width of lines in user coordinates */ bool line_width_is_default; /* line width is (Plotter-specific) default? */ double device_line_width; /* line width in device coordinates */ int quantized_device_line_width; /* line width, quantized to integer */ const double *dash_array; /* array of dash on/off lengths (nonnegative)*/ int dash_array_len; /* length of same */ double dash_offset; /* offset distance into dash array (`phase') */ bool dash_array_in_effect; /* dash array should override line mode? */ int pen_type; /* pen type (0 = no pen, 1 = pen) */ int fill_type; /* fill type (0 = no fill, 1 = fill, ...) */ int orientation; /* orientation of circles etc.(1=c'clockwise)*/ /* 2. text-related attributes */ const char *font_name; /* font name */ double font_size; /* font size in user coordinates */ bool font_size_is_default; /* font size is (Plotter-specific) default? */ double text_rotation; /* degrees counterclockwise, for labels */ const char *true_font_name; /* true font name (as retrieved) */ double true_font_size; /* true font size (as retrieved) */ double font_ascent; /* font ascent (as retrieved) */ double font_descent; /* font descent (as retrieved) */ double font_cap_height; /* font capital height (as received) */ int font_type; /* PL_F_{HERSHEY|POSTSCRIPT|PCL|STICK|OTHER} */ int typeface_index; /* typeface index (in g_fontdb.h table) */ int font_index; /* font index, within typeface */ bool font_is_iso8859_1; /* whether font uses iso8859_1 encoding */ /* 3. color attributes (fgcolor and fillcolor are path-related; fgcolor affects other primitives too) */ plColor fgcolor; /* foreground color, i.e., pen color */ plColor fillcolor_base; /* fill color (not affected by fill_type) */ plColor fillcolor; /* fill color (takes fill_type into account) */ plColor bgcolor; /* background color for graphics display */ bool bgcolor_suppressed; /* no actual background color? */ /* default values for certain attributes, used when an out-of-range value is requested (these two are special because they're set by fsetmatrix()) */ double default_line_width; /* width of lines in user coordinates */ double default_font_size; /* font size in user coordinates */ /****************** DEVICE-DEPENDENT PART ***************************/ /* elements specific to the HPGL Plotter drawing state */ double hpgl_pen_width; /* pen width (frac of diag dist betw P1,P2) */ /* elements specific to the Fig Plotter drawing state */ int fig_font_point_size; /* font size in fig's idea of points */ int fig_fill_level; /* fig's fill level */ int fig_fgcolor; /* fig's foreground color */ int fig_fillcolor; /* fig's fill color */ /* elements specific to the PS Plotter drawing state */ double ps_fgcolor_red; /* RGB for fgcolor, each in [0.0,1.0] */ double ps_fgcolor_green; double ps_fgcolor_blue; double ps_fillcolor_red; /* RGB for fillcolor, each in [0.0,1.0] */ double ps_fillcolor_green; double ps_fillcolor_blue; int ps_idraw_fgcolor; /* index of idraw fgcolor in table */ int ps_idraw_bgcolor; /* index of idraw bgcolor in table */ int ps_idraw_shading; /* index of idraw shading in table */ /* elements specific to the GIF Plotter drawing state */ plColor i_pen_color; /* pen color (24-bit RGB) */ plColor i_fill_color; /* fill color (24-bit RGB) */ plColor i_bg_color; /* background color (24-bit RGB) */ unsigned char i_pen_color_index; /* pen color index */ unsigned char i_fill_color_index; /* fill color index */ unsigned char i_bg_color_index; /* bg color index */ bool i_pen_color_status; /* foreground color index is genuine? */ bool i_fill_color_status; /* fill color index is genuine? */ bool i_bg_color_status; /* background color index is genuine? */ #ifndef X_DISPLAY_MISSING /* elements specific to the X Drawable Plotter drawing state */ unsigned int x_font_pixel_size; /* pixel size according to server */ XFontStruct *x_font_struct; /* font structure (used in x_text.c) */ const unsigned char *x_label; /* label (hint to _x_retrieve_font()) */ GC x_gc_fg; /* graphics context, for drawing */ GC x_gc_fill; /* graphics context, for filling */ GC x_gc_bg; /* graphics context, for erasing */ plColor x_current_fgcolor; /* pen color stored in GC (48-bit RGB) */ plColor x_current_fillcolor; /* fill color stored in GC (48-bit RGB) */ plColor x_current_bgcolor; /* bg color stored in GC (48-bit RGB) */ unsigned long x_gc_fgcolor; /* color stored in drawing GC (pixel value) */ unsigned long x_gc_fillcolor; /* color stored in filling GC (pixel value) */ unsigned long x_gc_bgcolor; /* color stored in erasing GC (pixel value) */ bool x_gc_fgcolor_status; /* pixel value in drawing GC is genuine? */ bool x_gc_fillcolor_status; /* pixel value in filling GC is genuine? */ bool x_gc_bgcolor_status; /* pixel value in erasing GC is genuine? */ int x_gc_line_style; /* line style stored in drawing GC */ int x_gc_cap_style; /* cap style stored in drawing GC */ int x_gc_join_style; /* join style stored in drawing GC */ int x_gc_line_width; /* line width stored in drawing GC */ const char *x_gc_dash_list; /* dash list stored in drawing GC */ int x_gc_dash_list_len; /* length of dash list stored in drawing GC */ int x_gc_dash_offset; /* offset into dash sequence, in drawing GC */ int x_gc_fill_rule; /* fill rule stored in filling GC */ #endif /* not X_DISPLAY_MISSING */ /* pointer to previous drawing state */ struct plDrawStateStruct *previous; } plDrawState; /**********************************************************************/ /* An output buffer that may easily be resized. Used by most Plotters that do not do real-time output, to store device code for all graphical objects plotted on a page, and page-specific data such as the bounding box and `fonts used' information. (See e.g. g_outbuf.c.) Plotters that wait until they are deleted before outputing graphics, e.g. PSPlotters and CGMPlotters, maintain not just one of these things but rather a linked list, one output buffer per page. */ /* NUM_PS_FONTS and NUM_PCL_FONTS should agree with the number of fonts of each type in g_fontdb.c. These are also defined in libplot/extern.h. */ #define NUM_PS_FONTS 35 #define NUM_PCL_FONTS 45 typedef struct plOutbufStruct { /* if non-NULL, a plOutbuf containing a page header */ struct plOutbufStruct *header; /* if non-NULL, a plOutbuf containing a page trailer */ struct plOutbufStruct *trailer; /* device code for the graphics on the page */ char *base; /* start of buffer */ unsigned long len; /* size of buffer */ char *point; /* current point (high-water mark) */ char *reset_point; /* point below which contents are frozen */ unsigned long contents; /* size of contents */ unsigned long reset_contents; /* size of frozen contents if any */ /* page-specific information that some Plotters generate and use (this is starting to look like a Christmas tree...) */ double xrange_min; /* bounding box, in device coordinates */ double xrange_max; double yrange_min; double yrange_max; bool ps_font_used[NUM_PS_FONTS]; /* PS fonts used on page */ bool pcl_font_used[NUM_PCL_FONTS]; /* PCL fonts used on page */ plColor bg_color; /* background color for the page */ bool bg_color_suppressed; /* background color is "none"? */ /* a hook for Plotters to hang other page-specific data */ void * extra; /* pointer to previous Outbuf in page list if any */ struct plOutbufStruct *next; } plOutbuf; /* Each Plotter caches the color names that have previously been mapped to RGB triples via libplot's colorname database (see g_colorname.h). For the cache, a linked list is currently used. */ typedef struct { const char *name; unsigned char red; unsigned char green; unsigned char blue; } plColorNameInfo; typedef struct plCachedColorNameInfoStruct { const plColorNameInfo *info; struct plCachedColorNameInfoStruct *next; } plCachedColorNameInfo; typedef struct { plCachedColorNameInfo *cached_colors; /* head of linked list */ } plColorNameCache; #ifndef X_DISPLAY_MISSING /* Each X DrawablePlotter (or X Plotter) keeps track of which fonts have been request from an X server, in any connection, by constructing a linked list of these records. A linked list is good enough if we don't have huge numbers of font changes. */ typedef struct plXFontRecordStruct { char *x_font_name; /* font name, preferably an XLFD name */ XFontStruct *x_font_struct; /* font structure */ unsigned int x_font_pixel_size; unsigned int x_font_cap_height; bool x_font_is_iso8859_1; bool subset; /* did we retrieve a subset of the font? */ unsigned char subset_vector[32]; /* 256-bit vector, 1 bit per font char */ struct plXFontRecordStruct *next; /* most recently retrieved font */ } plXFontRecord; /* Allocated color cells are kept track of similarly */ typedef struct plColorRecordStruct { XColor rgb; /* RGB value and pixel value (if any) */ bool allocated; /* pixel value successfully allocated? */ int frame_number; /* frame that cell was most recently used in*/ int page_number; /* page that cell was most recently used in*/ struct plColorRecordStruct *next; /* most recently retrieved color cell */ } plColorRecord; #endif /* not X_DISPLAY_MISSING */ /***********************************************************************/ /* The Plotter class, and also its derived classes (in libplotter). In libplot, a Plotter is a struct, and there are no derived classes; the data members of the derived classes are located inside the Plotter structure. */ /* A few miscellaneous constants that appear in the declaration of the Plotter class (should be moved elsewhere if possible). */ /* Number of recognized Plotter parameters (see g_params2.c). */ #define NUM_PLOTTER_PARAMETERS 33 /* Maximum number of pens, or logical pens, for an HP-GL/2 device. Some such devices permit as many as 256, but all should permit at least 32. Our pen numbering will range over 0..HPGL2_MAX_NUM_PENS-1. */ #define HPGL2_MAX_NUM_PENS 32 /* Maximum number of non-builtin colors that can be specified in an xfig input file. See also FIG_NUM_STD_COLORS, defined in libplot/extern.h. */ #define FIG_MAX_NUM_USER_COLORS 512 /* Supported Plotter types. These values are used in a `tag field', in libplot but not libplotter. (C++ doesn't have such things, at least it didn't until RTTI was invented :-)). */ #ifdef NOT_LIBPLOTTER typedef enum { PL_GENERIC, /* instance of base Plotter class */ PL_BITMAP, /* bitmap class, derived from by PNM and PNG */ PL_META, /* GNU graphics metafile */ PL_TEK, /* Tektronix 4014 with EGM */ PL_REGIS, /* ReGIS (remote graphics instruction set) */ PL_HPGL, /* HP-GL and HP-GL/2 */ PL_PCL, /* PCL 5 (i.e. HP-GL/2 w/ header, trailer) */ PL_FIG, /* xfig 3.2 */ PL_CGM, /* CGM (Computer Graphics Metafile) */ PL_PS, /* Postscript, with idraw support */ PL_AI, /* Adobe Illustrator 5 (or 3) */ PL_SVG, /* Scalable Vector Graphics */ PL_GIF, /* GIF 87a or 89a */ PL_PNM /* Portable Anymap Format (PBM/PGM/PPM) */ #ifdef INCLUDE_PNG_SUPPORT , PL_PNG /* PNG: Portable Network Graphics */ #endif #ifndef X_DISPLAY_MISSING , PL_X11_DRAWABLE /* X11 Drawable */ , PL_X11 /* X11 (pops up, manages own window[s]) */ #endif } plPlotterTag; #endif /* NOT_LIBPLOTTER */ /* Types of Plotter output model. The `output_model' data element in any Plotter class specifies the output model, and the libplot machinery takes it from there. In particular, plOutbuf structures (one per page) are maintained if necessary, and written out at the appropriate time. Note: in the PAGES_ALL_AT_ONCE, OUTPUT_VIA_CUSTOM_ROUTINES* cases, the Plotter is responsible for managing its own output. In the PAGES_ALL_AT_ONCE case, libplot maintains not just one but an entire linked list of plOutbuf's, to be scanned over by the derived Plotter at deletion time. */ typedef enum { PL_OUTPUT_NONE, /* No output at all; Plotter is used primarily for subclassing. E.g., generic and Bitmap Plotters. */ PL_OUTPUT_ONE_PAGE, /* Plotter produces at most one page of output (the first), and uses libplot's builtin plOutbuf-based output mechanism. The first page, which is written to a plOutbuf, is written out by the first invocation of closepl(), and all later pages are ignored. E.g., Fig, Illustrator, and SVG Plotters. */ PL_OUTPUT_ONE_PAGE_AT_A_TIME, /* Plotter produces any number of pages of output, and uses libplot's builtin plOutbuf-based output mechanism. Each page is written out as soon as closepl() is called on it. E.g., HP-GL/PCL Plotters. */ PL_OUTPUT_PAGES_ALL_AT_ONCE, /* Plotter produces any number of pages of output, and uses libplot's builtin plOutbuf-based output mechanism. But pages are written out only when the Plotter is deleted, i.e., when the internal terminate() function is called. (Actually, it's the generic-class terminate(), which any derived-class terminate() calls, that does it.) Because all pages need to be stored, a linked list of plOutbuf's is created, one per page. E.g., PS and CGM Plotters. */ PL_OUTPUT_VIA_CUSTOM_ROUTINES, /* Plotter uses its own output routines to write one or possibly more pages to its output stream, as whole pages (i.e., when closepl() is called). It doesn't use libplot's plOutbuf-based output routines. E.g., PNM, GIF, and PNG Plotters (all of which output only 1 page). */ PL_OUTPUT_VIA_CUSTOM_ROUTINES_IN_REAL_TIME, /* Plotter uses its own output routines to write to its output stream, in real time. It doesn't use libplot's plOutbuf-based output routines. E.g., Metafile, Tektronix, and ReGIS Plotters. */ PL_OUTPUT_VIA_CUSTOM_ROUTINES_TO_NON_STREAM /* Plotter uses its own output routines to write to something other than an output stream, which must presumably be passed to it as a Plotter parameter. May or may not plot in real time. E.g., X Drawable and X Plotters (both of which plot in real time). */ } plPlotterOutputModel; /* Plotter data. These data members of any Plotter object are stuffed into a single struct, for convenience. Most of them are initialized by the initialize() method, and don't change thereafter. So they're really parameters: they define the functioning of any Plotter. A few of these, e.g. the `page' member, do change at later times. But it's the core Plotter code that changes them; not the device-specific drivers. They're flagged by D: (i.e. dynamic), in their description. */ typedef struct { /* data members (a great many!) which are really Plotter parameters */ #ifdef NOT_LIBPLOTTER /* tag field */ plPlotterTag type; /* Plotter type: one of PL_* defined above */ #endif /* NOT_LIBPLOTTER */ /* low-level I/O issues */ plPlotterOutputModel output_model;/* one of PL_OUTPUT_* (see above) */ FILE *infp; /* stdio-style input stream if any */ FILE *outfp; /* stdio-style output stream if any */ FILE *errfp; /* stdio-style error stream if any */ #ifndef NOT_LIBPLOTTER istream *instream; /* C++-style input stream if any */ ostream *outstream; /* C++-style output stream if any */ ostream *errstream; /* C++-style error stream if any */ #endif /* not NOT_LIBPLOTTER */ /* device driver parameters (i.e., instance copies of class variables) */ void * params[NUM_PLOTTER_PARAMETERS]; /* (mostly) user-queryable capabilities: 0/1/2 = no/yes/maybe */ int have_wide_lines; int have_dash_array; int have_solid_fill; int have_odd_winding_fill; int have_nonzero_winding_fill; int have_settable_bg; int have_escaped_string_support; /* can plot labels containing escapes? */ int have_ps_fonts; int have_pcl_fonts; int have_stick_fonts; int have_extra_stick_fonts; int have_other_fonts; /* text and font-related parameters (internal, not queryable by user) */ int default_font_type; /* PL_F_{HERSHEY|POSTSCRIPT|PCL|STICK} */ bool pcl_before_ps; /* PCL fonts searched first? (if applicable) */ bool have_horizontal_justification; /*device can justify text horizontally?*/ bool have_vertical_justification; /* device can justify text vertically? */ bool kern_stick_fonts; /* device kerns variable-width HP vector fonts?*/ bool issue_font_warning; /* issue warning on font substitution? */ /* path-related parameters (also internal) */ int max_unfilled_path_length; /* user-settable, for unfilled polylines */ bool have_mixed_paths; /* can mix arcs/Beziers and lines in paths? */ plScalingType allowed_arc_scaling; /* scaling allowed for circular arcs */ plScalingType allowed_ellarc_scaling; /* scaling allowed for elliptic arcs */ plScalingType allowed_quad_scaling; /*scaling allowed for quadratic Beziers*/ plScalingType allowed_cubic_scaling; /* scaling allowed for cubic Beziers */ plScalingType allowed_box_scaling; /* scaling allowed for boxes */ plScalingType allowed_circle_scaling; /* scaling allowed for circles */ plScalingType allowed_ellipse_scaling; /* scaling allowed for ellipses */ /* color-related parameters (also internal) */ bool emulate_color; /* emulate color by grayscale? */ /* cache of previously retrieved color names (used for speed) */ plColorNameCache *color_name_cache;/* pointer to color name cache */ /* info on the device coordinate frame (ranges for viewport in terms of native device coordinates, etc.; note that if flipped_y=true, then jmax