home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / Gnuplot / Source / term / corel.trm < prev    next >
Encoding:
Text File  |  1993-03-02  |  10.8 KB  |  349 lines

  1. /*
  2.  * $Id: corel.trm%v 3.38.2.74 1993/02/19 01:11:43 woo Exp woo $
  3.  */
  4.  
  5. /*
  6.    corel.trm
  7.  
  8.    A modified ai.trm for CorelDraw import filters
  9.    by Chris Parks, parks@physics.purdue.edu
  10.    Import from CorelDraw with the CorelTrace filter
  11.  
  12.    syntax: set terminal default
  13.            set terminal mode "fontname" fontsize,xsize,ysize,linewidth
  14.  
  15.            mode= color or monochrome             (default=mono)
  16.            "fontname"= postscript font name      (default="SwitzerlandLight")
  17.            fontsize  = size of font in points    (default=22pt)
  18.            xsize     = width of page in inches   (default=8.2in)
  19.            ysize     = height of page in inches  (default=10in)
  20.            linewidth = width of lines in points  (default=1.2pt)
  21.  
  22. */
  23.  
  24. /* plots for publication should be sans-serif (don't use TimesRoman) */
  25. char corel_font[MAX_ID_LEN+1] = "SwitzerlandLight" ; /* name of font */
  26. int corel_fontsize = 22;                            /* size of font in pts */
  27. TBOOLEAN corel_color = FALSE;
  28. TBOOLEAN corel_stroke = FALSE;
  29. int corel_path_count=0;            /* count of lines in path */
  30. int corel_ang=0;                   /* text angle */
  31. enum JUSTIFY corel_justify=LEFT;   /* text is flush left */
  32.  
  33.  
  34. /* default mode constants */
  35. #define CORELD_XOFF  0               /* page offset in pts */
  36. #define CORELD_YOFF  0
  37. #define COREL_SC     (10.0)           /* scale is 1pt = 10 units */
  38. #define CORELD_LW    (1.2*COREL_SC)  /* linewidth = 1.2 pts */
  39. #define CORELD_XMAX  5960            /* 8.2 inches wide */
  40. #define CORELD_YMAX  7200            /* 10 inches high  */
  41. #define CORELD_VTIC  (CORELD_YMAX/80)
  42. #define CORELD_HTIC  (CORELD_YMAX/80)
  43. #define CORELD_VCHAR (22*COREL_SC)      /* default is 22 point characters */
  44. #define CORELD_HCHAR (22*COREL_SC*6/10)
  45.  
  46. unsigned int corel_xmax=CORELD_XMAX;
  47. unsigned int corel_ymax=CORELD_YMAX;
  48. float corel_lw=CORELD_LW;
  49.  
  50. COREL_options()
  51. {
  52.     extern struct value *const_express();
  53.     extern double real();
  54.         struct value a;
  55.  
  56.                 if (!END_OF_COMMAND && almost_equals(c_token,"def$ault")) {
  57.                         corel_color=FALSE;
  58.                         strcpy(corel_font,"SwitzerlandLight");
  59.                         corel_fontsize = 22;
  60.                         corel_lw=CORELD_LW;
  61.                 corel_xmax=CORELD_XMAX;
  62.                 corel_ymax=CORELD_YMAX;
  63.             c_token++;
  64.                 }
  65.                 if (!END_OF_COMMAND && almost_equals(c_token,"mono$chrome")) {
  66.                         corel_color=FALSE;
  67.             c_token++;
  68.                 } else
  69.                 if (!END_OF_COMMAND && almost_equals(c_token,"color$")) {
  70.                         corel_color=TRUE;
  71.             c_token++;
  72.                 }
  73.                 if (!END_OF_COMMAND && isstring(c_token)) {
  74.                   quote_str(corel_font,c_token);
  75.                   c_token++;
  76.                 }
  77.                 if (!END_OF_COMMAND) {
  78.                   /* We have font size specified */
  79.                   corel_fontsize = (int)real(const_express(&a));
  80.                   c_token++;
  81.                   term_tbl[term].v_char = (unsigned int)(corel_fontsize*COREL_SC);
  82.                   term_tbl[term].h_char = (unsigned int)(corel_fontsize*COREL_SC*6/10);
  83.                 }
  84.                 if (!END_OF_COMMAND) {
  85.                   corel_xmax=(unsigned int)(real(const_express(&a))*720);
  86.                   c_token++;
  87.                   if (!END_OF_COMMAND) {
  88.                     corel_ymax=(unsigned int)(real(const_express(&a))*720);
  89.                     c_token++;
  90.                   }
  91.                   term_tbl[term].xmax=corel_xmax;
  92.                   term_tbl[term].ymax=corel_ymax;
  93.                   term_tbl[term].v_tic=corel_ymax/80;
  94.                   term_tbl[term].h_tic=corel_ymax/80;
  95.                 }
  96.                 if (!END_OF_COMMAND) {
  97.                   corel_lw= real(const_express(&a))*COREL_SC;
  98.                   c_token++;
  99.                 }
  100.  
  101.         sprintf(term_options,"%s \"%s\" %d,%0.1f,%0.1f,%0.1f",
  102.                 corel_color ? "color" : "monochrome",corel_font,
  103.                 corel_fontsize,corel_xmax/720.0,corel_ymax/720.0,
  104.                 corel_lw/COREL_SC);
  105. }
  106.  
  107. COREL_init()
  108. {
  109. struct termentry *t = &term_tbl[term];
  110. int i;
  111.     fprintf(outfile,"%%!PS-Adobe-2.0 EPSF-1.2\n");
  112.         fprintf(outfile,"%%%%BoundingBox: %d %d %d %d\n", CORELD_XOFF,CORELD_YOFF,
  113.                 (int)((corel_xmax)/COREL_SC+0.5+CORELD_XOFF),
  114.                 (int)((corel_ymax)/COREL_SC+0.5+CORELD_YOFF) );
  115.         fprintf(outfile,"%%%%TemplateBox: %d %d %d %d\n", CORELD_XOFF,CORELD_YOFF,
  116.                 (int)((corel_xmax)/COREL_SC+0.5+CORELD_XOFF),
  117.                 (int)((corel_ymax)/COREL_SC+0.5+CORELD_YOFF) );
  118.     fprintf(outfile,"%%%%EndComments\n");
  119.     fprintf(outfile,"%%%%EndProlog\n");
  120.         fprintf(outfile,"%%%%BeginSetup\n%%%%EndSetup\n");
  121. }
  122.  
  123.  
  124. COREL_graphics()
  125. {
  126.  
  127. struct termentry *t = &term_tbl[term];
  128.         corel_path_count = 0;
  129.         corel_stroke = FALSE;
  130. }
  131.  
  132.  
  133. COREL_text()
  134. {
  135.         if (corel_stroke) {
  136.         fprintf(outfile,"S\n");
  137.                 corel_stroke = FALSE;
  138.     }
  139.         corel_path_count = 0;
  140. }
  141.  
  142.  
  143. COREL_reset()
  144. {
  145.     fprintf(outfile,"%%%%Trailer\n");
  146. }
  147.  
  148.  
  149. COREL_linetype(linetype)
  150. int linetype;
  151. {
  152.         if (corel_stroke) {
  153.         fprintf(outfile,"S\n");
  154.                 corel_stroke = FALSE;
  155.     }
  156.     switch(linetype) {
  157.                 case -2 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  158.                                 if (corel_color) {
  159.                     fprintf(outfile,"0 0 0 1 K\n");
  160.                 }
  161.                 else {                
  162.                                         fprintf(outfile,"[] 0 d\n");
  163.                                         fprintf(outfile,"0 j\n0 G\n");
  164.                 }
  165.                 break;
  166.  
  167.                 case -1 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  168.                                 if (corel_color) {
  169.                     fprintf(outfile,"0 0 0 1 K\n");
  170.                 }
  171.                 else {                
  172.                     fprintf(outfile,"[1 2] 0 d\n");
  173.                                         fprintf(outfile,"0 j\n0 G\n");
  174.                                 }
  175.                 break;
  176.                 
  177.                 case 0 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  178.                                 if (corel_color) {
  179.                     fprintf(outfile,"1 0 1 0 K\n");
  180.                 }
  181.                 else {                
  182.                     fprintf(outfile,"[] 0 d\n");
  183.                                         fprintf(outfile,"2 j\n0 G\n");
  184.                                 }
  185.                 break;
  186.                 
  187.                 case 1 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  188.                                 if (corel_color) {
  189.                     fprintf(outfile,"1 1 0 0 K\n");
  190.                 }
  191.                 else {                
  192.                     fprintf(outfile,"[4 2] 0 d\n");
  193.                                         fprintf(outfile,"2 j\n0 G\n");
  194.                                 }
  195.                 break;
  196.                 
  197.                 case 2 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  198.                                 if (corel_color) {
  199.                     fprintf(outfile,"0 1 1 0 K\n");
  200.                 }
  201.                 else {                
  202.                                         fprintf(outfile,"[2 3] 0 d\n");
  203.                                         fprintf(outfile,"2 j\n0 G\n");
  204.                                 }
  205.                 break;
  206.                 
  207.                 case 3 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  208.                                 if (corel_color) {
  209.                     fprintf(outfile,"0 1 0 0 K\n");
  210.                 }
  211.                 else {                
  212.                     fprintf(outfile,"[1 1.5] 0 d\n");
  213.                                         fprintf(outfile,"2 j\n0 G\n");
  214.                                 }
  215.                 break;
  216.                 
  217.                 case 4 :  fprintf(outfile,"%f w\n",corel_lw/COREL_SC);
  218.                                 if (corel_color) {
  219.                     fprintf(outfile,"1 0 0 0 K\n");
  220.                                 }
  221.                 else {                
  222.                     fprintf(outfile,"[5 2 1 2] 0 d\n");
  223.                                         fprintf(outfile,"2 j\n0 G\n");
  224.                                 }
  225.                 break;
  226.                 
  227.                 case 5 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  228.                                 if (corel_color) {
  229.                     fprintf(outfile,"0 0 1 0 K\n");
  230.                 }
  231.                 else {                
  232.                     fprintf(outfile,"[4 3 1 3] 0 d\n");
  233.                                         fprintf(outfile,"2 j\n0 G\n");
  234.                                 }
  235.                 break;
  236.                 
  237.                 case 6 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  238.                                 if (corel_color) {
  239.                     fprintf(outfile,"0 0 0 1 K\n");
  240.                 }
  241.                 else {                
  242.                     fprintf(outfile,"[2 2 2 4] 0 d\n");
  243.                                         fprintf(outfile,"2 j\n0 G\n");
  244.                                 }
  245.                 break;
  246.                 
  247.                 case 7 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  248.                                 if (corel_color) {
  249.                     fprintf(outfile,"0 0.7 1 0 K\n");
  250.                 }
  251.                 else {                
  252.                     fprintf(outfile,"[2 2 2 2 2 4] 0 d\n");
  253.                                         fprintf(outfile,"2 j\n0 G\n");
  254.                                 }
  255.                 break;
  256.                 
  257.                 case 8 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  258.                                 if (corel_color) {
  259.                     fprintf(outfile,"0.5 0.5 0.5 0 K\n");
  260.                 }
  261.                 else {                
  262.                     fprintf(outfile,"[2 2 2 2 2 2 2 4] 0 d\n");
  263.                                         fprintf(outfile,"2 j\n0 G\n");
  264.                                 }
  265.                 break;
  266.         }
  267.         corel_path_count = 0;
  268. }
  269.  
  270.  
  271. COREL_move(x,y)
  272. unsigned int x,y;
  273. {
  274.         if (corel_stroke) fprintf(outfile,"S\n");
  275.         fprintf(outfile,"%0.2f %0.2f m\n", x/COREL_SC, y/COREL_SC);
  276.         corel_path_count += 1;
  277.         corel_stroke = TRUE;
  278. }
  279.  
  280.  
  281. COREL_vector(x,y)
  282. unsigned int x,y;
  283. {
  284.         fprintf(outfile,"%.2f %.2f l\n", x/COREL_SC, y/COREL_SC);
  285.         corel_path_count += 1;
  286.         corel_stroke = TRUE;
  287.         if (corel_path_count >= 400) {
  288.                 fprintf(outfile,"S\n%.2f %.2f m\n",x/COREL_SC,y/COREL_SC);
  289.                 corel_path_count = 0;
  290.     }
  291. }
  292.  
  293.  
  294. COREL_put_text(x,y,str)
  295. unsigned int x, y;
  296. char *str;
  297. {
  298. char ch;
  299.         if (corel_stroke) {
  300.         fprintf(outfile,"S\n");
  301.                 corel_stroke = FALSE;
  302.     }
  303.         switch(corel_justify) {
  304.                 case LEFT :   fprintf(outfile,"/_%s %d %d 0 0 z\n",
  305.                                       corel_font,corel_fontsize,corel_fontsize);
  306.             break;
  307.                 case CENTRE : fprintf(outfile,"/_%s %d %d 0 1 z\n",
  308.                                       corel_font,corel_fontsize,corel_fontsize);
  309.             break;
  310.                 case RIGHT :  fprintf(outfile,"/_%s %d %d 0 2 z\n",
  311.                                       corel_font,corel_fontsize,corel_fontsize);
  312.             break;
  313.     }
  314.         if (corel_ang==0) {
  315.                 fprintf(outfile,"[1 0 0 1 %.2f %.2f]e\n0 g\n",
  316.                         x/COREL_SC,y/COREL_SC - corel_fontsize/3.0);
  317.     }
  318.     else {
  319.                 fprintf(outfile,"[0 1 -1 0 %.2f %.2f]e\n0 g\n",
  320.                         x/COREL_SC - corel_fontsize/3.0,y/COREL_SC);
  321.     }
  322.         
  323.     putc('(',outfile);
  324.     ch = *str++;
  325.     while(ch!='\0') {
  326.         if ( (ch=='(') || (ch==')') || (ch=='\\') )
  327.             putc('\\',outfile);
  328.         putc(ch,outfile);
  329.         ch = *str++;
  330.     }
  331.         fprintf(outfile,")t\nT\n");
  332.         corel_path_count = 0;
  333. }
  334.  
  335. int COREL_text_angle(ang)
  336. int ang;
  337. {
  338.         corel_ang=ang;
  339.     return TRUE;
  340. }
  341.  
  342. int COREL_justify_text(mode)
  343. enum JUSTIFY mode;
  344. {
  345.         corel_justify=mode;
  346.     return TRUE;
  347. }
  348.  
  349.