PLplot  5.11.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
plplotP.h
Go to the documentation of this file.
1 // Internal (private) macros and prototypes for the PLplot package. This
2 // header file must be included before all others, including system header
3 // files. This file is typically needed when including driver specific
4 // header files (e.g. pltkd.h).
5 //
6 // Copyright (C) 1993, 1994, 1995 by
7 // Maurice J. LeBrun, Geoff Furnish, Tony Richardson.
8 //
9 // Copyright (C) 2004 Rafael Laboissiere
10 // Copyright (C) 2004 Joao Cardoso
11 // Copyright (C) 2004 Andrew Roach
12 // Copyright (C) 2006 Andrew Ross
13 // Copyright (C) 2006 Hazen Babcock
14 //
15 //
16 // This file is part of PLplot.
17 //
18 // PLplot is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU Library General Public License as published
20 // by the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 // PLplot is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU Library General Public License for more details.
27 //
28 // You should have received a copy of the GNU Library General Public License
29 // along with PLplot; if not, write to the Free Software
30 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 //
32 //
33 //
34 
35 #ifndef __PLPLOTP_H__
36 #define __PLPLOTP_H__
37 
38 //--------------------------------------------------------------------------
39 // Select environment. Must be done before anything else.
40 //
41 // Basically we want the widest range of system services that are available.
42 // Fortunately on many systems, that is the default. To get "everything",
43 // one of the following must be defined, as appropriate:
44 //
45 // _GNU_SOURCE on Linux (default)
46 // _OSF_SOURCE on OSF1 (default)
47 // _HPUX_SOURCE on HP (not default)
48 // _ALL_SOURCE on AIX (no idea)
49 //
50 // To see where these are set, do the following:
51 //
52 // cd /usr/include; grep SOURCE *.h | fgrep 'define '
53 //
54 // and the file containing lots of these is the one you want (features.h on
55 // Linux, standards.h on OSF1, etc). Follow the logic to see what needs to be
56 // defined to get "everything", i.e. POSIX.*, XOPEN, etc.
57 //
58 // Note that for specific functionality, we test using autoconf. Still it's
59 // best to stick to ANSI C, POSIX.1, and POSIX.2, in that order, for maximum
60 // portability.
61 //--------------------------------------------------------------------------
62 
63 // HPUX - if this is no longer needed, please remove it
64 #ifdef _HPUX
65 #define _HPUX_SOURCE
66 #endif
67 
68 // A/IX - if this is no longer needed, please remove it
69 #ifdef _AIX
70 #define _ALL_SOURCE
71 #endif
72 
73 // Add others here as needed.
74 
75 //--------------------------------------------------------------------------
76 // Configuration settings
77 //
78 // Some of the macros set during configuration are described here.
79 //
80 // If HAVE_TERMIOS_H is set, we employ POSIX.1 tty terminal I/O. One purpose
81 // of this is to select character-oriented (CBREAK) i/o in the tek driver and
82 // all its variants. It is usable without this but not as powerful. The
83 // reason for using this is that some supported systems are still not
84 // POSIX.1 compliant (and some may never be).
85 //
86 // If STDC_HEADERS is defined, the system's libc is ANSI-compliant.
87 // ANSI libc calls are used for: (a) setting up handlers to be called
88 // before program exit (via the "atexit" call), and (b) for seek
89 // operations. Again, the code is usable without these. An ANSI libc
90 // should be available, given the requirement of an ANSI compiler. Some
91 // reasons why not: (a) the vendor didn't supply a complete ANSI
92 // environment, or (b) the ANSI libc calls are buggy, or (c) you ported
93 // gcc to your system but not glibc (for whatever reason). Note: without
94 // an ANSI C lib, if you ^C out of a program using one of the PLplot tek
95 // drivers, your terminal may be left in a strange state.
96 //--------------------------------------------------------------------------
97 
98 #include "plConfig.h"
99 #ifdef caddr_t
100 #undef caddr_t
101 #ifndef __USE_BSD
102 typedef char * caddr_t;
103 #endif
104 #endif
105 
106 // System headers
107 
108 #include <ctype.h>
109 #include <math.h>
110 #include <string.h>
111 #include <limits.h>
112 #include <float.h>
113 #ifdef PL_HAVE_UNISTD_H
114 #include <unistd.h>
115 #endif
116 
117 #include <locale.h>
118 
119 // (AM) Define M_PI if the platform does not include it
120 // (MSVC for instance)
121 #if !defined ( M_PI )
122 #define M_PI 3.14159265358979323846
123 #endif
124 
125 //
126 // Macros for file positioning. I tried switching to f[sg]etpos() because I
127 // like the semantics better, but ran into the problem that fpos_t is not
128 // always a base type (it may be a struct). This is a problem because the
129 // metafile driver needs to write relative offsets into the file itself. So
130 // instead we use f{seek,tell} at a low level but keep the f[sg]etpos
131 // semantics using these macros.
132 //
133 
134 #ifdef STDC_FPOS_T
135 #undef STDC_FPOS_T
136 #endif
137 
138 #ifdef STDC_FPOS_T
139 #define FPOS_T fpos_t
140 #define pl_fsetpos( a, b ) fsetpos( a, b )
141 #define pl_fgetpos( a, b ) fgetpos( a, b )
142 
143 #else
144 #define FPOS_T long
145 #define pl_fsetpos( a, b ) fseek( a, *b, 0 )
146 #define pl_fgetpos( a, b ) ( -1L == ( *b = ftell( a ) ) )
147 #endif
148 
149 #include "pldll.h"
150 
151 // Include all externally-visible definitions and prototypes
152 // plplot.h also includes some handy system header files
153 
154 #include "plplot.h"
155 
156 // plstream definition
157 
158 #include "plstrm.h"
159 
160 // If not including this file from inside of plcore.h, declare plsc
161 
162 #ifndef __PLCORE_H__
163 #ifdef __cplusplus
164 extern "C" {
165 #endif
166 // extern PLStream PLDLLIMPORT *plsc;
167 extern PLDLLIMPEXP_DATA( PLStream * ) plsc;
168 #ifdef __cplusplus
169 }
170 #endif
171 #include "pldebug.h"
172 #endif
173 
174 //--------------------------------------------------------------------------
175 // Utility macros
176 //--------------------------------------------------------------------------
177 
178 #ifndef TRUE
179 #define TRUE 1
180 #define FALSE 0
181 #endif
182 
183 // Used to help ensure everything malloc'ed gets freed
184 
185 #define free_mem( a ) \
186  if ( a != NULL ) { free( (void *) a ); a = NULL; }
187 
188 // Allows multi-argument setup calls to not affect selected arguments
189 
190 #define plsetvar( a, b ) \
191  if ( b != PL_NOTSET ) a = b;
192 
193 // Lots of cool math macros
194 
195 #ifndef MAX
196 #define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
197 #endif
198 #ifndef MIN
199 #define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
200 #endif
201 #ifndef ABS
202 #define ABS( a ) ( ( a ) < 0 ? -( a ) : ( a ) )
203 #endif
204 #ifndef ROUND
205 #define ROUND( a ) (PLINT) ( ( a ) < 0. ? ( ( a ) - .5 ) : ( ( a ) + .5 ) )
206 #endif
207 #ifndef BETW
208 #define BETW( ix, ia, ib ) ( ( ( ix ) <= ( ia ) && ( ix ) >= ( ib ) ) || ( ( ix ) >= ( ia ) && ( ix ) <= ( ib ) ) )
209 #endif
210 #ifndef SSQR
211 #define SSQR( a, b ) sqrt( ( a ) * ( a ) + ( b ) * ( b ) )
212 #endif
213 #ifndef SIGN
214 #define SIGN( a ) ( ( a ) < 0 ? -1 : 1 )
215 #endif
216 #ifndef TRANSFORM
217 #define TRANSFORM( x, y, xnew, ynew ) if ( plsc->coordinate_transform ) { plsc->coordinate_transform( ( x ), ( y ), ( xnew ), ( ynew ), plsc->coordinate_transform_data ); } else { *xnew = x; *ynew = y; }
218 #endif
219 
220 // A coordinate value that should never occur
221 
222 #define PL_UNDEFINED -9999999
223 
224 // Declarations for save string functions
225 
226 #ifdef PL_HAVE_SNPRINTF
227 // In case only _snprintf is declared (as for Visual C++ and
228 // Borland compiler toolset) we redefine the function names
229  #ifdef _PL_HAVE_SNPRINTF
230  #define snprintf _snprintf
231  #define snscanf _snscanf
232  #endif // _PL_HAVE_SNPRINTF
233 #else // !PL_HAVE_SNPRINTF
234 // declare dummy functions which just call the unsafe
235 // functions ignoring the size of the string
236 int plsnprintf( char *buffer, int n, const char *format, ... );
237 int plsnscanf( const char *buffer, int n, const char *format, ... );
238  #define snprintf plsnprintf
239  #define snscanf plsnscanf
240 #endif // PL_HAVE_SNPRINTF
241 
242 //--------------------------------------------------------------------------
243 // Add in missing isnan / isinf functions on some platforms
244 //--------------------------------------------------------------------------
245 
246 #if defined ( PL__HAVE_ISNAN )
247 # define isnan _isnan
248 # if defined ( _MSC_VER )
249 # include <float.h>
250 # endif
251 #endif
252 #if defined ( PL__HAVE_ISINF )
253 # define isinf _isinf
254 #endif
255 #if defined ( PL_HAVE_FINITE )
256 # define isfinite finite
257 #endif
258 #if defined ( PL__HAVE_FINITE )
259 # define isfinite _finite
260 #endif
261 
262 // Note these replacements follow the old BSD convention and not
263 // C99. In particular isinf does not distinguish +/- inf.
264 #if !defined ( PL_HAVE_ISNAN )
265 # define isnan( x ) ( ( x ) != ( x ) )
266 #endif
267 #if !defined ( PL_HAVE_ISINF )
268 # define isinf( x ) ( !isnan( x ) && isnan( x - x ) )
269 #endif
270 #if !defined ( PL_HAVE_ISFINITE )
271 # define isfinite( x ) ( !isnan( x - x ) )
272 #endif
273 
274 // Check if C99 HUGE_VAL macro is available - if not then
275 // define a replacement
276 #ifndef HUGE_VAL
277 #define HUGE_VAL ( 1.0 / 0.0 )
278 #endif
279 
280 //--------------------------------------------------------------------------
281 // PLPLOT control macros
282 //--------------------------------------------------------------------------
283 
284 // Some constants
285 
286 #define PL_MAXPOLY 256 // Max segments in polyline or polygon
287 #define PL_NSTREAMS 100 // Max number of concurrent streams.
288 #define PL_RGB_COLOR -1 // A hack
289 
290 #define TEXT_MODE 0
291 #define GRAPHICS_MODE 1
292 #ifndef PI
293 #define PI 3.1415926535897932384
294 #endif
295 
296 // These define the virtual coordinate system used by the metafile driver.
297 // Others are free to use it, or some variation, or define their own.
298 
299 // Note desktop monitors of reasonable quality typically have 0.25 mm spacing
300 // between dots which corresponds to 4.0 dots per mm. The parameters here
301 // roughly correspond to a 14" monitor at 1024x768 resolution, which should
302 // work fine at other sizes/resolutions. The number of virtual dots per mm is
303 // scaled by a factor of 32, with pixels scaled accordingly. The customary
304 // x/y ratio of 4:3 is used.
305 //
306 
307 #define PIXELS_X 32768 // Number of virtual pixels in x
308 #define PIXELS_Y 24576 // Number of virtual pixels in x
309 #define DPMM 4. // dots per mm
310 #define VDPMM ( DPMM * 32 ) // virtual dots per mm
311 #define LPAGE_X ( PIXELS_X / VDPMM ) // virtual page length in x in mm (256)
312 #define LPAGE_Y ( PIXELS_Y / VDPMM ) // virtual page length in y in mm (192)
313 
314 // This defines the first argument of the plRotPhy invocation that is made
315 // in a number of device drivers (e.g., found in ljii.c, ljiip.c, ps.c,
316 // and pstex.c) to rotate them "permanently" from portrait mode to non-
317 // portrait mode. ORIENTATION of 1 corresponds to seascape mode (90 deg
318 // clockwise rotation from portrait). This is the traditional value
319 // effectively used in all older versions of PLplot. ORIENTATION of 3
320 // corresponds to landscape mode (90 deg *counter*-clockwise rotation from
321 // portrait) which is the new default non-portrait orientation.
322 
323 #define ORIENTATION 3
324 
325 // Switches for state function call.
326 
327 #define PLSTATE_WIDTH 1 // pen width
328 #define PLSTATE_COLOR0 2 // change to color in cmap 0
329 #define PLSTATE_COLOR1 3 // change to color in cmap 1
330 #define PLSTATE_FILL 4 // set area fill to a standard pattern
331 #define PLSTATE_CMAP0 5 // change to cmap 0
332 #define PLSTATE_CMAP1 6 // change to cmap 1
333 #define PLSTATE_CHR 7 // change character height
334 #define PLSTATE_SYM 8 // change symbol size
335 
336 
337 // Bit switches used in the driver interface
338 
339 #define PLDI_MAP 0x01
340 #define PLDI_ORI 0x02
341 #define PLDI_PLT 0x04
342 #define PLDI_DEV 0x08
343 
344 // Default size for family files, in KB.
345 
346 #ifndef PL_FILESIZE_KB
347 #define PL_FILESIZE_KB 1000
348 #endif
349 
350 // Font file names.
351 
352 #define PLPLOT5_FONTS
353 
354 #ifdef PLPLOT5_FONTS
355 #define PL_XFONT "plxtnd5.fnt"
356 #define PL_SFONT "plstnd5.fnt"
357 #else
358 #define PL_XFONT "plxtnd4.fnt"
359 #define PL_SFONT "plstnd4.fnt"
360 #endif
361 
362 //--------------------------------------------------------------------------
363 // The following environment variables are defined:
364 //
365 // PLPLOT_BIN # where to find executables
366 // PLPLOT_LIB # where to find library files (fonts, maps, etc)
367 // PLPLOT_TCL # where to find tcl scripts
368 //
369 // PLPLOT_HOME # basename of plplot hierarchy
370 //
371 // search order:
372 // 1) the most specific possible locators, one of
373 // $(PLPLOT_BIN)
374 // $(PLPLOT_LIB)
375 // $(PLPLOT_TCL)
376 // as appropriate
377 //
378 // 2) the current directory
379 //
380 // 3) one of $(PLPLOT_HOME)/bin
381 // $(PLPLOT_HOME)/lib
382 // $(PLPLOT_HOME)/tcl
383 // as appropriate
384 //
385 // 4) as appropriate, the compile-time (Makefile)
386 // BIN_DIR, LIB_DIR, TCL_DIR
387 //
388 // 8 Jun 1994 mj olesen (olesen@weber.me.queensu.ca)
389 //
390 // Other notes:
391 //
392 // In addition to the directories above, the following are also used:
393 //
394 // Lib file search path: PLLIBDEV (see plctrl.c). This is checked last,
395 // and is a system-dependent hardwired location.
396 //
397 // Tcl search path: $HOME/tcl is searched before the install location,
398 // TCL_DIR.
399 //--------------------------------------------------------------------------
400 
401 #define PLPLOT_BIN_ENV "PLPLOT_BIN"
402 #define PLPLOT_LIB_ENV "PLPLOT_LIB"
403 #define PLPLOT_TCL_ENV "PLPLOT_TCL"
404 #define PLPLOT_HOME_ENV "PLPLOT_HOME"
405 
406 // Maximum size for path strings in the plplot code
407 #define PLPLOT_MAX_PATH 1024
408 
409 //
410 // Some stuff that is included (and compiled into) plsym.h
411 // Other modules might want this, so we will "extern" it
412 //
413 //
414 
415 #ifndef __PLSYM_H__
416 
417 typedef struct
418 {
419  unsigned int Hershey;
421  char Font;
423 
426 
427 
428 #endif
429 
430 // Greek character translation array (defined in plcore.c)
431 extern const char plP_greek_mnemonic[];
432 
433 //--------------------------------------------------------------------------
434 // Function Prototypes
435 //
436 // These typically should not be called directly by the user.
437 //--------------------------------------------------------------------------
438 
439 #ifdef __cplusplus
440 extern "C" {
441 #endif
442 
443 // Number of elements in the affine vector representation of the affine
444 // transformation matrix.
445 #define NAFFINE 6
446 
447 // Returns affine identity matrix
448 
449 PLDLLIMPEXP void
450 plP_affine_identity( PLFLT *affine_vector );
451 
452 // Translate new coordinate system axes relative to the old.
453 
454 PLDLLIMPEXP void
455 plP_affine_translate( PLFLT *affine_vector, PLFLT xtranslate, PLFLT ytranslate );
456 
457 // Scale new coordinate system axes relative to the old.
458 
459 PLDLLIMPEXP void
460 plP_affine_scale( PLFLT *affine_vector, PLFLT xscale, PLFLT yscale );
461 
462 // Rotate new coordinate system axes relative to the old.
463 // angle is in degrees.
464 
465 PLDLLIMPEXP void
466 plP_affine_rotate( PLFLT *affine_vector, PLFLT angle );
467 
468 // Skew new X coordinate axis relative to the old.
469 // angle is in degrees.
470 
471 PLDLLIMPEXP void
472 plP_affine_xskew( PLFLT *affine_vector, PLFLT angle );
473 
474 // Skew new Y coordinate axis relative to the old.
475 // angle is in degrees.
476 
477 PLDLLIMPEXP void
478 plP_affine_yskew( PLFLT *affine_vector, PLFLT angle );
479 
480 // Multiply two affine transformation matrices to form a third.
481 //
482 // A = B * C
483 //
484 //
485 
486 PLDLLIMPEXP void
488  PLFLT *affine_vectorA,
489  const PLFLT *affine_vectorB,
490  const PLFLT *affine_vectorC );
491 
492 // Determines interval between numeric labels
493 
494 void
495 pldtik( PLFLT vmin, PLFLT vmax, PLFLT *tick, PLINT *nsubt, PLBOOL ld );
496 
497 // Writes numeric labels on side(s) of box in custom locations
498 
499 void
500 label_box_custom( const char *xopt, PLINT n_xticks, const PLFLT *xticks, const char *yopt, PLINT n_yticks, const PLFLT *yticks );
501 
502 // Determine factor to convert date / time in seconds to more natural
503 // units
504 
505 void
506 pldtfac( PLFLT vmin, PLFLT vmax, PLFLT *factor, PLFLT *tstart );
507 
508 // Determines precision of box labels
509 
510 void
511 pldprec( PLFLT vmin, PLFLT vmax, PLFLT tick, PLINT lf,
512  PLINT *mode, PLINT *prec, PLINT digmax, PLINT *scale );
513 
514 // Draws a polyline within the clip limits.
515 
516 void
517 plP_pllclp( PLINT *x, PLINT *y, PLINT npts,
519  void ( *draw )( short *, short *, PLINT ) );
520 
521 // Fills a polygon within the clip limits.
522 
523 void
524 plP_plfclp( PLINT *x, PLINT *y, PLINT npts,
525  PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax,
526  void ( *draw )( short *, short *, PLINT ) );
527 
528 // Clip a polygon to the 3d bounding plane
529 int
530 plP_clip_poly( int Ni, PLFLT *Vi[3], int axis, PLFLT dir, PLFLT offset );
531 
532 // Get clipped endpoints
533 
534 int
535 plP_clipline( PLINT *p_x1, PLINT *p_y1, PLINT *p_x2, PLINT *p_y2,
536  PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax );
537 
538 // Stores hex digit value into FCI (font characterization integer).
539 void
540 plP_hex2fci( unsigned char hexdigit, unsigned char hexpower, PLUNICODE *pfci );
541 
542 // Retrieves hex digit value from FCI (font characterization integer).
543 PLDLLIMPEXP void
544 plP_fci2hex( PLUNICODE fci, unsigned char *phexdigit, unsigned char hexpower );
545 
546 // Pattern fills in software the polygon bounded by the input points.
547 
548 PLDLLIMPEXP void
549 plfill_soft( short *x, short *y, PLINT npts );
550 
551 // In case of an abort this routine is called. It just prints out an
552 // error message and tries to clean up as much as possible.
553 
554 PLDLLIMPEXP void
555 plexit( const char *errormsg );
556 
557 // Just a front-end to exit().
558 
559 void
560 pl_exit( void );
561 
562 // A handy way to issue warnings, if need be.
563 
564 PLDLLIMPEXP void
565 plwarn( const char *errormsg );
566 
567 // Same as plwarn(), but appends ", aborting plot" to the error message
568 
569 PLDLLIMPEXP void
570 plabort( const char *errormsg );
571 
572 // Loads either the standard or extended font.
573 
574 void
575 plfntld( PLINT fnt );
576 
577 // Release memory for fonts.
578 
579 void
580 plfontrel( void );
581 
582 // A replacement for strdup(), which isn't portable.
583 
584 PLDLLIMPEXP char *
585 plstrdup( const char *src );
586 
587 // Bin up cmap 1 space and assign colors to make inverse mapping easy.
588 
589 PLDLLIMPEXP void
590 plcmap1_calc( void );
591 
592 // Draws a slanting tick at position (mx,my) (measured in mm) of
593 // vector length (dx,dy).
594 
595 void
596 plstik( PLFLT mx, PLFLT my, PLFLT dx, PLFLT dy );
597 
598 // Prints out a "string" at reference position with physical coordinates
599 // (refx,refy).
600 
601 void
602 plstr( PLINT base, PLFLT *xform, PLINT refx, PLINT refy, const char *string );
603 
604 // Draws a tick parallel to x.
605 
606 void
607 plxtik( PLINT x, PLINT y, PLINT below, PLINT above );
608 
609 // Draws a tick parallel to y.
610 
611 void
612 plytik( PLINT x, PLINT y, PLINT left, PLINT right );
613 
614 // Driver interface filter --
615 // passes all coordinates through a variety of filters.
616 
617 PLDLLIMPEXP void
618 difilt( PLINT *, PLINT *, PLINT,
619  PLINT *, PLINT *, PLINT *, PLINT * );
620 
621 // Transforms the clipping region coordinates as necessary
622 // based on the current plot orientation, etc.
623 
624 PLDLLIMPEXP void
625 difilt_clip( PLINT *, PLINT * );
626 
627 // Calculate scale of font size and scale of magnitude of vertical
628 // offset associated with superscripts and subscripts.
629 
630 PLDLLIMPEXP void
631 plP_script_scale( PLBOOL ifupper, PLINT *level,
632  PLFLT *old_scale, PLFLT *scale,
633  PLFLT *old_offset, PLFLT *offset );
634 
635 // Driver draws text
636 
637 void
638 plP_text( PLINT base, PLFLT just, PLFLT *xform, PLINT x, PLINT y,
639  PLINT refx, PLINT refy, const char *string );
640 
641 // Save LC_NUMERIC locale string, then set "C" locale to protect
642 // parts of PLplot which absolutely demand the LC_NUMERIC "C" locale.
643 
644 PLDLLIMPEXP char *
645 plsave_set_locale( void );
646 
647 // Restore LC_NUMERIC locale that was determined by plsave_set_locale.
648 
649 PLDLLIMPEXP void
650 plrestore_locale( char * save_lc_numeric_locale );
651 
652 // Writes the Hershey symbol "ch" centred at the physical coordinate (x,y).
653 void
654 plhrsh( PLINT ch, PLINT x, PLINT y );
655 
656 // where should structure definitions that must be seen by drivers and core source files, be?
657 
658 // structure to be used by plcore.c and anydriver.c, related to plP_text()
659 
660 typedef struct
661 {
662  // Indicates the type of text stored in the structure. This flag
663  // is used by the plot metafiles to correctly store and then render
664  // the contents.
665  enum { PL_STRING_TEXT, PL_STRING_SYMBOL } text_type;
666 
667  // Positioning settings
668  PLINT base; // ref point at base(1) or center(0) of text. Currently plplot only use 0
669  PLFLT just; // continuos justification, 0 left, 0.5 center, 1 right
670  PLFLT *xform; // transformation (rotation) matrix
671 
672  // raw reference point--after any transformation
675 
676  // processed ref. point--after justification, displacement, etc, processing
679 
680  // font face OPTIONALLY used for rendering hershey codes
681  char font_face;
682 
683  // The following 3 fields are used by the alternative text handling pathway.
684  // The alternative text handling pathway allows the driver to process
685  // each character individually for unicode font handling
686  // See drivers/cairo.h for details about how this works.
687  PLUNICODE n_fci; // font storage
688  PLUNICODE n_char; // character storage
689  PLINT n_ctrl_char; // control character
690 
691  // Used by plsym to store a unicode character for use by plfreetype
692  PLUNICODE unicode_char; // an int to hold either a Hershey, ASC-II, or Unicode value for plsym calls
693 
694  // Used to store a processed unicode string. Used by plsym and
695  // text rendering by the driver
696  PLUNICODE *unicode_array; // a pointer to an array of ints holding either a Hershey, ASC-II, or Unicode value for cached plsym
697  unsigned short unicode_array_len;
698 
699  // Non-unicode strings and unprocessed string in the unicode case
700  const char *string; // text to draw
701  PLINT symbol; // plot symbol to draw
702 }EscText;
703 
704 //
705 // structure that contains driver specific information, to be used by
706 // plargs.c and anydriver.c, related to plParseDrvOpts() and plHelpDrvOpts()
707 //
708 
709 typedef struct
710 {
711  const char *opt; // a string with the name of the option
712  PLINT type; // the type of the variable to be set, see bellow the available types
713  void *var_ptr; // a pointer to the variable to be set
714  const char *hlp_msg; // help message of the option
715 } DrvOpt;
716 
717 // the available variable types, DrvOpt.type, for driver specific options
718 
720 
721 // parse driver specific options, as in -drvopt <option[=value]>*
722 
723 PLDLLIMPEXP int
725 
726 // give help on driver specific options
727 
728 void
729 plHelpDrvOpts( DrvOpt * );
730 
731 //
732 // structures to store contour lines
733 //
734 
735 #define LINE_ITEMS 20
736 
737 typedef struct cont_line
738 {
742  struct cont_line *next;
743 } CONT_LINE;
744 
745 typedef struct cont_level
746 {
747  // INDENT-OFF (stop infinite recursion)
748  PLFLT level; // contour level
749  struct cont_line *line; // contour line struct
750  struct cont_level *next; // contour level struct
751  // INDENT-ON
752 } CONT_LEVEL;
753 
754 void
755 cont_store( const PLFLT * const *f, PLINT nx, PLINT ny,
756  PLINT kx, PLINT lx, PLINT ky, PLINT ly,
757  const PLFLT *clevel, PLINT nlevel,
758  void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ),
759  PLPointer pltr_data,
760  CONT_LEVEL **contour );
761 
762 void
764 
765 // Get the viewport boundaries in world coordinates, expanded slightly
766 
767 void
768 plP_xgvpw( PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax );
769 
770 // Get x-y domain in world coordinates for 3d plots
771 
772 void
773 plP_gdom( PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax );
774 
775 // Get vertical (z) scale parameters for 3-d plot
776 
777 void
778 plP_grange( PLFLT *p_zscl, PLFLT *p_zmin, PLFLT *p_zmax );
779 
780 // Get parameters used in 3d plots
781 
782 void
783 plP_gw3wc( PLFLT *p_dxx, PLFLT *p_dxy, PLFLT *p_dyx, PLFLT *p_dyy,
784  PLFLT *p_dyz );
785 
786 // Get clip boundaries in physical coordinates
787 
788 void
789 plP_gclp( PLINT *p_ixmin, PLINT *p_ixmax, PLINT *p_iymin, PLINT *p_iymax );
790 
791 // Set clip boundaries in physical coordinates
792 
793 void
794 plP_sclp( PLINT ixmin, PLINT ixmax, PLINT iymin, PLINT iymax );
795 
796 // Get physical device limits in physical coordinates
797 
798 PLDLLIMPEXP void
799 plP_gphy( PLINT *p_ixmin, PLINT *p_ixmax, PLINT *p_iymin, PLINT *p_iymax );
800 
801 // Get number of subpages on physical device and current subpage
802 
803 PLDLLIMPEXP void
804 plP_gsub( PLINT *p_nx, PLINT *p_ny, PLINT *p_cs );
805 
806 // Set number of subpages on physical device and current subpage
807 
808 PLDLLIMPEXP void
809 plP_ssub( PLINT nx, PLINT ny, PLINT cs );
810 
811 // Set up plot parameters according to the number of subpages.
812 
813 void
814 plP_subpInit( void );
815 
816 // Get number of pixels to a millimeter
817 
818 PLDLLIMPEXP void
819 plP_gpixmm( PLFLT *p_x, PLFLT *p_y );
820 
821 // All the drivers call this to set physical pixels/mm.
822 
823 PLDLLIMPEXP void
824 plP_setpxl( PLFLT xpmm0, PLFLT ypmm0 );
825 
826 // Get background parameters (including line width) for 3d plot.
827 
828 void
829 plP_gzback( PLINT **zbf, PLINT **zbc, PLFLT **zbt, PLFLT **zbw );
830 
831 // Move to physical coordinates (x,y).
832 
833 void
834 plP_movphy( PLINT x, PLINT y );
835 
836 // Draw to physical coordinates (x,y).
837 
838 void
839 plP_draphy( PLINT x, PLINT y );
840 
841 // Move to world coordinates (x,y).
842 
843 void
844 plP_movwor( PLFLT x, PLFLT y );
845 
846 // Draw to world coordinates (x,y).
847 
848 void
849 plP_drawor( PLFLT x, PLFLT y );
850 
851 // Draw polyline in physical coordinates.
852 
853 void
854 plP_draphy_poly( PLINT *x, PLINT *y, PLINT n );
855 
856 // Draw polyline in world coordinates.
857 
858 void
859 plP_drawor_poly( const PLFLT *x, const PLFLT *y, PLINT n );
860 
861 // Sets up physical limits of plotting device.
862 
863 PLDLLIMPEXP void
864 plP_setphy( PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax );
865 
866 // Set up the subpage boundaries according to the current subpage selected
867 
868 PLDLLIMPEXP void
869 plP_setsub( void );
870 
871 // Get the floating point precision (in number of places) in numeric labels.
872 
873 void
874 plP_gprec( PLINT *p_setp, PLINT *p_prec );
875 
876 // Get the date / time format for numeric labels
877 
878 const char *
879 plP_gtimefmt( void );
880 
881 // Computes the length of a string in mm, including escape sequences.
882 
883 PLFLT
884 plstrl( const char *string );
885 
886 // Similar to strpos, but searches for occurence of string str2.
887 
888 PLINT
889 plP_stindex( const char *str1, const char *str2 );
890 
891 // Searches string str for first occurence of character chr.
892 
894 plP_strpos( const char *str, int chr );
895 
896 // Searches string str for character chr (case insensitive).
897 
898 PLBOOL
899 plP_stsearch( const char *str, int chr );
900 
901 // Conversion functions
902 
903 // device coords to physical coords (x)
904 
905 PLINT
906 plP_dcpcx( PLFLT x );
907 
908 // device coords to physical coords (y)
909 
910 PLINT
911 plP_dcpcy( PLFLT y );
912 
913 // millimeters from bottom left-hand corner to physical coords (x)
914 
915 PLINT
916 plP_mmpcx( PLFLT x );
917 
918 // millimeters from bottom left-hand corner to physical coords (y)
919 
920 PLINT
921 plP_mmpcy( PLFLT y );
922 
923 // world coords to physical coords (x)
924 
925 PLINT
926 plP_wcpcx( PLFLT x );
927 
928 // world coords to physical coords (y)
929 
930 PLINT
931 plP_wcpcy( PLFLT y );
932 
933 // physical coords to device coords (x)
934 
935 PLFLT
936 plP_pcdcx( PLINT x );
937 
938 // physical coords to device coords (y)
939 
940 PLFLT
941 plP_pcdcy( PLINT y );
942 
943 // millimeters from bottom left corner to device coords (x)
944 
945 PLFLT
946 plP_mmdcx( PLFLT x );
947 
948 // millimeters from bottom left corner to device coords (y)
949 
950 PLFLT
951 plP_mmdcy( PLFLT y );
952 
953 // world coords into device coords (x)
954 
955 PLFLT
956 plP_wcdcx( PLFLT x );
957 
958 // world coords into device coords (y)
959 
960 PLFLT
961 plP_wcdcy( PLFLT y );
962 
963 // subpage coords to device coords (x)
964 
965 PLFLT
966 plP_scdcx( PLFLT x );
967 
968 // subpage coords to device coords (y)
969 
970 PLFLT
971 plP_scdcy( PLFLT y );
972 
973 // device coords to millimeters from bottom left-hand corner (x)
974 
975 PLFLT
976 plP_dcmmx( PLFLT x );
977 
978 // device coords to millimeters from bottom left-hand corner (y)
979 
980 PLFLT
981 plP_dcmmy( PLFLT y );
982 
983 // world coords into millimeters (x)
984 
985 PLFLT
986 plP_wcmmx( PLFLT x );
987 
988 // world coords into millimeters (y)
989 
990 PLFLT
991 plP_wcmmy( PLFLT y );
992 
993 // device coords to subpage coords (x)
994 
995 PLFLT
996 plP_dcscx( PLFLT x );
997 
998 // device coords to subpage coords (y)
999 
1000 PLFLT
1001 plP_dcscy( PLFLT y );
1002 
1003 // 3-d coords to 2-d projection (x)
1004 
1005 PLFLT
1006 plP_w3wcx( PLFLT x, PLFLT y, PLFLT z );
1007 
1008 // 3-d coords to 2-d projection (y)
1009 
1010 PLFLT
1011 plP_w3wcy( PLFLT x, PLFLT y, PLFLT z );
1012 
1013 // 3-d coords to 2-d projection (z)
1014 
1015 PLFLT
1016 plP_w3wcz( PLFLT x, PLFLT y, PLFLT z );
1017 
1018 // Returns the rotation and shear angle and stride from a plplot transformation matrix
1019 
1020 PLDLLIMPEXP void
1021 plRotationShear( PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride );
1022 
1023 // Test whether a point is in a polygon.
1024 int
1025 plP_pointinpolygon( PLINT n, const PLFLT *x, const PLFLT *y,
1026  PLFLT xp, PLFLT yp );
1027 
1028 // Driver calls
1029 
1030 // Initialize device.
1031 
1032 void
1033 plP_init( void );
1034 
1035 // Draw line between two points
1036 
1037 void
1038 plP_line( short *x, short *y );
1039 
1040 // Draw polyline
1041 
1042 void
1043 plP_polyline( short *x, short *y, PLINT npts );
1044 
1045 // Fill polygon
1046 
1047 PLDLLIMPEXP void
1048 plP_fill( short *x, short *y, PLINT npts );
1049 
1050 // Render gradient
1051 
1052 void
1053 plP_gradient( short *x, short *y, PLINT npts );
1054 
1055 // draw image
1056 
1057 void
1058 plP_image( PLFLT *z, PLINT nx, PLINT ny, PLFLT xmin, PLFLT ymin, PLFLT dx, PLFLT dy,
1059  void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ), PLPointer pltr_data );
1060 
1061 // Structure for holding arc data
1062 typedef struct
1063 {
1072 } arc_struct;
1073 
1074 // End of page
1075 
1076 PLDLLIMPEXP void
1077 plP_eop( void );
1078 
1079 // End of page
1080 
1081 PLDLLIMPEXP void
1082 plP_bop( void );
1083 
1084 // Tidy up device (flush buffers, close file, etc.)
1085 
1086 void
1087 plP_tidy( void );
1088 
1089 // Change state.
1090 
1091 PLDLLIMPEXP void
1092 plP_state( PLINT op );
1093 
1094 // Escape function, for driver-specific commands.
1095 
1096 PLDLLIMPEXP void
1097 plP_esc( PLINT op, void *ptr );
1098 
1099 // Set up plot window parameters.
1100 
1101 void
1102 plP_swin( PLWindow *plwin );
1103 
1104 // Return file pointer to lib file.
1105 
1106 FILE *
1107 plLibOpen( const char *fn );
1108 
1109 // Does required startup initialization of library.
1110 
1111 PLDLLIMPEXP void
1112 pllib_init( void );
1113 
1114 // Does preliminary setup of device driver.
1115 
1116 PLDLLIMPEXP void
1117 pllib_devinit( void );
1118 
1119 // Utility to copy one PLColor to another.
1120 
1121 PLDLLIMPEXP void
1122 pl_cpcolor( PLColor *to, PLColor *from );
1123 
1124 // Does required startup initialization of a stream.
1125 
1126 void
1127 plstrm_init( void );
1128 
1129 // Builds a list of the active devices/streams by device name
1130 
1131 void
1132 PLDLLIMPEXP plP_getinitdriverlist( char *names );
1133 
1134 // Checks a give list of device names against active streams and returns the number of matches
1135 
1136 PLINT
1137 plP_checkdriverinit( char *names );
1138 
1139 // disable writing to plot buffer and pixmap
1140 void
1141 NoBufferNoPixmap( void );
1142 
1143 // restart writing to plot buffer and pixmap
1144 void
1146 
1147 void
1148 grimage( short *x, short *y, unsigned short *z, PLINT nx, PLINT ny );
1149 
1150 PLDLLIMPEXP int
1151 plInBuildTree( void );
1152 
1153 void
1154 plimageslow( PLFLT *idata, PLINT nx, PLINT ny,
1155  PLFLT xmin, PLFLT ymin, PLFLT dx, PLFLT dy,
1156  void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ),
1157  PLPointer pltr_data );
1158 
1159 typedef struct
1160 {
1162 } IMG_DT;
1163 
1164 //
1165 // void plfvect()
1166 //
1167 // Internal routine to plot a vector array with arbitrary coordinate
1168 // and vector transformations.
1169 // This is not currently intended to be called direct by the user
1170 //
1171 PLDLLIMPEXP void
1173  PLPointer f2evalv_data, PLPointer f2evalc_data,
1174  PLINT nx, PLINT ny, PLFLT scale,
1175  void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ),
1176  PLPointer pltr_data );
1177 
1178 //
1179 // Internal function to get an index to the hershey table
1180 //
1181 int
1182 plhershey2unicode( int in );
1183 
1184 // struct used for FCI to FontName lookups.
1185 typedef struct
1186 {
1188  const unsigned char *pfont;
1190 
1191 // Internal function to obtain a pointer to a valid font name.
1192 PLDLLIMPEXP const char *
1194  const FCI_to_FontName_Table lookup[], const int nlookup );
1195 
1196 
1197 // Internal function to free memory from driver options
1198 void
1199 plP_FreeDrvOpts( void );
1200 
1201 // Convert a ucs4 unichar to utf8 char string
1202 PLDLLIMPEXP int
1203 ucs4_to_utf8( PLUNICODE unichar, char *ptr );
1204 
1205 //
1206 // Wrapper functions for the system IO routines fread, fwrite
1207 //
1208 
1209 // wraps fwrite
1210 
1211 void
1212 plio_fwrite( void *, size_t, size_t, FILE * );
1213 
1214 // wraps fread
1215 
1216 void
1217 plio_fread( void *, size_t, size_t, FILE * );
1218 
1219 // wraps fgets
1220 
1221 void
1222 plio_fgets( char *, int, FILE * );
1223 
1224 // Draws a tick parallel to x, using world coordinates
1225 void
1226 plwxtik( PLFLT x, PLFLT y, PLBOOL minor, PLBOOL invert );
1227 
1228 // Draws a tick parallel to y, using world coordinates
1229 void
1230 plwytik( PLFLT x, PLFLT y, PLBOOL minor, PLBOOL invert );
1231 
1232 // get drivers directory
1233 
1234 #ifdef ENABLE_DYNDRIVERS
1235 PLDLLIMPEXP const char*
1236 plGetDrvDir( void );
1237 #endif
1238 
1239 #ifdef PL_HAVE_FREETYPE
1240 PLDLLIMPEXP void
1241 plD_FreeType_init( PLStream * );
1242 
1243 PLDLLIMPEXP void
1244 plD_render_freetype_text( PLStream *, EscText * );
1245 
1246 PLDLLIMPEXP void
1247 plD_FreeType_Destroy( PLStream * );
1248 
1249 PLDLLIMPEXP void
1250 pl_set_extended_cmap0( PLStream *, int, int );
1251 
1252 #endif
1253 
1254 // Create a temporary file securely
1255 PLDLLIMPEXP FILE *
1256 pl_create_tempfile( char **fname );
1257 
1258 // Create a temporary fifo securely
1259 PLDLLIMPEXP char *
1260 pl_create_tempfifo( const char **p_fifoname, const char **p_dirname );
1261 
1262 // Read a meta file
1263 PLDLLIMPEXP void
1264 plreadmetafile( char *infile );
1265 
1266 #ifdef __cplusplus
1267 }
1268 #endif
1269 
1270 #endif // __PLPLOTP_H__