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