ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/okimate.c
Revision: 1.1
Committed: Sat Feb 22 02:07:26 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * Program to print meta-files on a dot-matrix printer
6 *
7 * cc -o okimate okimate.c mplot.o plot.o mfio.o syscalls.o palloc.o misc.o
8 *
9 * Okimate 20 printer (version for black ribbon)
10 */
11
12
13 #define MAXALLOC 5000
14
15 #define DXSIZE 960 /* x resolution */
16
17 #define DYSIZE 1152 /* y resolution */
18
19 #define LINWIDT DXSIZE /* line width */
20
21 #define LINHITE 24 /* line height */
22
23 #define NLINES (DYSIZE/LINHITE) /* number of lines */
24
25 #define CHARWIDTH 12
26
27 #define PNORM "\024\022\033%H"
28
29 #define PINIT "\033O\033T\033I\002\033%H\033T\022\033A\014\0332"
30
31 #define PUNINIT ""
32
33 #define DBLON "\033%G"
34
35 #define GRPH "\033%O"
36
37 #define XCOM "pexpand +vOCIsp %s | psort -Y +x"
38
39
40
41
42 #include "meta.h"
43
44 #include "plot.h"
45
46 #include "span.h"
47
48
49
50
51 char *progname;
52
53 struct span outspan;
54
55 int dxsize = DXSIZE, dysize = DYSIZE,
56 linwidt = LINWIDT, linhite = LINHITE,
57 nrows = (LINHITE-1)/8+1;
58
59 int maxalloc = MAXALLOC;
60
61 int spanmin = 0, spanmax = LINWIDT-1;
62
63 int charwidth = CHARWIDTH;
64
65 static char chrtype[16][4] = {
66 "",
67 "\016",
68 "",
69 "\016",
70 "\033:",
71 "\033:\016",
72 "\033:",
73 "\033:\016",
74 "\017",
75 "\017\016",
76 "\017",
77 "\017\016",
78 "\017",
79 "",
80 "\017",
81 ""
82 };
83
84 static int lineno = 0;
85
86 static short condonly = FALSE,
87 conditioned = FALSE;
88
89
90 main(argc, argv)
91
92 int argc;
93 char **argv;
94
95 {
96 FILE *fp;
97 #ifdef UNIX
98 FILE *popen();
99 #endif
100 char comargs[200], command[300];
101
102 #ifdef CPM
103 fixargs("okimate", &argc, &argv);
104 #endif
105
106 progname = *argv++;
107 argc--;
108
109 condonly = FALSE;
110 #ifdef CPM
111 conditioned = TRUE;
112 #else
113 conditioned = FALSE;
114 #endif
115
116 minwidth = 1; /* so lines aren't invisible */
117
118 while (argc && **argv == '-') {
119 switch (*(*argv+1)) {
120 #ifdef UNIX
121 case 'c':
122 condonly = TRUE;
123 break;
124 case 'r':
125 conditioned = TRUE;
126 break;
127 #endif
128 default:
129 error(WARNING, "unknown option");
130 break;
131 }
132 argv++;
133 argc--;
134 }
135
136 if (conditioned) {
137 fputs(PINIT, stdout);
138 if (argc)
139 while (argc) {
140 fp = efopen(*argv, "r");
141 plot(fp);
142 fclose(fp);
143 argv++;
144 argc--;
145 }
146 else
147 plot(stdin);
148 if (lineno)
149 nextpage();
150 fputs(PUNINIT, stdout);
151 } else {
152 comargs[0] = '\0';
153 while (argc) {
154 strcat(comargs, " ");
155 strcat(comargs, *argv);
156 argv++;
157 argc--;
158 }
159 sprintf(command, XCOM, comargs);
160 #ifdef UNIX
161 if (condonly)
162 return(system(command));
163 else {
164 fputs(PINIT, stdout);
165 if ((fp = popen(command, "r")) == NULL)
166 error(SYSTEM, "cannot execute input filter");
167 plot(fp);
168 pclose(fp);
169 if (lineno)
170 nextpage();
171 fputs(PUNINIT, stdout);
172 }
173 #endif
174 }
175
176 return(0);
177 }
178
179
180
181
182
183
184
185 thispage() /* rewind and initialize current page */
186
187 {
188
189 if (lineno)
190 error(USER, "cannot restart page in thispage");
191
192 }
193
194
195
196
197 nextpage() /* advance to next page */
198
199 {
200
201 fputs("\r\f", stdout);
202
203 lineno = 0;
204
205 }
206
207
208
209
210 contpage() /* continue new plot on current page */
211
212 {
213
214 while (lineno++ < NLINES)
215 putc('\n', stdout);
216
217 lineno = 0;
218
219 }
220
221
222
223 printspan() /* output span to printer */
224
225 {
226 register int i,j;
227
228 if (spanmin <= spanmax) {
229 j = spanmin/charwidth;
230 while (j--)
231 putc(' ', stdout);
232
233 fputs(GRPH, stdout);
234 j = spanmin%charwidth;
235 putc((spanmax-spanmin+j+1)%256, stdout);
236 putc((spanmax-spanmin+j+1)/256, stdout);
237
238 j *= 3;
239 while (j--)
240 putc('\0', stdout);
241
242 for (i = spanmin; i <= spanmax; i++)
243 for (j = 2; j >= 0; j--)
244 putc(outspan.cols[j*dxsize + i], stdout);
245 }
246 fputs("\r\n", stdout);
247 lineno++;
248
249 }
250
251
252
253
254
255 printstr(p) /* output a string to the printer */
256
257 PRIMITIVE *p;
258
259 {
260 int i;
261
262 i = CONV(p->xy[XMN], dxsize)/charwidth;
263 while (i--)
264 putc(' ', stdout);
265
266 if (p->arg0 & 0100) /* double strike */
267 fputs(DBLON, stdout);
268
269 fputs(chrtype[(p->arg0 >> 2) & 017], stdout);
270 fputs(p->args, stdout);
271 fputs(PNORM, stdout);
272 putc('\r', stdout);
273
274 }