ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/xmeta.c
(Generate patch)

Comparing ray/src/meta/xmeta.c (file contents):
Revision 1.2 by schorsch, Mon Oct 27 10:28:59 2003 UTC vs.
Revision 1.4 by greg, Mon Oct 8 18:07:57 2007 UTC

# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   */
11  
12   #include  "rtprocess.h"
13 + #include  "string.h"
14   #include  "meta.h"
15   #include  "plot.h"
16  
# Line 30 | Line 31 | static PLIST  recording;
31  
32   int maxalloc = 0;               /* no limit */
33  
34 + extern void     pXFlush(void);
35  
36  
37 < main(argc, argv)
36 <
37 < int  argc;
38 < char  **argv;
39 <
40 < {
41 < FILE  *fp;
42 < char  *geometry = NULL;
43 < short  condonly, conditioned;
44 < char  comargs[500], command[600];
45 <
46 < progname = *argv++;
47 < argc--;
48 <
49 < condonly = FALSE;
50 < conditioned = FALSE;
51 <
52 < for ( ; argc; argv++, argc--)
53 <    if (!strcmp(*argv, "-c"))
54 <        condonly = TRUE;
55 <    else if (!strcmp(*argv, "-r"))
56 <        conditioned = TRUE;
57 <    else if (**argv == '=')
58 <        geometry = *argv;
59 <    else
60 <        break;
61 <
62 < if (conditioned) {
63 <    init(progname, geometry);
64 <    if (argc)
65 <       while (argc)  {
66 <          fp = efopen(*argv, "r");
67 <          plot(fp);
68 <          fclose(fp);
69 <          argv++;
70 <          argc--;
71 <          }
72 <    else
73 <       plot(stdin);
74 < } else  {
75 <    comargs[0] = '\0';
76 <    while (argc)  {
77 <       strcat(comargs, " ");
78 <       strcat(comargs, *argv);
79 <       argv++;
80 <       argc--;
81 <       }
82 <    sprintf(command, XCOM, comargs);
83 <    if (condonly)
84 <       return(system(command));
85 <    else  {
86 <       init(progname, geometry);
87 <       if ((fp = popen(command, "r")) == NULL)
88 <          error(SYSTEM, "cannot execute input filter");
89 <       plot(fp);
90 <       pclose(fp);
91 <       }
92 <    }
93 <
94 < if (!newpage)
95 <     endpage();
96 <
97 < return(0);
98 < }
99 <
100 <
101 <
102 <
103 < plot(infp)              /* plot meta-file */
104 <
105 < FILE  *infp;
106 <
107 < {
108 <    PRIMITIVE  nextp;
109 <
110 <    set(SALL, NULL);
111 <    do {
112 <        readp(&nextp, infp);
113 <        while (isprim(nextp.com)) {
114 <            doprim(&nextp, 1);
115 <            readp(&nextp, infp);
116 <        }
117 <        doglobal(&nextp, 1);
118 <    } while (nextp.com != PEOF);
119 <
120 < }
121 <
122 <
123 <
124 < replay(xmin, ymin, xmax, ymax)          /* play back region */
125 < int  xmin, ymin, xmax, ymax;
126 < {
127 <    register PRIMITIVE  *p;
128 <
129 <    unset(SALL);
130 <    set(SALL, NULL);
131 <    for (p = recording.ptop; p != NULL; p = p->pnext)
132 <        if (isprim(p->com)) {
133 <            if (overlap(p, xmin, ymin, xmax, ymax))
134 <                doprim(p, 0);
135 <        } else
136 <            doglobal(p, 0);
137 <
138 < }
139 <
140 <
141 <
142 <
37 > void
38   save(p)                         /* record primitive */
39   PRIMITIVE  *p;
40   {
# Line 147 | Line 42 | PRIMITIVE  *p;
42  
43      if ((pnew = palloc()) == NULL)
44              error(SYSTEM, "out of memory in save");
45 <    mcopy(pnew, p, sizeof(PRIMITIVE));
45 >    mcopy((char *)pnew, (char *)p, sizeof(PRIMITIVE));
46      add(pnew, &recording);
47   }
48  
49  
50 <
156 <
50 > void
51   doglobal(g, sf)                 /* execute a global command */
158
52   register PRIMITIVE  *g;
53   int  sf;
161
54   {
55  
56      switch (g->com) {
# Line 167 | Line 59 | int  sf;
59              return;
60  
61          case PDRAW:
62 <            XFlush();
62 >            pXFlush();
63              break;
64  
65          case PEOP:
# Line 200 | Line 92 | int  sf;
92   }
93  
94  
95 <
204 <
95 > void
96   doprim(p, sf)           /* plot primitive */
206
97   register PRIMITIVE  *p;
98   int  sf;
209
99   {
100  
101      switch (p->com) {
# Line 242 | Line 131 | int  sf;
131      }
132  
133   }
134 +
135 +
136 + void
137 + plot(infp)              /* plot meta-file */
138 + FILE  *infp;
139 + {
140 +    PRIMITIVE  nextp;
141 +
142 +    set(SALL, NULL);
143 +    do {
144 +        readp(&nextp, infp);
145 +        while (isprim(nextp.com)) {
146 +            doprim(&nextp, 1);
147 +            readp(&nextp, infp);
148 +        }
149 +        doglobal(&nextp, 1);
150 +    } while (nextp.com != PEOF);
151 +
152 + }
153 +
154 +
155 + void
156 + replay(xmin, ymin, xmax, ymax)          /* play back region */
157 + int  xmin, ymin, xmax, ymax;
158 + {
159 +    register PRIMITIVE  *p;
160 +
161 +    unset(SALL);
162 +    set(SALL, NULL);
163 +    for (p = recording.ptop; p != NULL; p = p->pnext)
164 +        if (isprim(p->com)) {
165 +            if (overlap(p, xmin, ymin, xmax, ymax))
166 +                doprim(p, 0);
167 +        } else
168 +            doglobal(p, 0);
169 +
170 + }
171 +
172 +
173 + int
174 + main(argc, argv)
175 + int  argc;
176 + char  **argv;
177 + {
178 + FILE  *fp;
179 + char  *geometry = NULL;
180 + short  condonly, conditioned;
181 + char  comargs[500], command[600];
182 +
183 + progname = *argv++;
184 + argc--;
185 +
186 + condonly = FALSE;
187 + conditioned = FALSE;
188 +
189 + for ( ; argc; argv++, argc--)
190 +    if (!strcmp(*argv, "-c"))
191 +        condonly = TRUE;
192 +    else if (!strcmp(*argv, "-r"))
193 +        conditioned = TRUE;
194 +    else if (**argv == '=')
195 +        geometry = *argv;
196 +    else
197 +        break;
198 +
199 + if (conditioned) {
200 +    init(progname, geometry);
201 +    if (argc)
202 +       while (argc)  {
203 +          fp = efopen(*argv, "r");
204 +          plot(fp);
205 +          fclose(fp);
206 +          argv++;
207 +          argc--;
208 +          }
209 +    else
210 +       plot(stdin);
211 + } else  {
212 +    comargs[0] = '\0';
213 +    while (argc)  {
214 +       strcat(comargs, " ");
215 +       strcat(comargs, *argv);
216 +       argv++;
217 +       argc--;
218 +       }
219 +    sprintf(command, XCOM, comargs);
220 +    if (condonly)
221 +       return(system(command));
222 +    else  {
223 +       init(progname, geometry);
224 +       if ((fp = popen(command, "r")) == NULL)
225 +          error(SYSTEM, "cannot execute input filter");
226 +       plot(fp);
227 +       pclose(fp);
228 +       }
229 +    }
230 +
231 + if (!newpage)
232 +     endpage();
233 +
234 + return(0);
235 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines