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