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