home *** CD-ROM | disk | FTP | other *** search
- #include "plplot.h"
- #include "declare.h"
- #include <stdio.h>
-
- /* Asks for number of plotting device, and call plbeg to divide the */
- /* page into nx by ny subpages */
-
- static int mk=0, sp=0;
- static int iffHeight ;
-
- void plstar(nx,ny)
- int nx, ny;
- {
- int dev,lev;
-
- glev(&lev);
- if (lev != 0) plend();
-
- printf("\nPlotting Options:");
- printf("\n < 1> Amiga");
- printf("\n < 2> LaserJet II file (landscape)");
- printf("\n < 3> LaserJet II file (portrait)");
- printf("\n < 4> imPRESS file (landscape)");
- printf("\n < 5> imPRESS file (portrait)");
- printf("\n < 6> Tektronix file (landscape)");
- printf("\n < 7> Tektronix file (portrait)");
- printf("\n < 8> PostScript file (landscape)");
- printf("\n < 9> PostScript file (portrait)");
- printf("\n <10> IFF file (unrotated)");
- printf("\n <11> Preferences printer (landscape)");
- printf("\n <12> Preferences printer (portrait)");
- printf("\n");
- printf("\nEnter device number: ");
- scanf("%d",&dev);
- while(getchar() != '\n') /* Read all of line including new line char */
- ;
- plbeg(dev,nx,ny);
- }
-
- /* Initializes the graphics device "dev" */
- void grbeg(dev)
- int dev;
- {
- int termin, phyxmi, phyxma, phyymi, phyyma;
- void grinit(), grclr(), grcol(), grgra();
-
- /* Set up device specific stuff */
-
- /* Use setpxl to set the device dots per mm in the x and y directions */
- /* dpmmx = dots/mm in x direction (float) */
- /* dpmmy = dots/mm in y direction (float) */
- /* setpxl(dpmmx,dpmmy); */
-
- /* PLPLOT assumes that the plot origin is in the lower left corner */
- /* with y increasing upward and x increasing to the right */
- /* Use setphy to specify how PLPLOT should translate plotting coords */
- /* to device coords */
- /* xmindev = minimum x device coordinate (int) */
- /* xmaxdev = maximum x device coordinate (int) */
- /* ymindev = minimum y device coordinate (int) */
- /* ymaxdev = maximum y device coordinate (int) */
- /* setphy(xmindev,xmaxdev,ymindev,ymaxdev); */
-
- switch (dev) {
- case 1:
- setpxl(2.52,2.25);
- setphy(0,639,0,399);
- termin = 1;
- break ;
- case 2:
- setpxl(5.905,5.905); /* 150 dpi mode */
- termin = 0;
- setphy(0,1409,0,1103);
- break ;
- case 3:
- setpxl(5.905,5.905); /* 150 dpi mode buggy because of bad `down' */
- termin = 0;
- setphy(0,1103,1409,0);
- break ;
- case 4:
- setpxl(11.81,11.81); /* 300 dpi */
- termin = 0;
- setphy(0,2999,0,2249);
- break ;
- case 5:
- setpxl(11.81,11.81); /* 300 dpi */
- termin = 0;
- setphy(2249,0,0,2999);
- break ;
- case 6:
- setpxl(4.771,4.653);
- termin = 0;
- setphy(0,1023,0,779);
- break ;
- case 7:
- setpxl(4.653,4.771);
- termin = 0;
- setphy(779,0,0,1023);
- break ;
- case 8:
- setpxl(11.81,11.81); /* 300 dpi */
- termin = 0;
- setphy(0,2999,0,2249);
- break ;
- case 9:
- setpxl(11.81,11.81); /* 300 dpi */
- termin = 0;
- setphy(2249,0,0,2999);
- break ;
- case 10:
- {
- int iffx, iffy, iffX, iffY ; /* declare resolution (dpi), size */
-
- iffquery(&iffx, &iffy, &iffX, &iffY) ;
- setpxl(iffx / 25.4, iffy / 25.4) ;
- termin = 0 ;
- /* setphy(0, iffX-1, iffY-1, 0) ; changed for good definition of `down' */
- setphy(0, iffX-1, 0, iffY-1) ;
- iffHeight = iffY ;
- }
- break ;
- case 11:
- {
- int iffx, iffy, iffX, iffY ; /* declare resolution (dpi), size */
-
- prefquery(&iffx, &iffy, &iffX, &iffY) ;
- setpxl(iffy / 25.4, iffx / 25.4) ;
- termin = 0 ;
- setphy(0, iffY-1, 0, iffX-1) ;
- }
- break ;
- case 12:
- {
- int iffx, iffy, iffX, iffY ; /* declare resolution (dpi), size */
-
- prefquery(&iffx, &iffy, &iffX, &iffY) ;
- setpxl(iffx / 25.4, iffy / 25.4) ;
- termin = 0 ;
- setphy(0, iffX-1, 0, iffY-1) ;
- iffHeight = iffY ;
- }
- break ;
- default:
- printf("\nUnknown output device\n");
- exit(1);
- }
-
- sdev(dev,termin,0);
- grinit();
-
- /* Set default sizes, fonts, and colors */
- plschr(4.0,1.0);
- plssym(4.0,1.0);
- plsmaj(3.0,1.0);
- plsmin(1.5,1.0);
- satt(1,1);
-
- /* Switch to graphics mode and clear screen */
- grgra();
- grclr();
- grcol();
- plstyl(0,&mk,&sp);
-
- gphy(&phyxmi,&phyxma,&phyymi,&phyyma);
- sclp(phyxmi,phyxma,phyymi,phyyma);
- }
-
- /* Clears the graphics screen */
- void grclr()
- {
- switch(device) {
- case 1:
- amiclr();
- break ;
- case 2:
- case 3:
- jetclr();
- break ;
- case 4:
- case 5:
- impclr();
- break ;
- case 6:
- case 7:
- tekclr();
- break ;
- case 8:
- case 9:
- psclr();
- break ;
- case 10:
- iffclr();
- break ;
- case 11:
- case 12:
- prefclr() ;
- break ;
- default:
- break ;
- }
- }
-
- /* Sets up the line colour to value in global variable "colour" */
- void grcol()
- {
- if (device == 1)
- amicol(colour);
- }
-
- /* Initializes the graphics device */
- void grinit()
- {
- switch(device) {
- case 1:
- amiini();
- break ;
- case 2:
- case 3:
- jetini();
- break ;
- case 4:
- case 5:
- impini();
- break ;
- case 6:
- case 7:
- tekini();
- break ;
- case 8:
- case 9:
- psini();
- break ;
- case 10:
- iffini() ;
- break ;
- case 11:
- case 12:
- prefini() ;
- break ;
- default:
- break ;
- }
- }
-
- /* Switches to graphics mode */
- void grgra()
- {
- switch(device) {
- case 1:
- amigra();
- break ;
- case 2:
- case 3:
- jetgra();
- break ;
- case 4:
- case 5:
- impgra();
- break ;
- case 6:
- case 7:
- tekgra();
- break ;
- case 8:
- case 9:
- tekgra();
- break ;
- case 10:
- case 11:
- case 12:
- iffgra() ;
- break ;
- default:
- break ;
- }
- graphx = 1;
- }
-
- /* Draws a line from (x1,x2) to (x2,y2), used by genlin() */
- /* Notice how x and y are swapped to switch from the default */
- /* orientation */
- void grline(x1,y1,x2,y2)
- int x1,y1,x2,y2;
- {
- switch(device) {
- case 1:
- amilin(x1,y1,x2,y2);
- break ;
- case 2:
- jetlin(y1,x1,y2,x2);
- break ;
- case 3:
- jetlin(x1,y1,x2,y2);
- break ;
- case 4:
- implin(x1,y1,x2,y2);
- break ;
- case 5:
- implin(y1,x1,y2,x2);
- break ;
- case 6:
- teklin(x1,y1,x2,y2);
- break ;
- case 7:
- teklin(y1,x1,y2,x2);
- break ;
- case 8:
- pslin(x1,y1,x2,y2);
- break ;
- case 9:
- pslin(y1,x1,y2,x2);
- break ;
- case 10:
- case 12:
- ifflin(x1,iffHeight-y1,x2,iffHeight-y2) ;
- break ;
- case 11:
- ifflin(y1,x1,y2,x2) ;
- break ;
- default:
- break ;
- }
- }
-
- /* Switches to text mode */
- void grtext()
- {
- switch(device) {
- case 1:
- amitex();
- break ;
- case 2:
- case 3:
- jettex();
- break ;
- case 4:
- case 5:
- imptex();
- break ;
- case 6:
- case 7:
- tektex();
- break ;
- case 8:
- case 9:
- pstex();
- break ;
- case 10:
- case 11:
- case 12:
- ifftex() ;
- break ;
- default:
- break ;
- }
- graphx = 0;
- }
-
- /* Called by plend to tidy up graphics device */
- void grtidy()
- {
- switch(device) {
- case 1:
- amitid();
- break ;
- case 2:
- case 3:
- jettid();
- break ;
- case 4:
- case 5:
- imptid();
- break ;
- case 6:
- case 7:
- tektid();
- break ;
- case 8:
- case 9:
- pstid();
- break ;
- case 10:
- ifftid() ;
- break ;
- case 11:
- case 12:
- preftid() ;
- break ;
- default:
- break ;
- }
- }
-