home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 334_02 / qms.trm < prev    next >
Text File  |  1991-02-05  |  4KB  |  153 lines

  1. /* GNUPLOT - qms.trm */
  2. /*
  3.  * Copyright (C) 1990   
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *  
  15.  * This software  is provided "as is" without express or implied warranty.
  16.  * 
  17.  * This file is included by ../term.c.
  18.  *
  19.  * This terminal driver supports:
  20.  *  QMS laser printers
  21.  *
  22.  * AUTHORS
  23.  *  Colin Kelley, Thomas Williams, Russell Lang
  24.  * 
  25.  * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  26.  * 
  27.  */
  28.  
  29. #define QMS_XMAX 9000
  30. #define QMS_YMAX 6000
  31.  
  32. #define QMS_XLAST (QMS_XMAX - 1)
  33. #define QMS_YLAST (QMS_YMAX - 1)
  34.  
  35. #define QMS_VCHAR        120
  36. #define QMS_HCHAR        70
  37. #define QMS_VTIC        70
  38. #define QMS_HTIC        70
  39.  
  40. int qms_line = 0;    /* to remember current line type */
  41.  
  42. QMS_init()
  43. {
  44. /* This was just ^IOL, but at Rutgers at least we need some more stuff */
  45.   fprintf(outfile,"^PY^-\n^IOL\n^ISYNTAX00000^F^IB11000^IJ00000^IT00000\n");
  46. /*                 ^ QUIC on    ^set defaults  ^ set botttom,top,left margins
  47.                           ^landscape         ^free format   */
  48. /* set defaults are: implicit decimal point, units in inches, 
  49.    numbers left justified, units in 1/1000 inch, do not ignore spaces */
  50. /* margins are in 1/1000 inch units */
  51. }
  52.  
  53.  
  54. QMS_graphics()
  55. {
  56.     fprintf(outfile,"^IGV\n");
  57. /*                     ^enter graphics vector mode */
  58. }
  59.  
  60.  
  61.  
  62. QMS_text()
  63. {
  64. /* added ^-, because ^, after an ^I command doesn't actually print a page */
  65. /* Did anybody try this code out?  [uhh...-cdk] */
  66.     fprintf(outfile,"^IGE\n^-^,");
  67. /*                     ^exit graphics vector mode
  68.                            ^pass terminator
  69.                              ^print page  */
  70. }
  71.  
  72.  
  73. QMS_linetype(linetype)
  74. int linetype;
  75. {
  76. static int width[2+9] = {7, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7};
  77. static int type[2+9] =  {0, 1, 0, 2, 3, 0, 2, 3, 0, 2, 3};
  78. /*
  79.  * I don't know about Villanova, but on our printer, using ^V without
  80.  * previously setting up a pattern crashes the microcode.
  81.  * [nope, doesn't crash here. -cdk]
  82.  * [it generates a controller error here on dotted lines. - rjl]
  83.  */
  84. /* Code to define patterns added by rjl
  85.  * According to the manual it should work - but it doesn't
  86.  */
  87.     qms_line = linetype;
  88.     if (linetype >= 9)
  89.         linetype %= 9;
  90.     fprintf(outfile,"^PW%02d\n",width[linetype+2]); 
  91. /*                     ^width in dots */
  92.     switch (type[linetype+2]) {
  93.         case 1 :    /* short dash */
  94.             fprintf(outfile,"^PV102025^G\n^V1\n");
  95. /* ^PV = define pattern vector, 1 = pattern number,
  96.    02 = number of pen downs and ups, 025 = .025" length of ups/downs */
  97.             break;
  98.         case 2 :    /* medium dash */
  99.             fprintf(outfile,"^PV202050^G\n^V2\n");
  100.             break;
  101.         case 3 :    /* long dash */
  102.             fprintf(outfile,"^PV302100^G\n^V3\n");
  103.             break;
  104.         default:
  105.         case 0 :
  106.             fprintf(outfile,"^V0\n");
  107.             break;
  108.     }
  109. }
  110.  
  111.  
  112. QMS_move(x,y)
  113. int x,y;
  114. {
  115.     fprintf(outfile,"^U%05d:%05d\n", 1000 + x, QMS_YLAST + 1000 - y);
  116. /*                     ^pen up vector*/
  117. }
  118.  
  119.  
  120. QMS_vector(x2,y2)
  121. int x2,y2;
  122. {
  123.     fprintf(outfile,"^D%05d:%05d\n", 1000 + x2, QMS_YLAST + 1000 - y2);
  124. /*                     ^pen down vector*/
  125. }
  126.  
  127.  
  128. QMS_put_text(x,y,str)
  129. unsigned int x,y;
  130. char str[];
  131. {
  132. char ch;
  133.     QMS_move(x,y + QMS_VCHAR/3);
  134.     fputs("^IGE\n",outfile);
  135.     ch = *str++;
  136.     while(ch!='\0') {
  137.         if (ch=='^')
  138.             putc('^',outfile);
  139.         putc(ch,outfile);
  140.         ch = *str++;
  141.     }
  142.     fputs("\n^IGV\n",outfile);
  143.     QMS_linetype(qms_line); /* restore line type */
  144. }
  145.  
  146.  
  147. QMS_reset()
  148. {
  149.     fprintf(outfile,"^PN^-\n");
  150. /*                     ^QUIC off*/
  151. }
  152.  
  153.