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.6 by greg, Thu Apr 18 14:35:19 1991 UTC vs.
Revision 1.8 by greg, Thu May 30 10:33:30 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1987 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# 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 +
24                                          /* output picture size */
25   int  xsiz = 0;
26   int  ysiz = 0;
# Line 33 | Line 37 | int  checkthresh = 0;                  /* check threshold value */
37   char  *progname;
38  
39   struct {
40 <        char  *name;                    /* file name */
40 >        char  *name;                    /* file or command name */
41          FILE  *fp;                      /* stream pointer */
42          int  xres, yres;                /* picture size */
43          int  xloc, yloc;                /* anchor point */
# Line 45 | Line 49 | int  nfile;                    /* number of files */
49  
50   int  wrongformat = 0;
51  
52 + char  tmpbuf[128];
53  
54 + FILE  *popen();
55 +
56 +
57   tabputs(s)                      /* print line preceded by a tab */
58   char  *s;
59   {
# Line 66 | Line 74 | int  argc;
74   char  *argv[];
75   {
76          double  atof();
77 +        int  ncolumns = 0;
78 +        int  dolabels = 0;
79 +        int  curcol = 0, curx = 0, cury = 0;
80          int  an;
81  
82          progname = argv[0];
# Line 84 | Line 95 | char  *argv[];
95                                          atof(argv[an+3]));
96                          an += 3;
97                          break;
98 +                case 'a':
99 +                        ncolumns = atoi(argv[++an]);
100 +                        break;
101 +                case 'l':
102 +                        dolabels++;
103 +                        break;
104                  case '\0':
105                  case 't':
106                          goto dofiles;
# Line 92 | Line 109 | char  *argv[];
109                  }
110   dofiles:
111          for (nfile = 0; an < argc; nfile++) {
112 <                if (nfile >= MAXFILE) {
113 <                        fprintf(stderr, "%s: too many files\n", progname);
114 <                        quit(1);
112 >                if (dolabels) {
113 >                        if (nfile >= MAXFILE-1) {
114 >                                fprintf(stderr,
115 >                                "%s: only %d files allowed with labels\n",
116 >                                        progname, MAXFILE/2);
117 >                                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                  }
126                  input[nfile].hasmin = input[nfile].hasmax = 0;
127                  while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+'))
# Line 124 | Line 151 | dofiles:
151                                  goto userr;
152                          }
153   getfile:
154 <                if (argc-an < 3)
154 >                if (argc-an < (ncolumns ? 1 : 3))
155                          goto userr;
156                  if (!strcmp(argv[an], "-")) {
157                          input[nfile].name = "<stdin>";
158                          input[nfile].fp = stdin;
159                  } else {
160                          input[nfile].name = argv[an];
161 <                        if ((input[nfile].fp = fopen(argv[an], "r")) == NULL) {
161 >                        if ((input[nfile].fp = argv[an][0] == '!' ?
162 >                                        popen(argv[an]+1, "r") :
163 >                                        fopen(argv[an], "r")) == NULL) {
164                                  perror(argv[an]);
165                                  quit(1);
166                          }
# Line 152 | Line 181 | getfile:
181                                          input[nfile].name);
182                          quit(1);
183                  }
184 <                input[nfile].xloc = atoi(argv[an++]);
185 <                input[nfile].yloc = atoi(argv[an++]);
184 >                if (ncolumns > 0) {
185 >                        if (curcol >= ncolumns) {
186 >                                cury = ymax;
187 >                                curx = 0;
188 >                                curcol = 0;
189 >                        }
190 >                        input[nfile].xloc = curx;
191 >                        input[nfile].yloc = cury;
192 >                        curx += input[nfile].xres;
193 >                        curcol++;
194 >                } else {
195 >                        input[nfile].xloc = atoi(argv[an++]);
196 >                        input[nfile].yloc = atoi(argv[an++]);
197 >                }
198                  if (input[nfile].xloc < xmin)
199                          xmin = input[nfile].xloc;
200                  if (input[nfile].yloc < ymin)
# Line 162 | Line 203 | getfile:
203                          xmax = input[nfile].xloc+input[nfile].xres;
204                  if (input[nfile].yloc+input[nfile].yres > ymax)
205                          ymax = input[nfile].yloc+input[nfile].yres;
206 +                if (dolabels) {
207 +                        input[++nfile].name = "<Label>";
208 +                        setpscom(tmpbuf, input[nfile-1].name);
209 +                        if ((input[nfile].fp = popen(tmpbuf, "r")) == NULL)
210 +                                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;
216 +                        input[nfile].xloc = input[nfile-1].xloc;
217 +                        input[nfile].yloc = input[nfile-1].yloc +
218 +                                        input[nfile-1].yres - SIGNHT;
219 +                        input[nfile].hasmin = input[nfile].hasmax = 0;
220 +                }
221          }
222          if (xsiz <= 0)
223                  xsiz = xmax;
# Line 176 | Line 232 | getfile:
232          
233          quit(0);
234   userr:
235 <        fprintf(stderr, "Usage: %s [-x xres][-y yres][-b r g b] ", progname);
236 <        fprintf(stderr, "[-t min1][+t max1] file1 x1 y1 ..\n");
235 >        fprintf(stderr, "Usage: %s [-x xr][-y yr][-b r g b][-a n][-l] ",
236 >                        progname);
237 >        fprintf(stderr, "[-t min1][+t max1] pic1 x1 y1 ..\n");
238 >        quit(1);
239 > labelerr:
240 >        fprintf(stderr, "%s: error opening label\n", progname);
241          quit(1);
242   }
243  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines