home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d3xx / d306 / rexxplplot.lha / RexxPlPlot / src / src.zoo / plstar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-06  |  7.4 KB  |  393 lines

  1. #include "plplot.h"
  2. #include "declare.h"
  3. #include <stdio.h>
  4.  
  5. /* Asks for number of plotting device, and call plbeg to divide the */
  6. /* page into nx by ny subpages */
  7.  
  8. static int mk=0, sp=0;
  9. static int iffHeight ;
  10.  
  11. void plstar(nx,ny)
  12. int nx, ny;
  13. {
  14.    int dev,lev;
  15.  
  16.    glev(&lev);
  17.    if (lev != 0) plend();
  18.       
  19.    printf("\nPlotting Options:");
  20.    printf("\n < 1> Amiga");
  21.    printf("\n < 2> LaserJet II file    (landscape)");
  22.    printf("\n < 3> LaserJet II file    (portrait)");
  23.    printf("\n < 4> imPRESS     file    (landscape)");
  24.    printf("\n < 5> imPRESS     file    (portrait)");
  25.    printf("\n < 6> Tektronix   file    (landscape)");
  26.    printf("\n < 7> Tektronix   file    (portrait)");
  27.    printf("\n < 8> PostScript  file    (landscape)");
  28.    printf("\n < 9> PostScript  file    (portrait)");
  29.    printf("\n <10> IFF         file    (unrotated)");
  30.    printf("\n <11> Preferences printer (landscape)");
  31.    printf("\n <12> Preferences printer (portrait)");
  32.    printf("\n");
  33.    printf("\nEnter device number: ");
  34.    scanf("%d",&dev);
  35.    while(getchar() != '\n') /* Read all of line including new line char */
  36.        ;
  37.    plbeg(dev,nx,ny);
  38. }
  39.  
  40. /* Initializes the graphics device "dev"  */
  41. void grbeg(dev)
  42. int dev;
  43. {
  44.    int termin, phyxmi, phyxma, phyymi, phyyma;
  45.    void grinit(), grclr(), grcol(), grgra();
  46.  
  47.    /* Set up device specific stuff */
  48.  
  49.    /* Use setpxl to set the device dots per mm in the x and y directions */
  50.    /* dpmmx = dots/mm in x direction (float) */
  51.    /* dpmmy = dots/mm in y direction (float) */
  52.    /* setpxl(dpmmx,dpmmy); */
  53.  
  54.    /* PLPLOT assumes that the plot origin is in the lower left corner */
  55.    /* with y increasing upward and x increasing to the right */
  56.    /* Use setphy to specify how PLPLOT should translate plotting coords */
  57.    /* to device coords */
  58.    /* xmindev = minimum x device coordinate (int) */
  59.    /* xmaxdev = maximum x device coordinate (int) */
  60.    /* ymindev = minimum y device coordinate (int) */
  61.    /* ymaxdev = maximum y device coordinate (int) */
  62.    /* setphy(xmindev,xmaxdev,ymindev,ymaxdev); */
  63.  
  64.    switch (dev) {
  65. case 1:
  66.      setpxl(2.52,2.25);
  67.      setphy(0,639,0,399);
  68.      termin = 1;
  69.      break ;
  70. case 2:
  71.      setpxl(5.905,5.905);  /* 150 dpi mode */
  72.      termin = 0;
  73.      setphy(0,1409,0,1103);
  74.      break ;
  75. case 3:
  76.      setpxl(5.905,5.905);  /* 150 dpi mode  buggy because of bad `down' */
  77.      termin = 0;
  78.      setphy(0,1103,1409,0);
  79.      break ;
  80. case 4:
  81.      setpxl(11.81,11.81);  /* 300 dpi */
  82.      termin = 0;
  83.      setphy(0,2999,0,2249);
  84.      break ;
  85. case 5:
  86.      setpxl(11.81,11.81);  /* 300 dpi */
  87.      termin = 0;
  88.      setphy(2249,0,0,2999);
  89.      break ;
  90. case 6:
  91.      setpxl(4.771,4.653);
  92.      termin = 0;
  93.      setphy(0,1023,0,779);
  94.      break ;
  95. case 7:
  96.      setpxl(4.653,4.771);
  97.      termin = 0;
  98.      setphy(779,0,0,1023);
  99.      break ;
  100. case 8:
  101.      setpxl(11.81,11.81);  /* 300 dpi */
  102.      termin = 0;
  103.      setphy(0,2999,0,2249);
  104.      break ;
  105. case 9:
  106.      setpxl(11.81,11.81);  /* 300 dpi */
  107.      termin = 0;
  108.      setphy(2249,0,0,2999);
  109.      break ;
  110. case 10:
  111.      {
  112.         int iffx, iffy, iffX, iffY ;  /* declare resolution (dpi), size */
  113.  
  114.         iffquery(&iffx, &iffy, &iffX, &iffY) ;
  115.         setpxl(iffx / 25.4, iffy / 25.4) ;
  116.         termin = 0 ;
  117. /*      setphy(0, iffX-1, iffY-1, 0) ; changed for good definition of `down' */
  118.         setphy(0, iffX-1, 0, iffY-1) ;
  119.         iffHeight = iffY ;
  120.      }
  121.      break ;
  122. case 11:
  123.      {
  124.         int iffx, iffy, iffX, iffY ;  /* declare resolution (dpi), size */
  125.  
  126.         prefquery(&iffx, &iffy, &iffX, &iffY) ;
  127.         setpxl(iffy / 25.4, iffx / 25.4) ;
  128.         termin = 0 ;
  129.         setphy(0, iffY-1, 0, iffX-1) ;
  130.      }
  131.      break ;
  132. case 12:
  133.      {
  134.         int iffx, iffy, iffX, iffY ;  /* declare resolution (dpi), size */
  135.  
  136.         prefquery(&iffx, &iffy, &iffX, &iffY) ;
  137.         setpxl(iffx / 25.4, iffy / 25.4) ;
  138.         termin = 0 ;
  139.         setphy(0, iffX-1, 0, iffY-1) ;
  140.         iffHeight = iffY ;
  141.      }
  142.      break ;
  143. default:
  144.      printf("\nUnknown output device\n");
  145.      exit(1);
  146.    }
  147.  
  148.    sdev(dev,termin,0);
  149.    grinit();
  150.  
  151.    /* Set default sizes, fonts, and colors */
  152.    plschr(4.0,1.0);
  153.    plssym(4.0,1.0);
  154.    plsmaj(3.0,1.0);
  155.    plsmin(1.5,1.0);
  156.    satt(1,1);
  157.  
  158.    /* Switch to graphics mode and clear screen */
  159.    grgra();
  160.    grclr();
  161.    grcol();
  162.    plstyl(0,&mk,&sp);
  163.       
  164.    gphy(&phyxmi,&phyxma,&phyymi,&phyyma);
  165.    sclp(phyxmi,phyxma,phyymi,phyyma);
  166. }
  167.  
  168. /* Clears the graphics screen */
  169. void grclr()
  170. {
  171.       switch(device) {
  172. case 1:
  173.          amiclr();
  174.          break ;
  175. case 2:
  176. case 3:
  177.          jetclr();
  178.          break ;
  179. case 4:
  180. case 5:
  181.          impclr();
  182.          break ;
  183. case 6:
  184. case 7:
  185.          tekclr();
  186.          break ;
  187. case 8:
  188. case 9:
  189.          psclr();
  190.          break ;
  191. case 10:
  192.          iffclr();
  193.          break ;
  194. case 11:
  195. case 12:
  196.          prefclr() ;
  197.          break ;
  198. default:
  199.          break ;
  200.       }
  201. }
  202.  
  203. /* Sets up the line colour to value in global variable "colour" */
  204. void grcol()
  205. {
  206.       if (device == 1)
  207.         amicol(colour);
  208. }
  209.  
  210. /* Initializes the graphics device */
  211. void grinit()
  212. {
  213.       switch(device) {
  214. case 1:
  215.         amiini();
  216.         break ;
  217. case 2:
  218. case 3:
  219.         jetini();
  220.         break ;
  221. case 4:
  222. case 5:
  223.         impini();
  224.         break ;
  225. case 6:
  226. case 7:
  227.         tekini();
  228.         break ;
  229. case 8:
  230. case 9:
  231.         psini();
  232.         break ;
  233. case 10:
  234.         iffini() ;
  235.         break ;
  236. case 11:
  237. case 12:
  238.         prefini() ;
  239.         break ;
  240. default:
  241.         break ;
  242.      }
  243. }
  244.  
  245. /* Switches to graphics mode */
  246. void grgra()
  247. {
  248.       switch(device) {
  249. case 1:
  250.         amigra();
  251.         break ;
  252. case 2:
  253. case 3:
  254.         jetgra();
  255.         break ;
  256. case 4:
  257. case 5:
  258.         impgra();
  259.         break ;
  260. case 6:
  261. case 7:
  262.         tekgra();
  263.         break ;
  264. case 8:
  265. case 9:
  266.         tekgra();
  267.         break ;
  268. case 10:
  269. case 11:
  270. case 12:
  271.         iffgra() ;
  272.         break ;
  273. default:
  274.         break ;
  275.       }
  276.       graphx = 1;
  277. }
  278.  
  279. /* Draws a line from (x1,x2) to (x2,y2), used by genlin() */
  280. /* Notice how x and y are swapped to switch from the default */
  281. /* orientation */
  282. void grline(x1,y1,x2,y2)
  283. int x1,y1,x2,y2;
  284. {
  285.       switch(device) {
  286. case 1:
  287.         amilin(x1,y1,x2,y2);
  288.         break ;
  289. case 2:
  290.         jetlin(y1,x1,y2,x2);
  291.         break ;
  292. case 3:
  293.         jetlin(x1,y1,x2,y2);
  294.         break ;
  295. case 4:
  296.         implin(x1,y1,x2,y2);
  297.         break ;
  298. case 5:
  299.         implin(y1,x1,y2,x2);
  300.         break ;
  301. case 6:
  302.         teklin(x1,y1,x2,y2);
  303.         break ;
  304. case 7:
  305.         teklin(y1,x1,y2,x2);
  306.         break ;
  307. case 8:
  308.         pslin(x1,y1,x2,y2);
  309.         break ;
  310. case 9:
  311.         pslin(y1,x1,y2,x2);
  312.         break ;
  313. case 10:
  314. case 12:
  315.         ifflin(x1,iffHeight-y1,x2,iffHeight-y2) ;
  316.         break ;
  317. case 11:
  318.         ifflin(y1,x1,y2,x2) ;
  319.         break ;
  320. default:
  321.         break ;
  322.       }
  323. }
  324.  
  325. /* Switches to text mode */
  326. void grtext()
  327. {
  328.       switch(device) {
  329. case 1:
  330.         amitex();
  331.         break ;
  332. case 2:
  333. case 3:
  334.         jettex();
  335.         break ;
  336. case 4:
  337. case 5:
  338.         imptex();
  339.         break ;
  340. case 6:
  341. case 7:
  342.         tektex();
  343.         break ;
  344. case 8:
  345. case 9:
  346.         pstex();
  347.         break ;
  348. case 10:
  349. case 11:
  350. case 12:
  351.         ifftex() ;
  352.         break ;
  353. default:
  354.         break ;
  355.       }
  356.       graphx = 0;
  357. }
  358.  
  359. /* Called by plend to tidy up graphics device */
  360. void grtidy()
  361. {
  362.       switch(device) {
  363. case 1:
  364.         amitid();
  365.         break ;
  366. case 2:
  367. case 3:
  368.         jettid();
  369.         break ;
  370. case 4:
  371. case 5:
  372.         imptid();
  373.         break ;
  374. case 6:
  375. case 7:
  376.         tektid();
  377.         break ;
  378. case 8:
  379. case 9:
  380.         pstid();
  381.         break ;
  382. case 10:
  383.         ifftid() ;
  384.         break ;
  385. case 11:
  386. case 12:
  387.         preftid() ;
  388.         break ;
  389. default:
  390.         break ;
  391.     }
  392. }
  393.