home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / plplot.lzh / PLPLOT / PLPLOT.LZH / plplot / unix / hp7580.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-23  |  2.9 KB  |  146 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 HPXMIN  -4500
  8. #define HPXMAX   4500
  9. #define HPYMIN  -2790
  10. #define HPYMAX   2790
  11. #define ESC    27
  12.  
  13. static FILE *OutFile;
  14. static int  porient;
  15. static int select=0;
  16. char FileName[80];
  17.  
  18. void hp7580setup(xdpi,ydpi,xwid,ywid)
  19. PLINT xwid, ywid;
  20. PLFLT xdpi, ydpi;
  21. {
  22. }
  23.  
  24. /* Open file.  Set up for graphics. */
  25. void hp7580init()
  26. {
  27.       char response[80];
  28.       int ori;
  29.  
  30.       smod(0);  /* not an interactive terminal */
  31.       scol(1);
  32.       swid(1);
  33.       setpxl(40.,40.);
  34.       
  35.       if(!select) {
  36.          printf("Landscape or portrait orientation? (0 or 1): ");
  37.          fgets(response,sizeof(response),stdin);
  38.          if(sscanf(response,"%d",&ori) != 1)
  39.             ori = 0;   /* carriage return defaults to landscape */
  40.       }
  41.       
  42.       porient = ori;
  43.       if(!porient)
  44.          setphy(HPXMIN,HPXMAX,HPYMIN,HPYMAX);
  45.       else
  46.          setphy(HPYMIN,HPYMAX,HPXMIN,HPXMAX);
  47.  
  48.       OutFile = NULL;
  49.       while(!OutFile) {
  50.          if(!select) {
  51.             printf("Enter graphics command storage file name. ");
  52.             fgets(response,sizeof(response),stdin);
  53.             if(sscanf(response,"%s",FileName) != 1) {
  54.                 printf("Invalid entry.n");
  55.                 continue;
  56.             }
  57.          }
  58.          if ((OutFile = fopen(FileName,"w")) == NULL) 
  59.              printf("Can't open %s.\n",FileName);
  60.          select = 0;
  61.       }
  62.       fprintf(OutFile,"%c.I200;;17:%c.N;19:%c.M;;;10:in;\n",ESC,ESC,ESC);
  63.       fprintf(OutFile,"ro 90;ip;sp 4;pa;");
  64. }
  65.  
  66. void hp7580select(ori,file)
  67. PLINT ori;
  68. char *file;
  69. {
  70.    porient = ori;
  71.    strncpy(FileName,file,sizeof(FileName)-1);
  72.    FileName[sizeof(FileName)-1] = '\0';
  73.    select = 1;
  74. }
  75.  
  76. /* Sets to text mode */
  77. void hp7580text()
  78. {
  79. }
  80.  
  81. /* Sets the IMPRESS to graphics mode */
  82. void hp7580graph()
  83. {
  84. }
  85.  
  86. /* Form feed */
  87. void hp7580clear()
  88. {
  89. }
  90.  
  91. static int xold, yold;
  92.  
  93. void hp7580page()
  94. {
  95.    xold=-100000; yold=-100000;
  96. }
  97.  
  98. /* May put something here someday */
  99. void hp7580color(colour)
  100. PLINT colour;
  101. {
  102.   if(colour<1 || colour>8)
  103.     fprintf(stderr,"\nInvalid pen selection.");
  104.   else
  105.     fprintf(OutFile,"sp%d\n",colour);
  106. }
  107.  
  108. void hp7580width(width)
  109. PLINT width;
  110. {
  111. }
  112.  
  113. void hp7580line(x1,y1,x2,y2)
  114. PLINT x1,y1,x2,y2;
  115. {
  116.  
  117.       if(!porient) {
  118.          if(x1 == xold && y1 == yold) 
  119.            /* Add new point to path */
  120.            fprintf(OutFile," %d %d",x2,y2);
  121.          else 
  122.            /* Write out old path */
  123.            fprintf(OutFile,"\npu%d %d pd%d %d",x1,y1,x2,y2);
  124.       }
  125.       else {
  126.          if(x1 == xold && y1 == yold) 
  127.            /* Add new point to path */
  128.            fprintf(OutFile," %d %d",-y2,x2);
  129.          else 
  130.            /* Write out old path */
  131.            fprintf(OutFile,"\npu%d %d pd%d %d",-y1,x1,-y2,x2);
  132.       }
  133.         
  134.       xold = x2;
  135.       yold = y2;
  136. }
  137.       
  138. /* Close graphics file */
  139. void hp7580tidy()
  140. {
  141.       fprintf(OutFile,"\nsp0");
  142.       fclose(OutFile);
  143.       select = 0;
  144. }
  145.  
  146.