1 /* 2 * Grace - GRaphing, Advanced Computation and Exploration of data 3 * 4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/ 5 * 6 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR 7 * Copyright (c) 1996-2000 Grace Development Team 8 * 9 * Maintained by Evgeny Stambulchik 10 * 11 * 12 * All Rights Reserved 13 * 14 * This program is free software; you can redistribute it and/or modify 15 * it under the terms of the GNU General Public License as published by 16 * the Free Software Foundation; either version 2 of the License, or 17 * (at your option) any later version. 18 * 19 * This program is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License 25 * along with this program; if not, write to the Free Software 26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 */ 28 29 /* 30 * 31 * constants and typedefs 32 * 33 */ 34 #ifndef __DEFINES_H_ 35 #define __DEFINES_H_ 36 37 #include <config.h> 38 39 /* 40 * some constants 41 * 42 */ 43 44 /* max path length */ 45 #define GR_MAXPATHLEN 256 46 47 /* max length for strings */ 48 #define MAX_STRING_LENGTH 512 49 50 51 #define MAXAXES 4 /* max number of axes per graph */ 52 #define MAX_TICKS 256 /* max number of ticks/labels per axis */ 53 #define MAXREGION 5 /* max number of regions */ 54 55 #define MAX_ZOOM_STACK 20 /* max stack depth for world stack */ 56 57 #define MAXPARM 10 /* max number of parameters for non-lin fit */ 58 59 #define MAXFIT 12 /* max degree of polynomial+1 that can be 60 * fitted */ 61 62 63 /* number of extra objects of a given type to allocate if not enough */ 64 #define OBJECT_BUFNUM 10 65 66 67 #define MAX_ARROW 3 68 #define MAX_PREC 10 69 70 /* symbol types */ 71 72 #define SYM_NONE 0 73 #define SYM_CIRCLE 1 74 #define SYM_SQUARE 2 75 #define SYM_DIAMOND 3 76 #define SYM_TRIANG1 4 77 #define SYM_TRIANG2 5 78 #define SYM_TRIANG3 6 79 #define SYM_TRIANG4 7 80 #define SYM_PLUS 8 81 #define SYM_X 9 82 #define SYM_SPLAT 10 83 #define SYM_CHAR 11 84 85 /* max number of symbols defined */ 86 #define MAXSYM 12 87 88 /* dot (obsolete) */ 89 #define SYM_DOT_OBS 1 90 91 /* 92 * types of coordinate frames 93 */ 94 #define COORDINATES_XY 0 /* Cartesian coordinates */ 95 #define COORDINATES_POLAR 1 /* Polar coordinates */ 96 97 /* 98 * types of axis scale mappings 99 */ 100 #define SCALE_NORMAL 0 /* normal linear scale */ 101 #define SCALE_LOG 1 /* logarithmic scale */ 102 #define SCALE_REC 2 /* reciprocal, reserved */ 103 #define SCALE_LOGIT 3 /* logit scale */ 104 105 /* 106 * coordinates 107 */ 108 #define AXIS_TYPE_ANY -1 109 #define AXIS_TYPE_X 0 110 #define AXIS_TYPE_Y 1 111 #define AXIS_TYPE_BAD 2 112 113 /* 114 * types of axes 115 */ 116 #define ALL_AXES -3 117 #define ALL_X_AXES -2 118 #define ALL_Y_AXES -1 119 120 #define X_AXIS 0 121 #define Y_AXIS 1 122 #define ZX_AXIS 2 123 #define ZY_AXIS 3 124 125 126 /* setno == all sets selected */ 127 #define ALL_SETS -1 128 /* setno == new set to be created */ 129 #define NEW_SET -2 130 131 /* 132 * gno == all graphs selected 133 */ 134 #define ALL_GRAPHS -1 135 136 /* type of splines */ 137 #define INTERP_LINEAR 0 138 #define INTERP_SPLINE 1 139 #define INTERP_ASPLINE 2 140 141 /* Canvas types */ 142 #define PAGE_FREE 0 143 #define PAGE_FIXED 1 144 145 /* Strings and things */ 146 #define OBJECT_NONE -1 147 #define OBJECT_LINE 0 148 #define OBJECT_BOX 1 149 #define OBJECT_ELLIPSE 2 150 #define OBJECT_STRING 3 151 152 /* Region definitions */ 153 #define REGION_ABOVE 0 154 #define REGION_BELOW 1 155 #define REGION_TOLEFT 2 156 #define REGION_TORIGHT 3 157 #define REGION_POLYI 4 158 #define REGION_POLYO 5 159 #define REGION_HORIZI 6 160 #define REGION_VERTI 7 161 #define REGION_HORIZO 8 162 #define REGION_VERTO 9 163 164 /* Axis label layout */ 165 #define LAYOUT_PARALLEL 0 166 #define LAYOUT_PERPENDICULAR 1 167 168 /* Placement (axis labels, ticks, error bars */ 169 typedef enum { 170 PLACEMENT_NORMAL, 171 PLACEMENT_OPPOSITE, 172 PLACEMENT_BOTH 173 } PlacementType; 174 175 /* Tick label placement */ 176 #define LABEL_ONTICK 0 177 #define LABEL_BETWEEN 1 178 179 /* Coordinates */ 180 #define COORD_VIEW 0 181 #define COORD_WORLD 1 182 183 /* Tick sign type */ 184 #define SIGN_NORMAL 0 185 #define SIGN_ABSOLUTE 1 186 #define SIGN_NEGATE 2 187 188 189 /* Tick label/display formats */ 190 #define FORMAT_INVALID -1 191 #define FORMAT_DECIMAL 0 192 #define FORMAT_EXPONENTIAL 1 193 #define FORMAT_GENERAL 2 194 #define FORMAT_POWER 3 195 #define FORMAT_SCIENTIFIC 4 196 #define FORMAT_ENGINEERING 5 197 #define FORMAT_COMPUTING 6 198 #define FORMAT_DDMMYY 7 199 #define FORMAT_MMDDYY 8 200 #define FORMAT_YYMMDD 9 201 #define FORMAT_MMYY 10 202 #define FORMAT_MMDD 11 203 #define FORMAT_MONTHDAY 12 204 #define FORMAT_DAYMONTH 13 205 #define FORMAT_MONTHS 14 206 #define FORMAT_MONTHSY 15 207 #define FORMAT_MONTHL 16 208 #define FORMAT_DAYOFWEEKS 17 209 #define FORMAT_DAYOFWEEKL 18 210 #define FORMAT_DAYOFYEAR 19 211 #define FORMAT_HMS 20 212 #define FORMAT_MMDDHMS 21 213 #define FORMAT_MMDDYYHMS 22 214 #define FORMAT_YYMMDDHMS 23 215 #define FORMAT_DEGREESLON 24 216 #define FORMAT_DEGREESMMLON 25 217 #define FORMAT_DEGREESMMSSLON 26 218 #define FORMAT_MMSSLON 27 219 #define FORMAT_DEGREESLAT 28 220 #define FORMAT_DEGREESMMLAT 29 221 #define FORMAT_DEGREESMMSSLAT 30 222 #define FORMAT_MMSSLAT 31 223 224 /* Focus policy */ 225 #define FOCUS_CLICK 0 226 #define FOCUS_SET 1 227 #define FOCUS_FOLLOWS 2 228 229 /* Placement of labels etc */ 230 #define TYPE_AUTO 0 231 #define TYPE_SPEC 1 232 233 /* User-defined tickmarks/labels */ 234 #define TICKS_SPEC_NONE 0 235 #define TICKS_SPEC_MARKS 1 236 #define TICKS_SPEC_BOTH 2 237 238 /* Tick direction */ 239 #define TICKS_IN 0 240 #define TICKS_OUT 1 241 #define TICKS_BOTH 2 242 243 /* Data source type */ 244 #define SOURCE_DISK 0 245 #define SOURCE_PIPE 1 246 247 248 /* Types of running command */ 249 #define RUN_AVG 0 250 #define RUN_MED 1 251 #define RUN_MIN 2 252 #define RUN_MAX 3 253 #define RUN_STD 4 254 255 /* Types of Fourier transforms */ 256 #define FFT_FFT 0 257 #define FFT_INVFFT 1 258 #define FFT_DFT 2 259 #define FFT_INVDFT 3 260 261 /* return codes */ 262 #define RETURN_SUCCESS (0) 263 #define RETURN_FAILURE (1) 264 265 #ifndef TRUE 266 # define TRUE 1 267 #endif 268 #ifndef FALSE 269 # define FALSE 0 270 #endif 271 272 /* types of autscales */ 273 #define AUTOSCALE_NONE 0 274 #define AUTOSCALE_X 1 275 #define AUTOSCALE_Y 2 276 #define AUTOSCALE_XY 3 277 278 /* 279 * for set selector gadgets 280 */ 281 #define SET_SELECT_ERROR -99 282 #define SET_SELECT_ACTIVE 0 283 #define SET_SELECT_ALL -1 284 #define SET_SELECT_NEXT -2 285 #define SET_SELECT_NEAREST -3 286 #define GRAPH_SELECT_CURRENT -1 287 #define GRAPH_SELECT_ALL -2 288 #define FILTER_SELECT_NONE 0 289 #define FILTER_SELECT_ACTIVE 1 290 #define FILTER_SELECT_ALL 2 291 #define FILTER_SELECT_INACT 3 292 #define FILTER_SELECT_DEACT 4 293 #define FILTER_SELECT_SORT 5 294 #define SELECTION_TYPE_SINGLE 0 295 #define SELECTION_TYPE_MULTIPLE 1 296 297 /* Default document name */ 298 #define NONAME "Untitled" 299 300 /* for data pruning */ 301 #define PRUNE_INTERPOLATION 0 302 #define PRUNE_CIRCLE 1 303 #define PRUNE_ELLIPSE 2 304 #define PRUNE_RECTANGLE 3 305 306 #define PRUNE_LIN 0 307 #define PRUNE_LOG 1 308 309 #define PRUNE_VIEWPORT 0 310 #define PRUNE_WORLD 1 311 312 313 /* for io filters */ 314 #define FILTER_INPUT 0 315 #define FILTER_OUTPUT 1 316 317 #define FILTER_MAGIC 0 318 #define FILTER_PATTERN 1 319 320 /* set line types */ 321 #define LINE_TYPE_NONE 0 322 #define LINE_TYPE_STRAIGHT 1 323 #define LINE_TYPE_LEFTSTAIR 2 324 #define LINE_TYPE_RIGHTSTAIR 3 325 #define LINE_TYPE_SEGMENT2 4 326 #define LINE_TYPE_SEGMENT3 5 327 328 /* baseline types */ 329 #define BASELINE_TYPE_0 0 330 #define BASELINE_TYPE_SMIN 1 331 #define BASELINE_TYPE_SMAX 2 332 #define BASELINE_TYPE_GMIN 3 333 #define BASELINE_TYPE_GMAX 4 334 #define BASELINE_TYPE_SAVG 5 335 336 /* set fill types */ 337 #define SETFILL_NONE 0 338 #define SETFILL_POLYGON 1 339 #define SETFILL_BASELINE 2 340 341 /* types of ann. values */ 342 #define AVALUE_TYPE_NONE 0 343 #define AVALUE_TYPE_X 1 344 #define AVALUE_TYPE_Y 2 345 #define AVALUE_TYPE_XY 3 346 #define AVALUE_TYPE_STRING 4 347 #define AVALUE_TYPE_Z 5 348 349 /* ticks */ 350 #define TICK_TYPE_MAJOR 0 351 #define TICK_TYPE_MINOR 1 352 353 /* push set direction */ 354 #define PUSH_SET_TOFRONT 0 355 #define PUSH_SET_TOBACK 1 356 357 /* restriction types */ 358 #define RESTRICT_NONE -1 359 #define RESTRICT_WORLD -2 360 #define RESTRICT_REG0 0 361 #define RESTRICT_REG1 1 362 #define RESTRICT_REG2 2 363 #define RESTRICT_REG3 3 364 #define RESTRICT_REG4 4 365 366 367 /* 368 * defaults 369 */ 370 typedef struct { 371 int color; 372 int bgcolor; 373 int pattern; 374 int lines; 375 double linew; 376 double charsize; 377 int font; 378 double symsize; 379 } defaults; 380 381 typedef struct { 382 int color; 383 int pattern; 384 /* 385 * int transparency; 386 */ 387 } Pen; 388 389 /* A point in world coordinates */ 390 typedef struct { 391 double x; 392 double y; 393 } WPoint; 394 395 396 /* A point in viewport coordinates */ 397 typedef struct { 398 double x; 399 double y; 400 } VPoint; 401 402 typedef struct { 403 double x; 404 double y; 405 } VVector; 406 407 typedef struct { 408 double xg1, xg2, yg1, yg2; /* window into world coords */ 409 } world; 410 411 typedef struct { 412 double xv1, xv2, yv1, yv2; /* viewport */ 413 } view; 414 415 416 /* 417 * typedefs for objects 418 */ 419 typedef struct { 420 int active; 421 int loctype; 422 int gno; 423 double x1; 424 double y1; 425 double x2; 426 double y2; 427 int lines; 428 double linew; 429 int color; 430 int fillcolor; 431 int fillpattern; 432 view bb; 433 } boxtype; 434 435 typedef struct { 436 int type; 437 double length; /* head length (L) */ 438 double dL_ff; /* d/L form factor */ 439 double lL_ff; /* l/L form factor */ 440 } Arrow; 441 442 typedef struct { 443 int active; 444 int loctype; 445 int gno; 446 double x1; 447 double y1; 448 double x2; 449 double y2; 450 int lines; 451 double linew; 452 int color; 453 int arrow_end; 454 Arrow arrow; 455 view bb; 456 } linetype; 457 458 typedef struct { 459 int active; 460 int loctype; 461 int gno; 462 double x1; 463 double y1; 464 double x2; 465 double y2; 466 int lines; 467 double linew; 468 int color; 469 int fillcolor; 470 int fillpattern; 471 view bb; 472 } ellipsetype; 473 474 typedef struct { 475 int active; 476 int loctype; 477 int gno; 478 double x; 479 double y; 480 int color; 481 int rot; 482 int font; 483 int just; 484 double charsize; 485 char *s; 486 view bb; 487 } plotstr; 488 489 490 /* 491 * world stack 492 */ 493 typedef struct { 494 world w; /* current world */ 495 } world_stack; 496 497 typedef struct { 498 plotstr title; /* graph title */ 499 plotstr stitle; /* graph subtitle */ 500 } labels; 501 502 typedef struct { 503 int active; /* active flag */ 504 int type; /* regression type */ 505 double xmin; 506 double xmax; 507 double coef[15]; 508 } Regression; 509 510 typedef struct { 511 int active; /* active flag */ 512 int type; /* regression type */ 513 int npts; /* number of points */ 514 double xmin; 515 double xmax; 516 double *a; 517 double *b; 518 double *c; 519 double *d; 520 } Spline; 521 522 typedef struct { 523 int active; /* on/off */ 524 PlacementType ptype; /* placement type */ 525 Pen pen; /* pen */ 526 double linew; /* error bar line width */ 527 int lines; /* error bar line style */ 528 double riser_linew; /* connecting line between error limits line width */ 529 int riser_lines; /* connecting line between error limits line style */ 530 double barsize; /* size of error bar */ 531 int arrow_clip; /* draw arrows if clipped */ 532 double cliplen; /* riser clipped length (v.p.) */ 533 } Errbar; 534 535 /* Annotative strings for data values */ 536 typedef struct { 537 int active; /* active or not */ 538 int type; /* type */ 539 double size; /* char size */ 540 int font; /* font */ 541 int color; /* color */ 542 int angle; /* angle */ 543 int format; /* format */ 544 int prec; /* precision */ 545 char prestr[64]; /* prepend string */ 546 char appstr[64]; /* append string */ 547 VPoint offset; /* offset related to symbol position */ 548 } AValue; 549 550 551 552 typedef struct { 553 int type; 554 double wtpos; 555 char *label; 556 } tickloc; 557 558 typedef struct { 559 double size; /* length of tickmarks */ 560 int color; /* color of tickmarks */ 561 double linew; /* linewidth of tickmarks */ 562 int lines; /* linestyle of tickmarks */ 563 int gridflag; /* grid lines at tick marks */ 564 } tickprops; 565 566 typedef struct { 567 int active; /* active or not */ 568 569 int zero; /* "zero" axis or plain */ 570 571 plotstr label; /* graph axis label */ 572 int label_layout; /* axis label orientation (h or v) */ 573 int label_place; /* axis label placement (specfied or auto) */ 574 PlacementType label_op; /* tick labels on opposite side or both */ 575 576 int t_drawbar; /* draw a bar connecting tick marks */ 577 int t_drawbarcolor; /* color of bar */ 578 int t_drawbarlines; /* linestyle of bar */ 579 double t_drawbarlinew; /* line width of bar */ 580 581 double offsx, offsy; /* offset of axes in viewport coords 582 (attention: these 583 are not x and y coordinates but 584 perpendicular and parallel offsets */ 585 586 int t_flag; /* toggle tickmark display */ 587 int t_autonum; /* approximate default number of major ticks */ 588 589 int t_spec; /* special (user-defined) tickmarks/ticklabels, */ 590 /* can be none/marks/both marks and labels */ 591 592 int t_round; /* place major ticks at rounded positions */ 593 594 double tmajor; /* major tick divisions */ 595 int nminor; /* number of minor ticks per one major division */ 596 597 int nticks; /* total number of ticks */ 598 tickloc tloc[MAX_TICKS]; /* locations of ticks */ 599 600 int t_inout; /* ticks inward, outward or both */ 601 PlacementType t_op; /* ticks on opposite side */ 602 603 tickprops props; 604 tickprops mprops; 605 606 int tl_flag; /* toggle ticmark labels on or off */ 607 int tl_angle; /* angle to draw labels */ 608 609 int tl_format; /* tickmark label format */ 610 int tl_prec; /* places to right of decimal point */ 611 612 char *tl_formula; /* transformation formula */ 613 614 int tl_skip; /* tick labels to skip */ 615 int tl_staggered; /* tick labels staggered */ 616 int tl_starttype; /* start at graphmin or use tl_start/stop */ 617 int tl_stoptype; /* start at graphmax or use tl_start/stop */ 618 double tl_start; /* value of x to begin tick labels and major ticks */ 619 double tl_stop; /* value of x to end tick labels and major ticks */ 620 621 PlacementType tl_op; /* tick labels on opposite side or both */ 622 623 int tl_gaptype; /* tick label placement auto or specified */ 624 VVector tl_gap; /* tick label to tickmark distance 625 (parallel and perpendicular to axis) */ 626 627 int tl_font; /* font to use for tick labels */ 628 double tl_charsize; /* character size for tick labels */ 629 int tl_color; /* color of tick labels */ 630 631 char tl_appstr[64]; /* append string to tick label */ 632 char tl_prestr[64]; /* prepend string to tick label */ 633 634 } tickmarks; 635 636 typedef struct { 637 int active; /* legend on or off */ 638 int loctype; /* locate in world or viewport coords */ 639 int vgap; /* verticle gap between entries */ 640 int hgap; /* horizontal gap(s) between legend string 641 elements */ 642 int len; /* length of line to draw */ 643 int invert; /* switch between ascending and descending 644 order of set legends */ 645 double legx; /* location on graph */ 646 double legy; 647 int font; 648 double charsize; 649 int color; 650 Pen boxpen; 651 Pen boxfillpen; 652 double boxlinew; /* legend frame line width */ 653 int boxlines; /* legend frame line style */ 654 view bb; 655 } legend; 656 657 typedef struct { 658 int active; /* region on or off */ 659 int type; /* region type */ 660 int color; /* region color */ 661 int lines; /* region linestyle */ 662 double linew; /* region line width */ 663 int linkto; /* associated with graph linkto */ 664 int n; /* number of points if type is POLY */ 665 double *x, *y; /* coordinates if type is POLY */ 666 double x1, y1, x2, y2; /* starting and ending points if type is not POLY */ 667 } region; 668 669 typedef struct { 670 int type; /* frame type */ 671 Pen pen; /* frame pen */ 672 int lines; /* frame linestyle */ 673 double linew; /* frame line width */ 674 Pen fillpen; /* fill pen */ 675 } framep; 676 677 678 /* parameters for non-linear fit */ 679 typedef struct { 680 double value; /* parameter itself */ 681 int constr; /* whether or not to use constraints */ 682 double min; /* low bound constraint */ 683 double max; /* upper bound constraint */ 684 } nonlparms; 685 686 /* options for non-linear fit */ 687 typedef struct { 688 char *title; /* fit title */ 689 char *formula; /* fit function */ 690 int parnum; /* # of fit parameters */ 691 double tolerance; /* tolerance */ 692 } nonlopts; 693 694 /* real time inputs */ 695 typedef struct _Input_buffer { 696 int fd; /* file descriptor */ 697 int errors; /* number of successive parse errors */ 698 int lineno; /* line number */ 699 int zeros; /* number of successive reads of zero byte */ 700 int reopen; /* non-zero if we should close and reopen */ 701 /* when other side is closed (mainly for fifos) */ 702 char *name; /* name of the input (filename or symbolic name) */ 703 int size; /* size of the buffer for already read lines */ 704 int used; /* number of bytes used in the buffer */ 705 char *buf; /* buffer for already read lines */ 706 unsigned long id; /* id for X library */ 707 } Input_buffer; 708 709 /* dates formats */ 710 typedef enum { FMT_iso, 711 FMT_european, 712 FMT_us, 713 FMT_nohint 714 } Dates_format; 715 716 /* rounding types for dates */ 717 #define ROUND_SECOND 1 718 #define ROUND_MINUTE 2 719 #define ROUND_HOUR 3 720 #define ROUND_DAY 4 721 #define ROUND_MONTH 5 722 723 /* tokens for the calendar dates parser */ 724 typedef struct { int value; 725 int digits; 726 } Int_token; 727 728 #endif /* __DEFINES_H_ */ 729