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