1 2 #ifndef TRUE 3 # define TRUE 1 4 #endif 5 #ifndef FALSE 6 # define FALSE 0 7 #endif 8 9 /* 10 * types of tick displays 11 */ 12 #define X_AXIS 0 13 #define Y_AXIS 1 14 #define ZX_AXIS 2 15 #define ZY_AXIS 3 16 17 #ifndef MAXARR 18 # define MAXARR 20000 /* max elements in an array */ 19 #endif 20 21 #define MAXGRAPH 10 /* max number of graphs */ 22 #define MAXPLOT 30 /* max number of sets in a graph */ 23 #define MAXAXES 4 /* max number of axes per graph */ 24 #define MAX_SET_COLS 6 /* max number of data columns for a set */ 25 #define MAX_TICK_LABELS 40 /* max number of user defined ticks/labels */ 26 #define MAX_ZOOM_STACK 20 /* max stack depth for world stack */ 27 #define MAXREGION 5 /* max number of regions */ 28 #define MAXBOXES 50 /* max number of boxes */ 29 #define MAXLINES 50 /* max number of lines */ 30 #define MAXELLIPSES 50 /* max number of ellipses */ 31 #define MAXSTR 100 /* max number of strings */ 32 33 #define PAGE_FREE 0 34 35 #define GR_PS_L 1 /* PostScript landscape */ 36 37 /* set HDEV to the default hardcopy device */ 38 #ifndef HDEV 39 # define HDEV GR_PS_L 40 #endif 41 42 #define DATASET_MISSING (1.23456789e+30) 43 44 #define NONAME "Untitled" 45 46 #define ABOVE 589 47 #define ABSOLUTE 309 48 #define AUTO 324 49 #define BAR 332 50 #define BELOW 590 51 #define BOTH 336 52 #define BOTTOM 337 53 #define CENTER 342 54 #define COLOR 348 55 #define DAYMONTH 600 56 #define DAYOFWEEKL 605 57 #define DAYOFWEEKS 604 58 #define DAYOFYEAR 606 59 #define DDMMYY 594 60 #define DECIMAL 352 61 #define DEGREESLAT 615 62 #define DEGREESLON 611 63 #define DEGREESMMLAT 616 64 #define DEGREESMMLON 612 65 #define DEGREESMMSSLAT 617 66 #define DEGREESMMSSLON 613 67 #define DISK 360 68 #define EXPONENTIAL 373 69 #define FIXED 634 70 #define FREE 633 71 #define GENERAL 593 72 #define HBAR 395 73 #define HMS 607 74 #define HORIZONTAL 399 75 #define IN 407 76 #define LANDSCAPE 631 77 #define LEFT 419 78 #define LOGX 432 79 #define LOGXY 434 80 #define LOGY 433 81 #define MMDD 598 82 #define MMDDHMS 608 83 #define MMDDYY 596 84 #define MMDDYYHMS 609 85 #define MMSSLAT 618 86 #define MMSSLON 614 87 #define MMYY 597 88 #define MONTHDAY 599 89 #define MONTHL 603 90 #define MONTHS 601 91 #define MONTHSY 602 92 #define NEGATE 443 93 #define NONE 445 94 #define NORMAL 446 95 #define OFF 448 96 #define ON 451 97 #define OUT 454 98 #define PARA 456 99 #define PATTERN 460 100 #define PERP 462 101 #define PIE 464 102 #define POLAR 468 103 #define POLY 469 104 #define POLYI 591 105 #define POLYO 592 106 #define PORTRAIT 632 107 #define POWER 470 108 #define RIGHT 490 109 #define SPEC 513 110 #define STACKEDBAR 517 111 #define STACKEDHBAR 518 112 #define STACKEDLINE 519 113 #define TOP 535 114 #define VERTICAL 540 115 #define VIEW 542 116 #define WORLD 544 117 #define XY 554 118 #define XYBOX 556 119 #define XYBOXPLOT 557 120 #define XYDX 563 121 #define XYDXDX 565 122 #define XYDXDY 567 123 #define XYDY 564 124 #define XYDYDY 566 125 #define XYFIXED 558 126 #define XYHILO 559 127 #define XYRT 560 128 #define XYSTRING 562 129 #define XYUV 573 130 #define XYZ 571 131 #define YYMMDD 595 132 133 /* 134 * defaults 135 */ 136 typedef struct { 137 int color; 138 int lines; 139 int linew; 140 double charsize; 141 int font; 142 int fontsrc; 143 double symsize; 144 } defaults; 145 146 typedef struct { 147 double xg1, xg2, yg1, yg2; /* window into world coords */ 148 } world; 149 150 typedef struct { 151 double xv1, xv2, yv1, yv2; /* device viewport */ 152 } view; 153 154 /* 155 * world stack 156 */ 157 typedef struct { 158 world w; /* current world */ 159 world t[3]; /* current tick spacing */ 160 int prec[MAXAXES]; /* precision of labels */ 161 } world_stack; 162 163 typedef struct { 164 int active; 165 int loctype; 166 int gno; 167 double x; 168 double y; 169 int lines; 170 int linew; 171 int color; 172 int rot; 173 int font; 174 int just; 175 double charsize; 176 char *s; 177 } plotstr; 178 179 180 typedef struct { 181 plotstr title; /* graph title */ 182 plotstr stitle; /* graph subtitle */ 183 } labels; 184 185 typedef struct { 186 int active; /* active flag */ 187 int type; /* regression type */ 188 double xmin; 189 double xmax; 190 double coef[15]; 191 } Regression; 192 193 typedef struct { 194 int active; /* active flag */ 195 int type; /* regression type */ 196 int npts; /* number of points */ 197 double xmin; 198 double xmax; 199 double *a; 200 double *b; 201 double *c; 202 double *d; 203 } Spline; 204 205 typedef struct { 206 int active; /* active flag */ 207 int type; /* dataset type */ 208 int deact; /* deactivated set */ 209 int len; /* set length */ 210 int nx, ny; /* number of pts in X and Y for grids */ 211 int setno; /* set number */ 212 int gno; /* graph number */ 213 char comments[256]; /* how did this set originate */ 214 char lstr[256]; /* legend for this set */ 215 216 double missing; /* value for missing data */ 217 double *ex[MAX_SET_COLS]; /* x, y, dx, z, r, hi depending on dataset type */ 218 char **s; /* pointer to strings */ 219 int nel; /* # of ? */ 220 int **con; /* con */ 221 222 double xmin, xmax; /* min max for x */ 223 double ymin, ymax; /* min max for y */ 224 225 int sym; /* set plot symbol */ 226 char symchar; /* character for symbol */ 227 int symskip; /* How many symbols to skip */ 228 int symfill; /* Symbol fill type */ 229 int symdot; /* Symbol dot in center */ 230 int symlines; /* Symbol linestyle */ 231 int symlinew; /* Symbol linewidth */ 232 int symcolor; /* color for symbol line */ 233 double symsize; /* size of symbols */ 234 235 int avgflag; /* average */ 236 int avgstdflag; /* average+- std */ 237 int avg2stdflag; /* average+- 2std */ 238 int avg3stdflag; /* average+- 3std */ 239 int avgallflag; /* average+- 3std */ 240 int avgvalflag; /* average+- val */ 241 int harmonicflag; /* harmonic mean */ 242 int geometricflag; /* geometric */ 243 244 int font; /* font for strings */ 245 int format; /* format for drawing values */ 246 int prec; /* precision for drawing values */ 247 int just; /* justification for drawing values */ 248 int where; /* where to draw values */ 249 double valsize; /* char size for drawing values */ 250 251 int lines; /* set line style */ 252 int linew; /* line width */ 253 int color; /* color for linestyle */ 254 int lineskip; /* How many points to skip when drawing lines */ 255 int clipflag; /* turn clipping on or off for this set */ 256 257 int fill; /* fill type */ 258 int fillusing; /* fill using color or pattern */ 259 int fillcolor; /* fill color */ 260 int fillpattern; /* fill pattern */ 261 262 int errbar; /* if type is _DX, _DY, _DXDY and errbar = TRUE */ 263 int errbarxy; /* type of error bar */ 264 int errbar_linew; /* error bar line width */ 265 int errbar_lines; /* error bar line style */ 266 int errbar_riser; /* connecting line between error limits */ 267 int errbar_riser_linew; /* connecting line between error limits line width */ 268 int errbar_riser_lines; /* connecting line between error limits line style */ 269 270 double errbarper; /* length of error bar */ 271 double hilowper; /* length of hi-low */ 272 273 int density_plot; /* if type is XYZ then density_plot = 1 */ 274 double zmin, zmax; /* min max for density plots */ 275 276 int hotlink; /* hot linked set */ 277 int hotsrc; /* source for hot linked file (DISK|PIPE) */ 278 char hotfile[256]; /* hot linked filename */ 279 280 double emin[MAX_SET_COLS]; /* min for each column */ 281 double emax[MAX_SET_COLS]; /* max for each column */ 282 int imin[MAX_SET_COLS]; /* min loc for each column */ 283 int imax[MAX_SET_COLS]; /* max loc for each column */ 284 285 Regression *r; /* coefs from any regression performed on this set */ 286 Spline *spl; /* coefs from any spline performed on this set */ 287 288 void *ep; /* pointer to EditPoints structure */ 289 290 } plotarr; 291 292 typedef struct { 293 int axis; /* which axis */ 294 int active; /* active or not */ 295 int alt; /* alternate map if TRUE */ 296 double tmin, tmax; /* mapping for alternate tickmarks */ 297 double tmajor, tminor; /* major, minor tick divisions */ 298 double offsx, offsy; /* offset of axes in viewport coords */ 299 plotstr label; /* graph axis label */ 300 int label_layout; /* axis label orientation (h or v) */ 301 int label_place; /* axis label placement (specfied or auto) */ 302 int tl_flag; /* toggle ticmark labels on or off */ 303 int tl_type; /* either auto or specified (below) */ 304 int tl_loc; /* Tick label location, at tick, between ticks */ 305 int tl_layout; /* horizontal, vertical, or specified */ 306 int tl_angle; /* angle to draw labels if layout is specified */ 307 int tl_sign; /* tick labels normal, absolute value, or negate */ 308 int tl_just; /* justification of ticklabel and type of anchor point */ 309 int tl_prec; /* places to right of decimal point */ 310 int tl_format; /* decimal or exponential ticmark labels .. */ 311 int tl_skip; /* tick labels to skip */ 312 int tl_staggered; /* tick labels staggered */ 313 int tl_starttype; /* start at graphmin or use tl_start/stop */ 314 int tl_stoptype; /* start at graphmax or use tl_start/stop */ 315 double tl_start; /* value of x to begin tick labels and major ticks */ 316 double tl_stop; /* value of x to begin tick labels and major ticks */ 317 int tl_op; /* tick labels on opposite side or both */ 318 double tl_vgap; /* tick label to tickmark distance vertically */ 319 double tl_hgap; /* tick label to tickmark distance horizontally */ 320 int tl_font; /* font to use for labels */ 321 double tl_charsize; /* character size for labels */ 322 int tl_color; /* color */ 323 int tl_linew; /* line width for labels */ 324 char tl_appstr[256]; /* append string to tick label */ 325 char tl_prestr[256]; /* prepend string to tick label */ 326 int t_type; /* type of tickmarks, usual, xticstart, or specified */ 327 int t_flag; /* toggle tickmark display */ 328 int t_mflag; /* toggle minor tickmark display */ 329 int t_integer; /* major tic marks on integer divisions */ 330 int t_num; /* approximate default number of X-axis ticks */ 331 int t_inout; /* ticks inward, outward or both */ 332 int t_log; /* logarithmic ticmarks */ 333 int t_op; /* ticks on opposite side */ 334 int t_color; /* colors and linestyles */ 335 int t_lines; 336 int t_linew; 337 int t_mcolor; 338 int t_mlines; 339 int t_mlinew; /* minor grid colors and linestyles */ 340 double t_size; /* length of tickmarks */ 341 double t_msize; /* length of minor tickmarks */ 342 int t_drawbar; /* draw a bar connecting tick marks */ 343 int t_drawbarcolor; /* color of bar */ 344 int t_drawbarlines; /* linestyle of bar */ 345 int t_drawbarlinew; /* line width of bar */ 346 int t_gridflag; /* grid lines at major tick marks */ 347 int t_mgridflag; /* grid lines at minor tick marks */ 348 int t_spec; /* number of ticks at specified locations */ 349 double t_specloc[MAX_TICK_LABELS]; 350 plotstr t_speclab[MAX_TICK_LABELS]; 351 int spec_font; 352 double spec_charsize; 353 int spec_color; 354 int spec_linew; 355 } tickmarks; 356 357 typedef struct { 358 int active; /* legend on or off */ 359 int loctype; /* locate in world or viewport coords */ 360 int layout; /* verticle or horizontal */ 361 int vgap; /* verticle gap between entries */ 362 int hgap; /* horizontal gap between entries */ 363 int len; /* length of line to draw */ 364 int box; /* box around legend on or off */ 365 double legx; /* location on graph */ 366 double legy; 367 int font; 368 double charsize; 369 int color; 370 int linew; 371 int lines; 372 int boxfill; /* legend frame fill toggle */ 373 int boxfillusing; /* legend frame fill type */ 374 int boxfillcolor; /* legend frame fill color */ 375 int boxfillpat; /* legend frame fill pattern */ 376 int boxlcolor; /* legend frame line color */ 377 int boxlinew; /* legend frame line width */ 378 int boxlines; /* legend frame line style */ 379 } legend; 380 381 typedef struct { 382 int active; /* region on or off */ 383 int type; /* region type */ 384 int color; /* region color */ 385 int lines; /* region linestyle */ 386 int linew; /* region line width */ 387 int *linkto; /* associated with graphs in linkto */ 388 int n; /* number of points if type is POLY */ 389 double *x, *y; /* coordinates if type is POLY */ 390 double x1, y1, x2, y2; /* starting and ending points if type is not POLY */ 391 } region; 392 393 typedef struct { 394 int active; /* frame on or off */ 395 int type; /* frame type */ 396 int color; /* frame color */ 397 int lines; /* frame linestyle */ 398 int linew; /* frame line width */ 399 int fillbg; /* fill background */ 400 int bgcolor; /* background color inside frame */ 401 } framep; 402 403 typedef struct _BoxPlot { 404 double il; /* inner lower limit */ 405 double iu; /* inner upper limit */ 406 double ol; /* outer lower limit */ 407 double ou; /* outer uppper limit */ 408 int nthresh; /* threshhold for number of points for 409 * boxplot */ 410 int outliers; /* plot outliers */ 411 int wtype; /* 1 = width by std dev or 0 = symsize */ 412 double boxwid; 413 } BoxPlot; 414 415 typedef struct { 416 int active; /* velocity legend on or off */ 417 int type; /* velocity type */ 418 int color; /* velocity color */ 419 int lines; /* velocity linestyle */ 420 int linew; /* velocity line width */ 421 int arrowtype; /* velocity arrow type, fixed or variable head */ 422 int loctype; /* world or viewport coords for legend */ 423 double velx, vely; /* location of velocity legend */ 424 double vscale; /* velocity scale */ 425 int units; /* units of flow field */ 426 double userlength; /* length of the legend vector in user units */ 427 plotstr vstr; /* legend string for velocity legend */ 428 } velocityp; 429 430 /* 431 * a graph 432 */ 433 typedef struct { 434 int active; /* alive or dead */ 435 int hidden; /* display or not */ 436 int label; /* label graph */ 437 int type; /* type of graph */ 438 int clipflag; /* turn clipping on or off */ 439 int autoscale; /* */ 440 int noautoscale; /* */ 441 int noauto_world; /* only time this is used is at startup */ 442 int noauto_tics; /* only time this is used is at startup */ 443 int auto_type; /* */ 444 int parmsread; /* was a paramter file read for this graph */ 445 int revx, revy; /* reverse mapping for x and y if true */ 446 int maxplot; /* max number of sets for this graph */ 447 plotarr *p; /* sets go here */ 448 legend l; /* legends */ 449 world w; /* world */ 450 view v; /* world/view */ 451 world rt; /* world for polar plots */ 452 labels labs; /* title, subtitle, axes labels */ 453 tickmarks t[MAXAXES]; /* flags etc. for tickmarks for all axes */ 454 framep f; /* type of box around plot */ 455 int pointset; /* if (dsx, dsy) have been set */ 456 int pt_type; /* type of locator display */ 457 double dsx, dsy; /* locator fixed point */ 458 int fx, fy; /* locator format type */ 459 int px, py; /* locator precision */ 460 double barwid; /* bar width for bar charts */ 461 double sbarwid; /* bar width for stacked bar charts */ 462 world_stack ws[MAX_ZOOM_STACK]; /* zoom stack */ 463 int ws_top; /* stack pointer */ 464 int curw; /* for cycling through the stack */ 465 velocityp vp; 466 BoxPlot bp; 467 } graph; 468 469 /* 470 * typedefs for objects 471 */ 472 typedef struct { 473 int active; 474 int loctype; 475 int gno; 476 double x1; 477 double y1; 478 double x2; 479 double y2; 480 int lines; 481 int linew; 482 int color; 483 int fill; 484 int fillcolor; 485 int fillpattern; 486 } boxtype; 487 488 typedef struct { 489 int active; 490 int loctype; 491 int gno; 492 double x1; 493 double y1; 494 double x2; 495 double y2; 496 int lines; 497 int linew; 498 int color; 499 int fill; 500 int fillcolor; 501 int fillpattern; 502 } ellipsetype; 503 504 typedef struct { 505 int active; 506 int loctype; 507 int gno; 508 double x1; 509 double y1; 510 double x2; 511 double y2; 512 int lines; 513 int linew; 514 int color; 515 int arrow; 516 int atype; 517 double asize; 518 } linetype; 519 520 #if defined(MAIN) 521 graph *g; 522 int cg = 0; /* the current graph */ 523 int maxgraph = MAXGRAPH; 524 char sformat[128] = "%16lg %16lg"; /* format for saving (ascii) projects */ 525 defaults grdefaults; /* default properties */ 526 int maxplot = MAXPLOT; 527 int maxarr = MAXARR; 528 plotstr timestamp; /* timestamp */ 529 region rg[MAXREGION]; 530 linetype *lines; /* lines */ 531 int maxlines = MAXLINES; 532 int maxboxes = MAXBOXES; 533 boxtype *boxes; /* boxes */ 534 plotstr *pstr; /* strings */ 535 int maxstr = MAXSTR; 536 int maxellipses = MAXELLIPSES; 537 ellipsetype *ellip; /* ellipses */ 538 double **blockdata; 539 int maxblock = MAXPLOT; 540 double *ax, *bx, *cx, *dx; /* scratch arrays used in scanner */ 541 char docname[512] = NONAME; 542 int blocklen; 543 int blockncols; 544 char description[2048]; 545 int page_layout = PAGE_FREE; 546 double scrollper = 0.05; /* scroll fraction */ 547 double shexper = 0.05; /* expand/shrink fraction */ 548 int scrolling_islinked = 0; /* linked scroll */ 549 char buf[1024]; /* a string used here and there */ 550 551 552 #else 553 extern graph *g; 554 extern int cg; 555 extern int maxarr; 556 extern char sformat[]; 557 extern defaults grdefaults; /* default properties */ 558 extern int maxgraph; 559 extern int maxplot; 560 extern plotstr timestamp; /* timestamp */ 561 extern region rg[]; 562 extern linetype *lines; /* lines */ 563 extern int maxlines; 564 extern int maxboxes; 565 extern boxtype *boxes; /* boxes */ 566 extern plotstr *pstr; /* strings */ 567 extern int maxstr; 568 extern int maxellipses; 569 extern ellipsetype *ellip; /* ellipses */ 570 extern double **blockdata; 571 extern int maxblock; 572 extern double *ax, *bx, *cx, *dx; 573 extern char docname[]; 574 extern int blocklen; 575 extern int blockncols; 576 extern char description[]; 577 extern int page_layout; 578 extern double scrollper; /* scroll fraction */ 579 extern double shexper; /* expand/shrink fraction */ 580 extern int scrolling_islinked; /* linked scroll */ 581 extern char buf[]; 582 583 #endif 584 585 586 void set_program_defaults(void); 587 void set_region_defaults(int rno); 588 void set_default_framep(framep * f); 589 void set_default_world(world * w); 590 void set_default_view(view * v); 591 void set_default_string(plotstr * s); 592 void set_default_line(linetype * l); 593 void set_default_box(boxtype * b); 594 void set_default_ellipse(ellipsetype * e); 595 void set_default_legend(int gno, legend * l); 596 void set_default_plotarr(plotarr * p); 597 void set_default_velocityp(velocityp * vp); 598 void set_default_graph(int gno); 599 void realloc_plots(int maxplot); 600 void realloc_graph_plots(int gno, int maxplot); 601 void realloc_graphs(void); 602 void set_default_annotation(void); 603 void set_default_ticks(tickmarks * t, int a); 604 void setdefaultcolors(int gno); 605 void kill_blockdata(void); 606 void alloc_blockdata(int ncols); 607 int init_array(double **a, int n); 608 int init_scratch_arrays(int n); 609 int read_boxtype(boxtype * d, FILE * fin); 610 int read_ellipsetype(ellipsetype * d, FILE * fin); 611 int read_linetype(linetype * d, FILE * fin); 612 int read_plotstr(plotstr * d, FILE * fin); 613 int read_graph(graph * d, FILE * fin); 614 void close_xdr(void); 615 int read_double(double *d, int n, FILE * fp); 616 int read_int(int *d, int n, FILE * fp); 617 int read_charstr(char *d, FILE * fp); 618 int read_char(char *d, int n, FILE * fp); 619 int read_short(short *d, int n, FILE * fp); 620 int read_float(float *d, int n, FILE * fp); 621 int replace_xdr_int( int *i ); 622 int replace_xdr_short( short *i ); 623 int is_state_save(char *fname); 624 int getbinary(int gno, char *fname, int imbed); 625 int do_writesets(int gno, int setno, int imbed, char *fn, char *format); 626 void putparms(int gno, FILE * pp, int imbed); 627 char *graph_types(int it, int which); 628 char *get_format_types(int f); 629 void get_graph_box(int i, boxtype * b); 630 void get_graph_ellipse(int i, ellipsetype * b); 631 void get_graph_line(int i, linetype * l); 632 void get_graph_string(int i, plotstr * s); 633 void get_graph_framep(int gno, framep * f); 634 void get_graph_world(int gno, world * w); 635 void get_graph_view(int gno, view * v); 636 void get_graph_labels(int gno, labels * labs); 637 void get_graph_plotarr(int gno, int i, plotarr * p); 638 void get_graph_tickmarks(int gno, tickmarks * t, int a); 639 void get_graph_legend(int gno, legend * leg); 640 void set_graph_tickmarks(int gno, tickmarks * t, int a); 641 void default_ticks(int gno, int axis, double *gmin, double *gmax); 642 void errmsg(char *buf); 643 char *escapequotes (char *s); 644 char *set_types(int it); 645 int is_hotlinked(int gno, int setno); 646 void cxfree(void *ptr); 647 648 #define isactive_set(gno, set) (g[gno].p[set].active == ON) 649 #define isactive_graph(gno) (g[gno].active == ON) 650 #define on_or_off(x) ((x == ON)?"on":"off") 651 #define w_or_v(x) ((x == WORLD)?"world":"view") 652 #define dataset_type(gno, set) (g[gno].p[set].type) 653 #define getx(gno, set) ((double *) g[gno].p[set].ex[0]) 654 #define gety(gno, set) ((double *) g[gno].p[set].ex[1]) 655 #define getsetlength(gno, set) (g[gno].p[set].len) 656 #define getcol(gno, set, col) ((double *) g[gno].p[set].ex[col]) 657