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.8 by greg, Thu May 30 10:33:30 1991 UTC vs.
Revision 1.9 by greg, Fri May 31 10:21:31 1991 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines