ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/tscat.c
Revision: 1.1
Committed: Sat Feb 22 02:07:26 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

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