| 9 |
|
* 5/20/85 |
| 10 |
|
*/ |
| 11 |
|
|
| 12 |
+ |
#include <string.h> |
| 13 |
+ |
|
| 14 |
|
#include "meta.h" |
| 15 |
+ |
#include "plot.h" |
| 16 |
|
|
| 14 |
– |
|
| 17 |
|
#define getsi(f, m) ICONV(geti(f)-(m), size) |
| 18 |
|
|
| 19 |
|
|
| 28 |
|
|
| 29 |
|
static short curmod = 0; /* current line drawing mode */ |
| 30 |
|
|
| 31 |
+ |
static void convert(FILE *infp); |
| 32 |
+ |
static int geti(FILE *fp); |
| 33 |
+ |
static int quadr(int x, int y, int xp, int yp); |
| 34 |
+ |
static void step(int d); |
| 35 |
|
|
| 36 |
+ |
static void linemod(char s[]); |
| 37 |
+ |
static void erase(void); |
| 38 |
+ |
static void space(int xmn, int ymn, int xmx, int ymx); |
| 39 |
+ |
static void move(int x, int y); |
| 40 |
+ |
static void cont(int x, int y); |
| 41 |
+ |
static void line(int x0, int y0, int x1, int y1); |
| 42 |
+ |
static void label(register char *s); |
| 43 |
+ |
static void point(int x, int y); |
| 44 |
+ |
static void arc(int x, int y, int x0, int y0, int x1, int y1); |
| 45 |
+ |
static void circle(int x, int y, int r); |
| 46 |
|
|
| 31 |
– |
main(argc, argv) |
| 47 |
|
|
| 48 |
< |
int argc; |
| 49 |
< |
char **argv; |
| 50 |
< |
|
| 48 |
> |
int |
| 49 |
> |
main( |
| 50 |
> |
int argc, |
| 51 |
> |
char **argv |
| 52 |
> |
) |
| 53 |
|
{ |
| 54 |
|
FILE *fp; |
| 55 |
|
|
| 80 |
|
pglob(PEOF, 0200, NULL); |
| 81 |
|
|
| 82 |
|
return(0); |
| 83 |
< |
} |
| 83 |
> |
} |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
< |
|
| 89 |
< |
convert(infp) /* convert to meta-file */ |
| 90 |
< |
|
| 91 |
< |
FILE *infp; |
| 75 |
< |
|
| 88 |
> |
void |
| 89 |
> |
convert( /* convert to meta-file */ |
| 90 |
> |
FILE *infp |
| 91 |
> |
) |
| 92 |
|
{ |
| 93 |
|
char *fgets(), sbuf[BUFSIZ]; |
| 94 |
|
int command; |
| 162 |
|
|
| 163 |
|
|
| 164 |
|
int |
| 165 |
< |
geti(fp) /* get two-byte integer from file */ |
| 166 |
< |
|
| 167 |
< |
register FILE *fp; |
| 152 |
< |
|
| 165 |
> |
geti( /* get two-byte integer from file */ |
| 166 |
> |
register FILE *fp |
| 167 |
> |
) |
| 168 |
|
{ |
| 169 |
|
register int i; |
| 170 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
< |
|
| 184 |
< |
move(x, y) /* move to new position */ |
| 185 |
< |
|
| 186 |
< |
register int x, y; |
| 187 |
< |
|
| 183 |
> |
void |
| 184 |
> |
move( /* move to new position */ |
| 185 |
> |
register int x, |
| 186 |
> |
register int y |
| 187 |
> |
) |
| 188 |
|
{ |
| 174 |
– |
|
| 189 |
|
curx = x; |
| 190 |
|
cury = y; |
| 177 |
– |
|
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
< |
|
| 196 |
< |
cont(x, y) /* draw line to point */ |
| 197 |
< |
|
| 198 |
< |
register int x, y; |
| 199 |
< |
|
| 195 |
> |
void |
| 196 |
> |
cont( /* draw line to point */ |
| 197 |
> |
register int x, |
| 198 |
> |
register int y |
| 199 |
> |
) |
| 200 |
|
{ |
| 188 |
– |
|
| 201 |
|
plseg(curmod, curx, cury, x, y); |
| 202 |
|
curx = x; |
| 203 |
|
cury = y; |
| 192 |
– |
|
| 204 |
|
} |
| 205 |
|
|
| 206 |
|
|
| 207 |
< |
|
| 208 |
< |
point(x, y) /* draw a point */ |
| 209 |
< |
|
| 210 |
< |
register int x, y; |
| 211 |
< |
|
| 207 |
> |
void |
| 208 |
> |
point( /* draw a point */ |
| 209 |
> |
register int x, |
| 210 |
> |
register int y |
| 211 |
> |
) |
| 212 |
|
{ |
| 202 |
– |
|
| 213 |
|
plseg(0, x, y, x, y); |
| 214 |
|
curx = x; |
| 215 |
|
cury = y; |
| 206 |
– |
|
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
< |
|
| 221 |
< |
line(x0, y0, x1, y1) /* draw a line segment */ |
| 222 |
< |
|
| 223 |
< |
int x0, y0, x1, y1; |
| 224 |
< |
|
| 220 |
> |
void |
| 221 |
> |
line( /* draw a line segment */ |
| 222 |
> |
int x0, |
| 223 |
> |
int y0, |
| 224 |
> |
int x1, |
| 225 |
> |
int y1 |
| 226 |
> |
) |
| 227 |
|
{ |
| 217 |
– |
|
| 228 |
|
move(x0, y0); |
| 229 |
|
cont(x1, y1); |
| 220 |
– |
|
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
|
| 233 |
< |
|
| 234 |
< |
label(s) /* print a label */ |
| 235 |
< |
|
| 236 |
< |
register char *s; |
| 228 |
< |
|
| 233 |
> |
void |
| 234 |
> |
label( /* print a label */ |
| 235 |
> |
register char *s |
| 236 |
> |
) |
| 237 |
|
{ |
| 230 |
– |
|
| 238 |
|
pprim(PMSTR, 0, curx, cury, curx, cury, s); |
| 232 |
– |
|
| 239 |
|
} |
| 240 |
|
|
| 241 |
|
|
| 242 |
|
|
| 237 |
– |
|
| 243 |
|
static int del = 100; |
| 244 |
< |
static step(d){ |
| 244 |
> |
|
| 245 |
> |
void |
| 246 |
> |
step( |
| 247 |
> |
int d |
| 248 |
> |
) |
| 249 |
> |
{ |
| 250 |
|
del = d; |
| 251 |
|
} |
| 252 |
< |
arc(x,y,x0,y0,x1,y1){ |
| 252 |
> |
|
| 253 |
> |
void |
| 254 |
> |
arc( |
| 255 |
> |
int x, |
| 256 |
> |
int y, |
| 257 |
> |
int x0, |
| 258 |
> |
int y0, |
| 259 |
> |
int x1, |
| 260 |
> |
int y1 |
| 261 |
> |
) |
| 262 |
> |
{ |
| 263 |
|
double pc; |
| 264 |
|
double sqrt(); |
| 265 |
|
int flg,m,xc,yc,xs,ys,qs,qf; |
| 350 |
|
} |
| 351 |
|
} |
| 352 |
|
} |
| 353 |
< |
quadr(x,y,xp,yp){ |
| 353 |
> |
|
| 354 |
> |
int |
| 355 |
> |
quadr( |
| 356 |
> |
int x, |
| 357 |
> |
int y, |
| 358 |
> |
int xp, |
| 359 |
> |
int yp |
| 360 |
> |
) |
| 361 |
> |
{ |
| 362 |
|
if(x < xp) |
| 363 |
|
if(y <= yp)return(1); |
| 364 |
|
else return(4); |
| 370 |
|
} |
| 371 |
|
|
| 372 |
|
|
| 373 |
< |
|
| 374 |
< |
circle(x,y,r){ |
| 373 |
> |
void |
| 374 |
> |
circle( |
| 375 |
> |
int x, |
| 376 |
> |
int y, |
| 377 |
> |
int r |
| 378 |
> |
) |
| 379 |
> |
{ |
| 380 |
|
arc(x,y,x+r,y,x+r,y); |
| 381 |
|
} |
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
< |
|
| 386 |
< |
erase() /* erase plot */ |
| 354 |
< |
|
| 385 |
> |
void |
| 386 |
> |
erase(void) /* erase plot */ |
| 387 |
|
{ |
| 356 |
– |
|
| 388 |
|
pglob(PEOP, 0200, NULL); |
| 358 |
– |
|
| 389 |
|
} |
| 390 |
|
|
| 391 |
|
|
| 392 |
< |
|
| 393 |
< |
|
| 394 |
< |
|
| 395 |
< |
|
| 366 |
< |
linemod(s) /* set line mode according to s */ |
| 367 |
< |
|
| 368 |
< |
char s[]; |
| 369 |
< |
|
| 392 |
> |
void |
| 393 |
> |
linemod( /* set line mode according to s */ |
| 394 |
> |
char s[] |
| 395 |
> |
) |
| 396 |
|
{ |
| 371 |
– |
|
| 397 |
|
switch (s[2]) { |
| 398 |
|
case 'l': /* solid */ |
| 399 |
|
curmod = 0; |
| 411 |
|
error(WARNING, "unknown line mode in linemod"); |
| 412 |
|
break; |
| 413 |
|
} |
| 389 |
– |
|
| 414 |
|
} |
| 415 |
|
|
| 416 |
|
|
| 417 |
< |
|
| 418 |
< |
|
| 419 |
< |
space(xmn, ymn, xmx, ymx) /* change space */ |
| 420 |
< |
|
| 421 |
< |
int xmn, ymn, xmx, ymx; |
| 422 |
< |
|
| 417 |
> |
void |
| 418 |
> |
space( /* change space */ |
| 419 |
> |
int xmn, |
| 420 |
> |
int ymn, |
| 421 |
> |
int xmx, |
| 422 |
> |
int ymx |
| 423 |
> |
) |
| 424 |
|
{ |
| 400 |
– |
|
| 425 |
|
if (xmn >= xmx || ymn >= ymx) |
| 426 |
|
error(USER, "illegal space specification in space"); |
| 427 |
|
|
| 428 |
|
xmin = xmn; |
| 429 |
|
ymin = ymn; |
| 430 |
|
size = min(xmx-xmn, ymx-ymn); |
| 407 |
– |
|
| 431 |
|
} |