7 |
|
|
8 |
|
|
9 |
|
#include "meta.h" |
10 |
– |
|
10 |
|
#include "plot.h" |
12 |
– |
|
11 |
|
#include "rast.h" |
12 |
|
|
13 |
|
|
17 |
|
|
18 |
|
static PRIMITIVE nextp; |
19 |
|
|
20 |
+ |
static void initplot(void); |
21 |
+ |
static void doglobal(PRIMITIVE *g); |
22 |
+ |
static void plotblock(FILE *infp); |
23 |
+ |
static void doprim(PRIMITIVE *p); |
24 |
+ |
static void doprim(PRIMITIVE *p); |
25 |
+ |
static void paintline(int x, int y, int run, int rise, int hrad, int vrad, |
26 |
+ |
int lpat, long run2, long rise2, int n); |
27 |
+ |
static void tfill(PRIMITIVE *p); |
28 |
+ |
static void fill(int attrib, int xmin, int ymin, int xmax, int ymax); |
29 |
|
|
23 |
– |
plot(infp) /* plot meta-file */ |
30 |
|
|
31 |
< |
FILE *infp; |
32 |
< |
|
31 |
> |
void |
32 |
> |
plot( /* plot meta-file */ |
33 |
> |
FILE *infp |
34 |
> |
) |
35 |
|
{ |
28 |
– |
|
36 |
|
do { |
37 |
|
readp(&nextp, infp); |
38 |
|
initplot(); |
41 |
|
doglobal(&nextp); |
42 |
|
fargs(&nextp); |
43 |
|
} while (nextp.com != PEOF); |
37 |
– |
|
44 |
|
} |
45 |
|
|
46 |
|
|
47 |
< |
|
48 |
< |
|
43 |
< |
|
44 |
< |
initplot() /* initialize this plot */ |
45 |
< |
|
47 |
> |
void |
48 |
> |
initplot(void) /* initialize this plot */ |
49 |
|
{ |
50 |
|
int i; |
51 |
|
|
53 |
|
/* allocate block */ |
54 |
|
if (outblock.xright <= 0) { |
55 |
|
for (i = 0; i < NUMSCANS; i++) |
56 |
< |
if ((outblock.cols[i] = (unsigned char *)malloc(dxsize)) == NULL) |
56 |
> |
if ((outblock.cols[i] = (unsigned char *)malloc(dxsiz)) == NULL) |
57 |
|
error(SYSTEM, "out of memory in initplot"); |
58 |
|
} |
59 |
|
outblock.xleft = 0; |
60 |
< |
outblock.xright = dxsize-1; |
60 |
> |
outblock.xright = dxsiz-1; |
61 |
|
if (ydown) { |
62 |
< |
outblock.ytop = dysize+NUMSCANS-1; |
63 |
< |
outblock.ybot = dysize; |
62 |
> |
outblock.ytop = dysiz+NUMSCANS-1; |
63 |
> |
outblock.ybot = dysiz; |
64 |
|
} else { |
65 |
|
outblock.ytop = -1; |
66 |
|
outblock.ybot = -NUMSCANS; |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
< |
|
73 |
< |
|
74 |
< |
|
75 |
< |
doglobal(g) /* execute a global command */ |
73 |
< |
|
74 |
< |
PRIMITIVE *g; |
75 |
< |
|
72 |
> |
void |
73 |
> |
doglobal( /* execute a global command */ |
74 |
> |
PRIMITIVE *g |
75 |
> |
) |
76 |
|
{ |
77 |
– |
char c; |
78 |
– |
int tty; |
79 |
– |
|
77 |
|
switch (g->com) { |
78 |
|
|
79 |
|
case PEOF: |
103 |
|
error(WARNING, errmsg); |
104 |
|
break; |
105 |
|
} |
109 |
– |
|
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
< |
|
111 |
< |
|
112 |
< |
plotblock(infp) /* plot next block */ |
113 |
< |
|
118 |
< |
FILE *infp; |
119 |
< |
|
110 |
> |
void |
111 |
> |
plotblock( /* plot next block */ |
112 |
> |
FILE *infp |
113 |
> |
) |
114 |
|
{ |
115 |
|
PLIST lastinq; |
116 |
|
register PRIMITIVE *p; |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
< |
|
142 |
< |
|
149 |
< |
nextblock() /* prepare next block */ |
150 |
< |
|
141 |
> |
extern void |
142 |
> |
nextblock(void) /* prepare next block */ |
143 |
|
{ |
144 |
|
register int i, n; |
145 |
|
register unsigned char *colp; |
146 |
|
/* clear block */ |
147 |
|
for (i = 0; i < NUMSCANS; i++) { |
148 |
|
colp = outblock.cols[i]; |
149 |
< |
n = dxsize; |
149 |
> |
n = dxsiz; |
150 |
|
while (n--) |
151 |
|
*colp++ = IWHT<<3 | IWHT; |
152 |
|
} |
159 |
|
outblock.ybot += NUMSCANS; |
160 |
|
} |
161 |
|
return; |
170 |
– |
memerr: |
171 |
– |
error(SYSTEM, "out of memory in nextblock"); |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
< |
|
166 |
< |
outputblock() /* output block to printer */ |
165 |
> |
void |
166 |
> |
outputblock(void) /* output block to printer */ |
167 |
|
{ |
168 |
|
register int i, n; |
169 |
|
register unsigned char *colp; |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
< |
|
185 |
< |
doprim(p) /* plot primitive */ |
186 |
< |
|
187 |
< |
register PRIMITIVE *p; |
198 |
< |
|
184 |
> |
void |
185 |
> |
doprim( /* plot primitive */ |
186 |
> |
register PRIMITIVE *p |
187 |
> |
) |
188 |
|
{ |
189 |
|
register PRIMITIVE *newp; |
190 |
|
|
196 |
|
|
197 |
|
case PRFILL: |
198 |
|
fill((p->arg0&0103) | (pati[(p->arg0>>2)&03]<<2), |
199 |
< |
CONV(p->xy[XMN],dxsize),CONV(p->xy[YMN],dysize), |
200 |
< |
CONV(p->xy[XMX],dxsize)+(p->arg0&0100?-1:0), |
201 |
< |
CONV(p->xy[YMX],dysize)+(p->arg0&0100?-1:0)); |
199 |
> |
CONV(p->xy[XMN],dxsiz),CONV(p->xy[YMN],dysiz), |
200 |
> |
CONV(p->xy[XMX],dxsiz)+(p->arg0&0100?-1:0), |
201 |
> |
CONV(p->xy[YMX],dysiz)+(p->arg0&0100?-1:0)); |
202 |
|
break; |
203 |
|
|
204 |
|
case PTFILL: |
218 |
|
newp->args = savestr(p->args); |
219 |
|
add(newp, &inqueue); |
220 |
|
} |
232 |
– |
|
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
< |
|
225 |
< |
|
226 |
< |
|
227 |
< |
plotlseg(p) /* plot a line segment */ |
240 |
< |
|
241 |
< |
register PRIMITIVE *p; |
242 |
< |
|
224 |
> |
void |
225 |
> |
plotlseg( /* plot a line segment */ |
226 |
> |
register PRIMITIVE *p |
227 |
> |
) |
228 |
|
{ |
229 |
|
register int ti; |
230 |
|
long run2 = 0L, rise2 = 0L; |
238 |
|
|
239 |
|
ti = (p->arg0 >> 2) & 03; /* compute line radius */ |
240 |
|
ti = WIDTH(ti) / 2; |
241 |
< |
hrad = CONV(ti, dxsize); |
242 |
< |
vrad = CONV(ti, dysize); |
241 |
> |
hrad = CONV(ti, dxsiz); |
242 |
> |
vrad = CONV(ti, dysiz); |
243 |
|
if (hrad < minwidth) |
244 |
|
hrad = minwidth; |
245 |
|
if (vrad < minwidth) |
246 |
|
vrad = minwidth; |
247 |
|
|
248 |
< |
x = CONV(p->xy[XMX], dxsize); /* start at top */ |
249 |
< |
y = CONV(p->xy[YMX], dysize); |
250 |
< |
run = CONV(p->xy[XMN], dxsize) - x; |
251 |
< |
rise = CONV(p->xy[YMN], dysize) - y; |
248 |
> |
x = CONV(p->xy[XMX], dxsiz); /* start at top */ |
249 |
> |
y = CONV(p->xy[YMX], dysiz); |
250 |
> |
run = CONV(p->xy[XMN], dxsiz) - x; |
251 |
> |
rise = CONV(p->xy[YMN], dysiz) - y; |
252 |
|
|
253 |
|
if (p->arg0 & 0100) /* slope < 0; reverse x */ |
254 |
|
x -= (run = -run); |
282 |
|
* This routine paints a line with calls to fill(). The line can |
283 |
|
* start and end at arbitrary points on a longer line segment. |
284 |
|
*/ |
285 |
< |
|
286 |
< |
paintline(x, y, run, rise, hrad, vrad, lpat, run2, rise2, n) |
287 |
< |
|
288 |
< |
register int x, y; |
289 |
< |
int run, rise; |
290 |
< |
int hrad, vrad; |
291 |
< |
int lpat; |
292 |
< |
long run2, rise2; |
293 |
< |
int n; |
294 |
< |
|
285 |
> |
void |
286 |
> |
paintline( |
287 |
> |
register int x, |
288 |
> |
register int y, |
289 |
> |
int run, |
290 |
> |
int rise, |
291 |
> |
int hrad, |
292 |
> |
int vrad, |
293 |
> |
int lpat, |
294 |
> |
long run2, |
295 |
> |
long rise2, |
296 |
> |
int n |
297 |
> |
) |
298 |
|
{ |
299 |
|
int xstep, ystep; |
300 |
|
|
339 |
|
} |
340 |
|
|
341 |
|
|
342 |
< |
|
343 |
< |
tfill(p) /* fill a triangle */ |
344 |
< |
register PRIMITIVE *p; |
342 |
> |
void |
343 |
> |
tfill( /* fill a triangle */ |
344 |
> |
register PRIMITIVE *p |
345 |
> |
) |
346 |
|
{ |
347 |
|
register int x, txmin, txmax; |
348 |
|
int xmn, ymn, tpat; |
349 |
|
long xsz, ysz; |
350 |
|
|
351 |
< |
xmn = CONV(p->xy[XMN], dxsize); |
352 |
< |
xsz = CONV(p->xy[XMX], dxsize) - xmn; |
353 |
< |
ymn = CONV(p->xy[YMN], dysize); |
354 |
< |
ysz = CONV(p->xy[YMX], dysize) - ymn; |
351 |
> |
xmn = CONV(p->xy[XMN], dxsiz); |
352 |
> |
xsz = CONV(p->xy[XMX], dxsiz) - xmn; |
353 |
> |
ymn = CONV(p->xy[YMN], dysiz); |
354 |
> |
ysz = CONV(p->xy[YMX], dysiz) - ymn; |
355 |
|
if (xsz <= 0 || ysz <= 0) |
356 |
|
return; |
357 |
|
txmin = (outblock.ybot - ymn)*xsz/ysz; |
386 |
|
|
387 |
|
|
388 |
|
|
389 |
< |
|
390 |
< |
fill(attrib, xmin, ymin, xmax, ymax) /* fill rectangle with attribute */ |
391 |
< |
|
392 |
< |
register int attrib; |
393 |
< |
int xmin, ymin, xmax, ymax; |
394 |
< |
|
389 |
> |
void |
390 |
> |
fill( /* fill rectangle with attribute */ |
391 |
> |
register int attrib, |
392 |
> |
int xmin, |
393 |
> |
int ymin, |
394 |
> |
int xmax, |
395 |
> |
int ymax |
396 |
> |
) |
397 |
|
{ |
398 |
|
register int i, j; |
399 |
|
|