1 |
greg |
1.1 |
#ifndef lint |
2 |
schorsch |
1.3 |
static const char RCSid[] = "$Id: tscat.c,v 1.2 2003/06/08 12:03:10 schorsch Exp $"; |
3 |
greg |
1.1 |
#endif |
4 |
|
|
/* |
5 |
|
|
* PROGRAM TO PLOT TEL-A-GRAF POINTS TO METAFILE |
6 |
|
|
* |
7 |
|
|
* Greg Ward |
8 |
|
|
* 12/12/84 |
9 |
|
|
* |
10 |
|
|
* cc -o ../tscat tscat.c tgraph.o primout.o mfio.o syscalls.o misc.o -lm |
11 |
|
|
*/ |
12 |
|
|
|
13 |
|
|
#include "tgraph.h" |
14 |
schorsch |
1.2 |
#include "paths.h" |
15 |
greg |
1.1 |
|
16 |
|
|
|
17 |
|
|
#define XLEGEND (XBEG+XSIZ+4*TSIZ) /* x start of legend */ |
18 |
|
|
|
19 |
|
|
#define YLEGEND (YBEG+2*YSIZ/3) /* y start of legend */ |
20 |
|
|
|
21 |
|
|
short usecurve[NCUR]; /* booleans for curve usage */ |
22 |
|
|
|
23 |
|
|
double xmin, ymin, xmax, ymax; /* domain */ |
24 |
|
|
|
25 |
|
|
double xsize, ysize; /* axis dimensions */ |
26 |
|
|
|
27 |
|
|
double xmnset = -FHUGE, xmxset = FHUGE, /* domain settings */ |
28 |
|
|
ymnset = -FHUGE, ymxset = FHUGE; |
29 |
|
|
|
30 |
|
|
short logx = FALSE, logy = FALSE; /* flags for log plots */ |
31 |
|
|
|
32 |
|
|
short polar = FALSE; /* flag for polar plots */ |
33 |
|
|
|
34 |
|
|
short grid = FALSE; /* flag for grid */ |
35 |
|
|
|
36 |
|
|
char *sym[NCUR] = {"ex", "triangle", "square", "triangle2", "diamond", |
37 |
|
|
"cross", "octagon", "crosssquare", "exsquare", |
38 |
|
|
"trianglesquare", "triangle2square", "crossdiamond", |
39 |
|
|
"crossoctagon", "exoctagon", "block", "bullet"}; |
40 |
|
|
|
41 |
|
|
int ncurves; |
42 |
|
|
|
43 |
|
|
int xlegend, |
44 |
|
|
ylegend; /* current legend position */ |
45 |
|
|
|
46 |
|
|
int symrad = SYMRAD; /* symbol radius */ |
47 |
|
|
|
48 |
|
|
char *progname; |
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
main(argc, argv) |
55 |
|
|
|
56 |
|
|
int argc; |
57 |
|
|
char **argv; |
58 |
|
|
|
59 |
|
|
/* |
60 |
|
|
* Take Tel-A-Graf runnable files and convert them to |
61 |
|
|
* metafile primitives to send to standard output |
62 |
|
|
*/ |
63 |
|
|
|
64 |
|
|
{ |
65 |
|
|
char tfname[MAXFNAME]; |
66 |
|
|
FILE *fp; |
67 |
|
|
int axflag; |
68 |
|
|
|
69 |
|
|
progname = *argv++; |
70 |
|
|
argc--; |
71 |
|
|
|
72 |
|
|
initialize(); |
73 |
|
|
|
74 |
|
|
for (; argc && (**argv == '-' || **argv == '+'); argc--, argv++) |
75 |
|
|
option(*argv); |
76 |
|
|
|
77 |
|
|
if (polar) /* avoid dumb choices */ |
78 |
|
|
logx = FALSE; |
79 |
|
|
|
80 |
|
|
axflag = XTICS|XNUMS|YTICS|YNUMS; |
81 |
|
|
if (grid) |
82 |
|
|
axflag |= XGRID|YGRID; |
83 |
|
|
if (polar) |
84 |
|
|
axflag |= ORIGIN; |
85 |
|
|
else |
86 |
|
|
axflag |= BOX; |
87 |
|
|
|
88 |
|
|
pglob(PINCL, 2, "symbols.mta"); |
89 |
|
|
|
90 |
|
|
if (argc) |
91 |
|
|
|
92 |
|
|
for ( ; argc--; argv++) { |
93 |
|
|
|
94 |
|
|
fp = efopen(*argv, "r"); |
95 |
|
|
normalize(fp, NULL); |
96 |
|
|
makeaxis(axflag); |
97 |
|
|
fseek(fp, 0L, 0); |
98 |
|
|
plot(fp); |
99 |
|
|
fclose(fp); |
100 |
|
|
} |
101 |
|
|
else { |
102 |
|
|
|
103 |
schorsch |
1.2 |
/*sprintf(tfname, "%sts%d", TDIR, getpid());*/ |
104 |
|
|
temp_filename(tfname, sizeof(tfname), NULL); |
105 |
greg |
1.1 |
fp = efopen(tfname, "w+"); |
106 |
|
|
normalize(stdin, fp); |
107 |
|
|
makeaxis(axflag); |
108 |
|
|
fseek(fp, 0L, 0); |
109 |
|
|
plot(fp); |
110 |
|
|
fclose(fp); |
111 |
|
|
unlink(tfname); |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
pglob(PEOF, 0200, NULL); |
115 |
|
|
|
116 |
|
|
return(0); |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
plot(fp) /* read file and generate plot */ |
124 |
|
|
|
125 |
|
|
FILE *fp; |
126 |
|
|
|
127 |
|
|
{ |
128 |
|
|
int ncur = 0; /* curves seen so far */ |
129 |
|
|
char line[255], *s; |
130 |
|
|
double x, y; |
131 |
|
|
|
132 |
|
|
xlegend = XLEGEND; |
133 |
|
|
ylegend = YLEGEND; |
134 |
|
|
|
135 |
|
|
if (ncurves > 0) { |
136 |
|
|
pprim(PMSTR, 0100, xlegend, ylegend+800, xlegend, ylegend+800, "Legend:"); |
137 |
|
|
pprim(PMSTR, 0100, xlegend, ylegend+800, xlegend, ylegend+800, "______"); |
138 |
|
|
} |
139 |
|
|
|
140 |
|
|
while (fgets(line, sizeof line, fp) != NULL) |
141 |
|
|
|
142 |
|
|
if (istitle(line)) { |
143 |
|
|
s = snagquo(line); |
144 |
|
|
boxstring(0, 0, YBEG+YSIZ+1000, XYSIZE-1, YBEG+YSIZ+1500, s); |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
else if (isxlabel(line)) { |
148 |
|
|
s = snagquo(line); |
149 |
|
|
boxstring(0, XBEG, YBEG-1250, XBEG+XSIZ, YBEG-900, s); |
150 |
|
|
} |
151 |
|
|
|
152 |
|
|
else if (isylabel(line)) { |
153 |
|
|
s = snagquo(line); |
154 |
|
|
boxstring(020, XBEG-1900, YBEG, XBEG-1550, YBEG+YSIZ, s); |
155 |
|
|
} |
156 |
|
|
|
157 |
|
|
else if (islabel(line)) { |
158 |
|
|
if (++ncur < NCUR && usecurve[ncur]) { |
159 |
|
|
symout(0, xlegend, ylegend+symrad, sym[ncur]); |
160 |
|
|
pprim(PMSTR, 020, xlegend+400, ylegend+200, |
161 |
|
|
xlegend+400, ylegend+200, snagquo(line)); |
162 |
|
|
ylegend -= 500; |
163 |
|
|
} |
164 |
|
|
} |
165 |
|
|
|
166 |
|
|
else if (usecurve[ncur] && isdata(line)) { |
167 |
|
|
|
168 |
|
|
if (getdata(line, &x, &y) >= 0) |
169 |
|
|
symout(0, XCONV(x), YCONV(y), sym[ncur]); |
170 |
|
|
|
171 |
|
|
} |
172 |
|
|
|
173 |
|
|
pglob(PEOP, 0200, NULL); |
174 |
|
|
|
175 |
|
|
} |
176 |
|
|
|