1 |
< |
/* Copyright (c) 1992 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1993 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
12 |
|
|
13 |
|
#include <stdio.h> |
14 |
|
|
15 |
+ |
#include <math.h> |
16 |
+ |
|
17 |
|
#ifdef MSDOS |
18 |
|
#include <fcntl.h> |
19 |
|
#endif |
24 |
|
|
25 |
|
#define MAXFILE 64 |
26 |
|
|
27 |
+ |
#define HASMIN 1 |
28 |
+ |
#define HASMAX 2 |
29 |
+ |
|
30 |
|
/* output picture size */ |
31 |
|
int xsiz = 0; |
32 |
|
int ysiz = 0; |
52 |
|
FILE *fp; /* stream pointer */ |
53 |
|
int xres, yres; /* picture size */ |
54 |
|
int xloc, yloc; /* anchor point */ |
55 |
< |
int hasmin, hasmax; /* has threshold values */ |
55 |
> |
int flags; /* HASMIN, HASMAX */ |
56 |
|
COLR thmin, thmax; /* thresholds */ |
57 |
|
} input[MAXFILE]; /* our input files */ |
58 |
|
|
70 |
|
{ |
71 |
|
char fmt[32]; |
72 |
|
|
73 |
< |
if (isformat(s)) { |
74 |
< |
formatval(fmt, s); |
73 |
> |
if (isheadid(s)) |
74 |
> |
return; |
75 |
> |
if (formatval(fmt, s)) |
76 |
|
wrongformat = strcmp(fmt, COLRFMT); |
77 |
< |
} else { |
77 |
> |
else { |
78 |
|
putc('\t', stdout); |
79 |
|
fputs(s, stdout); |
80 |
|
} |
88 |
|
int ncolumns = 0; |
89 |
|
int autolabel = 0; |
90 |
|
int curcol = 0, x0 = 0, curx = 0, cury = 0, spacing = 0; |
91 |
+ |
int xsgn, ysgn; |
92 |
|
char *thislabel; |
93 |
|
int an; |
94 |
|
#ifdef MSDOS |
144 |
|
goto userr; |
145 |
|
} |
146 |
|
dofiles: |
147 |
+ |
newheader("RADIANCE", stdout); |
148 |
|
for (nfile = 0; an < argc; nfile++) { |
149 |
|
if (nfile >= MAXFILE) |
150 |
|
goto toomany; |
151 |
|
thislabel = NULL; |
152 |
< |
input[nfile].hasmin = input[nfile].hasmax = 0; |
153 |
< |
while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+')) |
152 |
> |
input[nfile].flags = 0; |
153 |
> |
xsgn = ysgn = '-'; |
154 |
> |
while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+' |
155 |
> |
|| argv[an][0] == '=')) { |
156 |
|
switch (argv[an][1]) { |
157 |
|
case 't': |
158 |
|
checkthresh = 1; |
159 |
|
if (argv[an][0] == '-') { |
160 |
< |
input[nfile].hasmin = 1; |
160 |
> |
input[nfile].flags |= HASMIN; |
161 |
|
setcolr(input[nfile].thmin, |
162 |
|
atof(argv[an+1]), |
163 |
|
atof(argv[an+1]), |
164 |
|
atof(argv[an+1])); |
165 |
< |
} else { |
166 |
< |
input[nfile].hasmax = 1; |
165 |
> |
} else if (argv[an][0] == '+') { |
166 |
> |
input[nfile].flags |= HASMAX; |
167 |
|
setcolr(input[nfile].thmax, |
168 |
|
atof(argv[an+1]), |
169 |
|
atof(argv[an+1]), |
170 |
|
atof(argv[an+1])); |
171 |
< |
} |
172 |
< |
an += 2; |
171 |
> |
} else |
172 |
> |
goto userr; |
173 |
> |
an++; |
174 |
|
break; |
175 |
|
case 'l': |
176 |
|
if (strcmp(argv[an], "-l")) |
177 |
|
goto userr; |
178 |
< |
thislabel = argv[an+1]; |
168 |
< |
an += 2; |
178 |
> |
thislabel = argv[++an]; |
179 |
|
break; |
180 |
+ |
case '+': |
181 |
+ |
case '-': |
182 |
+ |
case '0': |
183 |
+ |
if (argv[an][0] != '=') |
184 |
+ |
goto userr; |
185 |
+ |
xsgn = argv[an][1]; |
186 |
+ |
ysgn = argv[an][2]; |
187 |
+ |
if (ysgn != '+' && ysgn != '-' && ysgn != '0') |
188 |
+ |
goto userr; |
189 |
+ |
break; |
190 |
|
case '\0': |
191 |
|
if (argv[an][0] == '-') |
192 |
|
goto getfile; |
194 |
|
default: |
195 |
|
goto userr; |
196 |
|
} |
197 |
+ |
an++; |
198 |
+ |
} |
199 |
|
getfile: |
200 |
|
if (argc-an < (ncolumns ? 1 : 3)) |
201 |
|
goto userr; |
245 |
|
curcol++; |
246 |
|
} else { |
247 |
|
input[nfile].xloc = atoi(argv[an++]); |
248 |
+ |
if (xsgn == '+') |
249 |
+ |
input[nfile].xloc -= input[nfile].xres; |
250 |
+ |
else if (xsgn == '0') |
251 |
+ |
input[nfile].xloc -= input[nfile].xres/2; |
252 |
|
input[nfile].yloc = atoi(argv[an++]); |
253 |
+ |
if (ysgn == '+') |
254 |
+ |
input[nfile].yloc -= input[nfile].yres; |
255 |
+ |
else if (ysgn == '0') |
256 |
+ |
input[nfile].yloc -= input[nfile].yres/2; |
257 |
|
} |
258 |
|
if (input[nfile].xloc < xmin) |
259 |
|
xmin = input[nfile].xloc; |
267 |
|
if (++nfile >= MAXFILE) |
268 |
|
goto toomany; |
269 |
|
input[nfile].name = Label; |
270 |
< |
input[nfile].hasmin = input[nfile].hasmax = 0; |
270 |
> |
input[nfile].flags = 0; |
271 |
|
input[nfile].xres = input[nfile-1].xres; |
272 |
|
input[nfile].yres = labelht; |
273 |
|
if ((input[nfile].fp = lblopen(thislabel, |
300 |
|
fprintf(stderr, |
301 |
|
"Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ", |
302 |
|
progname); |
303 |
< |
fprintf(stderr, "[-t min1][+t max1][-l lab] pic1 x1 y1 ..\n"); |
303 |
> |
fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n"); |
304 |
|
quit(1); |
305 |
|
toomany: |
306 |
|
fprintf(stderr, "%s: only %d files and labels allowed\n", |
349 |
|
if (x > xsiz) |
350 |
|
x = xsiz; |
351 |
|
for (x--; x >= 0 && x >= input[i].xloc; x--) { |
352 |
< |
if (input[i].hasmin && |
352 |
> |
if (input[i].flags & HASMIN && |
353 |
|
cmpcolr(scanin[x], input[i].thmin) <= 0) |
354 |
|
continue; |
355 |
< |
if (input[i].hasmax && |
355 |
> |
if (input[i].flags & HASMAX && |
356 |
|
cmpcolr(scanin[x], input[i].thmax) >= 0) |
357 |
|
continue; |
358 |
|
copycolr(scanout[x], scanin[x]); |