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 2.1 by greg, Tue Nov 12 16:04:44 1991 UTC vs.
Revision 2.16 by greg, Fri Jun 4 14:47:01 1993 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 12 | Line 12 | 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
20 +
21   #include  "color.h"
22  
23   #include  "resolu.h"
24  
25 < #define  MAXFILE        32
25 > #define  MAXFILE        64
26  
27                                          /* output picture size */
28   int  xsiz = 0;
# Line 33 | Line 39 | int  labelht = 24;                     /* label height */
39  
40   int  checkthresh = 0;                   /* check threshold value */
41  
42 + char  Command[] = "<Command>";
43 + char  Label[] = "<Label>";
44 +
45   char  *progname;
46  
47   struct {
# Line 50 | Line 59 | int  wrongformat = 0;
59  
60   FILE  *popen(), *lblopen();
61  
62 + extern char  *malloc();
63  
64 +
65   tabputs(s)                      /* print line preceded by a tab */
66   char  *s;
67   {
# Line 70 | Line 81 | main(argc, argv)
81   int  argc;
82   char  *argv[];
83   {
73        double  atof();
84          int  ncolumns = 0;
85          int  autolabel = 0;
86 <        int  curcol = 0, curx = 0, cury = 0;
86 >        int  curcol = 0, x0 = 0, curx = 0, cury = 0, spacing = 0;
87          char  *thislabel;
88          int  an;
89 <
89 > #ifdef MSDOS
90 >        extern int  _fmode;
91 >        _fmode = O_BINARY;
92 >        setmode(fileno(stdin), O_BINARY);
93 >        setmode(fileno(stdout), O_BINARY);
94 > #endif
95          progname = argv[0];
96  
97          for (an = 1; an < argc && argv[an][0] == '-'; an++)
98                  switch (argv[an][1]) {
99                  case 'x':
100 <                        xmax = xsiz = atoi(argv[++an]);
100 >                        xsiz = atoi(argv[++an]);
101                          break;
102                  case 'y':
103 <                        ymax = ysiz = atoi(argv[++an]);
103 >                        ysiz = atoi(argv[++an]);
104                          break;
105                  case 'b':
106                          setcolr(bgcolr, atof(argv[an+1]),
# Line 96 | Line 111 | char  *argv[];
111                  case 'a':
112                          ncolumns = atoi(argv[++an]);
113                          break;
114 +                case 's':
115 +                        spacing = atoi(argv[++an]);
116 +                        break;
117 +                case 'o':
118 +                        curx = x0 = atoi(argv[++an]);
119 +                        cury = atoi(argv[++an]);
120 +                        break;
121                  case 'l':
122                          switch (argv[an][2]) {
123                          case 'a':
# Line 120 | Line 142 | dofiles:
142          for (nfile = 0; an < argc; nfile++) {
143                  if (nfile >= MAXFILE)
144                          goto toomany;
145 <                if (autolabel)
124 <                        thislabel = argv[an];
125 <                else
126 <                        thislabel = NULL;
145 >                thislabel = NULL;
146                  input[nfile].hasmin = input[nfile].hasmax = 0;
147                  while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'))
148                          switch (argv[an][1]) {
# Line 147 | Line 166 | dofiles:
166                          case 'l':
167                                  if (strcmp(argv[an], "-l"))
168                                          goto userr;
169 <                                thislabel = argv[++an];
169 >                                thislabel = argv[an+1];
170 >                                an += 2;
171                                  break;
172                          case '\0':
173                                  if (argv[an][0] == '-')
# Line 159 | Line 179 | dofiles:
179   getfile:
180                  if (argc-an < (ncolumns ? 1 : 3))
181                          goto userr;
182 +                if (autolabel && thislabel == NULL)
183 +                        thislabel = argv[an];
184                  if (!strcmp(argv[an], "-")) {
185                          input[nfile].name = "<stdin>";
186                          input[nfile].fp = stdin;
187                  } else {
188 <                        input[nfile].name = argv[an];
189 <                        if ((input[nfile].fp = argv[an][0] == '!' ?
190 <                                        popen(argv[an]+1, "r") :
191 <                                        fopen(argv[an], "r")) == NULL) {
188 >                        if (argv[an][0] == '!') {
189 >                                input[nfile].name = Command;
190 >                                input[nfile].fp = popen(argv[an]+1, "r");
191 >                        } else {
192 >                                input[nfile].name = argv[an];
193 >                                input[nfile].fp = fopen(argv[an], "r");
194 >                        }
195 >                        if (input[nfile].fp == NULL) {
196                                  perror(argv[an]);
197                                  quit(1);
198                          }
# Line 189 | Line 215 | getfile:
215                  }
216                  if (ncolumns > 0) {
217                          if (curcol >= ncolumns) {
218 <                                cury = ymax;
219 <                                curx = 0;
218 >                                cury = ymax + spacing;
219 >                                curx = x0;
220                                  curcol = 0;
221                          }
222                          input[nfile].xloc = curx;
223                          input[nfile].yloc = cury;
224 <                        curx += input[nfile].xres;
224 >                        curx += input[nfile].xres + spacing;
225                          curcol++;
226                  } else {
227                          input[nfile].xloc = atoi(argv[an++]);
# Line 212 | Line 238 | getfile:
238                  if (thislabel != NULL) {
239                          if (++nfile >= MAXFILE)
240                                  goto toomany;
241 <                        input[nfile].name = "<Label>";
241 >                        input[nfile].name = Label;
242                          input[nfile].hasmin = input[nfile].hasmax = 0;
243 +                        input[nfile].xres = input[nfile-1].xres;
244 +                        input[nfile].yres = labelht;
245                          if ((input[nfile].fp = lblopen(thislabel,
246                                          &input[nfile].xres,
247                                          &input[nfile].yres)) == NULL)
# Line 225 | Line 253 | getfile:
253          }
254          if (xsiz <= 0)
255                  xsiz = xmax;
256 +        else if (xsiz > xmax)
257 +                xmax = xsiz;
258          if (ysiz <= 0)
259                  ysiz = ymax;
260 +        else if (ysiz > ymax)
261 +                ymax = ysiz;
262                                          /* add new header info. */
263          printargs(argc, argv, stdout);
264          fputformat(COLRFMT, stdout);
# Line 237 | Line 269 | getfile:
269          
270          quit(0);
271   userr:
272 <        fprintf(stderr, "Usage: %s [-x xr][-y yr][-b r g b][-a n][-la][-lh h] ",
272 >        fprintf(stderr,
273 >        "Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ",
274                          progname);
275          fprintf(stderr, "[-t min1][+t max1][-l lab] pic1 x1 y1 ..\n");
276          quit(1);
# Line 334 | Line 367 | int  *xp, *yp;
367          char  com[128];
368          FILE  *fp;
369  
370 <        sprintf(com, "psign -h %d '%.30s' | pfilt -1 -x /2 -y /2",
338 <                        2*labelht, s);
370 >        sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s);
371          if ((fp = popen(com, "r")) == NULL)
372                  return(NULL);
373          if (checkheader(fp, COLRFMT, NULL) < 0)
# Line 352 | Line 384 | err:
384   quit(code)              /* exit gracefully */
385   int  code;
386   {
387 +        register int  i;
388 +                                /* close input files */
389 +        for (i = 0; i < nfile; i++)
390 +                if (input[i].name == Command || input[i].name == Label)
391 +                        pclose(input[i].fp);
392 +                else
393 +                        fclose(input[i].fp);
394          exit(code);
395   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines