Back to index

radiance  4R0+20100331
plot4.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: plot4.c,v 1.4 2003/11/15 02:13:37 schorsch Exp $";
00003 #endif
00004 /*
00005  *  plot4.c - program to put four metafile pages onto one.
00006  *
00007  *     Greg Ward
00008  *     7/10/86
00009  */
00010 
00011 #include  "rtprocess.h"
00012 #include  "meta.h"
00013 #include  "plot.h"
00014 
00015 
00016 #define  OUTFILT  "pexpand +OCIms" /* output filter */
00017 
00018 #define  SEGNAME  "plot4seg"              /* segment name */
00019 
00020 
00021 extern FILE  *pout;                /* the output stream */
00022 
00023 char  *progname;
00024 
00025 static void plot4(FILE  *fp);
00026 static void doseg(int  n);
00027 
00028 
00029 int
00030 main(
00031        int  argc,
00032        char  *argv[]
00033 )
00034 {
00035        FILE  *fp;
00036        int  i;
00037 
00038        progname = argv[0];
00039 
00040        pout = popen(OUTFILT, "w");
00041 
00042        if (argc > 1)
00043               for (i = 1; i < argc; i++) {
00044                      fp = efopen(argv[i], "r");
00045                      plot4(fp);
00046                      fclose(fp);
00047               }
00048        else
00049               plot4(stdin);
00050        
00051        pglob(PEOF, 0200, NULL);
00052 
00053        return(pclose(pout));
00054 }
00055 
00056 
00057 void
00058 plot4(               /* put a file into its place on page */
00059        FILE  *fp
00060 )
00061 {
00062        static int  nplts = 0;
00063        PRIMITIVE  curp;
00064 
00065        pglob(POPEN, 0, SEGNAME);
00066 
00067        while (readp(&curp, fp))
00068               if (curp.com == PEOP) {
00069                      pglob(PCLOSE, 0200, NULL);
00070                      doseg(nplts++ % 4);
00071                      pglob(POPEN, 0, SEGNAME);
00072               } else
00073                      writep(&curp, pout);
00074        
00075        pglob(PCLOSE, 0200, NULL);
00076 }
00077 
00078 
00079 void
00080 doseg(        /* do segment number n */
00081        int  n
00082 )
00083 {
00084        switch (n) {
00085        case 0:                            /* upper left */
00086               pprim(PSEG, 0, 0, XYSIZE/2, XYSIZE/2-1, XYSIZE-1, SEGNAME);
00087               break;
00088        case 1:                            /* upper right */
00089               pprim(PSEG, 0, XYSIZE/2, XYSIZE/2, XYSIZE-1, XYSIZE-1, SEGNAME);
00090               break;
00091        case 2:                            /* lower left */
00092               pprim(PSEG, 0, 0, 0, XYSIZE/2-1, XYSIZE/2-1, SEGNAME);
00093               break;
00094        case 3:                            /* lower right, end page */
00095               pprim(PSEG, 0, XYSIZE/2, 0, XYSIZE-1, XYSIZE/2-1, SEGNAME);
00096               pglob(PEOP, 0200, NULL);
00097               break;
00098        }
00099 }