1 //	Contains declarations for PLStream and PLDev structs.
2 //	Also prototypes for stream & device utility functions.
3 //
4 //  Copyright (C) 2004  Andrew Ross
5 //  Copyright (C) 2004  Andrew Roach
6 //
7 //  This file is part of PLplot.
8 //
9 //  PLplot is free software; you can redistribute it and/or modify
10 //  it under the terms of the GNU Library General Public License as published
11 //  by the Free Software Foundation; either version 2 of the License, or
12 //  (at your option) any later version.
13 //
14 //  PLplot is distributed in the hope that it will be useful,
15 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 //  GNU Library General Public License for more details.
18 //
19 //  You should have received a copy of the GNU Library General Public License
20 //  along with PLplot; if not, write to the Free Software
21 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 
24 #include "pdf.h"
25 
26 #ifndef __PLSTRM_H__
27 #define __PLSTRM_H__
28 
29 #include "disptab.h"
30 #include "pldll.h"
31 #include "qsastime.h"
32 
33 //--------------------------------------------------------------------------
34 // Define the PLDev data structure.
35 //
36 // These are all quantities that must be saved on a per-device basis.
37 // Some drivers (xwin, tk) allocate structures defined internally.
38 //--------------------------------------------------------------------------
39 
40 typedef struct
41 {
42     PLFLT pxlx, pxly;
43     PLINT xold, yold;
44 
45     PLINT xmin, xmax, xlen;
46     PLINT ymin, ymax, ylen;
47 
48     PLINT xmin_dev, xmax_dev, xlen_dev;
49     PLINT ymin_dev, ymax_dev, ylen_dev;
50 
51     PLFLT xscale_dev, yscale_dev;
52 } PLDev;
53 
54 //--------------------------------------------------------------------------
55 // Define the PLStream data structure.
56 //
57 // This contains a copy of every variable that is stream dependent, which
58 // tends to be those which are settable by the user and persist for longer
59 // than one plot.
60 //
61 // Only those quantities listed in the PLStream struct will be preserved
62 // for an individual stream.  Note that the lack of every plplot constant
63 // means that one should only switch streams at a fairly high level, i.e.
64 // on the scale of an entire plot.  Otherwise intermediate quantities
65 // will be confused between the streams, possibly resulting in garbage plots.
66 // This structure may be expanded in time to improve intra-stream independence,
67 // but it is doubtful streams will ever be fully independent (perhaps
68 // neither necessary nor desirable? -- time will tell).
69 //
70 // There are undoubtably some inconsistencies in the declaration & use of
71 // the variables below.  This is a result of the continuing evolution of
72 // plplot and the numerous authors involved.  Hopefully in time the function
73 // of all variables can be fully documented and made more consistent.
74 //
75 // The quantities in each stream are as follows:
76 //
77 //--------------------------------------------------------------------------
78 //
79 // Misc control variables
80 //
81 // ipls		PLINT	Stream number
82 // level	PLINT	Initialization level
83 // program	char*	Program name
84 // verbose	PLINT	Be more verbose than usual
85 // debug	PLINT	Generate debugging output
86 // initialized	PLINT	Set if the stream has been initialized
87 // dev_initialized PLINT Set if the device driver has been loaded
88 // stream_closed PLBOOL  Set if the stream was closed or if there
89 //                       was some sort of error
90 //
91 //--------------------------------------------------------------------------
92 //
93 // Palettes (two of them)
94 //
95 // Color map 0 is intended for static objects, such as boxes, lines, points,
96 // labels, etc.  These should be allocated before calling plinit (else you
97 // get 16 by default, which can be undesirable on some platforms).  These
98 // are then explicitly selected by number (in order of allocation).  The
99 // lowest number is 0, but this is used for the background color, so all
100 // color drivers start with 1 as the default color.
101 //
102 // Color map 1 is for continuous-tone plots, where color is used to
103 // represent function value or intensity.  These are set in a relative way
104 // only, for increased portability and flexibility.  The actual number of
105 // colors used to represent intensity levels is determined by the driver.
106 // Note that it is only necessary to specify intensity (on a scale from 0
107 // to 1) to get an appropriate color.  Drivers incapable of fine shading
108 // will do the best job they can.
109 //
110 // A palette selection tool for both palettes is available for the Tk
111 // driver.  Direct writing of RGB values (i.e.  banging on the hardware) is
112 // supported but highly discouraged (colors so written will be affected
113 // unpredictably by the palette tools).
114 //
115 // icol0	PLINT	Color map 0 entry, current color (0 <= icol0 <= ncol0)
116 // ncol0	PLINT	Number of colors allocated in color map 0.
117 // icol1	PLINT	Color map 1 entry, current color (0 <= icol1 <= ncol1)
118 // ncol1	PLINT	Number of colors allocated in color map 1.
119 // ncol1cp	PLINT	Number of control points in cmap1 allocation (max PL_MAX_CMAP1CP)
120 // lcol1cp	PLFLT	Locations of control points in cmap1 [0,1]
121 // curcmap	PLINT	Current color map
122 // curcolor	RGB[]	Current color
123 // tmpcolor	RGB[]	Temporary color storage
124 // cmap0        RGB[]	Color map 0: maximum of ncol0 RGB 8-bit values
125 // cmap1        RGB[]	Color map 1: maximum of ncol1 RGB 8-bit values
126 // cmap1_min    PLFLT   Minimum color map 1 color to use in continuous tone plots
127 // cmap1_max    PLFLT   Maximum color map 1 color to use in continuous tone plots
128 //
129 //--------------------------------------------------------------------------
130 //
131 // Variables governing pen width
132 //
133 // width	Current pen width
134 // widthset	Set if pen width was specified
135 // widthlock	Set if pen width is locked
136 //
137 //--------------------------------------------------------------------------
138 //
139 // Variables governing arrow type
140 //
141 // arrow_x      x coordinates of points in arrow
142 // arrow_y      y coordinates of points in arrow
143 // arrow_npts   number of points in arrow_x, arrow_y
144 // arrow_fill   whether the arrow should be filled or not
145 //
146 //--------------------------------------------------------------------------
147 //
148 // Variables used to pass information between the core and the driver
149 //
150 // It would be nice to use the "dev_" prefix uniformly but changing
151 // all that old code would be quite a lot of work..
152 //
153 // device	PLINT	Graphics device id number
154 // dev_minor	PLINT	Minor device id (for variations on one type)
155 // color	PLINT	Set if color is available
156 // colorset	PLINT	Set if "color" was set prior to calling plinit
157 // plbuf_read	PLINT	Set during a plot buffer redraw
158 // plbuf_write	PLINT	Set if driver needs to use the plot buffer
159 // dev_fill0	PLINT	Set if driver can do solid area fills
160 // dev_gradient	PLINT	Set if driver can do (linear) gradients
161 // dev_text	PLINT	Set if driver want to do it's only text drawing
162 // dev_unicode	PLINT	Set if driver wants unicode
163 // dev_hrshsym	PLINT	Set for Hershey symbols to be used
164 // dev_fill1	PLINT	Set if driver can do pattern area fills
165 // dev_dash     PLINT   Set if driver can do dashed lines
166 // dev_di	PLINT	Set if driver wants to handle DI commands
167 // dev_flush	PLINT	Set if driver wants to handle flushes itself
168 // dev_swin	PLINT	Set if driver wants to handle 'set window' commands
169 // dev_fastimg  PLINT   Set if driver has fast image drawing capabilities
170 // dev_xor      PLINT   Set if driver supports xor mode.
171 // dev_clear    PLINT   Set if driver support clear.
172 // termin	PLINT	Set for interactive devices
173 // graphx	PLINT	Set if currently in graphics mode
174 // nopause	PLINT	Set if we are skipping the pause between frames
175 // family	PLINT	Set if familying is enabled
176 // member	PLINT	Number of current family member file open
177 // finc		PLINT	Number to increment between member files
178 // fflen	PLINT	Minimum field length to use in member file number
179 // bytemax	PLINT	Number of bytes maximum per member file
180 // famadv	PLINT	Set to advance to the next family member
181 // DevName	char*	Device name
182 // OutFile	FILE	Output file pointer
183 // BaseName	char*	Output base name (i.e. family)
184 // FileName	char*	Output file name
185 // output_type	int	0 for file, 1 for stream
186 // bytecnt	PLINT	Byte count for output stream
187 // page		PLINT	Page count for output stream
188 // linepos	PLINT	Line count for output stream
189 // pdfs		PDFstrm* PDF stream pointer
190 // dev_mem_alpha     PLINT  The user supplied memory buffer supports alpha values
191 // has_string_length PLINT  The driver can calculate the lengths of strings
192 // string_length     PLFLT  Set to the length of the current string (in mm) by the driver
193 // get_string_length PLINT  Tells the driver to calculate the length of the string
194 //                             but not to render it.
195 //
196 // These are used by the escape function (for area fill, etc).
197 //
198 // dev_npts	PLINT	Number of points we are plotting
199 // dev_x	short*	Pointer to array of x values
200 // dev_y	short*	Pointer to array of x values
201 // For the case where the boundary of the filled region is
202 // self-intersecting, use the even-odd fill rule rather than the
203 // default nonzero fill rule.
204 // dev_eofill   PLINT
205 //
206 // For images
207 // dev_nptsX	PLINT	Number of points we are plotting in X
208 // dev_nptsY	PLINT	Number of points we are plotting in Y
209 // dev_z	ushort*	Pointer to array of z values for the color
210 // dev_zmin,
211 // dev_zmax     ushort  Min and max values of z to plot
212 //
213 // The following pointer is for drivers that require device-specific
214 // data.  At initialization the driver should malloc the necessary
215 // space and set pls->dev to point to this area.  This way there can
216 // be multiple streams using the same driver without conflict.
217 //
218 // dev		void*	pointer to device-specific data (malloc'ed)
219 //
220 // User-supplied event handlers for use by interactive drivers (e.g. X).
221 // Can be used to take various actions depending on input.  Currently
222 // only a keyboard event handler is supported.
223 //
224 // KeyEH	void*	Keyboard event handler
225 // KeyEH_data	void*	Pointer to client data to pass
226 //
227 // ButtonEH	void*	(Mouse) Button event handler
228 // ButtonEH_data void*	Pointer to client data to pass
229 //
230 // bop_handler	void*	bop handler
231 // bop_data	void*	Pointer to client data to pass
232 //
233 // eop_handler	void*	eop handler
234 // eop_data	void*	Pointer to client data to pass
235 //
236 // Variables used for direct specification of device characteristics
237 // Not supported by all drivers (or even very many)
238 //
239 // xdpi..	PLFLT	Device DPI settings in x and y
240 // xlength..	PLINT	Device output lengths in x and y
241 // xoffset..	PLINT	Device offsets from upper left hand corner
242 // hack		PLINT	Enables driver-specific hack(s) if set
243 //
244 //--------------------------------------------------------------------------
245 //
246 // User customization tidy routine.  This is called before closing a stream
247 // to do any program specific cleanup.
248 //
249 // tidy		void*   pointer to cleanup routine
250 // tidy_data	void*   pointer to client data to pass
251 //
252 //--------------------------------------------------------------------------
253 //
254 // User error control variables.  Pass in a pointer for either to be set
255 // in exceptional conditions.  The caller is responsible for clearing the
256 // error code.
257 //
258 // errcode	PLINT*	pointer to variable to assign error code
259 // errmsg	char*	pointer to error message buffer (must be >= 160 bytes)
260 //
261 //--------------------------------------------------------------------------
262 //
263 // Stuff used by Xlib driver
264 //
265 // geometry	char*	Window geometry (malloc'ed)
266 // window_id	long	X-window window ID
267 // nopixmap	int	Set if you want to forbid allocation of pixmaps
268 // db		int	Set if you want to double buffer output
269 //			(only pixmap is drawn to directly; it is blitted
270 //			to output window on EOP or an Expose)
271 // ext_resize_draw int  Set if you want to control the redraw caused by a
272 //                      window resize by an external agent.
273 //--------------------------------------------------------------------------
274 //
275 // These are for support of the TK driver.
276 //
277 // server_name	char*	Main window name of server
278 // server_host	char*	Name of host to run server on
279 // server_port	char*	Port to talk to server on
280 // user		char*	Your user name on remote host (for remsh command)
281 // plserver	char*	Name of server
282 // plwindow	char*	Name of reference server window (malloc'ed)
283 // tk_file	char*   File for plserver use with its -file option
284 // auto_path	char*	Additional directories to autoload
285 // bufmax	int	Number of bytes sent before output buffer is flushed
286 // dp		int	Use Tcl-DP for communication, if set
287 // server_nokill int	Don't kill plserver on a ^C if set
288 //
289 //--------------------------------------------------------------------------
290 //
291 // Variables for use by the plot buffer
292 //
293 // For Memory Buffer (default)
294 // plbuf_buffer_grow  size_t  Memory buffer growth step
295 // plbuf_buffer_size  size_t  Current size of memory buffer
296 // plbuf_buffer	      void *  Pointer to memory buffer
297 // plbuf_top	      size_t  Offset to the top of used area/start of free area
298 // plbuf_readpos      size_t  Offset to current position being read
299 //
300 // plbufOwner	int	Typically set; only zero if current stream is cloned.
301 //
302 //--------------------------------------------------------------------------
303 //
304 // Driver interface (DI)
305 //
306 // difilt	PLINT	Driver interface filter flag
307 //
308 // dipxmin	PLFLT
309 // dipymin	PLFLT	Min, max relative plot coordinates
310 // dipxmax	PLFLT
311 // dipymax	PLFLT
312 // dipxax       PLFLT	Plot window transformation:
313 // dipxb        PLFLT	  x' = dipxax * x + dipxb
314 // dipyay       PLFLT
315 // dipyb        PLFLT	  y' = dipyay * y + dipyb
316 //
317 // aspdev	PLFLT	Original device aspect ratio
318 // aspect	PLFLT	Page aspect ratio
319 // aspori	PLFLT	Rotation-induced aspect ratio
320 // caspfactor	PLFLT	Factor applied to preserve character aspect ratio
321 // freeaspect	PLINT	Allow aspect ratio to adjust to orientation swaps
322 //                      when overall aspect ratio is changed.
323 // portrait	PLINT	Portrait mode (orientation and aspect ratio)
324 // mar		PLFLT	Page margin (minimum)
325 // jx		PLFLT	Page justification in x
326 // jy		PLFLT	Page justification in y
327 //
328 // didxax       PLFLT	Device window transformation:
329 // didxb        PLFLT	  x' = didxax * x + didxb
330 // didyay       PLFLT
331 // didyb        PLFLT	  y' = didyay * y + didyb
332 //
333 // diclpxmi	PLINT
334 // diclpxma	PLINT	Device clip limits
335 // diclpymi	PLINT
336 // diclpyma	PLINT
337 //
338 // diorot	PLFLT	Rotation angle (in units of pi/2)
339 // dioxax	PLFLT	Orientation transformation:
340 // dioxay	PLFLT	  x' = dioxax * x + dioxay * y + dioxb
341 // dioxb        PLFLT
342 // dioyax	PLFLT	  y' = dioyax * x + dioyay * y + dioyb
343 // dioyay	PLFLT
344 // dioyb        PLFLT
345 //
346 // dimxmin	PLFLT
347 // dimymin	PLFLT	Target coordinate system parameters.
348 // dimxmax	PLFLT
349 // dimymax	PLFLT
350 // dimxpmm	PLFLT
351 // dimypmm	PLFLT
352 // dimxax       PLFLT	Map meta to physical coordinates:
353 // dimxb        PLFLT	  x' = dimxax * x + dimxb
354 // dimyay       PLFLT
355 // dimyb        PLFLT	  y' = dimyay * y + dimyb
356 //
357 // page_status	PLINT	Flag to indicate current action
358 //
359 //--------------------------------------------------------------------------
360 //
361 // Fill pattern state information.
362 // patt < 0: Hardware fill, if available (not implemented yet)
363 // patt ==0: Hardware fill, if available, solid
364 // patt > 0: Software fill
365 //
366 // patt		Fill pattern number
367 // inclin	Array of inclinations in tenths of degree for fill lines
368 // delta	Array of spacings in micrometers between fill lines
369 // nps		Number of distinct line styles for fills
370 //
371 //--------------------------------------------------------------------------
372 //
373 // Variables used in line drawing
374 //
375 // currx	Physical x-coordinate of current point
376 // curry	Physical y-coordinate of current point
377 // line_style	index of last call to pllsty
378 // mark		Array of mark lengths in micrometers for broken lines
379 // space	Array of space lengths in micrometers for broken lines
380 // nms		Number of elements for current broken line style
381 // timecnt	Timer for broken lines
382 // alarm	Alarm indicating change of broken line status
383 // pendn	Flag indicating if pen is up or down
384 // curel	Current element within broken line
385 //
386 //--------------------------------------------------------------------------
387 //
388 // Variables governing character strings
389 //
390 // esc		Text string escape character
391 //
392 //--------------------------------------------------------------------------
393 //
394 // Scale factors for characters, symbols, and tick marks.
395 //
396 // scale	Scaling factor for chr, sym, maj, min.
397 // chr...	Character default height and current (scaled) height
398 // sym...	Symbol    default height and current (scaled) height
399 // maj...	Major tick default height and current (scaled) height
400 // min...	Minor tick default height and current (scaled) height
401 //
402 //--------------------------------------------------------------------------
403 //
404 // Variables governing numeric axis label appearance
405 //
406 // setpre	Non-zero to set precision using "prec"
407 // precis	User-specified precision
408 // xdigmax..	Allowed #digits in axes labels
409 // xdigits..	Actual field widths (returned)
410 // timefmt      Format string (for strftime)
411 //
412 //--------------------------------------------------------------------------
413 //
414 // Variables governing physical coordinate system
415 //
416 // vpp..	Viewport boundaries in physical coordinates
417 // spp..	Subpage  boundaries in physical coordinates
418 // clp..	Clip     boundaries in physical coordinates
419 // phy...	Physical device limits in physical coordinates
420 // um.		Number of micrometers in a pixel
421 // pmm		Number of pixels to a millimeter
422 //
423 //--------------------------------------------------------------------------
424 //
425 // State variables for 3d plots
426 //
427 // base3.	World coordinate size of base for 3-d plot
428 // basec.	Position of centre of base for 3-d plot
429 // dom...	Minimum and maximum values for domain
430 // zzscl	Vertical (z) scale for 3-d plot
431 // ran..	Minimum and maximum z values for 3-d plot
432 // c..		Coordinate transformation from 3-d to 2-d
433 //
434 //--------------------------------------------------------------------------
435 //
436 // Variables for keeping track of world coordinate windows on a page.
437 //
438 // nCWindows	Number of coordinate windows on current page
439 // windows	Array of plCWindow's for current page
440 //
441 //--------------------------------------------------------------------------
442 //
443 // Variables governing subpages and viewports.
444 //
445 // nsub...	Number of subpages on physical device
446 // cursub	Current subpage
447 // spd...	Subpage  boundaries in normalized device coordinates
448 // vpd...	Viewport boundaries in normalized device coordinates
449 // vpw...	Viewport boundaries in world coordinates
450 //
451 //--------------------------------------------------------------------------
452 //
453 // Transformation variables
454 //
455 // wp....	Transformation variables for world  to physical conversion
456 // wm....	Transformation variables for world coordinates to mm
457 //
458 //--------------------------------------------------------------------------
459 //
460 // Other variables
461 //
462 // dev_compression Compression level for supporting devices
463 //
464 //--------------------------------------------------------------------------
465 //
466 // Font related variables
467 //
468 // cfont           Current font number, replaces global 'font' in plsym.c
469 //                 This can be latter extended for font shape, series, family and size
470 // fci             FCI (font characterization integer)
471 // An FCI is sometimes inserted in the middle of a stream of
472 // unicode glyph indices.  Thus to distinguish it from those, the FCI is marked
473 // by 0x8 in the most significant 4 bits.  The remaining 7 hex digits
474 // stored in the 32-bit integer characterize 7 different font attributes.
475 // The font attributes are interpreted as follows:
476 // hexdigit =>                    0        1          2        3       4        5
477 // hexpower   Font attribute               Possible attribute values
478 //    0       font-family     sans-serif  serif    monospace  script  symbol |fantasy
479 //    1       font-style        upright   italic    oblique |
480 //    2       font-weight       medium     bold  |   bolder    light  lighter
481 //    3       font-variant      normal | small caps
482 //
483 // Everything to the right of the vertical bars is not implemented and is
484 // subject to change.  The four font attributes (font-family, font-style,
485 // font-weight, and font-variant are stored in the FCI in the order of
486 // hexpower, the left shift that is applied to the hex digit to place the
487 // hexdigit in the FCI.  The hexpower = 3 position is essentially undefined
488 // since there is currently only one hexdigit (0) defined, and similarly
489 // for hexpower = 4-6 so there is room for expansion of this scheme into more
490 // font attributes if required.  (hexpower = 7 is reserved for the 0x8 marker
491 // of the FCI.)
492 //
493 //--------------------------------------------------------------------------
494 //
495 // Time related variable
496 //
497 // qsasconfig is a pointer to a struct that keeps track of the details
498 // of the transformation between broken-down and continuous time used
499 // in the qsastime library.
500 //
501 //--------------------------------------------------------------------------
502 //
503 // Variables used in plgradient software fallback to communicate the polygon
504 // to the gradient_define callback used by plshades.
505 //
506 // n_polygon       Number of vertex points in the polygon defining the
507 //                 boundary of the gradient.
508 // x_polygon       Pointer to array of x vertex points in the polygon
509 //                 defining the boundary of the gradient.
510 // y_polygon       Pointer to array of y vertex points in the polygon
511 //                 defining the boundary of the gradient.
512 //--------------------------------------------------------------------------
513 //
514 // Variables used to store gradient information for device drivers.
515 //
516 // xgradient       Pointer to array of x coordinates of gradient vector.
517 // ygradient       Pointer to array of y coordinates of gradient vector.
518 // ngradient       Number of points (two) in gradient vector.
519 //--------------------------------------------------------------------------
520 
521 #define PL_MAX_CMAP1CP    256
522 
523 typedef struct
524 {
525 // Misc control information
526 
527     PLINT ipls, level, verbose, debug, initialized, dev_initialized;
528     //CONSTANT SOVERSION FIX
529     //    PLBOOL     stream_closed;
530     char  *program;
531 
532 // Plot-wide coordinate transform
533 
534     PLTRANSFORM_callback coordinate_transform;
535     PLPointer            coordinate_transform_data;
536 
537 // Colormaps
538 
539     PLINT       icol0, ncol0, icol1, ncol1, ncp1, curcmap;
540 
541     PLFLT       cmap1_min, cmap1_max;
542 
543     PLColor     curcolor, tmpcolor;
544     PLColor     *cmap0;
545     PLColor     *cmap1;
546 
547     PLControlPt cmap1cp[PL_MAX_CMAP1CP];
548     PLBOOL      cmap1cp_is_rgb;
549 
550 // Variables governing pen width
551 
552     PLFLT width;
553     PLINT widthset, widthlock;
554 
555 // Variables governing arrow
556     PLFLT *arrow_x;
557     PLFLT *arrow_y;
558     PLINT arrow_npts;
559     PLINT arrow_fill;
560 
561 // Driver dispatch table, obsoletes "device" member below.
562 
563     PLDispatchTable *dispatch_table;
564 
565 // Variables used for interacting with or by device driver
566 
567     PLINT   plbuf_read, plbuf_write;
568     PLINT   device, dev_minor, termin, graphx, nopause;
569     PLINT   color, colorset;
570     PLINT   family, member, finc, fflen, bytemax, famadv;
571     PLINT   dev_fill0, dev_fill1, dev_dash, dev_di, dev_flush, dev_swin;
572     PLINT   dev_text, dev_xor, dev_clear, dev_fastimg, dev_arc;
573 
574     char    DevName[80];
575     FILE    *OutFile;
576     char    *BaseName, *FileName;
577     int     output_type;
578     PLINT   bytecnt, page, linepos;
579     PDFstrm *pdfs;
580 
581     PLINT   dev_npts;
582     short   *dev_x, *dev_y;
583 
584     // variables for plimage()
585 
586     PLINT          dev_nptsX, dev_nptsY;
587     short          *dev_ix, *dev_iy;
588     unsigned short *dev_z;
589     unsigned short dev_zmin, dev_zmax;
590     PLINT          imclxmin, imclxmax, imclymin, imclymax;
591 
592     // end of variables for plimage()
593 
594     void *dev;
595 
596     void *dev_data;
597 
598     void ( *KeyEH )( PLGraphicsIn *gin, void *KeyEH_data,
599                      int *exit_eventloop );
600     void *KeyEH_data;
601 
602     void ( *ButtonEH )( PLGraphicsIn *gin, void *ButtonEH_data,
603                         int *exit_eventloop );
604     void *ButtonEH_data;
605 
606     void ( *LocateEH )( PLGraphicsIn *gin, void *LocateEH_data,
607                         int *locate_mode );
608     void  *LocateEH_data;
609 
610     void ( *bop_handler )( void *bop_data, int *skip_driver_bop );
611     void  *bop_data;
612 
613     void ( *eop_handler )( void *eop_data, int *skip_driver_eop );
614     void  *eop_data;
615 
616     PLFLT xdpi, ydpi;
617     PLINT xlength, ylength;
618     PLINT xoffset, yoffset;
619     PLINT hack;
620 
621 // Per stream tidy function.
622 
623     void ( *tidy )( void * );
624     void *tidy_data;
625 
626 // Error info
627 
628     PLINT *errcode;
629     char  *errmsg;
630 
631 // Stuff used by Xlib driver
632 
633     char *geometry;
634     long window_id;
635     int  nopixmap, db, ext_resize_draw;
636 
637 // Stuff used by TK, DP drivers
638 
639     char *server_name, *server_host, *server_port, *user;
640     char *plserver, *plwindow;
641     char *auto_path;
642     char *tk_file;  // plserver -file option
643     int  bufmax, dp, server_nokill;
644 
645 // Plot buffer settings
646 
647     size_t plbuf_buffer_grow;
648     size_t plbuf_buffer_size;
649     void   *plbuf_buffer;
650     size_t plbuf_top;
651     size_t plbuf_readpos;
652     int    plbufOwner;
653 
654 // Driver interface (DI)
655 
656     PLINT difilt, diclpxmi, diclpxma, diclpymi, diclpyma;
657     PLFLT dipxmin, dipymin, dipxmax, dipymax;
658     PLFLT dipxax, dipxb, dipyay, dipyb;
659     PLFLT aspdev, aspect, aspori, caspfactor, mar, jx, jy;
660     PLFLT didxax, didxb, didyay, didyb;
661     PLFLT diorot;
662     PLFLT dioxax, dioxay, dioxb, dioyax, dioyay, dioyb;
663     PLFLT dimxax, dimxb, dimyay, dimyb;
664     PLFLT dimxmin, dimymin, dimxmax, dimymax, dimxpmm, dimypmm;
665     PLINT page_status, freeaspect, portrait;
666 
667 // Fill pattern info
668 
669     PLINT patt, inclin[2], delta[2], nps;
670 
671 // Variables used in line drawing
672 
673     PLINT currx, curry;
674     //CONSTANT SOVERSION FIX
675     //PLINT line_style;
676     PLINT mark[10], space[10], nms;
677     PLINT timecnt, alarm, pendn, curel;
678 
679 // Variables governing character strings
680 
681     char esc;
682 
683 // Scale factors for characters, symbols, and tick marks.
684 
685     PLFLT scale;
686     PLFLT chrdef, chrht;
687     PLFLT symdef, symht;
688     PLFLT majdef, majht;
689     PLFLT mindef, minht;
690 
691 // Variables governing numeric axis label appearance
692 
693     PLINT                 setpre, precis;
694     PLINT                 xdigmax, ydigmax, zdigmax;
695     PLINT                 xdigits, ydigits, zdigits;
696     char                  *timefmt;
697     PLLABEL_FUNC_callback label_func;
698     PLPointer             label_data;
699 
700 // Variables governing physical coordinate system
701 
702     PLINT vppxmi, vppxma, vppymi, vppyma;
703     PLINT sppxmi, sppxma, sppymi, sppyma;
704     PLINT clpxmi, clpxma, clpymi, clpyma;
705     PLINT phyxmi, phyxma, phyxlen, phyymi, phyyma, phyylen;
706     PLINT umx, umy;
707     PLFLT xpmm, ypmm;
708 
709 // State variables for 3d plots
710 
711     PLFLT base3x, base3y, basecx, basecy;
712     PLFLT domxmi, domxma, domymi, domyma;
713     PLFLT zzscl, ranmi, ranma;
714     PLFLT cxx, cxy, cyx, cyy, cyz, czx, czy, czz;
715 
716 // Variables for keeping track of windows on a page.
717 
718     int      nplwin;
719     PLWindow plwin[PL_MAXWINDOWS];
720 
721 // Variables governing subpages and viewports.
722 
723     PLINT nsubx, nsuby, cursub;
724     PLFLT spdxmi, spdxma, spdymi, spdyma;
725     PLFLT vpdxmi, vpdxma, vpdymi, vpdyma;
726     PLFLT vpwxmi, vpwxma, vpwymi, vpwyma;
727 
728 // Transformation variables
729 
730     PLFLT wpxscl, wpxoff, wpyscl, wpyoff;
731     PLFLT wmxscl, wmxoff, wmyscl, wmyoff;
732     PLFLT wdxscl, wdxoff, wdyscl, wdyoff;
733 
734 // Other variables
735 
736     PLINT            dev_compression;
737     PLINT            cfont;
738 
739     void             *FT;
740 
741 // Stuff used by the Tkwin driver for Plframe
742     struct PlPlotter *plPlotterPtr;
743 
744 
745 // Unicode section
746 
747     PLINT     dev_unicode;
748 
749     PLINT     alt_unicode; // The alternative interface for unicode text rendering.
750 
751     PLUNICODE fci;
752 
753     PLINT     dev_hrshsym;
754 
755 // Used to keep a hold of a temporary copy of the original character height
756 // which I overload as a quick hack to fix up a bug in freetype an plsym()
757 //
758 
759     PLFLT original_chrdef, original_chrht;
760 
761     //
762     // Pointer to postscript document class used by psttf
763     //
764     void *psdoc;
765 
766     // pointer to a struct that keeps track of the details of the
767     // transformation between broken-down and continuous time used in
768     // the qsastime library.
769 
770     QSASConfig  *qsasconfig;
771 
772     // Gradient section.
773     PLINT       dev_gradient;
774     PLINT       ngradient;
775     PLINT       *xgradient, *ygradient;
776     // The next three variables define the polygon boundary used
777     // in the software fallback for the gradient.
778     PLINT       n_polygon;
779     const PLFLT *x_polygon, *y_polygon;
780 
781     //CONSTANT SOVERSION FIX
782     PLBOOL      stream_closed;
783     PLINT       line_style;
784     PLINT       dev_mem_alpha;
785     PLINT       has_string_length;
786     PLFLT       string_length;
787     PLINT       get_string_length;
788     PLINT       dev_eofill;
789 
790     // Drawing mode section
791     PLINT       dev_modeset;
792 
793     // Calculate bounding-box limits rather than plot box?
794     PLBOOL      if_boxbb;
795     // Bounding box limits in mm for box including decorations
796     // (inverted tick marks and numerical tick labels if either is
797     // present).
798     PLFLT boxbb_xmin, boxbb_xmax, boxbb_ymin, boxbb_ymax;
799 
800 // Plot metafile variables
801 //
802     char *mf_infile;
803     char *mf_outfile;
804 } PLStream;
805 
806 //--------------------------------------------------------------------------
807 // Prototypes for stream & device utility functions.
808 //--------------------------------------------------------------------------
809 
810 #ifdef __cplusplus
811 extern "C" {
812 #endif
813 
814 // Get the current stream pointer
815 
816 void PLDLLIMPEXP
817 plgpls( PLStream **p_pls );
818 
819 // Initializes device cmap 1 entry by interpolation from pls->cmap1 entries
820 
821 PLDLLIMPEXP void
822 plcol_interp( PLStream *pls, PLColor *newcolor, int i, int ncol );
823 
824 // Opens file for output, prompting if not set.
825 
826 PLDLLIMPEXP void
827 plOpenFile( PLStream *pls );
828 
829 // Close output file
830 
831 PLDLLIMPEXP void
832 plCloseFile( PLStream *pls );
833 
834 // Sets up next file member name (in pls->FileName), but does not open it.
835 
836 void
837 plP_getmember( PLStream *pls );
838 
839 // Sets up file name & family stem name.
840 
841 void
842 plP_sfnam( PLStream *pls, const char *fnam );
843 
844 // Initializes family file parameters.
845 
846 PLDLLIMPEXP void
847 plFamInit( PLStream *pls );
848 
849 // Starts new member file of family file set if necessary.
850 
851 PLDLLIMPEXP void
852 plGetFam( PLStream *pls );
853 
854 // Rotates physical coordinates if necessary for given orientation.
855 
856 PLDLLIMPEXP void
857 plRotPhy( PLINT orient, PLINT xmin, PLINT ymin, PLINT xmax, PLINT ymax,
858           PLINT *px, PLINT *py );
859 
860 // Allocates a standard PLDev structure for device-specific data
861 
862 PLDLLIMPEXP PLDev *
863 plAllocDev( PLStream *pls );
864 
865 // Just fills in the PLGraphicsIn with appropriate initial values.
866 
867 PLDLLIMPEXP void
868 plGinInit( PLGraphicsIn *gin );
869 
870 #ifdef __cplusplus
871 }
872 #endif
873 
874 #endif  // __PLSTRM_H__
875