home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / t / tel2305s.zip / RG / RGP.C < prev    next >
C/C++ Source or Header  |  1992-02-25  |  4KB  |  198 lines

  1. /*
  2. *
  3. *  rgp.c by Aaron Contorer for NCSA
  4. *
  5. * Routines for PostScript output.  Only 1 window output at a time.
  6. *
  7. */
  8.  
  9. #include <stdio.h>
  10. #include "externs.h"
  11.  
  12. #define TRUE 1
  13. #define FALSE 0
  14.  
  15. static char *psname="PostScript output";
  16. static char busy;                 /* is device already in use */
  17. #ifdef OLD_WAY
  18. static int winbot,winleft,wintall,winwide;    /* position and size of window into virtual space */
  19. #endif
  20. static void (*outfunc)(char *s);        /* the function to call with pointer to strings */
  21. static char pstext[100];        /* the string containing the PostScript output text */
  22. static char PSblank, PSnopath;
  23.  
  24. static void signore(char *s);
  25. static void psbegin(void );
  26. static void PSenv(void );
  27. static void stroke(void );
  28.  
  29. static void signore(char *s)
  30. {
  31.     s=s;
  32. }
  33.  
  34. /*
  35.     Specify the function that is to be called with pointers to all
  36.     the PostScript strings.
  37. */
  38. void RGPoutfunc(void (*f)(char *))
  39. {
  40.     outfunc=f;
  41. }
  42.  
  43. static void stroke(void )
  44. {
  45.     if(!PSnopath) 
  46.         (*outfunc)(" S ");
  47. }
  48.  
  49. static void PSenv(void )            /* set up PostScript environment for new page */
  50. {
  51.                         /* Map 4k x 4k graphics onto 11x8 inch paper space,leaving margins and preserving 4x3 aspect ratio. */
  52.     (*outfunc)("533 72 translate\n");
  53.     (*outfunc)("90 rotate\n");
  54.     (*outfunc)("newpath\n 1 setlinewidth\n 0.16 0.12 scale\n");
  55. }
  56.  
  57. static void psbegin(void )        /* set up PS environment for whole new printout */
  58. {
  59.     (*outfunc)("%! PostScript code from NCSA software\n");
  60.     (*outfunc)("% National Center for Supercomputing Applications\n");
  61.     (*outfunc)("% at the University of Illinois\n\n");
  62.     (*outfunc)("/M { moveto } def\n");
  63.     (*outfunc)("/L { lineto } def\n");
  64.     (*outfunc)("/N { newpath } def\n");
  65.     (*outfunc)("/S { stroke } def\n");
  66.     (*outfunc)("/R { rlineto } def\n");
  67.     (*outfunc)("/H { 0 0 moveto newpath } def\n");
  68. }
  69.  
  70. int RGPnewwin(void )
  71. {
  72.     if(busy) 
  73.         return(-1);
  74.     else {
  75.         busy=TRUE;
  76.         psbegin();
  77.         PSnopath=TRUE;
  78.         pstext[0]='\0';
  79.         PSblank=TRUE;
  80.         return(0);
  81.       }
  82. }
  83.  
  84. void RGPclrscr(int w)
  85. {
  86.     RGPpagedone(w);
  87. }
  88.  
  89. void RGPclose(int w) 
  90. {
  91.     RGPclrscr(w);
  92.     busy=FALSE;
  93. }
  94.  
  95. void RGPpoint(int w,int x,int y) 
  96. {
  97.     (*outfunc)("3 0 R -3 0 R\n");
  98.     PSblank=FALSE;
  99.     PSnopath=FALSE;
  100. /* Needed for possible future functionality */
  101.  
  102.     w=w;
  103.     x=x;
  104.     y=y;
  105.  
  106. void RGPdrawline(int w,int x0,int y0,int x1,int y1)
  107. {
  108.     stroke();
  109.     if(PSblank) {
  110.         PSenv();
  111.         PSblank=FALSE;
  112.       }
  113.     sprintf(pstext,"H %d %d M %d %d L\n",x0,y0,x1,y1);
  114.     (*outfunc)(pstext);
  115.     PSnopath=FALSE;
  116.     w=w;
  117. }
  118.  
  119. void RGPpagedone(int w) 
  120. {
  121.     if(!PSblank) {
  122.         stroke();
  123.         (*outfunc)("showpage\n");
  124.         (*outfunc)("% ++ DONE\n");
  125.       }
  126.     PSblank=TRUE;
  127.     w=w;
  128. }
  129.  
  130. /* Needed for possible future functionality */
  131. void RGPdataline(int w,char *data,int count)
  132. {
  133.     w=w;
  134.     data=data;
  135.     count=count;
  136. }
  137.  
  138. /* Needed for possible future functionality */
  139. void RGPpencolor(int w,int color)
  140. {
  141.     w=w;
  142.     color=color;
  143. }
  144.  
  145. /* Needed for possible future functionality */
  146. void RGPcharmode(int w,int rotation,int size)
  147. {
  148.     w=w;
  149.     rotation=rotation;
  150.     size=size;
  151. }
  152.  
  153. void RGPshowcur(void ) {}
  154. void RGPlockcur(void ) {}
  155. void RGPhidecur(void ) {}
  156.  
  157. /* Needed for possible future functionality */
  158. void RGPbell(int w)
  159. {
  160.     w=w;
  161. }
  162.  
  163.  
  164. /* Needed for possible future functionality */
  165. void RGPuncover(int w)
  166. {
  167.     w=w;
  168. }
  169.  
  170.  
  171. char *RGPdevname(void ) 
  172. {
  173.     return(psname);
  174. }
  175.  
  176. void RGPinit(void ) 
  177. {
  178.     busy=FALSE;
  179.     PSblank=TRUE;
  180.     PSnopath=TRUE;
  181.     outfunc=signore;
  182. }
  183.  
  184. /* Needed for possible future functionality */
  185. void RGPinfo(int w,int a,int b,int c,int d,int v)
  186. {
  187.     w=w;
  188.     a=a;
  189.     b=b;
  190.     c=c;
  191.     d=d;
  192.     v=v;
  193. }
  194.  
  195. void RGPgmode(void ) {}
  196. void RGPtmode(void ) {}
  197.