home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344b.lha / plplot_v2.6 / unix / hp7470.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-27  |  3.1 KB  |  153 lines

  1. /* This file contains the IMPRESS device dependent subroutines for */
  2. /* use with plplot. */
  3.  
  4. #include "plplot.h"
  5. #include <stdio.h>
  6.  
  7. #define ESC          27
  8. #define HP7470X   10299
  9. #define HP7470Y    7649
  10.  
  11. static FILE *OutFile;
  12. static int porient;
  13. static int select=0;
  14. static char FileName[80];
  15. static int curpen, curwid;
  16.  
  17. void hp7470setup(xdpi,ydpi,xwid,ywid)
  18. PLINT xwid, ywid;
  19. PLFLT xdpi, ydpi;
  20. {
  21. }
  22.  
  23. /* Open file.  Set up for graphics. */
  24. void hp7470init()
  25. {
  26.       char response[80];
  27.       int ori;
  28.  
  29.       smod(0);  /* not an interactive terminal */
  30.       scol(1);
  31.       swid(1);
  32.       setpxl(40.,40.);
  33.       
  34.       if(!select) {
  35.          printf("Landscape or portrait orientation? (0 or 1): ");
  36.          fgets(response,sizeof(response),stdin);
  37.          if(sscanf(response,"%d",&ori) != 1)
  38.             ori = 0;   /* carriage return defaults to landscape */
  39.       }
  40.       
  41.       porient = ori;
  42.       if(!porient)
  43.          setphy(0,HP7470X,0,HP7470Y);
  44.       else
  45.          setphy(0,HP7470Y,0,HP7470X);
  46.  
  47.       OutFile = NULL;
  48.       while(!OutFile) {
  49.          if(!select) {
  50.             printf("Enter graphics command storage file name. ");
  51.             fgets(response,sizeof(response),stdin);
  52.             if(sscanf(response,"%s",FileName) != 1) {
  53.                 printf("Invalid entry.n");
  54.                 continue;
  55.             }
  56.          }
  57.          if ((OutFile = fopen(FileName,"w")) == NULL) 
  58.              printf("Can't open %s.\n",FileName);
  59.          select=0;
  60.       }
  61.       fprintf(OutFile,"%c.I200;;17:%c.N;19:%c.M;;;10:in;\n",ESC,ESC,ESC);
  62. }
  63.  
  64. void hp7470select(ori,file)
  65. PLINT ori;
  66. char *file;
  67. {
  68.    porient = ori;
  69.    strncpy(FileName,file,79);
  70.    FileName[79]='\0';
  71.    select = 1;
  72. }
  73.  
  74. /* Sets the IMPRESS to text mode */
  75. void hp7470text()
  76. {
  77. }
  78.  
  79. /* Sets the IMPRESS to graphics mode */
  80. void hp7470graph()
  81. {
  82. }
  83.  
  84. /* Form feed */
  85. void hp7470clear()
  86. {
  87. }
  88.  
  89. static PLINT xold, yold;
  90.  
  91. void hp7470page()
  92. {
  93.    fprintf(OutFile,"pg;\n");
  94.    xold = -100000;
  95.    yold = -100000;
  96. }
  97.  
  98. void hp7470color(colour)
  99. PLINT colour;
  100. {
  101.   if(colour<1 || colour>8)
  102.     fprintf(stderr,"\nInvalid pen selection.");
  103.   else {
  104.     fprintf(OutFile,"sp%d %d\n",colour,curwid);
  105.     curpen = colour;
  106.   }
  107. }
  108.  
  109. void hp7470width(width)
  110. PLINT width;
  111. {
  112.   if(width<1 || width>48)
  113.     fprintf(stderr,"\nInvalid pen width selection.");
  114.   else {
  115.     fprintf(OutFile,"sp%d %d\n",curpen,width);
  116.     curwid = width;
  117.   }
  118. }
  119.  
  120. void hp7470line(x1,y1,x2,y2)
  121. PLINT x1,y1,x2,y2;
  122. {
  123.  
  124.       if(!porient) {
  125.          if(x1 == xold && y1 == yold) 
  126.            /* Add new point to path */
  127.            fprintf(OutFile,"pd%d %d\n",x2,y2);
  128.          else 
  129.            /* Write out old path */
  130.            fprintf(OutFile,"pu%d %d pd%d %d\n",x1,y1,x2,y2);
  131.       }
  132.       else {
  133.          if(x1 == xold && y1 == yold) 
  134.            /* Add new point to path */
  135.            fprintf(OutFile,"pd%d %d\n",HP7470X-y2,x2);
  136.          else 
  137.            /* Write out old path */
  138.            fprintf(OutFile,"pu%d %d pd%d %d\n",HP7470X-y1,x1,HP7470X-y2,x2);
  139.       }
  140.         
  141.       xold = x2;
  142.       yold = y2;
  143. }
  144.       
  145. /* Close graphics file */
  146. void hp7470tidy()
  147. {
  148.       fprintf(OutFile,"sp0\n");
  149.       fclose(OutFile);
  150.       select = 0;
  151. }
  152.  
  153.