1 |
#ifndef lint |
2 |
static const char RCSid[] = "$Id$"; |
3 |
#endif |
4 |
/* |
5 |
* plot4.c - program to put four metafile pages onto one. |
6 |
* |
7 |
* Greg Ward |
8 |
* 7/10/86 |
9 |
*/ |
10 |
|
11 |
#include "meta.h" |
12 |
|
13 |
|
14 |
#define OUTFILT "pexpand +OCIms" /* output filter */ |
15 |
|
16 |
#define SEGNAME "plot4seg" /* segment name */ |
17 |
|
18 |
|
19 |
extern FILE *pout; /* the output stream */ |
20 |
|
21 |
char *progname; |
22 |
|
23 |
|
24 |
main(argc, argv) |
25 |
int argc; |
26 |
char *argv[]; |
27 |
{ |
28 |
#ifdef UNIX |
29 |
FILE *popen(); |
30 |
#endif |
31 |
FILE *fp; |
32 |
int i; |
33 |
|
34 |
#ifdef CPM |
35 |
fixargs("plot4", &argc, &argv); |
36 |
#endif |
37 |
|
38 |
progname = argv[0]; |
39 |
|
40 |
#ifdef UNIX |
41 |
pout = popen(OUTFILT, "w"); |
42 |
#endif |
43 |
|
44 |
if (argc > 1) |
45 |
for (i = 1; i < argc; i++) { |
46 |
fp = efopen(argv[i], "r"); |
47 |
plot4(fp); |
48 |
fclose(fp); |
49 |
} |
50 |
else |
51 |
plot4(stdin); |
52 |
|
53 |
pglob(PEOF, 0200, NULL); |
54 |
|
55 |
#ifdef UNIX |
56 |
return(pclose(pout)); |
57 |
#else |
58 |
return(0); |
59 |
#endif |
60 |
} |
61 |
|
62 |
|
63 |
plot4(fp) /* put a file into its place on page */ |
64 |
FILE *fp; |
65 |
{ |
66 |
static int nplts = 0; |
67 |
PRIMITIVE curp; |
68 |
|
69 |
pglob(POPEN, 0, SEGNAME); |
70 |
|
71 |
while (readp(&curp, fp)) |
72 |
if (curp.com == PEOP) { |
73 |
pglob(PCLOSE, 0200, NULL); |
74 |
doseg(nplts++ % 4); |
75 |
pglob(POPEN, 0, SEGNAME); |
76 |
} else |
77 |
writep(&curp, pout); |
78 |
|
79 |
pglob(PCLOSE, 0200, NULL); |
80 |
} |
81 |
|
82 |
|
83 |
doseg(n) /* do segment number n */ |
84 |
int n; |
85 |
{ |
86 |
switch (n) { |
87 |
case 0: /* upper left */ |
88 |
pprim(PSEG, 0, 0, XYSIZE/2, XYSIZE/2-1, XYSIZE-1, SEGNAME); |
89 |
break; |
90 |
case 1: /* upper right */ |
91 |
pprim(PSEG, 0, XYSIZE/2, XYSIZE/2, XYSIZE-1, XYSIZE-1, SEGNAME); |
92 |
break; |
93 |
case 2: /* lower left */ |
94 |
pprim(PSEG, 0, 0, 0, XYSIZE/2-1, XYSIZE/2-1, SEGNAME); |
95 |
break; |
96 |
case 3: /* lower right, end page */ |
97 |
pprim(PSEG, 0, XYSIZE/2, 0, XYSIZE-1, XYSIZE/2-1, SEGNAME); |
98 |
pglob(PEOP, 0200, NULL); |
99 |
break; |
100 |
} |
101 |
} |