--- ray/src/px/pcompos.c 1991/04/18 14:35:19 1.6 +++ ray/src/px/pcompos.c 1992/06/16 16:48:41 2.5 @@ -1,4 +1,4 @@ -/* Copyright (c) 1987 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -14,6 +14,7 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" +#include "resolu.h" #define MAXFILE 32 @@ -28,12 +29,14 @@ int ymax = 0; COLR bgcolr = BLKCOLR; /* background color */ +int labelht = 24; /* label height */ + int checkthresh = 0; /* check threshold value */ char *progname; struct { - char *name; /* file name */ + char *name; /* file or command name */ FILE *fp; /* stream pointer */ int xres, yres; /* picture size */ int xloc, yloc; /* anchor point */ @@ -45,7 +48,9 @@ int nfile; /* number of files */ int wrongformat = 0; +FILE *popen(), *lblopen(); + tabputs(s) /* print line preceded by a tab */ char *s; { @@ -65,7 +70,10 @@ main(argc, argv) int argc; char *argv[]; { - double atof(); + int ncolumns = 0; + int autolabel = 0; + int curcol = 0, curx = 0, cury = 0; + char *thislabel; int an; progname = argv[0]; @@ -84,6 +92,23 @@ char *argv[]; atof(argv[an+3])); an += 3; break; + case 'a': + ncolumns = atoi(argv[++an]); + break; + case 'l': + switch (argv[an][2]) { + case 'a': + autolabel++; + break; + case 'h': + labelht = atoi(argv[++an]); + break; + case '\0': + goto dofiles; + default: + goto userr; + } + break; case '\0': case 't': goto dofiles; @@ -92,10 +117,12 @@ char *argv[]; } dofiles: for (nfile = 0; an < argc; nfile++) { - if (nfile >= MAXFILE) { - fprintf(stderr, "%s: too many files\n", progname); - quit(1); - } + if (nfile >= MAXFILE) + goto toomany; + if (autolabel) + thislabel = argv[an]; + else + thislabel = NULL; input[nfile].hasmin = input[nfile].hasmax = 0; while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+')) switch (argv[an][1]) { @@ -116,22 +143,34 @@ dofiles: } an += 2; break; + case 'l': + if (strcmp(argv[an], "-l")) + goto userr; + thislabel = argv[an+1]; + an += 2; + break; case '\0': if (argv[an][0] == '-') goto getfile; - /* fall through */ + goto userr; default: goto userr; } getfile: - if (argc-an < 3) + if (argc-an < (ncolumns ? 1 : 3)) goto userr; if (!strcmp(argv[an], "-")) { input[nfile].name = ""; input[nfile].fp = stdin; } else { - input[nfile].name = argv[an]; - if ((input[nfile].fp = fopen(argv[an], "r")) == NULL) { + if (argv[an][0] == '!') { + input[nfile].name = ""; + input[nfile].fp = popen(argv[an]+1, "r"); + } else { + input[nfile].name = argv[an]; + input[nfile].fp = fopen(argv[an], "r"); + } + if (input[nfile].fp == NULL) { perror(argv[an]); quit(1); } @@ -147,13 +186,25 @@ getfile: } /* get picture size */ if (fgetresolu(&input[nfile].xres, &input[nfile].yres, - input[nfile].fp) != (YMAJOR|YDECR)) { + input[nfile].fp) < 0) { fprintf(stderr, "%s: bad picture size\n", input[nfile].name); quit(1); } - input[nfile].xloc = atoi(argv[an++]); - input[nfile].yloc = atoi(argv[an++]); + if (ncolumns > 0) { + if (curcol >= ncolumns) { + cury = ymax; + curx = 0; + curcol = 0; + } + input[nfile].xloc = curx; + input[nfile].yloc = cury; + curx += input[nfile].xres; + curcol++; + } else { + input[nfile].xloc = atoi(argv[an++]); + input[nfile].yloc = atoi(argv[an++]); + } if (input[nfile].xloc < xmin) xmin = input[nfile].xloc; if (input[nfile].yloc < ymin) @@ -162,6 +213,19 @@ getfile: xmax = input[nfile].xloc+input[nfile].xres; if (input[nfile].yloc+input[nfile].yres > ymax) ymax = input[nfile].yloc+input[nfile].yres; + if (thislabel != NULL) { + if (++nfile >= MAXFILE) + goto toomany; + input[nfile].name = "