home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / gle / util / surf / vaxdevic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-29  |  3.8 KB  |  177 lines

  1. /* Screen and .gle driver for pc */
  2. #include "all.h"
  3. #include "vdevice.h"
  4. #define false 0
  5. #define true (!false)
  6. #define SOLID_LINE 1
  7. #define DASHED_LINE 2
  8. #include <math.h>
  9. #include "mygraph.h"
  10. #include "justify.h"
  11. /*---------------------------------------------------------------------------*/
  12. #define pi 3.141592653
  13. #define true (!false)
  14. int getch(void);
  15. int kbhit(void);
  16. extern int gle_nspeed;
  17. extern int gle_speed;
  18. /*---------------------------------------------------------------------------*/
  19. /* The global variables for the PC screen driver */
  20. /*-----------------------------------------------*/
  21.  
  22. float v_scale, v_xscale, v_yscale;
  23. char *gledir(char *s);
  24. int v_graphmode;
  25. int v_fillstyle=1,v_fillcolor;
  26. int vv_lstyle,v_lwidth;
  27. int v_maxy;
  28. static int ee;
  29. FILE *gf;
  30. extern char input_file[];
  31. char *bgidir();
  32. /*---------------------------------------------------------------------------*/
  33. v_open(float width, float height)
  34. {
  35.     static int g_driver,g_error;
  36.     float f;
  37.     char bigfile[80];
  38.     char glefile[80];
  39.  
  40.     strcpy(bigfile,input_file);
  41.     if (strchr(bigfile,'.')==NULL) {
  42.         gprint("Error in file name,  {%s} \n",input_file);
  43.         gle_abort("error in file name \n");
  44.     }
  45.     *strchr(bigfile,'.') = 0;
  46.     strcpy(glefile,bigfile);
  47.     strcat(glefile,".gle");
  48.     strcat(bigfile,".big");
  49.     gf = fopen(glefile,"r");
  50.     if (gf==NULL) { /* then it doesn't exist, so lets create it */
  51.         gf = fopen(glefile,"w");
  52.         if (gf==NULL) gprint("Failed to create {%s} \n",glefile);
  53.         else {
  54.             fprintf(gf,"size 24 18\n");
  55.             fprintf(gf,"bigfile %s\n",bigfile);
  56.             fclose(gf);
  57.         }
  58.     } else fclose(gf);
  59.  
  60.  
  61.     gf = fopen(bigfile,"w");
  62.     if (gf==NULL) {
  63.         gprint("Unable to open output gle file out.gle\n");
  64.         text_inkey();
  65.         abort();
  66.     }
  67.     gle_nspeed = 2;
  68.     g_open(width,height);
  69. }
  70. /*---------------------------------------------------------------------------*/
  71. v_close()
  72. {
  73.     g_close();
  74.     fclose(gf);
  75. }
  76. /*---------------------------------------------------------------------------*/
  77. v_lstyle(char *s)
  78. {
  79.     if (*s == 0) s = "1";
  80.     vv_lstyle = DASHED_LINE;
  81.     if (strcmp(s,"")==0) vv_lstyle = SOLID_LINE;
  82.     if (strcmp(s,"1")==0) vv_lstyle = SOLID_LINE;
  83.     g_set_line_style(s);
  84.     fprintf(gf,"set lstyle %s\n",s);
  85. }
  86. /*---------------------------------------------------------------------------*/
  87. v_line(float zx,float zy)
  88. {
  89.     g_line(zx,zy);
  90.     fprintf(gf,"aline %g %g \n",zx,zy);
  91. }
  92. v_move(float zx,float zy)
  93. {
  94.     g_move(zx,zy);
  95.     fprintf(gf,"amove %g %g \n",zx,zy);
  96. }
  97. /*---------------------------------------------------------------------------*/
  98. v_gsave()
  99. {
  100.     g_gsave();
  101.     fprintf(gf,"gsave \n");
  102. }
  103. v_grestore()
  104. {
  105.     g_grestore();
  106.     fprintf(gf,"grestore \n");
  107. }
  108. v_text(char *s)
  109. {
  110.     g_text(s);
  111.     fprintf(gf,"text %s \n",s);
  112. }
  113. double cur_hei;
  114. v_set_hei(float g)
  115. {
  116.     g_set_hei(g);
  117.     cur_hei = g;
  118.     fprintf(gf,"set hei %g\n",g);
  119. }
  120. v_set_just(char *s)
  121. {
  122.     if (strcmp(s,"RC")==0) g_set_just(JUST_RC);
  123.     if (strcmp(s,"TC")==0) g_set_just(JUST_TC);
  124.     if (strcmp(s,"BC")==0) g_set_just(JUST_BC);
  125.     if (strcmp(s,"CC")==0) g_set_just(JUST_CC);
  126.     if (strcmp(s,"LEFT")==0) g_set_just(JUST_LEFT); 
  127.     fprintf(gf,"set just %s\n",s);
  128. }
  129. v_rotate(float g)
  130. {
  131.     g_rotate(g);
  132.     fprintf(gf,"rotate %g \n",g);
  133. }
  134. v_marker(char *m)
  135. {
  136.     int i;
  137.     i = get_markeri(m);
  138.     g_marker(i,cur_hei);
  139.     fprintf(gf,"marker %s\n",m);
  140. }
  141. #include "global.h"
  142. long gt_firstval(OPKEY lkey,char *s);
  143. v_color(char *s)
  144. {
  145.   char black[10];
  146.     int i;
  147.     i = 0;
  148.     if (*s == 0) {strcpy(black,"BLACK"); s = black;}
  149.     strupr(s);
  150.     g_set_color(gt_firstval(&op_color_typ,s));
  151.     fprintf(gf,"set color %s\n",s);
  152. }
  153. long gt_firstval(OPKEY lkey,char *s)
  154. {
  155.     int nk,i,width=0,p;
  156.     for (i=0; (*lkey)[i].typ!=typ_end; i++) {
  157.         p = (*lkey)[i].pos;
  158.         if (p>width) width = p ;
  159.     }
  160.     nk = i;
  161.     for (i=0; i<nk; i++) {
  162.         if (strcmp((*lkey)[i].name,s)==0) {
  163.             return (*lkey)[i].idx;
  164.         }
  165.     }
  166. }
  167. get_markeri(char *s)
  168. {
  169.     int i;
  170.     long f=0;
  171.     /* if 0, maybe its a user defined marker, ie a subroutine */
  172.     /* Use -ve to signify subroutine instead of normal marker */
  173.     f = gt_firstval(&op_marker,s);
  174.     return f;
  175. }
  176.  
  177.