ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/mt160.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 mt160 mt160.c mplot.o plot.o mfio.o syscalls.o palloc.o misc.o
8 *
9 * Mannesman Tally MT160 high-speed
10 */
11
12
13 #define MAXALLOC 5000
14
15 #define DXSIZE 532 /* x resolution */
16
17 #define DYSIZE 512 /* y resolution */
18
19 #define LINWIDT DXSIZE /* line width */
20
21 #define LINHITE 8 /* line height */
22
23 #define NLINES (DYSIZE/LINHITE) /* number of lines to plot */
24
25 #define CHARWIDTH 4
26
27 #define PNORM "\033[0y\033[6w"
28
29 #define PINIT "\033[6~\033[7z\033[0y\033[6w"
30
31 #define PUNINIT "\033[6~"
32
33 #define DBLON "\033[=z"
34
35 #define DBLOFF "\033[>z"
36
37 #define OUTPUT "\033%5"
38
39 #define XCOM "pexpand +vOCIsp %s | psort -Y +x"
40
41
42
43
44 #include "meta.h"
45
46 #include "plot.h"
47
48 #include "span.h"
49
50
51
52
53 char *progname;
54
55 struct span outspan;
56
57 int dxsize = DXSIZE, dysize = DYSIZE,
58 linwidt = LINWIDT, linhite = LINHITE,
59 nrows = (LINHITE-1)/8+1;
60
61 int maxalloc = MAXALLOC;
62
63 int spanmin = 0, spanmax = LINWIDT-1;
64
65 int charwidth = CHARWIDTH;
66
67 static char chrtype[16][5] = {
68 "\033[4w",
69 "\033[0w",
70 "\033[4w",
71 "\033[0w",
72 "\033[5w",
73 "\033[1w",
74 "\033[5w",
75 "\033[1w",
76 "\033[6w",
77 "\033[2w",
78 "\033[6w",
79 "\033[2w",
80 "\033[7w",
81 "\033[3w",
82 "\033[7w",
83 "\033[3w"
84 };
85
86 static int lineno = 0;
87
88 static short condonly = FALSE,
89 conditioned = FALSE;
90
91
92 main(argc, argv)
93
94 int argc;
95 char **argv;
96
97 {
98 FILE *fp;
99 #ifdef UNIX
100 FILE *popen();
101 #endif
102 char comargs[200], command[300];
103
104 #ifdef CPM
105 fixargs("mt160", &argc, &argv);
106 #endif
107
108 progname = *argv++;
109 argc--;
110
111 condonly = FALSE;
112 #ifdef CPM
113 conditioned = TRUE;
114 #else
115 conditioned = FALSE;
116 #endif
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 thispage() /* rewind and initialize current page */
185
186 {
187
188 if (lineno)
189 error(USER, "cannot restart page in thispage");
190
191 }
192
193
194
195
196 nextpage() /* advance to next page */
197
198 {
199
200 fputs("\f\r", stdout);
201
202 lineno = 0;
203
204 }
205
206
207
208 contpage() /* continue new plot on current page */
209
210 {
211
212 while (lineno++ < NLINES)
213 putc('\n', stdout);
214
215 lineno = 0;
216
217 }
218
219
220
221 printspan() /* output span to printer */
222
223 {
224 register i;
225
226 if (spanmin <= spanmax) {
227
228 i = spanmin/charwidth;
229 while (i--)
230 putc(' ', stdout);
231
232 i = spanmin%charwidth;
233 fputs(OUTPUT, stdout);
234 putc((spanmax-spanmin+i+1)%256, stdout);
235 putc((spanmax-spanmin+i+1)/256, stdout);
236 while (i--)
237 putc('\0', stdout);
238
239 for (i = spanmin; i <= spanmax; i++)
240 putc(outspan.cols[i], stdout);
241
242 putc('\r', stdout);
243 }
244
245 putc('\n', stdout);
246 lineno++;
247
248 }
249
250
251
252
253
254
255
256 printstr(p) /* output a string to the printer */
257
258 PRIMITIVE *p;
259
260 {
261 int i;
262
263 i = CONV(p->xy[XMN], dxsize)/charwidth;
264 while (i--)
265 putc(' ', stdout);
266
267 if (p->arg0 & 0100) /* double strike */
268 fputs(DBLON, stdout);
269 else
270 fputs(DBLOFF, stdout);
271
272 fputs(chrtype[(p->arg0 >> 2) & 017], stdout);
273 fputs(p->args, stdout);
274 fputs(PNORM, stdout);
275 putc('\r', stdout);
276
277 }