PLplot  5.10.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 attribute
331 #define PLSTATE_CMAP0 5 // change to cmap 0
332 #define PLSTATE_CMAP1 6 // change to cmap 1
333 
334 // Bit switches used in the driver interface
335 
336 #define PLDI_MAP 0x01
337 #define PLDI_ORI 0x02
338 #define PLDI_PLT 0x04
339 #define PLDI_DEV 0x08
340 
341 // Default size for family files, in KB.
342 
343 #ifndef PL_FILESIZE_KB
344 #define PL_FILESIZE_KB 1000
345 #endif
346 
347 // Font file names.
348 
349 #define PLPLOT5_FONTS
350 
351 #ifdef PLPLOT5_FONTS
352 #define PL_XFONT "plxtnd5.fnt"
353 #define PL_SFONT "plstnd5.fnt"
354 #else
355 #define PL_XFONT "plxtnd4.fnt"
356 #define PL_SFONT "plstnd4.fnt"
357 #endif
358 
359 //--------------------------------------------------------------------------
360 // The following environment variables are defined:
361 //
362 // PLPLOT_BIN # where to find executables
363 // PLPLOT_LIB # where to find library files (fonts, maps, etc)
364 // PLPLOT_TCL # where to find tcl scripts
365 //
366 // PLPLOT_HOME # basename of plplot hierarchy
367 //
368 // search order:
369 // 1) the most specific possible locators, one of
370 // $(PLPLOT_BIN)
371 // $(PLPLOT_LIB)
372 // $(PLPLOT_TCL)
373 // as appropriate
374 //
375 // 2) the current directory
376 //
377 // 3) one of $(PLPLOT_HOME)/bin
378 // $(PLPLOT_HOME)/lib
379 // $(PLPLOT_HOME)/tcl
380 // as appropriate
381 //
382 // 4) as appropriate, the compile-time (Makefile)
383 // BIN_DIR, LIB_DIR, TCL_DIR
384 //
385 // 8 Jun 1994 mj olesen (olesen@weber.me.queensu.ca)
386 //
387 // Other notes:
388 //
389 // In addition to the directories above, the following are also used:
390 //
391 // Lib file search path: PLLIBDEV (see plctrl.c). This is checked last,
392 // and is a system-dependent hardwired location.
393 //
394 // Tcl search path: $HOME/tcl is searched before the install location,
395 // TCL_DIR.
396 //--------------------------------------------------------------------------
397 
398 #define PLPLOT_BIN_ENV "PLPLOT_BIN"
399 #define PLPLOT_LIB_ENV "PLPLOT_LIB"
400 #define PLPLOT_TCL_ENV "PLPLOT_TCL"
401 #define PLPLOT_HOME_ENV "PLPLOT_HOME"
402 
403 // Maximum size for path strings in the plplot code
404 #define PLPLOT_MAX_PATH 1024
405 
406 //
407 // Some stuff that is included (and compiled into) plsym.h
408 // Other modules might want this, so we will "extern" it
409 //
410 //
411 
412 #ifndef __PLSYM_H__
413 
414 typedef struct
415 {
416  unsigned int Hershey;
418  char Font;
420 
423 
424 
425 #endif
426 
427 // Greek character translation array (defined in plcore.c)
428 extern const char plP_greek_mnemonic[];
429 
430 //--------------------------------------------------------------------------
431 // Function Prototypes
432 //
433 // These typically should not be called directly by the user.
434 //--------------------------------------------------------------------------
435 
436 #ifdef __cplusplus
437 extern "C" {
438 #endif
439 
440 // Number of elements in the affine vector representation of the affine
441 // transformation matrix.
442 #define NAFFINE 6
443 
444 // Returns affine identity matrix
445 
446 PLDLLIMPEXP void
447 plP_affine_identity( PLFLT *affine_vector );
448 
449 // Translate new coordinate system axes relative to the old.
450 
451 PLDLLIMPEXP void
452 plP_affine_translate( PLFLT *affine_vector, PLFLT xtranslate, PLFLT ytranslate );
453 
454 // Scale new coordinate system axes relative to the old.
455 
456 PLDLLIMPEXP void
457 plP_affine_scale( PLFLT *affine_vector, PLFLT xscale, PLFLT yscale );
458 
459 // Rotate new coordinate system axes relative to the old.
460 // angle is in degrees.
461 
462 PLDLLIMPEXP void
463 plP_affine_rotate( PLFLT *affine_vector, PLFLT angle );
464 
465 // Skew new X coordinate axis relative to the old.
466 // angle is in degrees.
467 
468 PLDLLIMPEXP void
469 plP_affine_xskew( PLFLT *affine_vector, PLFLT angle );
470 
471 // Skew new Y coordinate axis relative to the old.
472 // angle is in degrees.
473 
474 PLDLLIMPEXP void
475 plP_affine_yskew( PLFLT *affine_vector, PLFLT angle );
476 
477 // Multiply two affine transformation matrices to form a third.
478 //
479 // A = B * C
480 //
481 //
482 
483 PLDLLIMPEXP void
485  PLFLT *affine_vectorA,
486  const PLFLT *affine_vectorB,
487  const PLFLT *affine_vectorC );
488 
489 // Determines interval between numeric labels
490 
491 void
492 pldtik( PLFLT vmin, PLFLT vmax, PLFLT *tick, PLINT *nsubt, PLBOOL ld );
493 
494 // Writes numeric labels on side(s) of box in custom locations
495 
496 void
497 label_box_custom( const char *xopt, PLINT n_xticks, const PLFLT *xticks, const char *yopt, PLINT n_yticks, const PLFLT *yticks );
498 
499 // Determine factor to convert date / time in seconds to more natural
500 // units
501 
502 void
503 pldtfac( PLFLT vmin, PLFLT vmax, PLFLT *factor, PLFLT *tstart );
504 
505 // Determines precision of box labels
506 
507 void
508 pldprec( PLFLT vmin, PLFLT vmax, PLFLT tick, PLINT lf,
509  PLINT *mode, PLINT *prec, PLINT digmax, PLINT *scale );
510 
511 // Draws a polyline within the clip limits.
512 
513 void
514 plP_pllclp( PLINT *x, PLINT *y, PLINT npts,
516  void ( *draw )( short *, short *, PLINT ) );
517 
518 // Fills a polygon within the clip limits.
519 
520 void
521 plP_plfclp( PLINT *x, PLINT *y, PLINT npts,
522  PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax,
523  void ( *draw )( short *, short *, PLINT ) );
524 
525 // Clip a polygon to the 3d bounding plane
526 int
527 plP_clip_poly( int Ni, PLFLT *Vi[3], int axis, PLFLT dir, PLFLT offset );
528 
529 // Get clipped endpoints
530 
531 int
532 plP_clipline( PLINT *p_x1, PLINT *p_y1, PLINT *p_x2, PLINT *p_y2,
533  PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax );
534 
535 // Stores hex digit value into FCI (font characterization integer).
536 void
537 plP_hex2fci( unsigned char hexdigit, unsigned char hexpower, PLUNICODE *pfci );
538 
539 // Retrieves hex digit value from FCI (font characterization integer).
540 PLDLLIMPEXP void
541 plP_fci2hex( PLUNICODE fci, unsigned char *phexdigit, unsigned char hexpower );
542 
543 // Pattern fills in software the polygon bounded by the input points.
544 
545 PLDLLIMPEXP void
546 plfill_soft( short *x, short *y, PLINT npts );
547 
548 // In case of an abort this routine is called. It just prints out an
549 // error message and tries to clean up as much as possible.
550 
551 PLDLLIMPEXP void
552 plexit( const char *errormsg );
553 
554 // Just a front-end to exit().
555 
556 void
557 pl_exit( void );
558 
559 // A handy way to issue warnings, if need be.
560 
561 PLDLLIMPEXP void
562 plwarn( const char *errormsg );
563 
564 // Same as plwarn(), but appends ", aborting plot" to the error message
565 
566 PLDLLIMPEXP void
567 plabort( const char *errormsg );
568 
569 // Loads either the standard or extended font.
570 
571 void
572 plfntld( PLINT fnt );
573 
574 // Release memory for fonts.
575 
576 void
577 plfontrel( void );
578 
579 // A replacement for strdup(), which isn't portable.
580 
581 PLDLLIMPEXP char *
582 plstrdup( const char *src );
583 
584 // Bin up cmap 1 space and assign colors to make inverse mapping easy.
585 
586 PLDLLIMPEXP void
587 plcmap1_calc( void );
588 
589 // Draws a slanting tick at position (mx,my) (measured in mm) of
590 // vector length (dx,dy).
591 
592 void
593 plstik( PLFLT mx, PLFLT my, PLFLT dx, PLFLT dy );
594 
595 // Prints out a "string" at reference position with physical coordinates
596 // (refx,refy).
597 
598 void
599 plstr( PLINT base, PLFLT *xform, PLINT refx, PLINT refy, const char *string );
600 
601 // Draws a tick parallel to x.
602 
603 void
604 plxtik( PLINT x, PLINT y, PLINT below, PLINT above );
605 
606 // Draws a tick parallel to y.
607 
608 void
609 plytik( PLINT x, PLINT y, PLINT left, PLINT right );
610 
611 // Driver interface filter --
612 // passes all coordinates through a variety of filters.
613 
614 PLDLLIMPEXP void
615 difilt( PLINT *, PLINT *, PLINT,
616  PLINT *, PLINT *, PLINT *, PLINT * );
617 
618 // Transforms the clipping region coordinates as necessary
619 // based on the current plot orientation, etc.
620 
621 PLDLLIMPEXP void
622 difilt_clip( PLINT *, PLINT * );
623 
624 // Calculate scale of font size and scale of magnitude of vertical
625 // offset associated with superscripts and subscripts.
626 
627 PLDLLIMPEXP void
628 plP_script_scale( PLBOOL ifupper, PLINT *level,
629  PLFLT *old_scale, PLFLT *scale,
630  PLFLT *old_offset, PLFLT *offset );
631 
632 // Driver draws text
633 
634 void
635 plP_text( PLINT base, PLFLT just, PLFLT *xform, PLINT x, PLINT y,
636  PLINT refx, PLINT refy, const char *string );
637 
638 // Save LC_NUMERIC locale string, then set "C" locale to protect
639 // parts of PLplot which absolutely demand the LC_NUMERIC "C" locale.
640 
641 PLDLLIMPEXP char *
642 plsave_set_locale( void );
643 
644 // Restore LC_NUMERIC locale that was determined by plsave_set_locale.
645 
646 PLDLLIMPEXP void
647 plrestore_locale( char * save_lc_numeric_locale );
648 
649 // where should structure definitions that must be seen by drivers and core source files, be?
650 
651 // structure to be used by plcore.c and anydriver.c, related to plP_text()
652 
653 typedef struct
654 {
655  PLINT base; // ref point at base(1) or center(0) of text. Currently plplot only use 0
656  PLFLT just; // continuos justification, 0 left, 0.5 center, 1 right
657  PLFLT *xform; // transformation (rotation) matrix
658  PLINT x; // raw reference point--after any transformation
660  PLINT refx; // processed ref. point--after justification, displacement, etc, processing
662  char font_face; // font face OPTIONALLY used for rendering hershey codes
663  // The following 3 fields are used by the alternative text handling pathway.
664  // See drivers/cairo.h for details about how this works.
665  PLUNICODE n_fci; // font storage for unicode font handling
666  PLUNICODE n_char; // character storage for unicode font handling
667  PLINT n_ctrl_char; // control character code storage for unicode font handling
668  PLUNICODE unicode_char; // an int to hold either a Hershey, ASC-II, or Unicode value for plsym calls
669  PLUNICODE *unicode_array; // a pointer to an array of ints holding either a Hershey, ASC-II, or Unicode value for cached plsym
670  unsigned short unicode_array_len;
671  const char *string; // text to draw
672 }EscText;
673 
674 //
675 // structure that contains driver specific information, to be used by plargs.c and anydriver.c,
676 // related to plParseDrvOpts() and plHelpDrvOpts()
677 //
678 
679 typedef struct
680 {
681  const char *opt; // a string with the name of the option
682  PLINT type; // the type of the variable to be set, see bellow the available types
683  void *var_ptr; // a pointer to the variable to be set
684  const char *hlp_msg; // help message of the option
685 } DrvOpt;
686 
687 // the available variable types, DrvOpt.type, for driver specific options
688 
690 
691 // parse driver specific options, as in -drvopt <option[=value]>*
692 
693 PLDLLIMPEXP int
695 
696 // give help on driver specific options
697 
698 void
699 plHelpDrvOpts( DrvOpt * );
700 
701 //
702 // structures to store contour lines
703 //
704 
705 #define LINE_ITEMS 20
706 
707 typedef struct cont_line
708 {
712  struct cont_line *next;
713 } CONT_LINE;
714 
715 typedef struct cont_level
716 {
717  // INDENT-OFF (stop infinite recursion)
718  PLFLT level; // contour level
719  struct cont_line *line; // contour line struct
720  struct cont_level *next; // contour level struct
721  // INDENT-ON
722 } CONT_LEVEL;
723 
724 void
725 cont_store( const PLFLT * const *f, PLINT nx, PLINT ny,
726  PLINT kx, PLINT lx, PLINT ky, PLINT ly,
727  const PLFLT *clevel, PLINT nlevel,
728  void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ),
729  PLPointer pltr_data,
730  CONT_LEVEL **contour );
731 
732 void
734 
735 // Get the viewport boundaries in world coordinates, expanded slightly
736 
737 void
738 plP_xgvpw( PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax );
739 
740 // Get x-y domain in world coordinates for 3d plots
741 
742 void
743 plP_gdom( PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax );
744 
745 // Get vertical (z) scale parameters for 3-d plot
746 
747 void
748 plP_grange( PLFLT *p_zscl, PLFLT *p_zmin, PLFLT *p_zmax );
749 
750 // Get parameters used in 3d plots
751 
752 void
753 plP_gw3wc( PLFLT *p_dxx, PLFLT *p_dxy, PLFLT *p_dyx, PLFLT *p_dyy,
754  PLFLT *p_dyz );
755 
756 // Get clip boundaries in physical coordinates
757 
758 void
759 plP_gclp( PLINT *p_ixmin, PLINT *p_ixmax, PLINT *p_iymin, PLINT *p_iymax );
760 
761 // Set clip boundaries in physical coordinates
762 
763 void
764 plP_sclp( PLINT ixmin, PLINT ixmax, PLINT iymin, PLINT iymax );
765 
766 // Get physical device limits in physical coordinates
767 
768 PLDLLIMPEXP void
769 plP_gphy( PLINT *p_ixmin, PLINT *p_ixmax, PLINT *p_iymin, PLINT *p_iymax );
770 
771 // Get number of subpages on physical device and current subpage
772 
773 PLDLLIMPEXP void
774 plP_gsub( PLINT *p_nx, PLINT *p_ny, PLINT *p_cs );
775 
776 // Set number of subpages on physical device and current subpage
777 
778 PLDLLIMPEXP void
779 plP_ssub( PLINT nx, PLINT ny, PLINT cs );
780 
781 // Set up plot parameters according to the number of subpages.
782 
783 void
784 plP_subpInit( void );
785 
786 // Get number of pixels to a millimeter
787 
788 PLDLLIMPEXP void
789 plP_gpixmm( PLFLT *p_x, PLFLT *p_y );
790 
791 // All the drivers call this to set physical pixels/mm.
792 
793 PLDLLIMPEXP void
794 plP_setpxl( PLFLT xpmm0, PLFLT ypmm0 );
795 
796 // Get background parameters (including line width) for 3d plot.
797 
798 void
799 plP_gzback( PLINT **zbf, PLINT **zbc, PLFLT **zbt, PLFLT **zbw );
800 
801 // Move to physical coordinates (x,y).
802 
803 void
804 plP_movphy( PLINT x, PLINT y );
805 
806 // Draw to physical coordinates (x,y).
807 
808 void
809 plP_draphy( PLINT x, PLINT y );
810 
811 // Move to world coordinates (x,y).
812 
813 void
814 plP_movwor( PLFLT x, PLFLT y );
815 
816 // Draw to world coordinates (x,y).
817 
818 void
819 plP_drawor( PLFLT x, PLFLT y );
820 
821 // Draw polyline in physical coordinates.
822 
823 void
824 plP_draphy_poly( PLINT *x, PLINT *y, PLINT n );
825 
826 // Draw polyline in world coordinates.
827 
828 void
829 plP_drawor_poly( const PLFLT *x, const PLFLT *y, PLINT n );
830 
831 // Sets up physical limits of plotting device.
832 
833 PLDLLIMPEXP void
834 plP_setphy( PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax );
835 
836 // Set up the subpage boundaries according to the current subpage selected
837 
838 PLDLLIMPEXP void
839 plP_setsub( void );
840 
841 // Get the floating point precision (in number of places) in numeric labels.
842 
843 void
844 plP_gprec( PLINT *p_setp, PLINT *p_prec );
845 
846 // Get the date / time format for numeric labels
847 
848 const char *
849 plP_gtimefmt( void );
850 
851 // Computes the length of a string in mm, including escape sequences.
852 
853 PLFLT
854 plstrl( const char *string );
855 
856 // Similar to strpos, but searches for occurence of string str2.
857 
858 PLINT
859 plP_stindex( const char *str1, const char *str2 );
860 
861 // Searches string str for first occurence of character chr.
862 
864 plP_strpos( const char *str, int chr );
865 
866 // Searches string str for character chr (case insensitive).
867 
868 PLBOOL
869 plP_stsearch( const char *str, int chr );
870 
871 // Conversion functions
872 
873 // device coords to physical coords (x)
874 
875 PLINT
876 plP_dcpcx( PLFLT x );
877 
878 // device coords to physical coords (y)
879 
880 PLINT
881 plP_dcpcy( PLFLT y );
882 
883 // millimeters from bottom left-hand corner to physical coords (x)
884 
885 PLINT
886 plP_mmpcx( PLFLT x );
887 
888 // millimeters from bottom left-hand corner to physical coords (y)
889 
890 PLINT
891 plP_mmpcy( PLFLT y );
892 
893 // world coords to physical coords (x)
894 
895 PLINT
896 plP_wcpcx( PLFLT x );
897 
898 // world coords to physical coords (y)
899 
900 PLINT
901 plP_wcpcy( PLFLT y );
902 
903 // physical coords to device coords (x)
904 
905 PLFLT
906 plP_pcdcx( PLINT x );
907 
908 // physical coords to device coords (y)
909 
910 PLFLT
911 plP_pcdcy( PLINT y );
912 
913 // millimeters from bottom left corner to device coords (x)
914 
915 PLFLT
916 plP_mmdcx( PLFLT x );
917 
918 // millimeters from bottom left corner to device coords (y)
919 
920 PLFLT
921 plP_mmdcy( PLFLT y );
922 
923 // world coords into device coords (x)
924 
925 PLFLT
926 plP_wcdcx( PLFLT x );
927 
928 // world coords into device coords (y)
929 
930 PLFLT
931 plP_wcdcy( PLFLT y );
932 
933 // subpage coords to device coords (x)
934 
935 PLFLT
936 plP_scdcx( PLFLT x );
937 
938 // subpage coords to device coords (y)
939 
940 PLFLT
941 plP_scdcy( PLFLT y );
942 
943 // device coords to millimeters from bottom left-hand corner (x)
944 
945 PLFLT
946 plP_dcmmx( PLFLT x );
947 
948 // device coords to millimeters from bottom left-hand corner (y)
949 
950 PLFLT
951 plP_dcmmy( PLFLT y );
952 
953 // world coords into millimeters (x)
954 
955 PLFLT
956 plP_wcmmx( PLFLT x );
957 
958 // world coords into millimeters (y)
959 
960 PLFLT
961 plP_wcmmy( PLFLT y );
962 
963 // device coords to subpage coords (x)
964 
965 PLFLT
966 plP_dcscx( PLFLT x );
967 
968 // device coords to subpage coords (y)
969 
970 PLFLT
971 plP_dcscy( PLFLT y );
972 
973 // 3-d coords to 2-d projection (x)
974 
975 PLFLT
976 plP_w3wcx( PLFLT x, PLFLT y, PLFLT z );
977 
978 // 3-d coords to 2-d projection (y)
979 
980 PLFLT
981 plP_w3wcy( PLFLT x, PLFLT y, PLFLT z );
982 
983 // 3-d coords to 2-d projection (z)
984 
985 PLFLT
986 plP_w3wcz( PLFLT x, PLFLT y, PLFLT z );
987 
988 // Returns the rotation and shear angle and stride from a plplot transformation matrix
989 
990 PLDLLIMPEXP void
991 plRotationShear( PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride );
992 
993 // Test whether a point is in a polygon.
994 int
995 plP_pointinpolygon( PLINT n, const PLFLT *x, const PLFLT *y,
996  PLFLT xp, PLFLT yp );
997 
998 // Driver calls
999 
1000 // Initialize device.
1001 
1002 void
1003 plP_init( void );
1004 
1005 // Draw line between two points
1006 
1007 void
1008 plP_line( short *x, short *y );
1009 
1010 // Draw polyline
1011 
1012 void
1013 plP_polyline( short *x, short *y, PLINT npts );
1014 
1015 // Fill polygon
1016 
1017 void
1018 plP_fill( short *x, short *y, PLINT npts );
1019 
1020 // Render gradient
1021 
1022 void
1023 plP_gradient( short *x, short *y, PLINT npts );
1024 
1025 // draw image
1026 
1027 void
1028 plP_image( PLFLT *z, PLINT nx, PLINT ny, PLFLT xmin, PLFLT ymin, PLFLT dx, PLFLT dy,
1029  void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ), PLPointer pltr_data );
1030 
1031 // Structure for holding arc data
1032 typedef struct
1033 {
1042 } arc_struct;
1043 
1044 // End of page
1045 
1046 PLDLLIMPEXP void
1047 plP_eop( void );
1048 
1049 // End of page
1050 
1051 PLDLLIMPEXP void
1052 plP_bop( void );
1053 
1054 // Tidy up device (flush buffers, close file, etc.)
1055 
1056 void
1057 plP_tidy( void );
1058 
1059 // Change state.
1060 
1061 PLDLLIMPEXP void
1062 plP_state( PLINT op );
1063 
1064 // Escape function, for driver-specific commands.
1065 
1066 PLDLLIMPEXP void
1067 plP_esc( PLINT op, void *ptr );
1068 
1069 // Set up plot window parameters.
1070 
1071 void
1072 plP_swin( PLWindow *plwin );
1073 
1074 // Return file pointer to lib file.
1075 
1076 FILE *
1077 plLibOpen( const char *fn );
1078 
1079 // Does required startup initialization of library.
1080 
1081 PLDLLIMPEXP void
1082 pllib_init( void );
1083 
1084 // Does preliminary setup of device driver.
1085 
1086 PLDLLIMPEXP void
1087 pllib_devinit( void );
1088 
1089 // Utility to copy one PLColor to another.
1090 
1091 PLDLLIMPEXP void
1092 pl_cpcolor( PLColor *to, PLColor *from );
1093 
1094 // Does required startup initialization of a stream.
1095 
1096 void
1097 plstrm_init( void );
1098 
1099 // Builds a list of the active devices/streams by device name
1100 
1101 void
1102 PLDLLIMPEXP plP_getinitdriverlist( char *names );
1103 
1104 // Checks a give list of device names against active streams and returns the number of matches
1105 
1106 PLINT
1107 plP_checkdriverinit( char *names );
1108 
1109 // disable writing to plot buffer and pixmap
1110 void
1111 NoBufferNoPixmap( void );
1112 
1113 // restart writing to plot buffer and pixmap
1114 void
1116 
1117 void
1118 grimage( short *x, short *y, unsigned short *z, PLINT nx, PLINT ny );
1119 
1120 PLDLLIMPEXP int
1121 plInBuildTree( void );
1122 
1123 void
1124 plimageslow( PLFLT *idata, PLINT nx, PLINT ny,
1125  PLFLT xmin, PLFLT ymin, PLFLT dx, PLFLT dy,
1126  void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ),
1127  PLPointer pltr_data );
1128 
1129 typedef struct
1130 {
1132 } IMG_DT;
1133 
1134 //
1135 // void plfvect()
1136 //
1137 // Internal routine to plot a vector array with arbitrary coordinate
1138 // and vector transformations.
1139 // This is not currently intended to be called direct by the user
1140 //
1141 PLDLLIMPEXP void
1143  PLPointer f2evalv_data, PLPointer f2evalc_data,
1144  PLINT nx, PLINT ny, PLFLT scale,
1145  void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ),
1146  PLPointer pltr_data );
1147 
1148 //
1149 // Internal function to get an index to the hershey table
1150 //
1151 int
1152 plhershey2unicode( int in );
1153 
1154 // struct used for FCI to FontName lookups.
1155 typedef struct
1156 {
1158  const unsigned char *pfont;
1160 
1161 // Internal function to obtain a pointer to a valid font name.
1162 PLDLLIMPEXP const char *
1164  const FCI_to_FontName_Table lookup[], const int nlookup );
1165 
1166 
1167 // Internal function to free memory from driver options
1168 void
1169 plP_FreeDrvOpts( void );
1170 
1171 // Convert a ucs4 unichar to utf8 char string
1172 PLDLLIMPEXP int
1173 ucs4_to_utf8( PLUNICODE unichar, char *ptr );
1174 
1175 //
1176 // Wrapper functions for the system IO routines fread, fwrite
1177 //
1178 
1179 // wraps fwrite
1180 
1181 void
1182 plio_fwrite( void *, size_t, size_t, FILE * );
1183 
1184 // wraps fread
1185 
1186 void
1187 plio_fread( void *, size_t, size_t, FILE * );
1188 
1189 // wraps fgets
1190 
1191 void
1192 plio_fgets( char *, int, FILE * );
1193 
1194 // Draws a tick parallel to x, using world coordinates
1195 void
1196 plwxtik( PLFLT x, PLFLT y, PLBOOL minor, PLBOOL invert );
1197 
1198 // Draws a tick parallel to y, using world coordinates
1199 void
1200 plwytik( PLFLT x, PLFLT y, PLBOOL minor, PLBOOL invert );
1201 
1202 // get drivers directory
1203 
1204 #ifdef ENABLE_DYNDRIVERS
1205 PLDLLIMPEXP const char*
1206 plGetDrvDir( void );
1207 #endif
1208 
1209 #ifdef PL_HAVE_FREETYPE
1210 PLDLLIMPEXP void
1211 plD_FreeType_init( PLStream * );
1212 
1213 PLDLLIMPEXP void
1214 plD_render_freetype_text( PLStream *, EscText * );
1215 
1216 PLDLLIMPEXP void
1217 plD_FreeType_Destroy( PLStream * );
1218 
1219 PLDLLIMPEXP void
1220 pl_set_extended_cmap0( PLStream *, int, int );
1221 
1222 #endif
1223 
1224 // Create a temporary file securely
1225 PLDLLIMPEXP FILE *
1226 pl_create_tempfile( char **fname );
1227 
1228 // Create a temporary fifo securely
1229 PLDLLIMPEXP char *
1230 pl_create_tempfifo( const char **p_fifoname, const char **p_dirname );
1231 
1232 #ifdef __cplusplus
1233 }
1234 #endif
1235 
1236 #endif // __PLPLOTP_H__