home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume05 / hpgl2ps.v2 < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  58.4 KB

  1. From decwrl!sun!pitstop!sundc!seismo!uunet!munnari!basser!root Sun Dec 11 17:12:07 PST 1988
  2. Article 748 of comp.sources.misc:
  3. Path: granite!decwrl!sun!pitstop!sundc!seismo!uunet!munnari!basser!root
  4. From: damc@natmlab.dms.oz.AU (Don McCormick)
  5. Newsgroups: comp.sources.misc
  6. Subject: v05i067: HPGL to PostScript Translator, version 2
  7. Message-ID: <1659@basser.oz>
  8. Date: 7 Dec 88 06:17:16 GMT
  9. Sender: root@basser.oz
  10. Organization: CSIRO Maths and Stats & Applied Physics, Sydney, Australia
  11. Lines: 2656
  12. Approved: john@cs.su.oz.AU
  13.  
  14. Posting-number: Volume 5, Issue 67
  15. Submitted-by: Don McCormick <damc@natmlab.dms.oz.AU>
  16. Archive-name: hpgl2ps-v2
  17.  
  18. I am posting this improved version of hpgl2ps.
  19.  
  20. The filter will work on the HPGL output from the CAD packages, AUTOCAD and
  21. VERSACAD.
  22.  
  23. Don McCormick
  24.  
  25. #--------------------------- Cut here ------------------------------------------
  26. # This is a shell archive.  Remove anything before this line, then
  27. # unpack it by saving it in a file and typing "sh file".  (Files
  28. # unpacked will be owned by you and have default permissions.)
  29. #
  30. # This archive contains:
  31. # README dxy2ps.man hpgl2ps.man Makefile changesizes.c circle.c defcoords.c defn.h dxy2ps.c dxycom.c end_draw.c getval.c hpgl2ps.c hpglcom.c linesize.c linetype.c manualfeed.c plotdot.c plotinit.c plotps.c ps_macros.c rectangle.c textps.c viewport.c window.c test1.dxy test1.hpgl
  32.  
  33. echo x - README
  34. cat > "README" << '//E*O*F README//'
  35. There are two filters in this package that are based on the Roland
  36. plotter command set.
  37.  
  38. 1. DXY: A simple command set that is used with all DXY plotters
  39.  
  40. 2. RD-GL: This command set is a superset of the HP (Hewlett Packard)
  41.    graphics language however it is compatable with the 7475A command
  42.    set. In fact this version of the hpgl2ps filter has been rewritten
  43.    using the 7475A command hand book.
  44.  
  45. Not all the commands of DXY or RD-GL (HPGL) are implemented (approx 95%
  46. are) and those commands that are not are skipped and a warning given.
  47. It is very easy to add to this filter if a particular unimplemented
  48. command is desired.
  49.  
  50. If you wish to implement a command go to the relevant portion in the
  51. command switch "dxycom.c" or "hpglcom.c" and call an appropriate user
  52. written procedure.  (You will need a good knowledge of writing
  53. PostScript programs). Also don't forget to put the procedure name in
  54. the Makefile.
  55.  
  56. The filters call the procedure "getopt" that is used to interpret
  57. command line options and arguments and is normally available on 4.3 bsd
  58. and Sys V Unix. For those sites running 4.1 or 4.2 it may be available
  59. as a local library and must be written into the Makefile.
  60.  
  61. IF YOU DONT HAVE GETOPT YOU WILL HAVE REWRITE THE CODE THAT INTERPRETS
  62. COMMAND LINE OPTIONS AND ARGUMENTS.
  63.  
  64. A procedure called "rint" is called in "dxycom.c" and "linetype.c"
  65. if you dont have this call in your maths library then the following
  66. C code will have to be written.
  67.  
  68. Call the following rint.c (put "rint.o" in the Makefile).
  69.  
  70. /*-----------Start rint.c------------------*/
  71.  
  72. int rint(f) double f; 
  73. {return (int)(f + ((f>0) ? 0.5 : -0.5));}
  74.  
  75. /*------------ End rint.c------------------*/
  76.  
  77. NOTE 1: The PostScript macros are written into a C procedure to allow
  78. each filter to be a single stand alone program. These macros can easily
  79. be incorporated into other filter programs.
  80.  
  81. NOTE 2: I have written some test procedures for the testing of each
  82. filter they are "test1.hpgl" for hpgl2ps and "test1.dxy" for dxy2ps.
  83.  
  84. Don McCormick.
  85.  
  86. //E*O*F README//
  87.  
  88. echo x - dxy2ps.man
  89. cat > "dxy2ps.man" << '//E*O*F dxy2ps.man//'
  90. .TH DXY2PS (1L) "25 September 1987"
  91. .SH NAME
  92. dxy2ps - A Roland DXY plot command filter to PostScript
  93. .SH SYNOPSIS
  94. \fBdxy2ps\fR
  95. [\fB-amr\fR]
  96. [\fB-l \fIline sizes\fR]
  97. [\fB-s \fIscale\fR]
  98. [\fB-x \fIoffset\fR]
  99. [\fB-y \fIoffset\fR]
  100. [\fIplotfile\fR]
  101. .SH DESCRIPTION
  102. This filter is used to convert the Roland DXY and the Roland 
  103. Graphics Language (RD-GL) (which is a superset of the Hewlet Packard
  104. Graphics Language (HP-GL)) commands to PostScript.
  105. .PP
  106. The RD-GL commands are only operated on if each command is prefixed with
  107. a "^", therfore if your plotfile only contains HP-GL or RD-GL commands
  108. use the filter \fBhpgl2ps\fR.
  109. .PP
  110. The default conditions for \fBdxy2ps\fR are:
  111. .TP
  112. .B 1.
  113. The plot translation is from ISO A3 (420mm x 297mm) to ISO A4
  114. (297mm x 210mm) on the LaserWriter.
  115. .TP
  116. .B 2.
  117. Line thicknesses are in millimeters and are for lines (pens) 1 to 9:
  118. ( 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 1.0, 1.25, 1.5 )
  119. .TP
  120. .B Note:
  121. If the plotfile is not specified then standard input is assumed.
  122. .SH ARGUMENTS
  123. .TP
  124. .B -a
  125. Draw on an A4 ISO (297mm x 210mm) sheet of paper. This will give an
  126. aproximate 1:1 translation to the LaserWriter.
  127. .TP
  128. \fB-l \fIline sizes\fR
  129. This option allows the default line sizes to be replaced with different
  130. sizes starting from line (pen) one through nine. The new sizes (real or
  131. integer) are entered in a comma seperated string (\fIline size\fR) and
  132. are in millimeters. Only the sizes entered in the string will be
  133. changed with respect to lines (pens) one to nine while nonentered line
  134. (pen) sizes will retain the default sizes.
  135. .sp
  136. In the following example only the first three sizes will be changed.
  137. .sp
  138. eg: dxy2ps -l 0.4,0.3,1 file | lpr -Plaser1
  139. .TP
  140. .B -m
  141. Enable the manual feed on the LaserWriter (cutoff time 3 minutes).
  142. .TP
  143. .B -r
  144. Rotate plot(s) through 90 degrees. (The plot is made smaller)
  145. .TP
  146. \fB-s\fI scale\fR Scale the plot from 0.1 to 3 times its original
  147. size.
  148. .TP
  149. \fB-x\fI offset\fR Place an X offset (in mm) in the plot.
  150. .TP
  151. \fB-y\fI offset\fR Place an Y offset (in mm) in the plot.
  152. .PP
  153. \fBNote:\fR Offsets are with respect to the 0, 0 (origin) of the HP-GL
  154. / RD-GL plotting commands, thus if the minimum plotting coordinates are
  155. below either the X and/or Y zero axis then a positive offset is
  156. applied.  Similarly if the minimum plot coordinates are above the X
  157. and/or Y zero axis then a negative offset is applied.
  158. .SH FILES
  159. /usr/local/bin/dxy2ps
  160. .br
  161. /usr/local/bin/hpgl2ps
  162. .SH AUTHOR
  163. Don McCormick
  164. .br
  165. CSIRO
  166. .br
  167. Division of Applied Physics
  168. .br
  169. PO 218, Lindfield, N.S.W., 2070
  170. .br
  171. Australia
  172. .SH BUGS
  173. Some of the graphics commands are unimplemented and a warning will be
  174. displayed. If this command is vital then it must be written into the code.
  175. .PP
  176. No interactive command is suported.
  177. .PP
  178. If any bugs are found notify damc@natmlab or damc@nifty or root.
  179. //E*O*F dxy2ps.man//
  180.  
  181. echo x - hpgl2ps.man
  182. cat > "hpgl2ps.man" << '//E*O*F hpgl2ps.man//'
  183. .TH HPGL2PS (1L) "25 September 1987"
  184. .SH NAME
  185. hpgl2ps - A HP (Hewlett Packard) plot command filter to PostScript
  186. .SH SYNOPSIS
  187. \fBhpgl2ps\fR
  188. [\fB-amr\fR]
  189. [\fB-l \fIline sizes\fR]
  190. [\fB-s \fIscale\fR]
  191. [\fB-x \fIoffset\fR]
  192. [\fB-y \fIoffset\fR]
  193. [\fIplotfile\fR]
  194. .SH DESCRIPTION
  195. This filter is used to convert the Hewlett Packard Graphic Language (HP-GL)
  196. 9873C plotter commands to PostScript. The HP-GL commands are a subset of the
  197. Roland plotter command set (RD-GL).
  198. .PP
  199. The default conditions for \fBhpgl2ps\fR are:
  200. .TP
  201. .B 1.
  202. The plot translation is from ISO A3 (420mm x 297mm) to ISO A4
  203. (297mm x 210mm) on the LaserWriter.
  204. .TP
  205. .B 2.
  206. Line thicknesses are in millimeters and are for lines (pens) 1 to 9:
  207. ( 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 1.0, 1.25, 1.5 )
  208. .TP
  209. .B Note:
  210. If the plotfile is not specified then standard input is assumed.
  211. .SH ARGUMENTS
  212. .TP
  213. .B -a
  214. Draw on an A4 ISO (297mm x 210mm) sheet of paper. This will give an
  215. aproximate 1:1 translation to the LaserWriter.
  216. .TP
  217. \fB-l \fIline sizes\fR
  218. This option allows the default line sizes to be replaced with different
  219. sizes starting from line (pen) one through nine. The new sizes (real or
  220. integer) are entered in a comma seperated string (\fIline size\fR) and
  221. are in millimeters. Only the sizes entered in the string will be
  222. changed with respect to lines (pens) one to nine while nonentered line
  223. (pen) sizes will retain the default sizes.
  224. .sp
  225. In the following example only the first three sizes will be changed.
  226. .sp
  227. eg: hpgl2ps -l 0.4,0.3,1 file | lpr -Plaser1
  228. .TP
  229. .B -m
  230. Enable the manual feed on the LaserWriter (cutoff time 3 minutes).
  231. .TP
  232. .B -r
  233. Rotate plot(s) through 90 degrees. (The plot is made smaller)
  234. .TP
  235. \fB-s\fI scale\fR Scale the plot from 0.1 to 3 times its original
  236. size.
  237. .TP
  238. \fB-x\fI offset\fR Place an X offset (in mm) in the plot.
  239. .TP
  240. \fB-y\fI offset\fR Place an Y offset (in mm) in the plot.
  241. .PP
  242. \fBNote:\fR Offsets are with respect to the 0, 0 (origin) of the HP-GL
  243. / RD-GL plotting commands, thus if the minimum plotting coordinates are
  244. below either the X and/or Y zero axis then a positive offset is
  245. applied.  Similarly if the minimum plot coordinates are above the X
  246. and/or Y zero axis then a negative offset is applied.
  247. .SH FILES
  248. /usr/local/bin/hpgl2ps
  249. .SH AUTHOR
  250. Don McCormick
  251. .br
  252. CSIRO
  253. .br
  254. Division of Applied Physics
  255. .br
  256. PO 218, Lindfield, N.S.W., 2070
  257. .br
  258. Australia
  259. .SH BUGS
  260. Some of the graphics commands are unimplemented and a warning will be
  261. displayed. If this command is vital then it must be written into the code.
  262. .PP
  263. No interactive command is suported.
  264. .PP
  265. If any bugs are found notify damc@natmlab or damc@nifty or root.
  266. //E*O*F hpgl2ps.man//
  267.  
  268. echo x - Makefile
  269. cat > "Makefile" << '//E*O*F Makefile//'
  270. # 1.0 dxy2ps and hpgl2ps (Copyright) D McCormick
  271. # Commercial reproduction prohibited.
  272. #
  273. FILTER1=    dxy2ps
  274. FILTER2=    hpgl2ps
  275. INSDIR=        /usr/local/bin
  276. INCLUDE=    defn.h
  277. LOCALLIB=    libroland.a
  278. AR=        ar
  279. ARFLAGS=    ru
  280. LOADLIBES=    -lm 
  281. CFLAGS=     -g
  282.  
  283. OBJ1=    dxy2ps.o
  284.  
  285. OBJ2=    hpgl2ps.o
  286.  
  287. OBJC=    changesizes.o circle.o      defcoords.o   dxycom.o\
  288.     end_draw.o    getval.o      hpglcom.o     linesize.o\
  289.     linetype.o    manualfeed.o  plotdot.o     plotinit.o\
  290.     plotps.o      ps_macros.o   rectangle.o   textps.o\
  291.     viewport.o    window.o
  292.  
  293. all:        $(FILTER1) $(FILTER2)
  294.  
  295. $(FILTER1):    $(LOCALLIB) $(OBJ1)
  296.         $(CC) $(CFLAGS) -o $@ $(OBJ1) $(LOCALLIB) $(LOADLIBES)
  297.  
  298. $(FILTER2):    $(LOCALLIB) $(OBJ2)
  299.         $(CC) $(CFLAGS) -o $@ $(OBJ2) $(LOCALLIB) $(LOADLIBES)
  300.  
  301. $(LOCALLIB):    $(OBJC)
  302.         $(AR) $(ARFLAGS) $@ $(OBJC)
  303.         ranlib $(LOCALLIB)
  304.  
  305. $(OBJC):    $(INCLUDE)
  306.  
  307. $(OBJ1):    $(INCLUDE)
  308.  
  309. $(OBJ2):    $(INCLUDE)
  310.  
  311. install:    $(FILTER1) $(FILTER2)
  312.         install -s $(FILTER1) $(INSDIR)
  313.         install -s $(FILTER2) $(INSDIR)
  314.  
  315. clean:
  316.         -rm -f *.o a.out core libroland.a
  317. //E*O*F Makefile//
  318.  
  319. echo x - changesizes.c
  320. cat > "changesizes.c" << '//E*O*F changesizes.c//'
  321. /*
  322.  * This utility will take a string of real numbers seperated by commas and
  323.  * put them in an array. 
  324.  *
  325.  * Don McCormick 
  326.  */
  327. #include "defn.h"
  328.  
  329. #define ERROR1 "Only 9 line sizes allowed"
  330. #define ERROR2 "Too many decimal points in number"
  331. #define ERROR3 "line size specification incorrect"
  332. #define ERROR4 "Max no of characters for each line size is 5"
  333.  
  334. changesizes(sizebuf)
  335. char    sizebuf[50];
  336. {
  337.     int     i;
  338.     int     j = 0;
  339.     int     k = 0;
  340.     int     DECIMAL = 0;
  341.     float   number;
  342.     char    numbuf[5];
  343.  
  344.     for (i = 0; i < 50; i++)
  345.     {
  346.     if (sizebuf[i] == ',' || sizebuf[i] == NULL)
  347.     {
  348.         if ((number = atof(numbuf)) >= 0.01 && number <= 10)
  349.         pen_size[j] = number;    /* Put number in array */
  350.         else
  351.         fprintf(stderr, "Warning: line size too large ignored \n");
  352.  
  353.         if (sizebuf[i] == NULL) return;
  354.  
  355.         if (j++ > 8)
  356.         {
  357.         fprintf(stderr, "Error: %s\n", ERROR1);
  358.         exit(1);
  359.         }
  360.         for (k = 0; k < 5; k++)
  361.         numbuf[k] = NULL;    /* Clear number buffer */
  362.  
  363.         k = 0;
  364.         DECIMAL = 0;    /* One decimal per number */
  365.  
  366.         while (sizebuf[i + 1] == ',' && sizebuf[i + 1] != NULL)
  367.         i++;        /* Get rid of extra commas */
  368.     } else
  369.     {
  370.         if ((sizebuf[i] >= '0' && sizebuf[i] <= '9')
  371.         || sizebuf[i] == '.')
  372.         {
  373.         if (sizebuf[i] == '.')
  374.         {
  375.             if (DECIMAL == 1)
  376.             {
  377.                 fprintf(stderr, "Error: %s\n", ERROR2);
  378.                 exit(1);
  379.             }
  380.             DECIMAL = 1;
  381.         }
  382.         numbuf[k] = sizebuf[i];
  383.         } else
  384.         {
  385.         fprintf(stderr, "Error: %s\n", ERROR3);
  386.         exit(1);
  387.         }
  388.         if (k++ > 5)
  389.         {
  390.         fprintf(stderr, "Error: %s\n", ERROR4);
  391.         exit(1);
  392.         }
  393.     }
  394.     }
  395. }
  396. //E*O*F changesizes.c//
  397.  
  398. echo x - circle.c
  399. cat > "circle.c" << '//E*O*F circle.c//'
  400. #include "defn.h"
  401.  
  402. circle(type)
  403. int    type;
  404. {
  405.     float    radius;
  406.     float    start_angle = 0;
  407.     float    end_angle = 360;
  408.     float    chord_angle = 0;
  409.     float    Xc, Yc;
  410.     float    percent;
  411.     float    distance;
  412.     float    length;
  413.     float    angle;
  414.  
  415.     end_draw();
  416.  
  417.     switch (type)
  418.     {
  419.     case RDGLCIRCLE:
  420.     if (SIGNED_NUMERIC)
  421.         radius = getval() * XSCALE;
  422.     if (SIGNED_NUMERIC)
  423.         chord_angle = getval();
  424.     Xc = absX;
  425.     Yc = absY;
  426.     break;
  427.  
  428.     case CIRCLE:
  429.     if (SIGNED_NUMERIC)
  430.         absX = Xc = getval() * XSCALE + XOFFSET;
  431.     if (SIGNED_NUMERIC)
  432.         absY = Yc = getval() * YSCALE + YOFFSET;
  433.     if (SIGNED_NUMERIC)
  434.         radius = getval() * XSCALE;
  435.     if (SIGNED_NUMERIC)
  436.         start_angle = getval();
  437.     if (SIGNED_NUMERIC)
  438.         end_angle = getval();
  439.     if (SIGNED_NUMERIC)
  440.         chord_angle = getval();
  441.     break;
  442.  
  443.     case RCIRCLE:
  444.     if (SIGNED_NUMERIC)
  445.         radius = getval() * XSCALE;
  446.     if (SIGNED_NUMERIC)
  447.         start_angle = getval();
  448.     if (SIGNED_NUMERIC)
  449.         end_angle = getval();
  450.     if (SIGNED_NUMERIC)
  451.         chord_angle = getval();
  452.     angle = deg2rad * (90.0 - start_angle);
  453.     Xc = absX - radius * cos(angle);
  454.     angle = deg2rad * (90.0 - start_angle);
  455.     Yc = absY + radius * sin(angle);
  456.     break;
  457.  
  458.     case CCIRCLE:
  459.     if (SIGNED_NUMERIC)
  460.        absX = getval() * XSCALE + XOFFSET;
  461.     if (SIGNED_NUMERIC)
  462.        absY = getval() * YSCALE + YOFFSET;
  463.     break;
  464.  
  465.     case ACIRCLE:
  466.     Xc = absX;
  467.     Yc = absY;
  468.     if (SIGNED_NUMERIC)
  469.         radius = getval() * XSCALE;
  470.     if (SIGNED_NUMERIC)
  471.         start_angle = getval();
  472.     if (SIGNED_NUMERIC)
  473.         end_angle = getval();
  474.     if (SIGNED_NUMERIC)
  475.         chord_angle = getval();
  476.     break;
  477.  
  478.     case SCIRCLE:
  479.     if (SIGNED_NUMERIC)
  480.         percent = getval();
  481.     if (SIGNED_NUMERIC)
  482.         distance = getval();
  483.     if (SIGNED_NUMERIC)
  484.         length = getval();
  485.     fprintf(stderr,
  486.         "Warning: segment and indication lines not available yet\n");
  487.     break;
  488.     }
  489.  
  490.     printf("%g %g %g %g %g %g Ellipse\n",
  491.         Xc, Yc, radius, radius, start_angle, end_angle);
  492. }
  493. //E*O*F circle.c//
  494.  
  495. echo x - defcoords.c
  496. cat > "defcoords.c" << '//E*O*F defcoords.c//'
  497. /*
  498.  *    Define Scaling plotting points.
  499.  *        P1 (P1x, P1y),  P2 (P2x, P2y)
  500.  *
  501.  *    Define User Unit mapping points.
  502.  *        U1 (U1x, U1y),  U2 (U2x, U2y)
  503.  *
  504.  *    Plotter PaperSize can be:
  505.  *        "A3" ISO (297mm by 420mm)
  506.  *        "A4" ISO (210mm by 297mm)
  507.  *        "A"  ANSI (8.5" by 11")
  508.  *        "B"  ANSI (11" by 17")
  509.  *
  510.  *    Maximum Plotting Range ( HPGL Plotter units) maxXrange, maxYrange
  511.  *
  512.  *        "A4" ISO 0-11040 by 0-7721     (274.6mm by 192.1mm)
  513.  *        "A3" ISO 0-16158 by 0-11040    (401.9mm by 274.6mm)
  514.  *        "A"  ANSI 0-10365 by 0-7962    (10.15" by 7.8")
  515.  *        "B"  ANSI 0-16640 by 0-10365    (16.3" by 10.15")
  516.  *
  517.  *      Note: will be scaled to fit on A4 LaserWriter paper.
  518.  *
  519.  *    Mode can be:    "HPGL" or "DXY"
  520.  *
  521.  * Don McCormick
  522.  */
  523.  
  524. #include "defn.h"
  525.  
  526. defcoords()
  527. {
  528.     if (strcmp(Mode, "HPGL") == 0)
  529.     {
  530.     if (strcmp(PaperSize, "A3") == 0)    /* HP-GL ISO A3 420mm * 297mm */
  531.     {
  532.         maxXrange = 16158;
  533.         maxYrange = 11040;
  534.         P2x = U2x = 15370;
  535.         P2y = U2y = 10602;
  536.         P1x = U1x = 170;
  537.         P1y = U1y = 602;
  538.     }
  539.     else                    /* HP-GL ISO A4 297mm * 210mm */
  540.     {
  541.         maxXrange = 11040;
  542.         maxYrange = 7721;
  543.         P2x = U2x = 10603;
  544.         P2y = U2y = 7721;
  545.         P1x = U1x = 603;
  546.         P1y = U1y = 521;
  547.     }
  548.     }
  549.     else
  550.     {
  551.     if (strcmp(PaperSize, "A3") == 0)    /* DXY ISO A3 420mm * 297mm */
  552.     {
  553.         maxXrange = P2x = U2x = 3800;
  554.         maxYrange = P2y = U2y = 2700;
  555.     }
  556.     else                    /* DXY ISO A4 297mm * 210mm */
  557.     {
  558.         maxXrange = P2x = U2x = 2700;
  559.         maxYrange = P2y = U2x = 1920;
  560.     }
  561.         P1x = P1y = U1x = U1y = 0.0;
  562.     }
  563. }
  564. //E*O*F defcoords.c//
  565.  
  566. echo x - defn.h
  567. cat > "defn.h" << '//E*O*F defn.h//'
  568. /*
  569.  *
  570.  *    The following definations allow for the efficient 
  571.  *    translation of DXY and RD-GL codes to PostScript code
  572.  *
  573.  */
  574.  
  575. #include <stdio.h>
  576. #include <math.h>
  577. #include <ctype.h>
  578. #include <string.h>
  579.  
  580. #define TRUE    1
  581. #define FALSE    0
  582.  
  583. #define CR    '\015'
  584. #define LF    '\012'
  585. #define SPACE    '\040'
  586.  
  587. #define SIGNED_NUMERIC  (ungetc(( ch = getc(stream)),stream) != EOF ) &&\
  588.         (((ch>='0') && (ch<='9')) || (ch=='-') || (ch=='+')\
  589.         || (ch==' ') || (ch==',') || (ch == '.'))
  590.  
  591. #define CIRCLE    21        /* DXY Circle */
  592. #define RCIRCLE 22        /* DXY Relative Circle */
  593. #define CCIRCLE 23        /* DXY Centered Circle */
  594. #define ACIRCLE 24        /* DXY Arc plus Circle */
  595. #define SCIRCLE 25        /* DXY Segment Circle */
  596. #define RDGLARCABS 26        /* RD-GL Arc Absolute */
  597. #define RDGLARCREL 27        /* RD-GL Arc Relative */
  598. #define RDGLCIRCLE 28        /* RD-GL Circle */
  599.  
  600. #define TEXT    31
  601. #define MARK    32
  602.  
  603. #define LINETYPE    41
  604. #define LINESCALE    42
  605. #define LINE_TYPE_SCALE    43
  606. /*
  607.  *    Maximum PostScript Page Coordinates (in mm)
  608.  */
  609. #define    PAGEHEIGHT    297;
  610. #define    PAGEWIDTH    210;
  611. #define PAGEMARGIN    8;        /* Margin around paper */
  612. /*
  613.  *    Files to open if any
  614.  */
  615. FILE    *stream;
  616. FILE    *fopen();
  617. /*
  618.  *    Plotting Parameters that will contain the necessary PostScript
  619.  *    commands to plot (see dxy2ps.c for the initialisation) and
  620.  *    ps_macros.c for the plotting macros).
  621.  */
  622. char    *MOVE;
  623. char    *RMOVE;
  624. char    *DRAW;
  625. char    *RDRAW;
  626. /*
  627.  *    Definition of "ch" used in SIGNED_NUMERIC
  628.  */
  629. char    ch;
  630. /*
  631.  *    Define the function getval() which returns a real number.
  632.  */
  633. float    getval();
  634. /*
  635.  *    Scaling parameters used for translation from DXY and RD-GL
  636.  *    coordinate sytem to the PostScript coordinate system which
  637.  *    has been defined in millimeters. (See above)
  638.  *
  639.  *    The procedure viewport.c allows the program to initialise
  640.  *    plotting scaling points and the user scaling points as well
  641.  *    as allowing the commands "IP" and "SC" to change them.
  642.  */
  643. float    SCALE;            /* User selected plot scale */
  644. float    XSCALE;            /* */
  645. float    YSCALE;            /* */
  646. float    XOFFSET;        /* */
  647. float    YOFFSET;        /* */
  648. float    maxXrange, maxYrange;    /* Max plotting range in plotter units */
  649. float    P1x, P1y;        /* Scaling point P1 area coords */
  650. float    P2x, P2y;        /* Scaling point P2 area coords */
  651. float    U1x, U1y;        /* User U1 area coords */
  652. float    U2x, U2y;        /* User U2 area coords */
  653. /*
  654.  *    End of line terminator (RD-GL / HP-GL)
  655.  */
  656. char    EOL;
  657. /*
  658.  *    PostScript Coordinate parameters
  659.  */
  660. float    lastXmove;
  661. float    lastYmove;
  662. float    absX;
  663. float    absY;
  664. float    xval;
  665. float    yval;
  666. float    xoffset, yoffset;
  667. /*
  668.  *    Extra parameters
  669.  */
  670. float    char_angle;
  671. float    char_height;
  672. float    char_width;
  673. float    char_space;
  674. float    char_slant;
  675.  
  676. char    *font;
  677.  
  678. char    symbol;
  679.  
  680. int    dcount;
  681. /*
  682.  *    Degree radian conversion parameter ie: deg_rad = asin(1) / 90.0;
  683.  *    ( Defined in dxy2ps.c or rdgl2ps.c )
  684.  */
  685. float    deg2rad;
  686. /*
  687.  *    Line / pen size parameter (max 9 sizes)
  688.  */
  689. float    pen_size[9];
  690. /*
  691.  *    Paper size (ie A3 or A4) and Mode (HPGL or DXY)
  692.  */
  693. char    *PaperSize;
  694. char    *Mode;
  695. /*
  696.  *    Flags
  697.  */
  698. int    LANDSCAPE;
  699. int    DRAW_FLAG;
  700. int    PLOTABS;
  701. int    PENDOWN;
  702. int    SETDOT;     /* HP-GL commands only */
  703. int    SYMBOL;        /* HP-GL commands only */
  704. int    DEBUG;
  705. int    SCALING;    /* True when SC command is detected */
  706. //E*O*F defn.h//
  707.  
  708. echo x - dxy2ps.c
  709. cat > "dxy2ps.c" << '//E*O*F dxy2ps.c//'
  710. #include    "defn.h"
  711.  
  712. #define USAGE "Usage: dxy2ps [-amr] [-l line sizes] [-s scale] [-x offset] [-y offset] [file]\n"
  713.  
  714. main(argc, argv)
  715. int     argc;
  716. char   *argv[];
  717. {
  718.     extern int optind;
  719.     extern char *optarg;
  720.  
  721.     int     op;
  722.     int     opt;
  723.     int        MANUAL_FEED = 0;            /* DEFAULT: No manual feed */
  724.  
  725.     PaperSize = "A3";
  726.     Mode = "DXY";
  727.     defcoords();            /* Set up plotter coordinates */
  728.  
  729.     plotinit();            /* Get other initialisations */
  730.  
  731.     while ((opt = getopt(argc, argv, "al:ms:x:y:r")) != EOF)
  732.     {
  733.     switch (opt)
  734.     {
  735.     case 'a':        /* DXY ISO A4 297mm * 210mm */
  736.         PaperSize = "A4";
  737.             defcoords();
  738.         break;
  739.  
  740.     case 'l':
  741.         changesizes(optarg);
  742.         break;
  743.  
  744.     case 'm':
  745.         MANUAL_FEED = 1;
  746.         break;
  747.  
  748.     case 'r':
  749.         LANDSCAPE = FALSE;
  750.         break;
  751.  
  752.     case 's':
  753.         SCALE = atof(optarg);
  754.         if (SCALE < 0.1)
  755.         SCALE = 0.1;
  756.         else
  757.         if (SCALE > 3)
  758.         SCALE = 3;
  759.         break;
  760.  
  761.     case 'x':
  762.         xoffset = atof(optarg);
  763.         break;
  764.  
  765.     case 'y':
  766.         yoffset = atof(optarg);
  767.         break;
  768.  
  769.     default:
  770.         fprintf(stderr, "%s\n", USAGE);
  771.         exit(1);
  772.     }
  773.     }
  774.     if (optind == argc)
  775.     stream = stdin;
  776.     else if ((stream = fopen(argv[optind], "r")) == NULL)
  777.     {
  778.     fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]);
  779.     exit(1);
  780.     }
  781.     ps_macros();            /* Output PostScript Macros */
  782.  
  783.     viewport(1);            /* Scale the viewport for the plot */
  784.  
  785.     printf("/%s %g Font\n", font, char_height);
  786.  
  787.     if (MANUAL_FEED)
  788.     manualfeed(1);
  789.  
  790.     while ((op = getc(stream)) != EOF)
  791.     if ((isalpha(op) > 0) || op == '^')
  792.         dxycom(op);
  793.  
  794.     end_draw();
  795.  
  796.     printf("showpage\n");
  797.  
  798.     if (MANUAL_FEED)
  799.     manualfeed(0);
  800. }
  801. //E*O*F dxy2ps.c//
  802.  
  803. echo x - dxycom.c
  804. cat > "dxycom.c" << '//E*O*F dxycom.c//'
  805. #include "defn.h"
  806.  
  807. dxycom(dxyop)
  808. char    dxyop;
  809. {
  810.     int intval;
  811.     int hpglop;
  812.  
  813.     switch (dxyop)
  814.     {
  815.     case 'H':            /* HOME */
  816.     case 'h':
  817.     break;
  818.  
  819.     case 'D':            /* DRAW */
  820.     case 'd':
  821.     plotps(DRAW);
  822.     break;
  823.  
  824.     case 'M':            /* MOVE */
  825.     case 'm':
  826.     plotps(MOVE);
  827.     break;
  828.  
  829.     case 'I':            /* RELATIVE DRAW */
  830.     case 'i':
  831.     plotps(RDRAW);
  832.     break;
  833.  
  834.     case 'R':            /* RELATIVE MOVE */
  835.     case 'r':
  836.     plotps(RMOVE);
  837.     break;
  838.  
  839.     case 'L':            /* LINE TYPE */
  840.     case 'l':
  841.     linetype(LINETYPE);
  842.     break;
  843.  
  844.     case 'B':            /* LINE SCALE */
  845.     case 'b':
  846.     linetype(LINESCALE);
  847.     break;
  848.  
  849.     case 'X':            /* AXIS */
  850.     case 'x':
  851.     {
  852.         int     p, q, r;
  853.  
  854.         p = rint(getval());
  855.         q = rint(getval());
  856.         r = rint(getval());
  857.         fprintf(stderr, "Warning %c not implemented yet\n", dxyop);
  858.     }
  859.     break;
  860.  
  861.     case 'P':            /* PRINT */
  862.     case 'p':
  863.     textps(TEXT);
  864.     break;
  865.  
  866.     case 'S':            /* ALPHA SCALE */
  867.     case 's':
  868.     {
  869.         int n;
  870.  
  871.         if (SIGNED_NUMERIC)
  872.             n = rint(getval());
  873.         else
  874.         n = 3;
  875.         char_height = (n + 1) * 0.8 * SCALE;
  876.         char_width = (n + 1) * 0.4 * SCALE;
  877.         char_space = (n + 1) * 0.2 * SCALE;
  878.     }
  879.     printf("/%s %g %g %g DefFont\n",
  880.         font, char_width, char_height, char_slant);
  881.     break;
  882.  
  883.     case 'Q':            /* ALPHA ROTATE */
  884.     case 'q':
  885.     intval = rint(getval());
  886.     switch (intval)
  887.     {
  888.     case 0:
  889.         char_angle = 0.0;
  890.         break;
  891.  
  892.     case 1:
  893.         char_angle = 90.0;
  894.         break;
  895.  
  896.     case 2:
  897.         char_angle = 180.0;
  898.         break;
  899.  
  900.     case 3:
  901.         char_angle = 270.0;
  902.         break;
  903.     }
  904.     break;
  905.  
  906.     case 'N':            /* MARK */
  907.     case 'n':
  908.     textps(MARK);
  909.     break;
  910.  
  911.     case 'J':            /* PEN CHANGE */
  912.     case 'j':
  913.     linesize();
  914.     break;
  915.  
  916.     case 'C':            /* CIRCLE */
  917.     case 'c':
  918.     circle(CIRCLE);
  919.     break;
  920.  
  921.     case 'E':            /* RELATIVE CIRCLE */
  922.     case 'e':
  923.     circle(RCIRCLE);
  924.     break;
  925.  
  926.     case 'A':            /* CIRCLE CENTER */
  927.     case 'a':
  928.     circle(CCIRCLE);
  929.     break;
  930.  
  931.     case 'G':            /* ARC + CIRCLE */
  932.     case 'g':
  933.     circle(ACIRCLE);
  934.     break;
  935.  
  936.     case 'K':            /* SEGMENT AND INDICATION LINES FOR CIRCLES */
  937.     case 'k':
  938.     circle(SCIRCLE);
  939.     break;
  940.  
  941.     case 'T':            /* HATCHING */
  942.     case 't':
  943.     rectangle();
  944.     break;
  945.  
  946.     case '^':            /* CALL HP-GL / RD-GL COMMANDS */
  947.     end_draw();
  948.     if ((hpglop = getc(stream)) != EOF)
  949.         hpglcom(hpglop);
  950.     break;
  951.  
  952.     default:
  953.     fprintf(stderr, "Warning: %c Unknown DXY command\n", dxyop);
  954.     break;
  955.     }
  956. }
  957. //E*O*F dxycom.c//
  958.  
  959. echo x - end_draw.c
  960. cat > "end_draw.c" << '//E*O*F end_draw.c//'
  961. #include "defn.h"
  962.  
  963. end_draw()
  964. {
  965.     if (DRAW_FLAG)
  966.     {
  967.     if (lastXmove == absX && lastYmove == absY)
  968.         printf("closepath\n");
  969.  
  970.     printf("stroke\n");
  971.     DRAW_FLAG = 0;
  972.     }
  973.     dcount = 0;
  974. }
  975. //E*O*F end_draw.c//
  976.  
  977. echo x - getval.c
  978. cat > "getval.c" << '//E*O*F getval.c//'
  979. /*
  980.  * Returns a real number 
  981.  */
  982.  
  983. #include "defn.h"
  984.  
  985. #define ERROR "Two or more decimal places in a number"
  986.  
  987. float
  988. getval()
  989. {
  990.     char    valbuf[10];
  991.     float   value;
  992.     int     DECIMAL = 0;
  993.     int     i;
  994.  
  995.     /* Null the value buffer "valbuf" */
  996.     for (i = 0; i < 10; i++)
  997.     valbuf[i] = NULL;
  998.  
  999.     i = 0;
  1000.     ch = getc(stream);
  1001.  
  1002. /*
  1003.  * Get Rid of seperators
  1004.  */
  1005.     while ((ch == ' ') || (ch == ','))
  1006.     ch = getc(stream);
  1007.  
  1008.     while ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-' || ch == '+')
  1009.     {
  1010.     if (ch == '.')
  1011.     {
  1012.         if (DECIMAL)
  1013.         {
  1014.         fprintf(stderr,"Error: %s\n", ERROR);
  1015.         exit(1);
  1016.         }
  1017.         DECIMAL = 1;
  1018.     }
  1019.     valbuf[i++] = ch;
  1020.     ch = getc(stream);
  1021.     }
  1022.     ungetc(ch, stream);        /* Put non numeric char back */
  1023.     value = atof (valbuf);
  1024.     return (value);
  1025. }
  1026. //E*O*F getval.c//
  1027.  
  1028. echo x - hpgl2ps.c
  1029. cat > "hpgl2ps.c" << '//E*O*F hpgl2ps.c//'
  1030. #include    "defn.h"
  1031.  
  1032. #define USAGE "Usage: hpgl2ps [-amr] [-l line sizes] [-s scale] [-x offset] [-y offset] [file]\n"
  1033.  
  1034. main(argc, argv)
  1035. int     argc ;
  1036. char   *argv[] ;
  1037. {
  1038.     extern int optind ;
  1039.     extern char *optarg ;
  1040.  
  1041.     int     op ;
  1042.     int     opt ;
  1043.     int        MANUAL_FEED = 0 ;            /* DEFAULT: No manual feed */
  1044.  
  1045.     DEBUG = FALSE ;
  1046.     SCALING = FALSE ;
  1047.     PaperSize = "A3" ;
  1048.     Mode = "HPGL" ;
  1049.     defcoords() ;
  1050.  
  1051.     plotinit() ;            /* Get other initialiasations */
  1052.  
  1053.     while ((opt = getopt(argc, argv, "Dal:ms:x:y:r")) != EOF)
  1054.     {
  1055.     switch (opt)
  1056.     {
  1057.     case 'D':
  1058.         DEBUG = TRUE ;
  1059.         break ;
  1060.  
  1061.     case 'a':        /* HP-GL ISO A4 297mm * 210mm */
  1062.         PaperSize = "A4" ;
  1063.         defcoords() ;
  1064.         break ;
  1065.  
  1066.     case 'l':
  1067.         changesizes(optarg) ;
  1068.         break ;
  1069.  
  1070.     case 'm':
  1071.         MANUAL_FEED = 1 ;
  1072.         break ;
  1073.  
  1074.     case 'r':
  1075.         LANDSCAPE = FALSE ;
  1076.         break ;
  1077.  
  1078.     case 's':
  1079.         SCALE = atof(optarg) ;
  1080.         if (SCALE < 0.1)
  1081.         SCALE = 0.1 ;
  1082.         else
  1083.         if (SCALE > 3)
  1084.         SCALE = 3 ;
  1085.         break ;
  1086.  
  1087.     case 'x':
  1088.         xoffset = atof(optarg) ;
  1089.         break ;
  1090.  
  1091.     case 'y':
  1092.         yoffset = atof(optarg) ;
  1093.         break ;
  1094.  
  1095.     default:
  1096.         fprintf(stderr, "%s\n", USAGE) ;
  1097.         exit(1) ;
  1098.     }
  1099.     }
  1100.     if (optind == argc)
  1101.     stream = stdin ;
  1102.     else if ((stream = fopen(argv[optind], "r")) == NULL)
  1103.     {
  1104.     fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]) ;
  1105.     exit(1) ;
  1106.     }
  1107.     ps_macros() ;            /* Output PostScript Macros */
  1108.  
  1109.     viewport(1) ;            /* Scale the viewport for the plot */
  1110.  
  1111.     if (MANUAL_FEED)
  1112.     manualfeed(1) ;
  1113.  
  1114.     while ((op = getc(stream)) != EOF)
  1115.     if (isalpha(op) > 0)
  1116.         hpglcom(op) ;
  1117.  
  1118.     end_draw() ;
  1119.  
  1120.     printf("showpage\n") ;
  1121.  
  1122.     if (MANUAL_FEED)
  1123.     manualfeed(0) ;
  1124. }
  1125. //E*O*F hpgl2ps.c//
  1126.  
  1127. echo x - hpglcom.c
  1128. cat > "hpglcom.c" << '//E*O*F hpglcom.c//'
  1129. /*
  1130.  * This procedure translates RD-GL (Roland DG Graphic Language) into the
  1131.  * equivalent PostScript language. 
  1132.  *
  1133.  * The RD-GL is a superset equivalent to HP-GL 
  1134.  *
  1135.  * Don McCormick 
  1136.  */
  1137.  
  1138. #include "defn.h"
  1139.  
  1140. /* The folowing defaults should be 0.5% and 1.0% for the respective  character
  1141.  * width and height, however this is too small when scaled to Postcript
  1142.  * charcter sizes.
  1143.  */
  1144. float DEFWIDTH = 0.0075 ;    /* 0.75 % of P2x - P1x for default char width */
  1145. float DEFHEIGHT = 0.015 ;    /* 1.5 % of P2y - P1y for default char height */
  1146.  
  1147. /*
  1148.  * Note the 1.4 multiplier allows for an approx conversion
  1149.  * between the plotter char size and what would be expected
  1150.  * on the Laser printer.
  1151.  */
  1152. float PSmult = 1.4 ;
  1153.  
  1154. hpglcom(op1)
  1155. char    op1 ;
  1156. {
  1157.     char    op2 ;
  1158.     int     arg ;
  1159.  
  1160.     PSmult *= SCALE ;
  1161.  
  1162.     switch (op1)
  1163.     {
  1164.     case 'A':
  1165.     case 'a':
  1166.     op2 = getc(stream) ;
  1167.     switch (op2)
  1168.     {
  1169.     case 'A':        /* (AA) Arc Absolute */
  1170.     case 'a':
  1171.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1172.         ungetc(arg, stream) ;
  1173.         fprintf(stderr, "Warning: Arc absolute not implemented yet\n") ;
  1174.         break ;
  1175.  
  1176.     case 'P':        /* (AP) Automatic Pen Lift (not implemented) */
  1177.     case 'p':
  1178.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1179.         ungetc(arg, stream) ;
  1180.         break ;
  1181.  
  1182.     case 'R':        /* (AR) Arc Relative */
  1183.     case 'r':
  1184.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1185.         ungetc(arg, stream) ;
  1186.         fprintf(stderr, "Warning: Arc relative not implemented yet\n") ;
  1187.         break ;
  1188.  
  1189.     default:
  1190.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n\n", op1, op2) ;
  1191.     }
  1192.     break ;
  1193.  
  1194.     case 'C':
  1195.     case 'c':
  1196.     op2 = getc(stream) ;
  1197.     switch (op2)
  1198.     {
  1199.     case 'A':        /* (CA) Alternate Character Set (Not Used) */
  1200.     case 'a':
  1201.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1202.         ungetc(arg, stream) ;
  1203.         fprintf(stderr, "Warning: Alt character set not implemented yet\n") ;
  1204.         break ;
  1205.  
  1206.     case 'I':        /* (CI) Circle */
  1207.     case 'i':
  1208.         circle(RDGLCIRCLE) ;
  1209.         break ;
  1210.  
  1211.     case 'P':        /* (CP) Character Plot */
  1212.     case 'p':
  1213.         {
  1214.         float   xspace, yspace ;
  1215.  
  1216.         xspace = getval() * XSCALE * (char_width + char_space) ;
  1217.         yspace = getval() * YSCALE * (char_width + char_space) ;
  1218.         end_draw() ;
  1219.         printf("    %g mm %g mm %s\n", xspace, yspace, RMOVE) ;
  1220.         }
  1221.         break ;
  1222.  
  1223.     case 'S':        /* (CS) Standard Character Set */
  1224.     case 's':
  1225.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1226.         ungetc(arg, stream) ;
  1227.         break ;
  1228.  
  1229.     default:
  1230.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1231.     }
  1232.     break ;
  1233.  
  1234.     case 'D':
  1235.     case 'd':
  1236.     op2 = getc(stream) ;
  1237.     switch (op2)
  1238.     {
  1239.     case 'C':        /* (DC) Digitize Clear (Not Used) */
  1240.     case 'c':
  1241.         break ;
  1242.  
  1243.     case 'F':        /* (DF) Default */
  1244.     case 'f':
  1245.         SETDOT = FALSE ;
  1246.         PENDOWN = FALSE ;
  1247.         SYMBOL = 0 ;
  1248.         EOL = '\003' ;
  1249.         char_angle = 0 ;
  1250.         char_slant = 0 ;
  1251.         char_width = DEFWIDTH * (P2x - P1x) * XSCALE * PSmult ;
  1252.         char_height = DEFHEIGHT * (P2y - P1y) * YSCALE * PSmult ;
  1253.         char_space = char_width * (1/.67 - 1) ;
  1254.         printf("/%s %g %g %g DefFont\n",
  1255.         font, char_width, char_height, char_slant) ;
  1256.         break ;
  1257.  
  1258.     case 'I':        /* (DI) Absolute Direction */
  1259.     case 'i':
  1260.         {
  1261.         float   run, rise ;
  1262.  
  1263.         if (SIGNED_NUMERIC)
  1264.         {
  1265.             run = getval() * XSCALE ;
  1266.             rise = getval() * YSCALE ;
  1267.             char_angle = atan2(rise, run) / deg2rad ;
  1268.         }
  1269.         else
  1270.             char_angle = 0 ;
  1271.         }
  1272.         break ;
  1273.  
  1274.     case 'P':        /* (DP) Digitize Point (Not Used) */
  1275.     case 'p':
  1276.         break ;
  1277.  
  1278.     case 'R':        /* (DR) Relative Direction */
  1279.     case 'r':
  1280.         {
  1281.         float   run, rise ;
  1282.  
  1283.         if (SIGNED_NUMERIC)
  1284.         {
  1285.             run = getval() * XSCALE ;
  1286.             rise = getval() * YSCALE ;
  1287.             char_angle += atan2(rise, run) / deg2rad ;
  1288.         }
  1289.         else
  1290.             char_angle = 0 ;
  1291.         }
  1292.         break ;
  1293.  
  1294.     case 'T':        /* (DT) Define Label Terminator */
  1295.     case 't':
  1296.         if ((arg = getc(stream)) != EOF)
  1297.         EOL = arg ;    /* End of label terminator */
  1298.         break ;
  1299.  
  1300.     default:
  1301.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1302.     }
  1303.     break ;
  1304.  
  1305.     case 'E':
  1306.     case 'e':
  1307.     op2 = getc(stream) ;
  1308.     switch (op2)
  1309.     {
  1310.     case 'A':        /* (EA) Edge Rectangle Absolute */
  1311.     case 'a':
  1312.         break ;
  1313.  
  1314.     case 'R':        /* (ER) Edge Rectangle Relative */
  1315.     case 'r':
  1316.         break ;
  1317.  
  1318.     case 'W':        /* (EW) Edge Wedge */
  1319.     case 'w':
  1320.         break ;
  1321.  
  1322.     default:
  1323.         fprintf(stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2) ;
  1324.     }
  1325.     break ;
  1326.  
  1327.     case 'F':
  1328.     case 'f':
  1329.     op2 = getc(stream) ;
  1330.     switch (op2)
  1331.     {
  1332.     case 'T':        /* (FT) Fill Type */
  1333.     case 't':
  1334.         fprintf(stderr, "Warning: Fill type not implemented yet\n") ;
  1335.         break ;
  1336.  
  1337.     default:
  1338.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1339.     }
  1340.     break ;
  1341.  
  1342.     case 'I':
  1343.     case 'i':
  1344.     op2 = getc(stream) ;
  1345.     switch (op2)
  1346.     {
  1347.     case 'M':        /* (IM) Input Mask (Not Used) */
  1348.     case 'm':
  1349.         break ;
  1350.  
  1351.     case 'N':        /* (IN) Initialize */
  1352.     case 'n':
  1353.         defcoords() ;
  1354.         SETDOT = FALSE ;
  1355.         PENDOWN = FALSE ;
  1356.         SYMBOL = 0 ;
  1357.         EOL = '\003' ;
  1358.         char_angle = 0 ;
  1359.         char_slant = 0 ;
  1360.         char_width = DEFWIDTH * (P2x - P1x) * XSCALE * PSmult ;
  1361.         char_height = DEFHEIGHT * (P2y - P1y) * YSCALE * PSmult ;
  1362.         char_space = char_width * (1/0.67 - 1) ;
  1363.         printf("/%s %g %g %g DefFont\n",
  1364.         font, char_width, char_height, char_slant) ;
  1365.         break ;
  1366.  
  1367.     case 'P':        /* (IP) Input P1 and P2 */
  1368.     case 'p':
  1369.         if (SIGNED_NUMERIC)
  1370.         {
  1371.         P1x = getval() ;
  1372.             if (SIGNED_NUMERIC)
  1373.             P1y = getval() ;
  1374.         else
  1375.         {
  1376.             fprintf(stderr,"Error expecting P1y from IP instruction\n") ;
  1377.             defcoords() ;        /* Set default coordinates */
  1378.             break ;
  1379.         }
  1380.         }
  1381.         else
  1382.         {
  1383.         defcoords() ;        /* Set default coordinates */
  1384.         break ;
  1385.         }
  1386.  
  1387.         if (SIGNED_NUMERIC)
  1388.         {
  1389.         P2x= getval() ;
  1390.             if (SIGNED_NUMERIC)
  1391.             P2y = getval() ;
  1392.         else
  1393.         {
  1394.             fprintf(stderr,"Error expecting P2y from IP instruction\n") ;
  1395.             defcoords() ;        /* Set default coordinates */
  1396.             break ;
  1397.         }
  1398.         }
  1399.         else
  1400.         {
  1401.         P2x += P1x ;            /* P2 tracks P1 */
  1402.         P2y += P1y ;            /* P2 tracks P1 */
  1403.         }
  1404.         viewport(0) ;
  1405.         break ;
  1406.  
  1407.     case 'W':        /* (IW) Input Window */
  1408.     case 'w':
  1409.         window() ;
  1410.         break ;
  1411.  
  1412.     default:
  1413.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1414.     }
  1415.     break ;
  1416.  
  1417.     case 'L':
  1418.     case 'l':
  1419.     op2 = getc(stream) ;
  1420.     switch (op2)
  1421.     {
  1422.     case 'B':        /* (LB) Label */
  1423.     case 'b':
  1424.         textps(TEXT) ;
  1425.         break ;
  1426.  
  1427.     case 'T':        /* (LT) Line Type */
  1428.     case 't':
  1429.         linetype(LINE_TYPE_SCALE) ;
  1430.         break ;
  1431.  
  1432.     default:
  1433.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1434.     }
  1435.     break ;
  1436.  
  1437.     case 'O':
  1438.     case 'o':
  1439.     op2 = getc(stream) ;
  1440.     switch (op2)
  1441.     {
  1442.     case 'A':        /* (OA) Output Actual Position */
  1443.     case 'a':
  1444.         break ;
  1445.  
  1446.     case 'C':        /* (OC) Output Commanded Position */
  1447.     case 'c':
  1448.         break ;
  1449.  
  1450.     case 'D':        /* (OD) Output Digitise */
  1451.     case 'd':
  1452.         break ;
  1453.  
  1454.     case 'E':        /* (OD) Output Error */
  1455.     case 'e':
  1456.         break ;
  1457.  
  1458.     case 'P':        /* (OP) Output P1 and P2 */
  1459.     case 'p':
  1460.         break ;
  1461.  
  1462.     case 'S':        /* (OS) Output Status */
  1463.     case 's':
  1464.         break ;
  1465.  
  1466.     case 'W':        /* (OW) Output Window */
  1467.     case 'w':
  1468.         break ;
  1469.  
  1470.     default:
  1471.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1472.     }
  1473.     break ;
  1474.  
  1475.     case 'P':
  1476.     case 'p':
  1477.     op2 = getc(stream) ;
  1478.     switch (op2)
  1479.     {
  1480.     case 'A':        /* (PA) Plot Absolute */
  1481.     case 'a':
  1482.         PLOTABS = TRUE ;
  1483.         if (SIGNED_NUMERIC)
  1484.         if (SETDOT || SYMBOL)
  1485.             plotdot(MOVE) ;
  1486.         else if (PENDOWN)
  1487.             plotps(DRAW) ;
  1488.         else
  1489.             plotps(MOVE) ;
  1490.         break ;
  1491.  
  1492.     case 'D':        /* (PD) Pen Down */
  1493.     case 'd':
  1494.         PENDOWN = TRUE ;
  1495.         if (SIGNED_NUMERIC)
  1496.         if (SETDOT || SYMBOL)
  1497.             plotdot(MOVE) ;
  1498.         else if (PLOTABS)
  1499.             plotps(DRAW) ;
  1500.         else 
  1501.             plotps(RDRAW) ;
  1502.         break ;
  1503.  
  1504.     case 'R':        /* (PR) Plot Relative */
  1505.     case 'r':
  1506.         PLOTABS = FALSE ;
  1507.         if (SIGNED_NUMERIC)
  1508.         if (SETDOT || SYMBOL)
  1509.             plotdot(RMOVE) ;
  1510.         else if (PENDOWN)
  1511.             plotps(RDRAW) ;
  1512.         else
  1513.             plotps(RMOVE) ;
  1514.         break ;
  1515.  
  1516.     case 'T':        /* (PT) Pen Thickness */
  1517.     case 't':
  1518.         {
  1519.         float   linewidth ;
  1520.  
  1521.         linewidth = getval() * SCALE ;        /* In mm */
  1522.         printf("%g mm setlinewidth\n", linewidth) ;
  1523.         }
  1524.         break ;
  1525.  
  1526.     case 'U':        /* (PU) Pen Up */
  1527.     case 'u':
  1528.         PENDOWN = FALSE ;
  1529.         if (SIGNED_NUMERIC)
  1530.         if (SETDOT)
  1531.             plotdot(MOVE) ;
  1532.         else if (PLOTABS)
  1533.             plotps(MOVE) ;
  1534.         else
  1535.             plotps(RMOVE) ;
  1536.         break ;
  1537.  
  1538.     default:
  1539.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1540.     }
  1541.     break ;
  1542.  
  1543.     case 'R':
  1544.     case 'r':
  1545.     op2 = getc(stream) ;
  1546.     switch (op2)
  1547.     {
  1548.     case 'A':        /* (RA) Shade Rectange Absolute */
  1549.     case 'a':
  1550.         break ;
  1551.  
  1552.     case 'R':        /* (RR) Shade Rectangle Relative */
  1553.     case 'r':
  1554.         break ;
  1555.  
  1556.     default:
  1557.         fprintf(stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2) ;
  1558.     }
  1559.     break ;
  1560.  
  1561.     case 'S':
  1562.     case 's':
  1563.     op2 = getc(stream) ;
  1564.     switch (op2)
  1565.     {
  1566.     case 'A':        /* (SA) Select Alternate Set (Not Used) */
  1567.     case 'a':
  1568.         break ;
  1569.  
  1570.     case 'C':        /* (SC) Scale */
  1571.     case 'c':
  1572.         if (SIGNED_NUMERIC)
  1573.         U1x = getval() ;
  1574.         else            /* Turn Scaling off */
  1575.         {
  1576.         SCALING = FALSE ;
  1577.         break ;
  1578.         }
  1579.  
  1580.         if (SIGNED_NUMERIC)
  1581.         U2x = getval() ;
  1582.         else
  1583.         {
  1584.         fprintf(stderr,"Error expecting U2x from SC instruction\n") ;
  1585.         SCALING = FALSE ;
  1586.         defcoords() ;        /* Set up default conditions */
  1587.         break ;
  1588.         }
  1589.         if (SIGNED_NUMERIC)
  1590.         U1y = getval() ;
  1591.         else
  1592.         {
  1593.         fprintf(stderr,"Error expecting U1y from SC instruction\n") ;
  1594.         SCALING = FALSE ;
  1595.         defcoords() ;        /* Set up default conditions */
  1596.         break ;
  1597.         }
  1598.         if (SIGNED_NUMERIC)
  1599.         {
  1600.         U2y = getval() ;
  1601.             SCALING = TRUE ;
  1602.         }
  1603.         else
  1604.         {
  1605.         fprintf(stderr,"Error expecting U2y from SC instruction\n") ;
  1606.         SCALING = FALSE ;
  1607.         defcoords() ;        /* Set up default conditions */
  1608.         break ;
  1609.         }
  1610.         viewport(0) ;
  1611.         break ;
  1612.  
  1613.     case 'I':        /* (SI) Absolute Character Size */
  1614.     case 'i':
  1615.         if (SIGNED_NUMERIC)
  1616.         {
  1617.         char_width = getval() * 10 * PSmult ;    /* In mm */
  1618.         char_height = getval() * 10 * PSmult ;    /* In mm */
  1619.         char_width *= 11040 / maxXrange ; /* Scale to A4 paper */
  1620.         char_height *= 7721 / maxYrange ; /* Scale to A4 paper */
  1621.         } else
  1622.         {
  1623.         if (((arg = getc(stream)) == ' ;') || isalpha(arg) != 0)
  1624.         {
  1625.             ungetc(arg, stream) ;
  1626.             if (strcmp(PaperSize, "A4") == 0)
  1627.             {
  1628.                 char_width = 1.87 * PSmult ;
  1629.                 char_height = 2.69 * PSmult ;
  1630.             char_width *= 11040 / maxXrange ;
  1631.             char_height *= 7721 / maxYrange ;
  1632.             }
  1633.             else
  1634.             {
  1635.                 char_width = 2.85 * PSmult ;
  1636.                 char_height = 3.75 * PSmult ;
  1637.             char_width *= 11040 / maxXrange ; /* Scale to A4 paper */
  1638.             char_height *= 7721 / maxYrange ; /* Scale to A4 paper */
  1639.             }
  1640.         }
  1641.         }
  1642.         char_space = char_width * (1/.67 - 1) ;
  1643.         printf("/%s %g %g %g DefFont\n",
  1644.         font, char_width, char_height, char_slant) ;
  1645.         break ;
  1646.  
  1647.     case 'L':        /* (SL) Character Slant */
  1648.     case 'l':
  1649.         if (SIGNED_NUMERIC)
  1650.         char_slant = char_height * getval() ;
  1651.         else
  1652.         char_slant = 0 ;
  1653.  
  1654.         char_space = char_width * (1/.67 - 1) ;
  1655.         printf("/%s %g %g %g DefFont\n",
  1656.         font, char_width, char_height, char_slant) ;
  1657.         break ;
  1658.  
  1659.     case 'M':        /* (SM) Symbol Mode */
  1660.     case 'm':
  1661.         if ((arg = getc(stream)) != EOF && arg != ' ;' && isgraph(arg) > 0)
  1662.         {
  1663.          symbol = arg ;
  1664.          SYMBOL = 1 ;
  1665.         }
  1666.         else
  1667.         SYMBOL = 0 ;
  1668.         break ;
  1669.  
  1670.     case 'P':        /* (SP) Pen Select */
  1671.     case 'p':
  1672.         linesize() ;
  1673.         break ;
  1674.  
  1675.     case 'R':        /* (SR) Relative Character Size */
  1676.     case 'r':
  1677.         {
  1678.         float   pwidth, pheight ;
  1679.  
  1680.         if (SIGNED_NUMERIC)
  1681.         {
  1682.             pwidth = getval() ;        /* Percent */
  1683.             pheight = getval() ;    /* Percent */
  1684.         } else
  1685.         {
  1686.             pwidth = DEFWIDTH * 100 ;
  1687.             pheight = DEFHEIGHT * 100 ;
  1688.         }
  1689.         char_width = (P2x - P1x) * XSCALE * pwidth / 100.0 * PSmult ;
  1690.         char_height = (P2y - P1y) * YSCALE * pheight / 100.0 * PSmult ;
  1691.             char_space = char_width * (1/.67 - 1) ;
  1692.         char_width *= 11040 / maxXrange ; /* Scale to A4 paper */
  1693.         char_height *= 7721 / maxYrange ; /* Scale to A4 paper */
  1694.         }
  1695.         printf("/%s %g %g %g DefFont\n",
  1696.         font, char_width, char_height, char_slant) ;
  1697.         break ;
  1698.  
  1699.     default:
  1700.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1701.     }
  1702.     break ;
  1703.  
  1704.     case 'T':
  1705.     case 't':
  1706.     op2 = getc(stream) ;
  1707.     switch (op2)
  1708.     {
  1709.     case 'L':        /* (TL) Tick Length */
  1710.     case 'l':
  1711.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1712.         ungetc(arg, stream) ;
  1713.         fprintf(stderr, "Warning: Tick length not implemented yet\n") ;
  1714.         break ;
  1715.  
  1716.     default:
  1717.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1718.     }
  1719.     break ;
  1720.  
  1721.     case 'U':
  1722.     case 'u':
  1723.     op2 = getc(stream) ;
  1724.     switch (op2)
  1725.     {
  1726.     case 'C':        /* (UC) User Defined Character */
  1727.     case 'c':
  1728.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1729.         ungetc(arg, stream) ;
  1730.         fprintf(stderr, "Warning: User defined character not implemented yet\n") ;
  1731.         break ;
  1732.  
  1733.     default:
  1734.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1735.     }
  1736.     break ;
  1737.  
  1738.     case 'V':
  1739.     case 'v':
  1740.     op2 = getc(stream) ;
  1741.     switch (op2)
  1742.     {
  1743.     case 'S':        /* (VS) Velocity Select */
  1744.     case 's':
  1745.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1746.         ungetc(arg, stream) ;
  1747.         break ;
  1748.  
  1749.     default:
  1750.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1751.     }
  1752.     break ;
  1753.  
  1754.     case 'W':
  1755.     case 'w':
  1756.     op2 = getc(stream) ;
  1757.     switch (op2)
  1758.     {
  1759.     case 'G':        /* (WS) Shade Wedge */
  1760.     case 'g':
  1761.         break ;
  1762.  
  1763.     default:
  1764.         fprintf(stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2) ;
  1765.     }
  1766.     break ;
  1767.  
  1768.     case 'X':
  1769.     case 'x':
  1770.     op2 = getc(stream) ;
  1771.     switch (op2)
  1772.     {
  1773.     case 'T':        /* (XT) X Tick */
  1774.     case 't':
  1775.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1776.         ungetc(arg, stream) ;
  1777.         fprintf(stderr, "Warning: X tick not implemented yet\n") ;
  1778.         break ;
  1779.  
  1780.     default:
  1781.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1782.     }
  1783.     break ;
  1784.  
  1785.     case 'Y':
  1786.     case 'y':
  1787.     op2 = getc(stream) ;
  1788.     switch (op2)
  1789.     {
  1790.     case 'T':        /* (YT) Y Tick */
  1791.     case 't':
  1792.         while (((arg = getc(stream)) != EOF) && isalpha(arg) == 0) ;
  1793.         ungetc(arg, stream) ;
  1794.         fprintf(stderr, "Warning: Y tick not implemented yet\n") ;
  1795.         break ;
  1796.  
  1797.     default:
  1798.         fprintf(stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2) ;
  1799.     }
  1800.     break ;
  1801.  
  1802.     default:
  1803.     fprintf(stderr, "Warning: %c Unknown HP-GL First Op Command\n", op1) ;
  1804.     break ;
  1805.     }
  1806. }
  1807. //E*O*F hpglcom.c//
  1808.  
  1809. echo x - linesize.c
  1810. cat > "linesize.c" << '//E*O*F linesize.c//'
  1811. #include "defn.h"
  1812.  
  1813. linesize()
  1814. {
  1815.     int        ipen = 0;
  1816.     float    linewidth;
  1817.  
  1818.    if (SIGNED_NUMERIC)
  1819.     ipen = getval() - 1;
  1820.  
  1821.    if (ipen < 0 || ipen > 8)
  1822.     ipen = 0;
  1823.  
  1824.     linewidth = pen_size[ipen] * SCALE;        /* In mm */
  1825.     printf("%g mm setlinewidth\n", linewidth);
  1826. }
  1827. //E*O*F linesize.c//
  1828.  
  1829. echo x - linetype.c
  1830. cat > "linetype.c" << '//E*O*F linetype.c//'
  1831. /*
  1832.  * Sets the line type and the scaling of the line pattern 
  1833.  *
  1834.  * Don McCormick CSIRO Division of Applied Physics National Measurements
  1835.  * Laboritory Bradfield Road Lindfield 2018 N.S.W. 
  1836.  *
  1837.  * NOTE: default length for a line pattern is approx 6.5 mm on A4 size paper. 
  1838.  */
  1839. #include "defn.h"
  1840.  
  1841. float   linescale;
  1842. int     linestyle;
  1843.  
  1844. linetype(line)
  1845. int     line;
  1846. {
  1847.     float   down1, down2;
  1848.     float   up1, up2;
  1849.     float   diagonal;
  1850.  
  1851.     end_draw();
  1852.  
  1853.     if (line == LINE_TYPE_SCALE)            /* HP-GL only */
  1854.     {
  1855.     if (SIGNED_NUMERIC)
  1856.     {
  1857.         if ((linestyle = rint(getval())) > 6)
  1858.         linestyle = 6;
  1859.         else if (linestyle < -6)
  1860.         linestyle = -6;
  1861.     }
  1862.     else
  1863.     {
  1864.         SETDOT = FALSE;
  1865.         printf("[] 0 setdash\n");
  1866.         return;
  1867.     }
  1868.  
  1869.     diagonal = pow((P2x - P1x),2.0) + pow((P2y - P1y),2.0);
  1870.     diagonal = pow(diagonal,0.5);
  1871.     if (SIGNED_NUMERIC)
  1872.         linescale = getval() * 0.01 * diagonal * XSCALE * 0.2;
  1873.     else
  1874.         linescale = 0.015 * diagonal * XSCALE * 0.2;
  1875.     } else
  1876.     if (line == LINESCALE)    /* DXY commands only */
  1877.     {
  1878.     if (SIGNED_NUMERIC)
  1879.         linescale = getval() / 80 * SCALE;
  1880.     else
  1881.         return;
  1882.     } else
  1883.     if (line == LINETYPE)    /* DXY commands only */
  1884.     {
  1885.     if (SIGNED_NUMERIC)
  1886.     {
  1887.         if ((linestyle = rint(getval())) > 5)
  1888.         linestyle = 5;
  1889.         else if (linestyle < -5)
  1890.         linestyle = -5;
  1891.     }
  1892.     else
  1893.         return;
  1894.     } else
  1895.     {
  1896.     fprintf(stderr, "Error: Unknown line flag in linetype.c\n");
  1897.     exit(1);
  1898.     }
  1899.     /*
  1900.      * select a line style/type and scale/pitch 
  1901.      */
  1902.     switch (linestyle)
  1903.     {
  1904.     case 6:
  1905.     down1 = 2.0;
  1906.     up1 = up2 = 1.5;
  1907.     down2 = 1.5;
  1908.     break;
  1909.  
  1910.     case 5:
  1911.     down1 = 3.0;
  1912.     up1 = up2 = 1.0;
  1913.     down2 = 1.5;
  1914.     break;
  1915.  
  1916.     case 4:
  1917.     down1 = 4.0;
  1918.     up1 = up2 = 0.75;
  1919.     down2 = 1.0;
  1920.     break;
  1921.  
  1922.     case 3:
  1923.     down1 = 5.0;
  1924.     up1 = up2 = 1.0;
  1925.     down2 = 0.5;
  1926.     break;
  1927.  
  1928.     case 2:
  1929.     down1 = 5.5;
  1930.     up1 = 1.0;
  1931.     up2 = down2 = 0.0;
  1932.     break;
  1933.  
  1934.     case 1:
  1935.     down1 = 5.0;
  1936.     up1 = 1.5;
  1937.     up2 = down2 = 0.0;
  1938.     break;
  1939.  
  1940.     case -1:
  1941.     down1 = 1.5;
  1942.     up1 = 3.5;
  1943.     down2 = 1.5;
  1944.     up2 = 0.0;
  1945.     break;
  1946.  
  1947.     case -2:
  1948.     down1 = 2.0;
  1949.     up1 = 2.5;
  1950.     down2 = 2.0;
  1951.     up2 = 0.0;
  1952.     break;
  1953.  
  1954.     case -3:
  1955.     down1 = 2.5;
  1956.     up1 = up2 = 1.75;
  1957.     down2 = 0.5;
  1958.     break;
  1959.  
  1960.     case -4:
  1961.     down1 = 2.5;
  1962.     up1 = up2 = 1.5;
  1963.     down2 = 1.5;
  1964.     break;
  1965.  
  1966.     case -5:
  1967.     down1 = down2 = 2.0;
  1968.     up1 = up2 = 1.25;
  1969.     break;
  1970.  
  1971.     case -6:
  1972.     down1 = down2 = 1.75;
  1973.     up1 = up2 = 1.5;
  1974.     break;
  1975.     }
  1976.     if (linestyle == 0)
  1977.     {
  1978.     SETDOT = TRUE;        /* For HP-GL only */
  1979.     printf("[] 0 setdash\n");    /* For DXY commands */
  1980.     } else
  1981.     {
  1982.     SETDOT = FALSE;        /* For HP-GL only */
  1983.     if (linescale <= 0) linescale = SCALE;
  1984.     down1 *= linescale;
  1985.     up2 *= linescale;
  1986.     up1 *= linescale;
  1987.     down2 *= linescale;
  1988.     printf("[%g mm %g mm %g mm %g mm] 0 setdash\n",
  1989.            down1, up1, down2, up2);
  1990.     }
  1991. }
  1992. //E*O*F linetype.c//
  1993.  
  1994. echo x - manualfeed.c
  1995. cat > "manualfeed.c" << '//E*O*F manualfeed.c//'
  1996. /*
  1997.  *    A procedure to allow the user to use the manual feed on
  1998.  *    the LaserWriter.
  1999.  *    The default wait before timeout is 3 minutes however this
  2000.  *    is easily changed.
  2001.  *
  2002.  *    argument: 1.   Enable manual feed.
  2003.  *          0.   Disable manual feed.
  2004.  *
  2005.  *    Don McCormick
  2006.  */
  2007. manualfeed(arg)
  2008. int     arg;
  2009. {
  2010.     if (arg == 1)
  2011.     {
  2012.     printf("statusdict /manualfeed true put\n");
  2013.     printf("statusdict /manualfeedtimeout 180 put\n");    /* 3 minute wait */
  2014.     } else
  2015.     printf("statusdict /manualfeed false put\n");
  2016.  
  2017.     printf("usertime 5000 add\n");
  2018.     printf("{dup usertime lt {pop exit} if} loop\n");
  2019. }
  2020. //E*O*F manualfeed.c//
  2021.  
  2022. echo x - plotdot.c
  2023. cat > "plotdot.c" << '//E*O*F plotdot.c//'
  2024. /*
  2025.  * Plot a dot or symbol on the paper 
  2026.  *
  2027.  * This doesnot quite emulate what HPGL is suposed to do.
  2028.  *
  2029.  * A symbol should be placed at the end of each vector, however this will
  2030.  * only occur in the penup or non draw mode and not for pendown or the draw
  2031.  * mode. The main problem is due to my limited knowledge of the PostScript
  2032.  * language, it is not quite a simple matter of combining lineplot and
  2033.  * text drawing commands.
  2034.  *
  2035.  * Don McCormick
  2036.  */
  2037. #include "defn.h"
  2038.  
  2039. plotdot(type)
  2040. char   *type;
  2041. {
  2042.     end_draw();
  2043.  
  2044.     while (SIGNED_NUMERIC)
  2045.     {
  2046.     xval = getval();
  2047.     yval = getval();
  2048.     if (type == RMOVE)
  2049.     {
  2050.         absX += xval * XSCALE;
  2051.         absY += yval * YSCALE;
  2052.     } else
  2053.     if (type == MOVE)
  2054.     {
  2055.         absX = xval * XSCALE + XOFFSET;
  2056.         absY = yval * YSCALE + YOFFSET;
  2057.     } else
  2058.     {
  2059.         fprintf(stderr, "Error: expecting move command not %s\n", type);
  2060.         exit(1);
  2061.     }
  2062.  
  2063.     if (SYMBOL)
  2064.         printf("%g %g 5 %g (%c) Text\n", absX, absY, char_angle, symbol);
  2065.         else if (SETDOT)
  2066.     {
  2067.             printf("newpath\n");
  2068.             printf("  %g %g %s %g %g %s\n", absX, absY, MOVE, absX, absY, DRAW);
  2069.         printf("stroke\n");
  2070.     }
  2071.     }
  2072. }
  2073. //E*O*F plotdot.c//
  2074.  
  2075. echo x - plotinit.c
  2076. cat > "plotinit.c" << '//E*O*F plotinit.c//'
  2077. #include "defn.h"
  2078.  
  2079. plotinit()
  2080. {
  2081.     /*
  2082.      * Initialisation of PostScript plot macros 
  2083.      */
  2084.     MOVE = "M";
  2085.     RMOVE = "R";
  2086.     DRAW = "D";
  2087.     RDRAW = "I";
  2088.  
  2089.     LANDSCAPE = TRUE;        /* Display plot in Landscape mode */
  2090.  
  2091.     PLOTABS = TRUE;        /* Absolute plot coordinates */
  2092.  
  2093.     PENDOWN = FALSE;        /* Penup */
  2094.  
  2095.     SETDOT = FALSE;        /* HP-GL only for linetype = 0 */
  2096.  
  2097.     SCALE = 1;             /* Default Scale, ie 1:1 */
  2098.  
  2099.     SYMBOL = 0;            /* HP-GL only */
  2100.     /*
  2101.      *       Default line/pen sizes (in mm)
  2102.      */
  2103.     pen_size[0] = 0.1;
  2104.     pen_size[1] = 0.2;
  2105.     pen_size[2] = 0.3;
  2106.     pen_size[3] = 0.4;
  2107.     pen_size[4] = 0.5;
  2108.     pen_size[5] = 0.7;
  2109.     pen_size[6] = 1.0;
  2110.     pen_size[7] = 1.25;
  2111.     pen_size[8] = 1.5;
  2112.  
  2113.     font = "Courier";        /* Default font (mono spaced) */
  2114.  
  2115.     EOL = '\003';        /* End of line terminator default */
  2116.  
  2117.     /*
  2118.      * Default character specifications for plotter A4 paper
  2119.      */
  2120.     char_angle = 0;        /* Degrees */
  2121.     char_slant = 0;        /* tan(angle) */
  2122.     char_height = 2.7;        /* mm */
  2123.     char_space = 0.8;        /* mm */
  2124.     char_width = 1.9;        /* mm */
  2125.     /*
  2126.      * Page offsets set to zero
  2127.      */
  2128.     xoffset = yoffset = 0;
  2129.     /*
  2130.      * Define degree to radian parameter
  2131.      */
  2132.     deg2rad = asin(1.0) / 90.0;
  2133. }
  2134. //E*O*F plotinit.c//
  2135.  
  2136. echo x - plotps.c
  2137. cat > "plotps.c" << '//E*O*F plotps.c//'
  2138. #include "defn.h"
  2139.  
  2140. #define MAXDRAWPOINTS    1000
  2141.  
  2142. plotps(type)
  2143. char   *type;
  2144. {
  2145.     if (type == MOVE || type == RMOVE)
  2146.     {
  2147.     while (SIGNED_NUMERIC)
  2148.     {
  2149.         if (type == MOVE)
  2150.         {
  2151.         end_draw();
  2152.         absX = lastXmove = getval() * XSCALE + XOFFSET;
  2153.         absY = lastYmove = getval() * YSCALE + YOFFSET;
  2154.         } else
  2155.         if (type == RMOVE)
  2156.         {
  2157.         end_draw();
  2158.         lastXmove = absX += getval() * XSCALE;
  2159.         lastYmove = absY += getval() * YSCALE;
  2160.         }
  2161.     }
  2162.     }
  2163.     else            /* Must be a DRAW or RDRAW */
  2164.     {
  2165.     while (SIGNED_NUMERIC)
  2166.     {
  2167.         if (dcount++ >= MAXDRAWPOINTS)
  2168.         {
  2169.         end_draw();
  2170.         printf("newpath\n");
  2171.         printf("  %g %g %s\n", absX, absY, MOVE);
  2172.         DRAW_FLAG = 1;
  2173.         fprintf(stderr, "Warning exceeded %d draw points\n",
  2174.             MAXDRAWPOINTS);
  2175.         }
  2176.         xval = getval();        /* Get HPGL X value */
  2177.         yval = getval();        /* Get HPGL Y value */
  2178.         if (!DRAW_FLAG)
  2179.         {
  2180.         printf("newpath\n");
  2181.         printf("  %g %g %s\n", absX, absY, MOVE);
  2182.         DRAW_FLAG = 1;
  2183.         }
  2184.         if (type == RDRAW)
  2185.         {
  2186.         float rxval, ryval;
  2187.  
  2188.         rxval = xval * XSCALE;
  2189.         ryval = yval * YSCALE;
  2190.         absX += rxval;
  2191.         absY += ryval;
  2192.         printf("  %g %g %s\n", rxval, ryval, RDRAW);
  2193.         } else
  2194.         if (type == DRAW)
  2195.         {
  2196.         absX = xval * XSCALE + XOFFSET;
  2197.         absY = yval * YSCALE + YOFFSET;
  2198.         printf("  %g %g %s\n", absX, absY, DRAW);
  2199.         } else
  2200.         {
  2201.         fprintf(stderr, "Error: expecting draw command not %s\n", type);
  2202.         exit(1);
  2203.         }
  2204.     }
  2205.     }
  2206. }
  2207. //E*O*F plotps.c//
  2208.  
  2209. echo x - ps_macros.c
  2210. cat > "ps_macros.c" << '//E*O*F ps_macros.c//'
  2211. ps_macros()
  2212. {
  2213.     printf("%%! PS-Adobe-1.0: For Apple LaserWriter\n");
  2214.     printf("%% default font is 10 pt. Helvetica\n");
  2215.     printf("/basefont {/Helvetica findfont 10 scalefont setfont} def\n");
  2216.  
  2217.     printf("/mm {72.27 mul 25.4 div} def\n");    /* Specify millimeters */
  2218.  
  2219.     printf("/M\n");                /* Move macro */
  2220.     printf("{\n");
  2221.     printf("    /Ymove exch def\n");
  2222.     printf("    /Xmove exch def\n");
  2223.     printf("    Xmove mm Ymove mm moveto\n");
  2224.     printf("} def\n");
  2225.  
  2226.     printf("/R\n");                /* Relative move macro */
  2227.     printf("{\n");
  2228.     printf("    /Yrmove exch def\n");
  2229.     printf("    /Xrmove exch def\n");
  2230.     printf("    Xrmove mm Yrmove mm rmoveto\n");
  2231.     printf("} def\n");
  2232.  
  2233.     printf("/D\n");                /* Draw macro */
  2234.     printf("{\n");
  2235.     printf("    /Ydraw exch def\n");
  2236.     printf("    /Xdraw exch def\n");
  2237.     printf("    Xdraw mm Ydraw mm lineto\n");
  2238.     printf("} def\n");
  2239.  
  2240.     printf("/I\n");                /* Relative draw  macro */
  2241.     printf("{\n");
  2242.     printf("    /Yrdraw exch def\n");
  2243.     printf("    /Xrdraw exch def\n");
  2244.     printf("    Xrdraw mm Yrdraw mm rlineto\n");
  2245.     printf("} def\n");
  2246.     /*
  2247.      *        Procedure to change font and size of font
  2248.      *        ---->   font size Font    <----
  2249.      */
  2250.     printf("/Font\n");
  2251.     printf("{\n");
  2252.     printf("    /Height exch def\n");
  2253.     printf("    /FontName exch def\n");
  2254.     printf("    FontName findfont Height mm scalefont setfont\n");
  2255.     printf("} def\n");
  2256.     /*
  2257.      *        Procedure to change font, width, slant and height
  2258.      *        ---->   font width height slant DefFont    <----
  2259.      *
  2260.      *    Note: slant = height * tan( slant_angle )
  2261.      */
  2262.     printf("/DefFont\n");
  2263.     printf("{\n");
  2264.     printf("    /Slant exch def\n");
  2265.     printf("    /Height exch def\n");
  2266.     printf("    /Width exch def\n");
  2267.     printf("    /FontName exch def\n");
  2268.     printf("    FontName findfont [ Width mm 0 Slant mm Height mm 0 0] makefont setfont\n");
  2269.     printf("} def\n");
  2270.     /*
  2271.      *        General Text Layout Procedure
  2272.      *        ---->   x y pos_num angle (text) Text    <----
  2273.      */
  2274.     printf("/Text\n");
  2275.     printf("{\n");
  2276.     printf("    /String exch def\n");
  2277.     printf("    /Angle exch def\n");
  2278.     printf("    /Position exch def\n");
  2279.     printf("    /Ymove exch def\n");
  2280.     printf("    /Xmove exch def\n");
  2281.     printf("    Position 1 lt {/hpf 0 def /lpf 0 def} if\n");
  2282.     printf("    Position 1 eq {/hpf 0 def /lpf 0 def} if\n");
  2283.     printf("    Position 2 eq {/hpf 0 def /lpf 0.5 def} if\n");
  2284.     printf("    Position 3 eq {/hpf 0 def /lpf 1 def} if\n");
  2285.     printf("    Position 4 eq {/hpf 0.5 def /lpf 0 def} if\n");
  2286.     printf("    Position 5 eq {/hpf 0.5 def /lpf 0.5 def} if\n");
  2287.     printf("    Position 6 eq {/hpf 0.5 def /lpf 1 def} if\n");
  2288.     printf("    Position 7 eq {/hpf 1 def /lpf 0 def} if\n");
  2289.     printf("    Position 8 eq {/hpf 1 def /lpf 0.5 def} if\n");
  2290.     printf("    Position 9 eq {/hpf 1 def /lpf 1 def} if\n");
  2291.     printf("    Position 9 gt {/hpf 1 def /lpf 1 def} if\n");
  2292.     printf("    /StrLen String stringwidth pop lpf mul def\n");
  2293.     printf("    /StrHt Height mm hpf mul def\n");
  2294.     printf("    /Xdiff StrHt Angle sin mul StrLen Angle cos mul sub def\n");
  2295.     printf("    /Ydiff StrHt Angle cos mul StrLen Angle sin mul add def\n");
  2296.     printf("    Xmove mm Xdiff add Ymove mm Ydiff sub moveto\n");
  2297.     printf("    gsave\n");
  2298.     printf("        Angle rotate\n");
  2299.     printf("        String show\n");
  2300.     printf("    grestore\n");
  2301.     printf("    /PosterOnly 0 def\n");
  2302.     printf("} def\n");
  2303.     /*
  2304.      *        Ellipse and Circle procedure.
  2305.      *  ---->   xcen ycen xrad yrad start_angle end_angle Ellipse   <----
  2306.      */
  2307.     printf("/EllipseDict 8 dict def\n");
  2308.     printf("EllipseDict /mtrx matrix put\n");
  2309.     printf("/Ellipse \n");
  2310.     printf("{   EllipseDict begin\n");
  2311.     printf("    /endangle exch def\n");
  2312.     printf("    /startangle exch def\n");
  2313.     printf("    /yradius exch def\n");
  2314.     printf("    /xradius exch def\n");
  2315.     printf("    /ycenter exch def\n");
  2316.     printf("    /xcenter exch def\n");
  2317.     printf("    /savematrix mtrx currentmatrix def\n");
  2318.     printf("    xcenter mm ycenter mm translate\n");
  2319.     printf("    xradius mm yradius mm div 1 scale\n");
  2320.     printf("    newpath\n");
  2321.     printf("        0 0 xradius mm startangle endangle arc\n");
  2322.     printf("    stroke\n");
  2323.     printf("    savematrix setmatrix\n");
  2324.     printf("    end\n");
  2325.     printf("} def\n");
  2326.  
  2327.     printf("basefont\n");        /* Set the default font */
  2328.     printf("1 setlinecap\n");        /* Use round caps */
  2329.     printf("1 setlinejoin\n");        /* Use round joins */
  2330.     printf("3 setmiterlimit\n");    /* Bevel small angle miters */
  2331. }
  2332. //E*O*F ps_macros.c//
  2333.  
  2334. echo x - rectangle.c
  2335. cat > "rectangle.c" << '//E*O*F rectangle.c//'
  2336. #include "defn.h"
  2337.  
  2338. rectangle()
  2339. {
  2340.     int        hatch;
  2341.     float    width, height;
  2342.     float    hatch_spacing;
  2343.     float    hatch_angle;
  2344.     
  2345.     if (SIGNED_NUMERIC)
  2346.     hatch = getval();
  2347.     if (SIGNED_NUMERIC)
  2348.     width = getval() * XSCALE;
  2349.     if (SIGNED_NUMERIC)
  2350.     height = getval() * YSCALE;
  2351.     if (SIGNED_NUMERIC)
  2352.     hatch_spacing = getval() * XSCALE;
  2353.     if (SIGNED_NUMERIC)
  2354.     hatch_angle = getval();
  2355.  
  2356.     end_draw();
  2357.     printf("%g %g M\n", xval, yval);
  2358.     printf("%g 0 I\n", width);
  2359.     printf("0 %g I\n", height);
  2360.     printf("-%g 0 I\n", width);
  2361.     printf("closepath stroke\n");
  2362.     if (hatch != 2)
  2363.         fprintf(stderr, "Warning: Cross hatching not implemented yet\n");
  2364. }
  2365. //E*O*F rectangle.c//
  2366.  
  2367. echo x - textps.c
  2368. cat > "textps.c" << '//E*O*F textps.c//'
  2369. #include "defn.h"
  2370.  
  2371. #define MAXBUFSIZE 100
  2372.  
  2373. textps(type)
  2374. int     type;
  2375. {
  2376.     int     chr;
  2377.     char    buffer[MAXBUFSIZE];
  2378.     int        intval;
  2379.     int     i;
  2380.  
  2381.     end_draw();
  2382.  
  2383.     if (type == TEXT)
  2384.     {
  2385.     for (i = 0 ; i < MAXBUFSIZE; i++)    /* Clear buffer */
  2386.         buffer[i] = NULL;
  2387.  
  2388.     i = 0;                    /* Reset buffer counter */
  2389.  
  2390. /*
  2391.  * For a mono spaced font (Emulates the plotter)
  2392.  */
  2393.     while (((chr = getc(stream)) != EOF)
  2394.             && chr != CR && chr != LF && chr != EOL)
  2395.     {
  2396.         buffer[i++] = chr;
  2397.         if (chr == '(' || chr == ')')
  2398.             printf("%g %g 1 %g (\\%c) Text\n", absX, absY, char_angle, chr);
  2399.         else
  2400.             printf("%g %g 1 %g (%c) Text\n", absX, absY, char_angle, chr);
  2401.          absX += (char_width) * cos(char_angle * deg2rad);
  2402.          absY += (char_width) * sin(char_angle * deg2rad);
  2403.     }
  2404.     }
  2405.     else            /* Must be a MARK */
  2406.     {
  2407.     int     symb_num;
  2408.     char    *symbol;
  2409.  
  2410.     if (SIGNED_NUMERIC)
  2411.         symb_num = getval();
  2412.     else
  2413.     {
  2414.         fprintf(stderr,
  2415.             "Error: expecting a symbol number not %c (%d)",
  2416.             symb_num, symb_num);
  2417.         exit(1);
  2418.     }
  2419.     intval = (int)(getval() + 0.5);
  2420.     switch (intval)
  2421.     {
  2422.     case 0:
  2423.         strcpy(symbol, "*");
  2424.         break;
  2425.  
  2426.     case 1:
  2427.         strcpy(symbol, "+");
  2428.         break;
  2429.  
  2430.     case 2:
  2431.         strcpy(symbol, "#");
  2432.         break;
  2433.  
  2434.     case 3:
  2435.         strcpy(symbol, "@");
  2436.         break;
  2437.  
  2438.     case 4:
  2439.         strcpy(symbol, "%");
  2440.         break;
  2441.  
  2442.     case 5:
  2443.         strcpy(symbol, "|");
  2444.         break;
  2445.  
  2446.     case 6:
  2447.         strcpy(symbol, "=");
  2448.         break;
  2449.  
  2450.     case 7:
  2451.         strcpy(symbol, "&");
  2452.         break;
  2453.  
  2454.     case 9:
  2455.         strcpy(symbol, "O");
  2456.         break;
  2457.  
  2458.     case 10:
  2459.         strcpy(symbol, "0");
  2460.         break;
  2461.  
  2462.     case 11:
  2463.         strcpy(symbol, "Y");
  2464.         break;
  2465.  
  2466.     case 12:
  2467.         strcpy(symbol, "X");
  2468.         break;
  2469.  
  2470.     case 13:
  2471.         strcpy(symbol, "Z");
  2472.         break;
  2473.  
  2474.     case 14:
  2475.         strcpy(symbol, "S");
  2476.         break;
  2477.  
  2478.     case 15:
  2479.         strcpy(symbol, "Q");
  2480.         break;
  2481.  
  2482.     default:
  2483.         fprintf(stderr, "Warning symbol number is %d\n", symb_num);
  2484.         strcpy(symbol, "*");
  2485.         break;
  2486.     }
  2487.     printf("%g %g 5 %g (%s) Text\n", absX, absY, char_angle, symbol);
  2488.     }
  2489. }
  2490. //E*O*F textps.c//
  2491.  
  2492. echo x - viewport.c
  2493. cat > "viewport.c" << '//E*O*F viewport.c//'
  2494. /*
  2495.  * This procedure sets up the variables for the translation of plotter
  2496.  * coordinates to PostScript coordinates.
  2497.  *
  2498.  * Don McCormick
  2499.  */
  2500. #include "defn.h"
  2501.  
  2502. static float psxmax, psymax ;        /* Sizes scaled to the viewport */
  2503. static float DefXScale, DefYScale ;    /* Default scales */
  2504.  
  2505. viewport(status)
  2506. int status ;
  2507. {
  2508.     float margin ;            /* Non printing area around paper */
  2509.     float pagewidth, pageheight ;    /* Maximum paper sizes */
  2510.  
  2511.     pagewidth = PAGEWIDTH ;
  2512.     pageheight = PAGEHEIGHT ;
  2513.     margin = PAGEMARGIN ;
  2514.  
  2515.     if (status == 1)            /* Set up initial conditions */
  2516.     {
  2517.     if (LANDSCAPE)        /* Create a positive Y axis */
  2518.     {
  2519.         printf("90 rotate\n") ;
  2520.         printf("0 -%g mm translate\n", pagewidth) ;
  2521.         psymax = pagewidth - margin * 2 ;
  2522.         psxmax = psymax * (maxXrange) / (maxYrange) ;
  2523.         XOFFSET = xoffset + (pageheight - psxmax) / 2.0 ;
  2524.         YOFFSET = yoffset + (margin) ;
  2525.     }
  2526.         else
  2527.         {
  2528.         psxmax = pagewidth - margin * 2 ;
  2529.         psymax = psxmax * (maxYrange) / (maxXrange) ;
  2530.         XOFFSET = yoffset + (margin) ;
  2531.         YOFFSET = yoffset + (pageheight - psymax) / 2.0 ;
  2532.         }
  2533.     printf("/%s %g Font\n", font, char_height) ;
  2534.     DefXScale = psxmax / (maxXrange) * SCALE ;
  2535.     DefYScale = psymax / (maxYrange) * SCALE ;
  2536.     }
  2537.  
  2538.     if (SCALING)
  2539.     {
  2540.         XSCALE = DefXScale * (P2x - P1x) / (U2x - U1x) ;
  2541.         YSCALE = DefYScale * (P2y - P1y) / (U2y - U1y) ;
  2542.     }
  2543.     else
  2544.     {
  2545.     XSCALE = DefXScale ;
  2546.     YSCALE = DefYScale ;
  2547.     }
  2548.     if (DEBUG)
  2549.     {
  2550.     fprintf(stderr,"Xscale= %g, Yscale = %g\n", XSCALE, YSCALE) ;
  2551.     fprintf(stderr,"Xoffset= %g, Yoffset = %g\n", XOFFSET, YOFFSET) ;
  2552.     }
  2553. }
  2554. //E*O*F viewport.c//
  2555.  
  2556. echo x - window.c
  2557. cat > "window.c" << '//E*O*F window.c//'
  2558. /*
  2559.  * The input window provides a means of restricting the plotting outside
  2560.  * the specific rectangular area defined.
  2561.  * Used with the "IW" command (HPGL).
  2562.  *
  2563.  * NOTE There is no checking if the HPGL code is correct.
  2564.  */
  2565.  
  2566. #include "defn.h"
  2567.  
  2568. window()
  2569. {
  2570.     float XloLeft, YloLeft;
  2571.     float XupRight, YupRight;
  2572.  
  2573.     if (SIGNED_NUMERIC)
  2574.     XloLeft = getval() * XSCALE + XOFFSET;
  2575.     else
  2576.     {
  2577.     printf("newpath\n");
  2578.     printf("    0 0 moveto\n");
  2579.     printf("    300 mm 0 lineto\n");
  2580.     printf("    300 mm 210 mm lineto\n");
  2581.     printf("    0 210 mm lineto\n");
  2582.     printf("closepath clip\n");
  2583.     return;
  2584.     }
  2585.  
  2586.     if (SIGNED_NUMERIC)
  2587.     YloLeft = getval() * YSCALE + YOFFSET;
  2588.     if (SIGNED_NUMERIC)
  2589.     XupRight = getval() * XSCALE + XOFFSET;
  2590.     if (SIGNED_NUMERIC)
  2591.     YupRight = getval() * YSCALE + YOFFSET;
  2592.  
  2593.     printf("newpath\n");
  2594.     printf("    %g %g %s\n", XloLeft, YloLeft, MOVE);
  2595.     printf("    %g %g %s\n", XupRight, YloLeft, DRAW);
  2596.     printf("    %g %g %s\n", XupRight, YupRight, DRAW);
  2597.     printf("    %g %g %s\n", XloLeft, YupRight, DRAW);
  2598.     printf("closepath clip\n");
  2599. }
  2600. //E*O*F window.c//
  2601.  
  2602. echo x - test1.dxy
  2603. cat > "test1.dxy" << '//E*O*F test1.dxy//'
  2604. J1
  2605. M 1000, 1000
  2606. N 2
  2607. I 100, 0, -200,0, 100, 0, 0,100,0, -200
  2608. P Hi There
  2609. C 1000, 1000, 500, 0, 250
  2610. M 2000,1000
  2611. I 100, 0, -200,0, 100, 0, 0,100,0, -200
  2612. L 2
  2613. J5
  2614. C 2000, 1000, 500, 250, 0
  2615. J3
  2616. M 0 0
  2617. I 3800,0,0,2700,-3800,0,0,-2700
  2618. M 500,2000
  2619. ^SL1;S50PDXY-880
  2620. ^SL;S3
  2621.  
  2622. //E*O*F test1.dxy//
  2623.  
  2624. echo x - test1.hpgl
  2625. cat > "test1.hpgl" << '//E*O*F test1.hpgl//'
  2626. IN;LT;
  2627. PU1000,1000;PD2000,1000,2000,2000,1000,2000,1000,1000;
  2628. PR-100,0,0,-100,100,0,0,100;
  2629. PU;PA0,0;PD10800,0,10800,7680,0,7680,0,0;PU;
  2630. LT6,2;PA;PU4000,1400;PD;PR4000,0;
  2631. LT5,2;PA;PU4000,1300;PD;PR4000,0;
  2632. LT4,2;PA;PU4000,1200;PD;PR4000,0;
  2633. LT3,2;PA;PU4000,1100;PD;PR4000,0;
  2634. LT2,2;PA;PU4000,1000;PD;PR4000,0;
  2635. LT1,2;PA;PU4000,900;PD;PR4000,0;
  2636. LT0;PA;PU4000,800;PD;PR4000,0;
  2637. LT-1,2;PA;PU4000,700;PD;PR4000,0;
  2638. LT-2,2;PA;PU4000,600;PD;PR4000,0;
  2639. LT-3,2;PA;PU4000,500;PD;PR4000,0;
  2640. LT-4,2;PA;PU4000,400;PD;PR4000,0;
  2641. LT-5,2;PA;PU4000,300;PD;PR4000,0;
  2642. LT-6,2;PA;PU4000,200;PD;PR4000,0;
  2643. PU;PA8000,3000;
  2644. SI.15,.3;
  2645. DI;LB  --   0deg --
  2646. DI1,1;LB  --  45deg --
  2647. DI0,1;LB  --  90deg --
  2648. DI-1,1;LB  -- 135deg --
  2649. DI-1,0;LB  -- 180deg --
  2650. DI-1,-1;LB  -- 225deg --
  2651. DI0,-1;LB  -- 270deg --
  2652. DI1,-1;LB  -- 315deg --
  2653. PA500,4000;
  2654. SI;
  2655. DI;SL1;LB SLANT of 45deg
  2656. PA500,3600;
  2657. SL-1;LB SLANT of -45deg
  2658. PA500,6000;
  2659. SL;SR;LB Size is relative
  2660. PA1000,5500;
  2661. SI;LB DEFAULT sizes
  2662. PA500,5000;
  2663. SI.4,.6;LBLARGE size (w=4mm, h=6mm)
  2664. LT;        PA 9000,1000;CI500,20;CI400;CI300;CI200,1;CI100;CI50;
  2665. IN;SM+;PA9000,1000,10000,1000;SM%;PR0,500,0,-1000;
  2666. SM;
  2667. //E*O*F test1.hpgl//
  2668.  
  2669. exit 0
  2670.  
  2671.  
  2672.