ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/tscat.c
Revision: 1.2
Committed: Sun Jun 8 12:03:10 2003 UTC (21 years ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 1.1: +4 -2 lines
Log Message:
Reduced compile warnings/errors on Windows.

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: tscat.c,v 1.1 2003/02/22 02:07:26 greg Exp $";
3 #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 #include "paths.h"
15
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 #ifdef CPM
70 fixargs("tscat", &argc, &argv);
71 #endif
72
73 progname = *argv++;
74 argc--;
75
76 initialize();
77
78 for (; argc && (**argv == '-' || **argv == '+'); argc--, argv++)
79 option(*argv);
80
81 if (polar) /* avoid dumb choices */
82 logx = FALSE;
83
84 axflag = XTICS|XNUMS|YTICS|YNUMS;
85 if (grid)
86 axflag |= XGRID|YGRID;
87 if (polar)
88 axflag |= ORIGIN;
89 else
90 axflag |= BOX;
91
92 pglob(PINCL, 2, "symbols.mta");
93
94 if (argc)
95
96 for ( ; argc--; argv++) {
97
98 fp = efopen(*argv, "r");
99 normalize(fp, NULL);
100 makeaxis(axflag);
101 fseek(fp, 0L, 0);
102 plot(fp);
103 fclose(fp);
104 }
105 else {
106
107 /*sprintf(tfname, "%sts%d", TDIR, getpid());*/
108 temp_filename(tfname, sizeof(tfname), NULL);
109 fp = efopen(tfname, "w+");
110 normalize(stdin, fp);
111 makeaxis(axflag);
112 fseek(fp, 0L, 0);
113 plot(fp);
114 fclose(fp);
115 unlink(tfname);
116 }
117
118 pglob(PEOF, 0200, NULL);
119
120 return(0);
121 }
122
123
124
125
126
127 plot(fp) /* read file and generate plot */
128
129 FILE *fp;
130
131 {
132 int ncur = 0; /* curves seen so far */
133 char line[255], *s;
134 double x, y;
135
136 xlegend = XLEGEND;
137 ylegend = YLEGEND;
138
139 if (ncurves > 0) {
140 pprim(PMSTR, 0100, xlegend, ylegend+800, xlegend, ylegend+800, "Legend:");
141 pprim(PMSTR, 0100, xlegend, ylegend+800, xlegend, ylegend+800, "______");
142 }
143
144 while (fgets(line, sizeof line, fp) != NULL)
145
146 if (istitle(line)) {
147 s = snagquo(line);
148 boxstring(0, 0, YBEG+YSIZ+1000, XYSIZE-1, YBEG+YSIZ+1500, s);
149 }
150
151 else if (isxlabel(line)) {
152 s = snagquo(line);
153 boxstring(0, XBEG, YBEG-1250, XBEG+XSIZ, YBEG-900, s);
154 }
155
156 else if (isylabel(line)) {
157 s = snagquo(line);
158 boxstring(020, XBEG-1900, YBEG, XBEG-1550, YBEG+YSIZ, s);
159 }
160
161 else if (islabel(line)) {
162 if (++ncur < NCUR && usecurve[ncur]) {
163 symout(0, xlegend, ylegend+symrad, sym[ncur]);
164 pprim(PMSTR, 020, xlegend+400, ylegend+200,
165 xlegend+400, ylegend+200, snagquo(line));
166 ylegend -= 500;
167 }
168 }
169
170 else if (usecurve[ncur] && isdata(line)) {
171
172 if (getdata(line, &x, &y) >= 0)
173 symout(0, XCONV(x), YCONV(y), sym[ncur]);
174
175 }
176
177 pglob(PEOP, 0200, NULL);
178
179 }
180