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 / RGHP.C < prev    next >
C/C++ Source or Header  |  1992-02-25  |  3KB  |  172 lines

  1. /*
  2. *
  3. *  rghp.c by Aaron Contorer for NCSA
  4. *
  5. *  Routines for HP-GL plotter 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 *HPname = "Hewlett-Packard HP-GL plotter";
  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 HPtext[100];    /* the string containing the HP-GL output text */
  22. static int HPpenx,HPpeny;
  23. static int HPblank;
  24. static int HPcolor;
  25.  
  26. static void HPbegin(void );
  27. static void signore(char *s);
  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 HP-GL strings.
  37. */
  38. void RGHPoutfunc(void (*f)(char *))
  39. {
  40.     outfunc=f;
  41. }
  42.  
  43. /* set up environment for whole new printout */
  44. static void HPbegin(void)
  45. {
  46.     (*outfunc)("IN;SP1;SC-50,4370,-100,4120;PU0,0;");
  47.     HPpenx=HPpeny=0;
  48. }
  49.  
  50. int RGHPnewwin(void)
  51. {
  52.     if(busy) 
  53.         return(-1);
  54.     HPtext[0]='\0';
  55.     HPpenx=HPpeny=0;
  56.     HPblank=TRUE;
  57.     HPcolor=100;
  58.     return(0);
  59. }
  60.  
  61. void RGHPclrscr(int w)
  62. {
  63.     RGHPpagedone(w);
  64. }
  65.  
  66. void RGHPclose(int w) 
  67. {
  68.     RGHPclrscr(w);
  69.     busy=FALSE;
  70. }
  71.  
  72. void RGHPpoint(int w,int x,int y) 
  73. {
  74.     (*outfunc)("PD;PU;");
  75.     w=w;
  76.     x=x;
  77.     y=y;
  78.  
  79. void RGHPdrawline(int w,int x0,int y0,int x1,int y1)
  80. {
  81.     w=w;
  82.     if(HPblank) {
  83.         HPbegin();
  84.         HPblank=FALSE;
  85.       }
  86.     if(x0!=HPpenx||y0!=HPpeny) {        /* only move pen if not already there */
  87.         sprintf(HPtext,"PU%d,%d;",x0, y0);
  88.         (*outfunc)(HPtext);
  89.       }
  90.     sprintf(HPtext,"PD%d,%d;",x1, y1);
  91.     (*outfunc)(HPtext);
  92.     HPpenx=x1;
  93.     HPpeny=y1;
  94. }
  95.  
  96. void RGHPpagedone(int w) 
  97. {
  98.     (*outfunc)("PG;");
  99.     HPblank=TRUE;
  100.     w=w;
  101. }
  102.  
  103. /* Needed for possible future functionality */
  104. void RGHPdataline(int w,char *data,int count)
  105. {
  106.     w=w;
  107.     data=data;
  108.     count=count;
  109. }
  110.  
  111.  
  112. void RGHPpencolor(int w,int color) 
  113. {
  114.     color&=7;
  115.     if(color) {
  116.         sprintf(HPtext,"SP%d;",color);
  117.         (*outfunc)(HPtext);
  118.       }
  119.     w=w;
  120. }
  121.  
  122. /* Needed for possible future functionality */
  123. void RGHPcharmode(int w,int rotation,int size)
  124. {
  125.     w=w;
  126.     rotation=rotation;
  127.     size=size;
  128. }
  129.  
  130. void RGHPshowcur(void) {}
  131. void RGHPlockcur(void) {}
  132. void RGHPhidecur(void) {}
  133.  
  134. /* Needed for possible future functionality */
  135. void RGHPbell(int w)
  136. {
  137.     w=w;
  138. }
  139.  
  140. /* Needed for possible future functionality */
  141. void RGHPuncover(int w)
  142. {
  143.     w=w;
  144. }
  145.  
  146.  
  147. char *RGHPdevname(void)
  148. {
  149.     return(HPname);
  150. }
  151.  
  152. void RGHPinit(void)
  153. {
  154.     busy=FALSE;
  155.     outfunc=signore;
  156. }
  157.  
  158. /* Needed for possible future functionality */
  159. void RGHPinfo(int w,int a,int b,int c,int d,int v)
  160. {
  161.     w=w;
  162.     a=a;
  163.     b=b;
  164.     c=c;
  165.     d=d;
  166.     v=v;
  167. }
  168.  
  169. void RGHPgmode(void) {}
  170. void RGHPtmode(void) {}
  171.