10 |
|
*/ |
11 |
|
|
12 |
|
#include <stdio.h> |
13 |
+ |
#include <string.h> |
14 |
|
|
15 |
+ |
#include "meta.h" |
16 |
|
#include "mgvars.h" |
15 |
– |
|
17 |
|
#include "mgraph.h" |
18 |
|
|
19 |
|
extern char *progname; /* argv[0] */ |
33 |
|
static int nplottable; /* number of plottable points */ |
34 |
|
static int nplotted; /* number of plotted points */ |
35 |
|
|
36 |
+ |
static void getbounds(void); |
37 |
+ |
static void polaraxis(void); |
38 |
+ |
static void makeaxis(void); |
39 |
+ |
static void plotcurves(void); |
40 |
+ |
static void cartaxis(void); |
41 |
+ |
static void stretchbounds(int c, double x, double y); |
42 |
+ |
static void boxstring(int xmin, int ymin, int xmax, int ymax, |
43 |
+ |
char *s, int d, int width, int color); |
44 |
+ |
static void drawcircle(int x, int y, int r, int typ, int wid, int col); |
45 |
+ |
static int rconv(double r); |
46 |
+ |
static int xconv(double x); |
47 |
+ |
static int yconv(double y); |
48 |
+ |
static void csymbol(int c, double u, double v); |
49 |
+ |
static int cmline(int c, int x, int y); |
50 |
+ |
static void cmsymbol(int c, int x, int y); |
51 |
+ |
static int inbounds(double x, double y); |
52 |
+ |
static void climline(int c, double x, double y, double xout, double yout); |
53 |
+ |
static void nextpoint(register int c, double x, double y); |
54 |
+ |
static void cline(int c, double u1, double v1, double u2, double v2); |
55 |
|
|
56 |
< |
mgraph() /* plot the current graph */ |
56 |
> |
|
57 |
> |
void |
58 |
> |
mgraph(void) /* plot the current graph */ |
59 |
|
{ |
60 |
|
/* load the symbol file */ |
61 |
|
if (gparam[SYMFILE].flags & DEFINED) |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
< |
getbounds() /* compute the boundaries */ |
75 |
> |
void |
76 |
> |
getbounds(void) /* compute the boundaries */ |
77 |
|
{ |
78 |
< |
int i, stretchbounds(); |
78 |
> |
int i; |
79 |
|
|
80 |
|
xbounds.min = gparam[XMIN].flags & DEFINED ? |
81 |
|
varvalue(gparam[XMIN].name) - FTINY : |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
< |
makeaxis() /* draw the coordinate axis */ |
147 |
> |
void |
148 |
> |
makeaxis(void) /* draw the coordinate axis */ |
149 |
|
{ |
150 |
|
char stmp[64]; |
151 |
|
|
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
< |
polaraxis() /* print polar coordinate axis */ |
184 |
> |
void |
185 |
> |
polaraxis(void) /* print polar coordinate axis */ |
186 |
|
{ |
187 |
|
int lw, tstyle, t0, t1; |
188 |
< |
double d, d1, ybeg, xstep; |
188 |
> |
double d, d1, ybeg; |
189 |
|
char stmp[64], *fmt, *goodformat(); |
190 |
|
/* get tick style */ |
191 |
|
if (gparam[TSTYLE].flags & DEFINED) |
284 |
|
} |
285 |
|
} |
286 |
|
|
287 |
< |
|
288 |
< |
cartaxis() /* print Cartesian coordinate axis */ |
287 |
> |
void |
288 |
> |
cartaxis(void) /* print Cartesian coordinate axis */ |
289 |
|
{ |
290 |
|
int lw, t0, t1, tstyle; |
291 |
|
double d, xbeg, ybeg; |
416 |
|
} |
417 |
|
} |
418 |
|
|
419 |
< |
|
420 |
< |
plotcurves() /* plot the curves */ |
419 |
> |
void |
420 |
> |
plotcurves(void) /* plot the curves */ |
421 |
|
{ |
422 |
< |
int i, j, k, nextpoint(); |
422 |
> |
int i, j, k; |
423 |
|
|
424 |
|
for (i = 0; i < MAXCUR; i++) { |
425 |
|
nplottable = nplotted = 0; |
437 |
|
} |
438 |
|
} |
439 |
|
|
440 |
< |
|
441 |
< |
nextpoint(c, x, y) /* plot the next point for c */ |
442 |
< |
register int c; |
443 |
< |
double x, y; |
440 |
> |
void |
441 |
> |
nextpoint( /* plot the next point for c */ |
442 |
> |
register int c, |
443 |
> |
double x, |
444 |
> |
double y |
445 |
> |
) |
446 |
|
{ |
447 |
|
if (inbounds(x, y)) { |
448 |
|
|
466 |
|
} |
467 |
|
|
468 |
|
|
469 |
< |
stretchbounds(c, x, y) /* stretch our boundaries */ |
470 |
< |
int c; |
471 |
< |
double x, y; |
469 |
> |
void |
470 |
> |
stretchbounds( /* stretch our boundaries */ |
471 |
> |
int c, |
472 |
> |
double x, |
473 |
> |
double y |
474 |
> |
) |
475 |
|
{ |
476 |
|
if (gparam[XMIN].flags & DEFINED && |
477 |
|
x < xbounds.min) |
502 |
|
#define exp10(x) exp((x)*2.3025850929940456) |
503 |
|
|
504 |
|
double |
505 |
< |
goodstep(interval) /* determine a good step for the interval */ |
506 |
< |
double interval; |
505 |
> |
goodstep( /* determine a good step for the interval */ |
506 |
> |
double interval |
507 |
> |
) |
508 |
|
{ |
509 |
|
static int steps[] = {50, 20, 10, 5, 2, 1}; |
510 |
|
double fact, exp(), log10(), floor(); |
523 |
|
|
524 |
|
|
525 |
|
int |
526 |
< |
xconv(x) /* convert x to meta coords */ |
527 |
< |
double x; |
526 |
> |
xconv( /* convert x to meta coords */ |
527 |
> |
double x |
528 |
> |
) |
529 |
|
{ |
530 |
|
if (gparam[XMAP].flags & DEFINED) |
531 |
|
x = funvalue(gparam[XMAP].name, 1, &x); |
535 |
|
|
536 |
|
|
537 |
|
int |
538 |
< |
yconv(y) /* convert y to meta coords */ |
539 |
< |
double y; |
538 |
> |
yconv( /* convert y to meta coords */ |
539 |
> |
double y |
540 |
> |
) |
541 |
|
{ |
542 |
|
if (gparam[YMAP].flags & DEFINED) |
543 |
|
y = funvalue(gparam[YMAP].name, 1, &y); |
546 |
|
} |
547 |
|
|
548 |
|
|
549 |
< |
pconv(xp, yp, t, r) /* convert theta and radius to meta coords */ |
550 |
< |
int *xp, *yp; |
551 |
< |
double t, r; |
549 |
> |
void |
550 |
> |
pconv( /* convert theta and radius to meta coords */ |
551 |
> |
int *xp, |
552 |
> |
int *yp, |
553 |
> |
double t, |
554 |
> |
double r |
555 |
> |
) |
556 |
|
{ |
557 |
|
t *= (2.*PI)/period; |
558 |
|
r = rconv(r); |
562 |
|
|
563 |
|
|
564 |
|
int |
565 |
< |
rconv(r) /* convert radius to meta coords */ |
566 |
< |
double r; |
565 |
> |
rconv( /* convert radius to meta coords */ |
566 |
> |
double r |
567 |
> |
) |
568 |
|
{ |
569 |
|
if (gparam[YMAP].flags & DEFINED) |
570 |
|
r = funvalue(gparam[YMAP].name, 1, &r); |
573 |
|
} |
574 |
|
|
575 |
|
|
576 |
< |
boxstring(xmin, ymin, xmax, ymax, s, d, width, color) /* put string in box */ |
577 |
< |
int xmin, ymin, xmax, ymax; |
578 |
< |
char *s; |
579 |
< |
int d, width, color; |
576 |
> |
void |
577 |
> |
boxstring( /* put string in box */ |
578 |
> |
int xmin, |
579 |
> |
int ymin, |
580 |
> |
int xmax, |
581 |
> |
int ymax, |
582 |
> |
char *s, |
583 |
> |
int d, |
584 |
> |
int width, |
585 |
> |
int color |
586 |
> |
) |
587 |
|
{ |
588 |
|
register long size; |
589 |
|
|
609 |
|
|
610 |
|
|
611 |
|
char * |
612 |
< |
goodformat(d) /* return a suitable format string for d */ |
613 |
< |
double d; |
612 |
> |
goodformat( /* return a suitable format string for d */ |
613 |
> |
double d |
614 |
> |
) |
615 |
|
{ |
616 |
|
static char *f[5] = {"%.0f", "%.1f", "%.2f", "%.3f", "%.4f"}; |
617 |
|
double floor(); |
629 |
|
} |
630 |
|
|
631 |
|
|
632 |
< |
drawcircle(x, y, r, typ, wid, col) /* draw a circle */ |
633 |
< |
int x, y, r; |
634 |
< |
int typ, wid, col; |
632 |
> |
void |
633 |
> |
drawcircle( /* draw a circle */ |
634 |
> |
int x, |
635 |
> |
int y, |
636 |
> |
int r, |
637 |
> |
int typ, |
638 |
> |
int wid, |
639 |
> |
int col |
640 |
> |
) |
641 |
|
{ |
642 |
|
double d; |
643 |
|
|
649 |
|
} |
650 |
|
|
651 |
|
|
652 |
< |
climline(c, x, y, xout, yout) /* print line from/to out of bounds */ |
653 |
< |
int c; |
654 |
< |
double x, y, xout, yout; |
652 |
> |
void |
653 |
> |
climline( /* print line from/to out of bounds */ |
654 |
> |
int c, |
655 |
> |
double x, |
656 |
> |
double y, |
657 |
> |
double xout, |
658 |
> |
double yout |
659 |
> |
) |
660 |
|
{ |
661 |
|
for ( ; ; ) |
662 |
|
if (xout < xbounds.min) { |
678 |
|
} |
679 |
|
|
680 |
|
|
681 |
< |
cline(c, u1, v1, u2, v2) /* print a curve line */ |
682 |
< |
int c; |
683 |
< |
double u1, v1, u2, v2; |
681 |
> |
void |
682 |
> |
cline( /* print a curve line */ |
683 |
> |
int c, |
684 |
> |
double u1, |
685 |
> |
double v1, |
686 |
> |
double u2, |
687 |
> |
double v2 |
688 |
> |
) |
689 |
|
{ |
690 |
|
int x, y; |
691 |
|
double ustep, vstep; |
715 |
|
|
716 |
|
|
717 |
|
int |
718 |
< |
cmline(c, x, y) /* start curve line in meta coords */ |
719 |
< |
int c; |
720 |
< |
int x, y; |
718 |
> |
cmline( /* start curve line in meta coords */ |
719 |
> |
int c, |
720 |
> |
int x, |
721 |
> |
int y |
722 |
> |
) |
723 |
|
{ |
724 |
|
int lw, lt, col; |
725 |
|
register VARIABLE *cv; |
748 |
|
} |
749 |
|
|
750 |
|
|
751 |
< |
csymbol(c, u, v) /* plot curve symbol */ |
752 |
< |
int c; |
753 |
< |
double u, v; |
751 |
> |
void |
752 |
> |
csymbol( /* plot curve symbol */ |
753 |
> |
int c, |
754 |
> |
double u, |
755 |
> |
double v |
756 |
> |
) |
757 |
|
{ |
758 |
|
int x, y; |
759 |
|
|
765 |
|
} |
766 |
|
|
767 |
|
|
768 |
< |
cmsymbol(c, x, y) /* print curve symbol in meta coords */ |
769 |
< |
int c; |
770 |
< |
int x, y; |
768 |
> |
void |
769 |
> |
cmsymbol( /* print curve symbol in meta coords */ |
770 |
> |
int c, |
771 |
> |
int x, |
772 |
> |
int y |
773 |
> |
) |
774 |
|
{ |
775 |
|
int col, ss; |
776 |
|
register VARIABLE *cv; |
795 |
|
} |
796 |
|
|
797 |
|
|
798 |
< |
inbounds(x, y) /* determine if x and y are within gbounds */ |
799 |
< |
double x, y; |
798 |
> |
int |
799 |
> |
inbounds( /* determine if x and y are within gbounds */ |
800 |
> |
double x, |
801 |
> |
double y |
802 |
> |
) |
803 |
|
{ |
804 |
|
if (x < xbounds.min || x > xbounds.max) |
805 |
|
return(0); |