| 1 | 
greg | 
1.1 | 
#ifndef lint | 
| 2 | 
schorsch | 
1.3 | 
static const char       RCSid[] = "$Id: plot4.c,v 1.2 2003/08/01 14:14:24 schorsch Exp $"; | 
| 3 | 
greg | 
1.1 | 
#endif | 
| 4 | 
  | 
  | 
/* | 
| 5 | 
  | 
  | 
 *  plot4.c - program to put four metafile pages onto one. | 
| 6 | 
  | 
  | 
 * | 
| 7 | 
  | 
  | 
 *      Greg Ward | 
| 8 | 
  | 
  | 
 *      7/10/86 | 
| 9 | 
  | 
  | 
 */ | 
| 10 | 
  | 
  | 
 | 
| 11 | 
schorsch | 
1.3 | 
#include  "rtprocess.h" | 
| 12 | 
greg | 
1.1 | 
#include  "meta.h" | 
| 13 | 
  | 
  | 
 | 
| 14 | 
  | 
  | 
 | 
| 15 | 
  | 
  | 
#define  OUTFILT  "pexpand +OCIms"      /* output filter */ | 
| 16 | 
  | 
  | 
 | 
| 17 | 
  | 
  | 
#define  SEGNAME  "plot4seg"            /* segment name */ | 
| 18 | 
  | 
  | 
 | 
| 19 | 
  | 
  | 
 | 
| 20 | 
  | 
  | 
extern FILE  *pout;                     /* the output stream */ | 
| 21 | 
  | 
  | 
 | 
| 22 | 
  | 
  | 
char  *progname; | 
| 23 | 
  | 
  | 
 | 
| 24 | 
  | 
  | 
 | 
| 25 | 
  | 
  | 
main(argc, argv) | 
| 26 | 
  | 
  | 
int  argc; | 
| 27 | 
  | 
  | 
char  *argv[]; | 
| 28 | 
  | 
  | 
{ | 
| 29 | 
  | 
  | 
        FILE  *fp; | 
| 30 | 
  | 
  | 
        int  i; | 
| 31 | 
  | 
  | 
 | 
| 32 | 
  | 
  | 
        progname = argv[0]; | 
| 33 | 
  | 
  | 
 | 
| 34 | 
  | 
  | 
        pout = popen(OUTFILT, "w"); | 
| 35 | 
  | 
  | 
 | 
| 36 | 
  | 
  | 
        if (argc > 1) | 
| 37 | 
  | 
  | 
                for (i = 1; i < argc; i++) { | 
| 38 | 
  | 
  | 
                        fp = efopen(argv[i], "r"); | 
| 39 | 
  | 
  | 
                        plot4(fp); | 
| 40 | 
  | 
  | 
                        fclose(fp); | 
| 41 | 
  | 
  | 
                } | 
| 42 | 
  | 
  | 
        else | 
| 43 | 
  | 
  | 
                plot4(stdin); | 
| 44 | 
  | 
  | 
         | 
| 45 | 
  | 
  | 
        pglob(PEOF, 0200, NULL); | 
| 46 | 
  | 
  | 
 | 
| 47 | 
  | 
  | 
        return(pclose(pout)); | 
| 48 | 
  | 
  | 
} | 
| 49 | 
  | 
  | 
 | 
| 50 | 
  | 
  | 
 | 
| 51 | 
  | 
  | 
plot4(fp)                       /* put a file into its place on page */ | 
| 52 | 
  | 
  | 
FILE  *fp; | 
| 53 | 
  | 
  | 
{ | 
| 54 | 
  | 
  | 
        static int  nplts = 0; | 
| 55 | 
  | 
  | 
        PRIMITIVE  curp; | 
| 56 | 
  | 
  | 
 | 
| 57 | 
  | 
  | 
        pglob(POPEN, 0, SEGNAME); | 
| 58 | 
  | 
  | 
 | 
| 59 | 
  | 
  | 
        while (readp(&curp, fp)) | 
| 60 | 
  | 
  | 
                if (curp.com == PEOP) { | 
| 61 | 
  | 
  | 
                        pglob(PCLOSE, 0200, NULL); | 
| 62 | 
  | 
  | 
                        doseg(nplts++ % 4); | 
| 63 | 
  | 
  | 
                        pglob(POPEN, 0, SEGNAME); | 
| 64 | 
  | 
  | 
                } else | 
| 65 | 
  | 
  | 
                        writep(&curp, pout); | 
| 66 | 
  | 
  | 
         | 
| 67 | 
  | 
  | 
        pglob(PCLOSE, 0200, NULL); | 
| 68 | 
  | 
  | 
} | 
| 69 | 
  | 
  | 
 | 
| 70 | 
  | 
  | 
 | 
| 71 | 
  | 
  | 
doseg(n)                /* do segment number n */ | 
| 72 | 
  | 
  | 
int  n; | 
| 73 | 
  | 
  | 
{ | 
| 74 | 
  | 
  | 
        switch (n) { | 
| 75 | 
  | 
  | 
        case 0:                         /* upper left */ | 
| 76 | 
  | 
  | 
                pprim(PSEG, 0, 0, XYSIZE/2, XYSIZE/2-1, XYSIZE-1, SEGNAME); | 
| 77 | 
  | 
  | 
                break; | 
| 78 | 
  | 
  | 
        case 1:                         /* upper right */ | 
| 79 | 
  | 
  | 
                pprim(PSEG, 0, XYSIZE/2, XYSIZE/2, XYSIZE-1, XYSIZE-1, SEGNAME); | 
| 80 | 
  | 
  | 
                break; | 
| 81 | 
  | 
  | 
        case 2:                         /* lower left */ | 
| 82 | 
  | 
  | 
                pprim(PSEG, 0, 0, 0, XYSIZE/2-1, XYSIZE/2-1, SEGNAME); | 
| 83 | 
  | 
  | 
                break; | 
| 84 | 
  | 
  | 
        case 3:                         /* lower right, end page */ | 
| 85 | 
  | 
  | 
                pprim(PSEG, 0, XYSIZE/2, 0, XYSIZE-1, XYSIZE/2-1, SEGNAME); | 
| 86 | 
  | 
  | 
                pglob(PEOP, 0200, NULL); | 
| 87 | 
  | 
  | 
                break; | 
| 88 | 
  | 
  | 
        } | 
| 89 | 
  | 
  | 
} |