PLplot: plplotP.h Source File

PLplot 5.10.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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