ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pcompos.c
(Generate patch)

Comparing ray/src/px/pcompos.c (file contents):
Revision 1.7 by greg, Thu May 30 09:44:36 1991 UTC vs.
Revision 1.10 by greg, Mon Nov 11 14:01:42 1991 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ LBL";
14  
15   #include  "color.h"
16  
17 + #include  "resolu.h"
18  
19   #define  MAXFILE        32
20  
20 #define  SIGNHT         24
21 #define  setpscom(b,n)  sprintf(b, "psign -h %d '%.30s'|pfilt -1 -x /2 -y /2",\
22                                2*SIGNHT, n)
23
21                                          /* output picture size */
22   int  xsiz = 0;
23   int  ysiz = 0;
# Line 32 | Line 29 | int  ymax = 0;
29  
30   COLR  bgcolr = BLKCOLR;                 /* background color */
31  
32 + int  labelht = 24;                      /* label height */
33 +
34   int  checkthresh = 0;                   /* check threshold value */
35  
36   char  *progname;
# Line 49 | Line 48 | int  nfile;                    /* number of files */
48  
49   int  wrongformat = 0;
50  
51 < char  tmpbuf[128];
51 > FILE  *popen(), *lblopen();
52  
54 FILE  *popen();
53  
56
54   tabputs(s)                      /* print line preceded by a tab */
55   char  *s;
56   {
# Line 75 | Line 72 | char  *argv[];
72   {
73          double  atof();
74          int  ncolumns = 0;
75 <        int  dolabels = 0;
75 >        int  autolabel = 0;
76          int  curcol = 0, curx = 0, cury = 0;
77 +        char  *thislabel;
78          int  an;
79  
80          progname = argv[0];
# Line 99 | Line 97 | char  *argv[];
97                          ncolumns = atoi(argv[++an]);
98                          break;
99                  case 'l':
100 <                        dolabels++;
100 >                        switch (argv[an][2]) {
101 >                        case 'a':
102 >                                autolabel++;
103 >                                break;
104 >                        case 'h':
105 >                                labelht = atoi(argv[++an]);
106 >                                break;
107 >                        case '\0':
108 >                                goto dofiles;
109 >                        default:
110 >                                goto userr;
111 >                        }
112                          break;
113                  case '\0':
114                  case 't':
# Line 109 | Line 118 | char  *argv[];
118                  }
119   dofiles:
120          for (nfile = 0; an < argc; nfile++) {
121 <                if (dolabels) {
122 <                        if (nfile >= MAXFILE-1) {
123 <                                fprintf(stderr,
124 <                                "%s: only %d files allowed with labels\n",
125 <                                        progname, MAXFILE/2);
126 <                        }
118 <                } else {
119 <                        if (nfile >= MAXFILE) {
120 <                                fprintf(stderr, "%s: only %d files allowed\n",
121 <                                                progname, MAXFILE);
122 <                                quit(1);
123 <                        }
124 <                }
125 <                if (nfile >= (dolabels ? MAXFILE-1 : MAXFILE)) {
126 <                        fprintf(stderr, "%s: too many files\n", progname);
127 <                        quit(1);
128 <                }
121 >                if (nfile >= MAXFILE)
122 >                        goto toomany;
123 >                if (autolabel)
124 >                        thislabel = argv[an];
125 >                else
126 >                        thislabel = NULL;
127                  input[nfile].hasmin = input[nfile].hasmax = 0;
128                  while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'))
129                          switch (argv[an][1]) {
# Line 146 | Line 144 | dofiles:
144                                  }
145                                  an += 2;
146                                  break;
147 +                        case 'l':
148 +                                if (strcmp(argv[an], "-l"))
149 +                                        goto userr;
150 +                                thislabel = argv[++an];
151 +                                break;
152                          case '\0':
153                                  if (argv[an][0] == '-')
154                                          goto getfile;
155 <                        /* fall through */
155 >                                goto userr;
156                          default:
157                                  goto userr;
158                          }
# Line 179 | Line 182 | getfile:
182                  }
183                                                  /* get picture size */
184                  if (fgetresolu(&input[nfile].xres, &input[nfile].yres,
185 <                                input[nfile].fp) != (YMAJOR|YDECR)) {
185 >                                input[nfile].fp) < 0) {
186                          fprintf(stderr, "%s: bad picture size\n",
187                                          input[nfile].name);
188                          quit(1);
# Line 206 | Line 209 | getfile:
209                          xmax = input[nfile].xloc+input[nfile].xres;
210                  if (input[nfile].yloc+input[nfile].yres > ymax)
211                          ymax = input[nfile].yloc+input[nfile].yres;
212 <                if (dolabels) {
213 <                        input[++nfile].name = "<Label>";
214 <                        setpscom(tmpbuf, input[nfile-1].name);
215 <                        if ((input[nfile].fp = popen(tmpbuf, "r")) == NULL)
212 >                if (thislabel != NULL) {
213 >                        if (++nfile >= MAXFILE)
214 >                                goto toomany;
215 >                        input[nfile].name = "<Label>";
216 >                        input[nfile].hasmin = input[nfile].hasmax = 0;
217 >                        if ((input[nfile].fp = lblopen(thislabel,
218 >                                        &input[nfile].xres,
219 >                                        &input[nfile].yres)) == NULL)
220                                  goto labelerr;
214                        if (checkheader(input[nfile].fp, COLRFMT, NULL) < 0)
215                                goto labelerr;
216                        if (fgetresolu(&input[nfile].xres, &input[nfile].yres,
217                                        input[nfile].fp) != (YMAJOR|YDECR))
218                                goto labelerr;
221                          input[nfile].xloc = input[nfile-1].xloc;
222                          input[nfile].yloc = input[nfile-1].yloc +
223 <                                        input[nfile-1].yres - SIGNHT;
222 <                        input[nfile].hasmin = input[nfile].hasmax = 0;
223 >                                        input[nfile-1].yres-input[nfile].yres;
224                  }
225          }
226          if (xsiz <= 0)
# Line 229 | Line 230 | getfile:
230                                          /* add new header info. */
231          printargs(argc, argv, stdout);
232          fputformat(COLRFMT, stdout);
233 <        printf("\n-Y %d +X %d\n", ysiz, xsiz);
233 >        putchar('\n');
234 >        fprtresolu(xsiz, ysiz, stdout);
235  
236          compos();
237          
238          quit(0);
239   userr:
240 <        fprintf(stderr, "Usage: %s [-x xres][-y yres][-b r g b] ", progname);
241 <        fprintf(stderr, "[-t min1][+t max1] file1 x1 y1 ..\n");
240 >        fprintf(stderr, "Usage: %s [-x xr][-y yr][-b r g b][-a n][-la][-lh h] ",
241 >                        progname);
242 >        fprintf(stderr, "[-t min1][+t max1][-l lab] pic1 x1 y1 ..\n");
243          quit(1);
244 + toomany:
245 +        fprintf(stderr, "%s: only %d files and labels allowed\n",
246 +                        progname, MAXFILE);
247 +        quit(1);
248   labelerr:
249          fprintf(stderr, "%s: error opening label\n", progname);
250          quit(1);
# Line 316 | Line 323 | register COLR  c1, c2;
323                  if (i = c1[j] - c2[j])
324                          return(i);
325          return(0);
326 + }
327 +
328 +
329 + FILE *
330 + lblopen(s, xp, yp)              /* open pipe to label generator */
331 + char  *s;
332 + int  *xp, *yp;
333 + {
334 +        char  com[128];
335 +        FILE  *fp;
336 +
337 +        sprintf(com, "psign -h %d '%.30s' | pfilt -1 -x /2 -y /2",
338 +                        2*labelht, s);
339 +        if ((fp = popen(com, "r")) == NULL)
340 +                return(NULL);
341 +        if (checkheader(fp, COLRFMT, NULL) < 0)
342 +                goto err;
343 +        if (fgetresolu(xp, yp, fp) < 0)
344 +                goto err;
345 +        return(fp);
346 + err:
347 +        pclose(fp);
348 +        return(NULL);
349   }
350  
351  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines