home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / hpgl2ps.lzh / hpgl2ps
Text File  |  1990-06-14  |  100KB  |  3,757 lines

  1. ---- Cut Here and unpack ----
  2. #!/bin/sh
  3. # shar:    Shell Archiver  (v1.22)
  4. #
  5. #    Run the following text with /bin/sh to create:
  6. #      Makefile
  7. #      README
  8. #      arcps.c
  9. #      changesizes.c
  10. #      circle.c
  11. #      defn.h
  12. #      dxy2ps.c
  13. #      dxy2ps.man
  14. #      dxycom.c
  15. #      end_draw.c
  16. #      getval.c
  17. #      hpgl2ps.c
  18. #      hpgl2ps.man
  19. #      hpglcom.c
  20. #      linesize.c
  21. #      linetype.c
  22. #      manualfeed.c
  23. #      plotcoords.c
  24. #      plotdot.c
  25. #      plotinit.c
  26. #      plotps.c
  27. #      printtest
  28. #      ps_macros.c
  29. #      rectangle.c
  30. #      test.hpgl
  31. #      test1.dxy
  32. #      test1.hpgl
  33. #      test3.hpgl
  34. #      textps.c
  35. #      tick.c
  36. #      userdefchar.c
  37. #      viewport.c
  38. #
  39. echo "x - extracting Makefile (Text)"
  40. sed 's/^X//' << 'SHAR_EOF' > Makefile &&
  41. X# 1.0 dxy2ps and hpgl2ps (Copyright) D McCormick
  42. X# Commercial reproduction prohibited.
  43. X#
  44. X# Obtained from UUCP Newsgroup comp.sources.unix
  45. X# Spring 1988
  46. X#
  47. X# Modified by Gordon Jacobs, July 1989
  48. X#
  49. X# Modified by Michael L. Brown, June, 1990
  50. X#
  51. XSHELL=        /bin/sh
  52. XFILTER1=    dxy2ps
  53. XFILTER2=    hpgl2ps
  54. XINCLUDE=    defn.h
  55. XLOCALLIB=    libroland.a
  56. XAR=        ar
  57. XARFLAGS=    ru
  58. X
  59. X#
  60. X# If compiling on a SystemV computer, add -DSYSV to the CFLAGS, or if
  61. X# your computer doesn't have rint() as part of math.h.  A simple rint()
  62. X# is defined in linetype.c
  63. X#
  64. X# Add -DNOTIMP to list the non-implemented HPGL commands.
  65. X#
  66. X# Add -DDEBUG for listing the HPGL implemented commands and the PostScript
  67. X# output that goes with it.
  68. X#
  69. XCFLAGS=     -O -DNOTIMP -DSYSV
  70. X
  71. X# For a Sun computer, activate the following two lines by replacing the
  72. X# names sake above.
  73. X#
  74. XINSDIR=        /usr/local/bin
  75. XLOADLIBES=    -lm 
  76. X
  77. X# For a Mips computer, activate the following two lines by replacing the
  78. X# names sake above.
  79. X#
  80. X# INSDIR=        /home/zion1/jac/bin
  81. X# LOADLIBES=    -lm
  82. X# CFLAGS=       -O0 -signed
  83. X
  84. X# For BSD computers that have ranlib, remove the # before the ranlib below.
  85. X# For systems that don't have ranlib, put a # in the first column before ranlib.
  86. X
  87. XOBJ1=    dxy2ps.o
  88. X
  89. XOBJ2=    hpgl2ps.o
  90. X
  91. XOBJC=    arcps.o       changesizes.o circle.o      dxycom.o      end_draw.o\
  92. X    getval.o      hpglcom.o     linesize.o    linetype.o\
  93. X    manualfeed.o  plotdot.o     plotinit.o    plotps.o\
  94. X    userdefchar.o ps_macros.o   rectangle.o   textps.o\
  95. X    viewport.o    plotcoords.o  tick.o
  96. X
  97. Xall:        $(FILTER1) $(FILTER2) install
  98. X
  99. X$(FILTER1):    $(LOCALLIB) $(OBJ1)
  100. X        $(CC) $(CFLAGS) -o $@ $(OBJ1) $(LOCALLIB) $(LOADLIBES)
  101. X
  102. X$(FILTER2):    $(OBJC) $(OBJ2)
  103. X        $(CC) $(CFLAGS) -o $@ $(OBJ2) $(OBJC) $(LOADLIBES)
  104. X
  105. X$(LOCALLIB):    $(OBJC)
  106. X        $(AR) $(ARFLAGS) $@ $(OBJC)
  107. X#        ranlib $(LOCALLIB)
  108. X
  109. X$(OBJC):    $(INCLUDE)
  110. X
  111. X$(OBJ1):    $(INCLUDE)
  112. X
  113. X$(OBJ2):    $(INCLUDE)
  114. X
  115. Xinstall:    install1 install2
  116. X
  117. Xinstall1:    $(FILTER1)
  118. X        install -s $(FILTER1) $(INSDIR)
  119. X
  120. Xinstall2:    $(FILTER2)
  121. X        install -s $(FILTER2) $(INSDIR)
  122. X
  123. Xclean:
  124. X        rm -f *.o a.out core libroland.a
  125. X
  126. SHAR_EOF
  127. chmod 0644 Makefile || echo "restore of Makefile fails"
  128. set `wc -c Makefile`;Sum=$1
  129. if test "$Sum" != "2020"
  130. then echo original size 2020, current size $Sum;fi
  131. echo "x - extracting README (Text)"
  132. sed 's/^X//' << 'SHAR_EOF' > README &&
  133. X/*  hpgl2ps.pckd  - enhanced version */
  134. X/*  hpgl2ps.ucb   - Further enhanced version */
  135. X/*  hpgl2ps.mlb   - Enhanced even further */
  136. X
  137. XThere are two filters in this package which are based on the Roland
  138. Xplotter command set.
  139. X
  140. X1. DXY: A simple command set which is used with all DXY plotters
  141. X
  142. X2. RD-GL: This command set is a superset of the HP (Hewlet Packard)
  143. X   graphics language.
  144. X
  145. XNot all the commands of DXY or RD-GL (HPGL) are implemented (approx 95%
  146. Xare) and those commands that are not are skipped and a warning given.
  147. XIt is very easy to add to this filter if a particular unimplemented
  148. Xcommand is desired.
  149. X
  150. XIf you wish to implement a command go to the relevant portion in the
  151. Xcommand switch "dxycom.c" or "hpglcom.c" and call an appropriate user
  152. Xwritten procedure.  (You will need a good knowledge of writing
  153. XPostScript programs)
  154. X
  155. XThe filters use the the procedure "getopt" which is used to interpret
  156. Xcommand line options and arguments and is normally available on 4.3 bsd
  157. Xand Sys V Unix. For those sites running 4.1 or 4.2 it may be available
  158. Xas a local library and must be written into the Makefile.
  159. X
  160. XIF YOU DONT HAVE GETOPT YOU WILL HAVE REWRITE THE CODE THAT INTERPRETS
  161. XCOMMAND LINE OPTIONS AND ARGUMENTS.
  162. X
  163. XNOTE 1: The method of writing text is not fully compatible with HPGL
  164. Xand will be changed at a later date.
  165. X
  166. XNOTE 2: The PostScript macros are written into a C procedure to allow
  167. Xeach filter to be a single stand alone program. These macros can easily
  168. Xbe incorporated into other filter programs.
  169. X
  170. XI have written some test procedures for the testing of each filter they
  171. Xare "test1.hpgl" for hpgl2ps and "test1.dxy" for dxy2ps.
  172. X
  173. XDon McCormick.
  174. X
  175. X-------------------------
  176. XNotes on first enhancement:
  177. X
  178. XSupport for user defined characters added by 
  179. XGerald William Kokodyniak B.A.Sc. M.A.Sc.
  180. XUniversity of Toronto, Department of Mechanical Engineering
  181. X
  182. X-------------------------
  183. XNotes on second enhancement:
  184. XSupport for Scaling, tickmarks, and better user defined characters
  185. Xadded by Gordon Jacobs, (Ph.D., since we're into titles above)
  186. XUniversity of California, Berkeley in July 1989.
  187. X
  188. XMods were made ONLY for the hpgl2ps program and are not guaranteed
  189. Xto work for dxy2ps.  HP-GL code from the Tektronix DSA 602
  190. XDigitizing Signal Analyzer (scope) were used as a test.
  191. XLaserwriter output was compared directly with plots from a
  192. XHP7550A plotter reading the same HP-GL file.
  193. X
  194. XSupport for scaling was added.
  195. XThe Scaling involves re-setting the coordinate
  196. Xsystem by re-calculating the XSCALE and YSCALE numbers and adding
  197. Xan offset to the origin.  The offset had to be added to all files
  198. Xthat make use of the scaling parameters.
  199. X
  200. XTick marks were added with tick.c.  Uses relative draw commands
  201. Xto make the tick marks and adds two global variables which are
  202. Xthe tick length as a percentage of the overall dimensions.
  203. X
  204. XThe parser was changed.  The SIGNED_NUMERIC macro recognized a comma
  205. Xas a valid character which does not make sense.  The HP-GL code from
  206. Xthe DSA 602 often contains a mnemonic followed by a comma, but with
  207. Xno parameters.  This is valid code although most sources will not
  208. Xplace a comma unless optional parameters actually follow.  The comma
  209. Xwas removed as a valid SIGNED_NUMERIC character and the function
  210. Xgetval() was modified to read all trailing commas and spaces.  In this way
  211. Xthe parser works for both the standard and odd case mentioned above.
  212. X
  213. XThe user defined character routine was modified heavily.  Original
  214. Xfunction did not take into account the angle of characters.  The
  215. Xnew function reads the current angle of characters and orients
  216. Xthe user defined character in the same way.  The scaling, which was
  217. Xoriginally huge for some reason now is dynamically set to a 
  218. Xproportion of the size of regular text character.  The linewidth
  219. Xof the user defined character is arbitrarily set to 0.25mm and
  220. Xthen the restored to the previous value.  This width seems to fit
  221. Xthe "linewidth" of the characters in the postscript helvetica
  222. Xfont sized for the DSA 602 output.
  223. X
  224. XThe default paper size is changed to be 8.5 x 11 inch paper with
  225. Xcommand line options added to support all others.
  226. X
  227. XThe command line options -w and -h were added because the relative
  228. Xscaling of fonts with the "SR" HP-GL command, while implemented
  229. Xcorrectly, gives much smaller character sizes than the HP7550A plotter.
  230. XThe defaults were set empirically to match plotter output.
  231. X
  232. XThe sizes in viewport.c were modified to get correct positioning
  233. Xon the 8.5 x 11 paper when compared to a plot directly from the
  234. XHP7550A on the same type of paper.
  235. X
  236. XThe textps() routine was modified to move the position pointers to
  237. Xthe end of a string when a string is drawn.  This was commented out
  238. Xin the code that I received, but needed to be restored for the
  239. Xuser defined character to be in the correct place.  The results
  240. Xmatch the HP plotter for the same code.
  241. X
  242. X----------------------
  243. XNotes on third enhancement:
  244. XAll changes pertain to HPGL stuff only.
  245. X
  246. XThe removale of the comma in the SIGNED_NUMBER function was incorrect.
  247. XThe problem was that some programs put out a comma after the PD command
  248. Xand before the set of numbers.  This problem was fixed when the parser
  249. Xwas enhanced.  For some reason the change mentioned above in the previous
  250. Xenhancement didn't work when the comma was followed by valid numbers.
  251. X
  252. XThe hpglcom.c parser was changed so that:
  253. X     1. All of the known HPGL commands (1984 HP 7580 plotter manual) have
  254. X    been added to the parser list, making it easier for someone to
  255. X    implement a command.
  256. X     2. All unknown commands had the data following that command, up until
  257. X    the next command, dumped.  This cleaned up the parser problem that
  258. X    I was seeing.
  259. X     3. Three new compilable options have been added:
  260. X    DEBUG:    When turned on, all PostScript output (after the macros)
  261. X        is put out on stderr, along with the HPGL commands.  This
  262. X        allows the programmer to see the input HPGL commands and
  263. X        the PostScript output.  The new AA command also puts out
  264. X        many of its computations.
  265. X    NOTIMP: Output all HGPL commands that are unknown.  If you don't
  266. X        want this list, turn off this compiler option.
  267. X    SYSV:    Many AT&T System V Unix systems don't have rint().  This
  268. X        option will use the very simple one that I included.
  269. X     4. The HPGL Absolute Arc (AA) command has been implemented.  The Arc
  270. X    Relative (AR) one has not (yet).  See the new routine arcps.c for
  271. X    further comments on what was done.
  272. X
  273. XThe default line sizes have been changed.  See the man page for the complete
  274. Xlist.
  275. SHAR_EOF
  276. chmod 0644 README || echo "restore of README fails"
  277. set `wc -c README`;Sum=$1
  278. if test "$Sum" != "6466"
  279. then echo original size 6466, current size $Sum;fi
  280. echo "x - extracting arcps.c (Text)"
  281. sed 's/^X//' << 'SHAR_EOF' > arcps.c &&
  282. X/* arcps.c */
  283. X/*
  284. X * HPGL supplies the needed arc as:
  285. X *    AA xcenter,ycenter,angle,chord
  286. X *
  287. X * PostScript needs it as:
  288. X *    xcenter ycenter radius start_deg end_deg arc stroke
  289. X *
  290. X * where the drawing starting point has no relationship to the current point,
  291. X * which is set by the HPGL PA command.  The start and ending degree values
  292. X * need to be computed. PostScript arc moves counterclockwise, while arcn
  293. X * moves clockwise from start to end degree locations.
  294. X *
  295. X * A positive HPGL angle means counterclockwise arc, while negative means
  296. X * a clockwise arc (PS arcn).
  297. X *
  298. X * The radius is determined by:
  299. X *    sqrt(x*x + y*y)
  300. X *
  301. X * where x and y are the distances from the current point to the center.
  302. X *
  303. X * The starting offset angle between the current point and the arc center:
  304. X *    180/pi(atan(x/y))  [the atan returns radians]
  305. X *
  306. X * The angle quadrant needs to be determined as well, and will be an offset
  307. X * starting base angle.  The PostScript base is along the X axis, to the right.
  308. X * The angle increases its value in the counterclockwise direction.  It is
  309. X * determined by the signs of the differences between the current point
  310. X * and arc center:
  311. X *    X    Y    start arc
  312. X *    +    +       90
  313. X *    +    -        0
  314. X *    -    -      180
  315. X *    -    +      270
  316. X */
  317. X
  318. X#include "defn.h"
  319. X
  320. Xarcps(type)
  321. Xint    type;
  322. X{
  323. X    float    radius;
  324. X    float    angle = 0;
  325. X    float    start_deg = 0;
  326. X    float    end_deg = 0;
  327. X    float    offset_deg = 0;
  328. X    float    chord_angle = 0;
  329. X    float    Xc, Yc;
  330. X    float    Xdiff, Ydiff;
  331. X
  332. X    end_draw();
  333. X
  334. X    switch (type)
  335. X    {
  336. X    case ARCA:
  337. X    if (SIGNED_NUMERIC)
  338. X        lastXmove = Xc = getval() * XSCALE + offX;
  339. X    if (SIGNED_NUMERIC)
  340. X        lastYmove = Yc = getval() * YSCALE + offY;
  341. X    if (SIGNED_NUMERIC)
  342. X        angle = getval();
  343. X    if (SIGNED_NUMERIC)
  344. X        chord_angle = getval();
  345. X    if (PENDOWN)
  346. X    {
  347. X        printf("newpath\n");
  348. X        debugp((stderr,"newpath\n"));
  349. X        printf("  %g %g %s\n", absX, absY, MOVE);
  350. X        debugp((stderr,"  %g %g %s\n", absX, absY, MOVE));
  351. X    }
  352. X    Xdiff = absX - Xc;
  353. X    Ydiff = absY - Yc;
  354. X    if (Xdiff < 0 && Ydiff > 0 )
  355. X        offset_deg = 90;
  356. X    if (Xdiff < 0 && Ydiff < 0 )
  357. X        offset_deg = 180;
  358. X    if (Xdiff > 0 && Ydiff < 0 )
  359. X        offset_deg = 270;
  360. X    radius = sqrt(fabs(Xdiff*Xdiff) + fabs(Ydiff*Ydiff));
  361. X    if (Xdiff == 0 || Ydiff == 0)
  362. X    {
  363. X        if (Ydiff > 0)
  364. X        start_deg = 90;
  365. X        if (Xdiff < 0)
  366. X        start_deg = 180;
  367. X        if (Ydiff < 0)
  368. X        start_deg = 270;
  369. X    }
  370. X    else if (fabs(Xdiff) < fabs(Ydiff))
  371. X        start_deg = 180/M_PI*(fabs(atan(Xdiff/Ydiff)));
  372. X    else
  373. X        start_deg = (180/M_PI*(fabs(atan(Ydiff/Xdiff)))) + 45;
  374. X    start_deg += offset_deg;
  375. X    if (angle > 0)
  376. X        end_deg = start_deg + angle;
  377. X    else
  378. X        end_deg = start_deg - fabs(angle);
  379. X    if (end_deg >= 360)
  380. X        end_deg -= 360;
  381. X    if (end_deg < 0)
  382. X        end_deg += 360;
  383. X
  384. X    DRAW_FLAG = 1;
  385. X
  386. X    break;
  387. X
  388. X    case ARCR:
  389. X
  390. X    break;
  391. X
  392. X    default:
  393. X
  394. X    debugp((stderr,"Unknown ARC command\n"));
  395. X
  396. X    }
  397. X    if (angle < 0)
  398. X    AARC = "AAC";
  399. X    else
  400. X    AARC = "AA";
  401. X
  402. X    printf("%g %g %g %g %g %s\n",Xc,Yc,radius,start_deg,end_deg,AARC);
  403. X    debugp((stderr,"%g %g %g %g %g %s\n",Xc,Yc,radius,start_deg,end_deg,AARC));
  404. X
  405. X    debugp((stderr,"\tabsX=%g\tabsY=%g\tXc=%g\tYc=%g\n",absX,absY,Xc,Yc));
  406. X    debugp((stderr,"\tXdiff=%g\tYdiff=%g\n",Xdiff,Ydiff));
  407. X    debugp((stderr,"\tradius=%g\tstart_deg=%g\tend_deg=%g\tangle=%g\n",radius,start_deg,end_deg,angle));
  408. X}
  409. SHAR_EOF
  410. chmod 0644 arcps.c || echo "restore of arcps.c fails"
  411. set `wc -c arcps.c`;Sum=$1
  412. if test "$Sum" != "3251"
  413. then echo original size 3251, current size $Sum;fi
  414. echo "x - extracting changesizes.c (Text)"
  415. sed 's/^X//' << 'SHAR_EOF' > changesizes.c &&
  416. X/* changesizes.c
  417. X * This utility will take a string of real numbers seperated by commas and
  418. X * put them in an array. 
  419. X *
  420. X * Don McCormick 
  421. X */
  422. X#include "defn.h"
  423. X
  424. X#define ERROR1 "Only 9 line sizes allowed"
  425. X#define ERROR2 "Too many decimal points in number"
  426. X#define ERROR3 "line size specification incorrect"
  427. X#define ERROR4 "Max no of characters for each line size is 5"
  428. X
  429. Xchangesizes(sizebuf)
  430. Xchar    sizebuf[50];
  431. X{
  432. X    int     i;
  433. X    int     j = 0;
  434. X    int     k = 0;
  435. X    int     DECIMAL = 0;
  436. X    float   number;
  437. X    char    numbuf[5];
  438. X
  439. X    for (i = 0; i < 50; i++)
  440. X    {
  441. X    if (sizebuf[i] == ',' || sizebuf[i] == NULL)
  442. X    {
  443. X        if ((number = atof(numbuf)) >= 0.01 && number <= 10)
  444. X        pen_size[j] = number;    /* Put number in array */
  445. X        else
  446. X        fprintf(stderr, "Warning: line size too large ignored \n");
  447. X
  448. X        if (sizebuf[i] == NULL) return;
  449. X
  450. X        if (j++ > 8)
  451. X        {
  452. X        fprintf(stderr, "Error: %s\n", ERROR1);
  453. X        exit(1);
  454. X        }
  455. X        for (k = 0; k < 5; k++)
  456. X        numbuf[k] = NULL;    /* Clear number buffer */
  457. X
  458. X        k = 0;
  459. X        DECIMAL = 0;    /* One decimal per number */
  460. X
  461. X        while (sizebuf[i + 1] == ',' && sizebuf[i + 1] != NULL)
  462. X        i++;        /* Get rid of extra commas */
  463. X    } else
  464. X    {
  465. X        if ((sizebuf[i] >= '0' && sizebuf[i] <= '9')
  466. X        || sizebuf[i] == '.')
  467. X        {
  468. X        if (sizebuf[i] == '.')
  469. X        {
  470. X            if (DECIMAL == 1)
  471. X            {
  472. X                fprintf(stderr, "Error: %s\n", ERROR2);
  473. X                exit(1);
  474. X            }
  475. X            DECIMAL = 1;
  476. X        }
  477. X        numbuf[k] = sizebuf[i];
  478. X        } else
  479. X        {
  480. X        fprintf(stderr, "Error: %s\n", ERROR3);
  481. X        exit(1);
  482. X        }
  483. X        if (k++ > 5)
  484. X        {
  485. X        fprintf(stderr, "Error: %s\n", ERROR4);
  486. X        exit(1);
  487. X        }
  488. X    }
  489. X    }
  490. X}
  491. SHAR_EOF
  492. chmod 0644 changesizes.c || echo "restore of changesizes.c fails"
  493. set `wc -c changesizes.c`;Sum=$1
  494. if test "$Sum" != "1613"
  495. then echo original size 1613, current size $Sum;fi
  496. echo "x - extracting circle.c (Text)"
  497. sed 's/^X//' << 'SHAR_EOF' > circle.c &&
  498. X/* circle.c */
  499. X#include "defn.h"
  500. X
  501. Xcircle(type)
  502. Xint    type;
  503. X{
  504. X    float    radius;
  505. X    float    start_angle = 0;
  506. X    float    end_angle = 360;
  507. X    float    chord_angle = 0;
  508. X    float    Xc, Yc;
  509. X    float    percent;
  510. X    float    distance;
  511. X    float    length;
  512. X    float    angle;
  513. X
  514. X    end_draw();
  515. X
  516. X    switch (type)
  517. X    {
  518. X    case RDGLCIRCLE:
  519. X    if (SIGNED_NUMERIC)
  520. X        radius = getval() * XSCALE;
  521. X    if (SIGNED_NUMERIC)
  522. X        chord_angle = getval();
  523. X    Xc = absX;
  524. X    Yc = absY;
  525. X    break;
  526. X
  527. X    case CIRCLE:
  528. X    if (SIGNED_NUMERIC)
  529. X        absX = Xc = getval() * XSCALE + offX;
  530. X    if (SIGNED_NUMERIC)
  531. X        absY = Yc = getval() * YSCALE + offY;
  532. X    if (SIGNED_NUMERIC)
  533. X        radius = getval() * XSCALE;
  534. X    if (SIGNED_NUMERIC)
  535. X        start_angle = getval();
  536. X    if (SIGNED_NUMERIC)
  537. X        end_angle = getval();
  538. X    if (SIGNED_NUMERIC)
  539. X        chord_angle = getval();
  540. X    break;
  541. X
  542. X    case RCIRCLE:
  543. X    if (SIGNED_NUMERIC)
  544. X        radius = getval() * XSCALE;
  545. X    if (SIGNED_NUMERIC)
  546. X        start_angle = getval();
  547. X    if (SIGNED_NUMERIC)
  548. X        end_angle = getval();
  549. X    if (SIGNED_NUMERIC)
  550. X        chord_angle = getval();
  551. X    angle = deg_rad * (90.0 - start_angle);
  552. X    Xc = absX - radius * cos(angle);
  553. X    angle = deg_rad * (90.0 - start_angle);
  554. X    Yc = absY + radius * sin(angle);
  555. X    break;
  556. X
  557. X    case CCIRCLE:
  558. X    if (SIGNED_NUMERIC)
  559. X       absX = getval() * XSCALE;
  560. X    if (SIGNED_NUMERIC)
  561. X       absY = getval() * YSCALE;
  562. X    break;
  563. X
  564. X    case ACIRCLE:
  565. X    Xc = absX;
  566. X    Yc = absY;
  567. X    if (SIGNED_NUMERIC)
  568. X        radius = getval() * XSCALE;
  569. X    if (SIGNED_NUMERIC)
  570. X        start_angle = getval();
  571. X    if (SIGNED_NUMERIC)
  572. X        end_angle = getval();
  573. X    if (SIGNED_NUMERIC)
  574. X        chord_angle = getval();
  575. X    break;
  576. X
  577. X    case SCIRCLE:
  578. X    if (SIGNED_NUMERIC)
  579. X        percent = getval();
  580. X    if (SIGNED_NUMERIC)
  581. X        distance = getval();
  582. X    if (SIGNED_NUMERIC)
  583. X        length = getval();
  584. X    fprintf("Warning: segment and indication lines not available yet\n");
  585. X    break;
  586. X    }
  587. X
  588. X    printf("%g %g %g %g %g %g Ellipse\n",
  589. X        Xc, Yc, radius, radius, start_angle, end_angle);
  590. X}
  591. SHAR_EOF
  592. chmod 0644 circle.c || echo "restore of circle.c fails"
  593. set `wc -c circle.c`;Sum=$1
  594. if test "$Sum" != "1904"
  595. then echo original size 1904, current size $Sum;fi
  596. echo "x - extracting defn.h (Text)"
  597. sed 's/^X//' << 'SHAR_EOF' > defn.h &&
  598. X/*
  599. X *
  600. X *    The following definations allow for the efficient 
  601. X *    translation of DXY and RD-GL codes to PostScript code
  602. X *
  603. X */
  604. X
  605. X#include <stdio.h>
  606. X#include <math.h>
  607. X#include <ctype.h>
  608. X
  609. X#define CR    '\015'
  610. X#define LF    '\012'
  611. X#define SPACE    '\040'
  612. X
  613. X/* the definition below was modified by Gordon Jacobs to remove
  614. X * the validity of a comma in a Signed Numeric quantity. The
  615. X * definition below is more accurate and the comma is now removed
  616. X * after reading the digit in getval()
  617. X */
  618. X#define SIGNED_NUMERIC  (ungetc(( ch = getc(stream)),stream) != EOF ) &&\
  619. X        (((ch>='0') && (ch<='9')) || (ch=='-') || (ch=='+')\
  620. X        || (ch==' ') || (ch == '.'))
  621. X
  622. X/* The debug stuff was added to trace what is going on during the conversion
  623. X * process to PostScript.
  624. X */
  625. X
  626. X#ifdef DEBUG
  627. X#define debugp(x) {fprintf x; (void) fflush(stderr);}
  628. X#else
  629. X#define debugp(x)
  630. X#endif
  631. X
  632. X#ifdef NOTIMP
  633. X#define notimp(x) {fprintf x; (void) fflush(stderr);}
  634. X#else
  635. X#define notimp(x)
  636. X#endif
  637. X
  638. X#define CIRCLE    21        /* DXY Circle */
  639. X#define RCIRCLE 22        /* DXY Relative Circle */
  640. X#define CCIRCLE 23        /* DXY Centered Circle */
  641. X#define ACIRCLE 24        /* DXY Arc plus Circle */
  642. X#define SCIRCLE 25        /* DXY Segment Circle */
  643. X#define RDGLCIRCLE 26        /* RD-GL Circle */
  644. X#define ARCA 27            /* HPGL Absolute Arc */
  645. X#define ARCR 28            /* HPGL Relative Arc */
  646. X
  647. X#define TEXT    31
  648. X#define MARK    32
  649. X
  650. X#define LINETYPE    41
  651. X#define LINESCALE    42
  652. X#define LINE_TYPE_SCALE    43
  653. X
  654. X#define XTICK 0
  655. X#define YTICK 1
  656. X/*
  657. X *    Files to open if any
  658. X */
  659. XFILE    *stream;
  660. XFILE    *fopen();
  661. X/*
  662. X *    Plotting Parameters that will contain the necessary PostScript
  663. X *    commands to plot (see dxy2ps.c for the initialisation) and
  664. X *    ps_macros.c for the plotting macros).
  665. X */
  666. Xchar    *MOVE;
  667. Xchar    *RMOVE;
  668. Xchar    *DRAW;
  669. Xchar    *RDRAW;
  670. Xchar    *ADRAW;
  671. Xchar    *AARC;
  672. Xchar    *RARC;
  673. X/*
  674. X *    Definition of "ch" used in SIGNED_NUMERIC
  675. X */
  676. Xchar    ch;
  677. X/*
  678. X *    Define the function getval() which returns a real number.
  679. X */
  680. Xfloat    getval();
  681. X/*
  682. X *    Scaling parameters used for translation from DXY and RD-GL
  683. X *    coordinate sytem to the PostScript coordinate system which
  684. X *    has been defined in millimeters. (See above)
  685. X */
  686. Xfloat    SCALE;
  687. Xfloat    XSCALE;
  688. Xfloat    YSCALE;
  689. Xfloat    xmax, xmin;
  690. Xfloat    ymax, ymin;
  691. Xfloat   psxmax,psymax;  /* max postscript dimensions */
  692. Xfloat   tlp,tln;      /* HP-GL tick length parameters */
  693. Xfloat   FONT_H_MULT;    /* fudge factor for font height */
  694. Xfloat   FONT_W_MULT;    /* fudge factor for font width */
  695. X/*
  696. X *    End of line terminator (RD-GL / HP-GL)
  697. X */
  698. Xchar    EOL;
  699. X/*
  700. X *    PostScript Coordinate parameters
  701. X */
  702. Xfloat    lastXmove;
  703. Xfloat    lastYmove;
  704. Xfloat    absX;
  705. Xfloat    absY;
  706. Xfloat   offX,offY;   /* used for Scale command */
  707. Xfloat    xval;
  708. Xfloat    yval;
  709. Xfloat    xoffset, yoffset;
  710. X/*
  711. X *    Extra parameters
  712. X */
  713. Xfloat    char_angle;
  714. Xfloat    char_height;
  715. Xfloat    char_width;
  716. Xfloat    char_space;
  717. Xfloat    char_slant;
  718. X
  719. Xchar    *font;
  720. X
  721. Xchar    symbol;
  722. X
  723. Xint    dcount;
  724. X/*
  725. X *    Degree radian conversion parameter ie: deg_rad = asin(1) / 90.0;
  726. X *    ( Defined in dxy2ps.c or rdgl2ps.c )
  727. X */
  728. Xfloat    deg_rad;
  729. X/*
  730. X *    Line / pen size parameter (max 9 sizes)
  731. X */
  732. Xfloat    pen_size[9];
  733. Xint     pen_number;
  734. X/*
  735. X *    Paper size (ie A3 or A4) and Mode (HPGL or DXY)
  736. X */
  737. Xchar    *PaperSize;
  738. Xchar    *Mode;
  739. X/*
  740. X *    Flags
  741. X */
  742. Xint    LANDSCAPE;
  743. Xint    DRAW_FLAG;
  744. Xint    PLOTABS;
  745. Xint    PLOTARC;
  746. Xint    PENDOWN;
  747. Xint    SETDOT;     /* HP-GL commands only */
  748. Xint    SYMBOL;        /* HP-GL commands only */
  749. SHAR_EOF
  750. chmod 0644 defn.h || echo "restore of defn.h fails"
  751. set `wc -c defn.h`;Sum=$1
  752. if test "$Sum" != "3258"
  753. then echo original size 3258, current size $Sum;fi
  754. echo "x - extracting dxy2ps.c (Text)"
  755. sed 's/^X//' << 'SHAR_EOF' > dxy2ps.c &&
  756. X/* dxy2ps.c */
  757. X#include    "defn.h"
  758. X
  759. X#define USAGE "Usage: dxy2ps [-amr] [-l line sizes] [-s scale] [-x offset] [-y offset] [file]\n"
  760. X
  761. Xmain(argc, argv)
  762. Xint     argc;
  763. Xchar   *argv[];
  764. X{
  765. X    extern int optind;
  766. X    extern char *optarg;
  767. X
  768. X    int     ch;                                 /* GWKMOD */
  769. X    int     op;                                 /* GWKMOD */
  770. X    /* GWK: char    op; */
  771. X    int        MANUAL_FEED = 0;            /* DEFAULT: No manual feed */
  772. X
  773. X    PaperSize = "A3";
  774. X    Mode = "DXY";
  775. X    plotcoords();            /* Set up plotter coordinates */
  776. X
  777. X    plotinit();            /* Get other initialisations */
  778. X
  779. X    while ((ch = getopt(argc, argv, "al:ms:x:y:r")) != EOF)
  780. X    {
  781. X    switch (ch)
  782. X    {
  783. X    case 'a':        /* DXY ISO A4 297mm * 210mm */
  784. X        PaperSize = "A4";
  785. X            plotcoords();
  786. X        break;
  787. X
  788. X    case 'l':
  789. X        changesizes(optarg);
  790. X        break;
  791. X
  792. X    case 'm':
  793. X        MANUAL_FEED = 1;
  794. X        break;
  795. X
  796. X    case 'r':
  797. X        LANDSCAPE = 0;
  798. X        break;
  799. X
  800. X    case 's':
  801. X        SCALE = atof(optarg);
  802. X        if (SCALE < 0.1)
  803. X        SCALE = 0.1;
  804. X        else
  805. X        if (SCALE > 3)
  806. X        SCALE = 3;
  807. X        break;
  808. X
  809. X    case 'x':
  810. X        xoffset = atof(optarg);
  811. X        break;
  812. X
  813. X    case 'y':
  814. X        yoffset = atof(optarg);
  815. X        break;
  816. X
  817. X    default:
  818. X        fprintf(stderr, "%s\n", USAGE);
  819. X        exit(1);
  820. X    }
  821. X    }
  822. X    if (optind == argc)
  823. X    stream = stdin;
  824. X    else if ((stream = fopen(argv[optind], "r")) == NULL)
  825. X    {
  826. X    fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]);
  827. X    exit(1);
  828. X    }
  829. X    ps_macros();            /* Output PostScript Macros */
  830. X
  831. X    viewport();        /* Scale the viewport for the plot */
  832. X
  833. X    printf("/%s %g Font\n", font, char_height);
  834. X
  835. X    if (MANUAL_FEED)
  836. X    manualfeed(1);
  837. X
  838. X    while ((op = getc(stream)) != EOF)
  839. X    if ((isalpha(op) > 0) || op == '^')
  840. X        dxycom(op);
  841. X
  842. X    end_draw();
  843. X
  844. X    printf("showpage\n");
  845. X
  846. X    if (MANUAL_FEED)
  847. X    manualfeed(0);
  848. X}
  849. SHAR_EOF
  850. chmod 0644 dxy2ps.c || echo "restore of dxy2ps.c fails"
  851. set `wc -c dxy2ps.c`;Sum=$1
  852. if test "$Sum" != "1775"
  853. then echo original size 1775, current size $Sum;fi
  854. echo "x - extracting dxy2ps.man (Text)"
  855. sed 's/^X//' << 'SHAR_EOF' > dxy2ps.man &&
  856. X.TH DXY2PS (1L) "25 September 1987"
  857. X.SH NAME
  858. Xdxy2ps - A Roland DXY plot command filter to PostScript
  859. X.SH SYNOPSIS
  860. X\fBdxy2ps\fR
  861. X[\fB-amr\fR]
  862. X[\fB-l \fIline sizes\fR]
  863. X[\fB-s \fIscale\fR]
  864. X[\fB-x \fIoffset\fR]
  865. X[\fB-y \fIoffset\fR]
  866. X[\fIplotfile\fR]
  867. X.SH DESCRIPTION
  868. XThis filter is used to convert the Roland DXY and the Roland 
  869. XGraphics Language (RD-GL) (which is a superset of the Hewlet Packard
  870. XGraphics Language (HP-GL)) commands to PostScript.
  871. X.PP
  872. XThe RD-GL commands are only operated on if each command is prefixed with
  873. Xa "^", therfore if your plotfile only contains HP-GL or RD-GL commands
  874. Xuse the filter \fBhpgl2ps\fR.
  875. X.PP
  876. XThe default conditions for \fBdxy2ps\fR are:
  877. X.TP
  878. X.B 1.
  879. XThe plot translation is from ISO A3 (420mm x 297mm) to ISO A4
  880. X(297mm x 210mm) on the LaserWriter.
  881. X.TP
  882. X.B 2.
  883. XLine thicknesses are in millimeters and are for lines (pens) 1 to 9:
  884. X( 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 1.0, 1.25, 1.5 )
  885. X.TP
  886. X.B Note:
  887. XIf the plotfile is not specified then standard input is assumed.
  888. X.SH ARGUMENTS
  889. X.TP
  890. X.B -a
  891. XDraw on an A4 ISO (297mm x 210mm) sheet of paper. This will give an
  892. Xaproximate 1:1 translation to the LaserWriter.
  893. X.TP
  894. X\fB-l \fIline sizes\fR
  895. XThis option allows the default line sizes to be replaced with different
  896. Xsizes starting from line (pen) one through nine. The new sizes (real or
  897. Xinteger) are entered in a comma seperated string (\fIline size\fR) and
  898. Xare in millimeters. Only the sizes entered in the string will be
  899. Xchanged with respect to lines (pens) one to nine while nonentered line
  900. X(pen) sizes will retain the default sizes.
  901. X.sp
  902. XIn the following example only the first three sizes will be changed.
  903. X.sp
  904. Xeg: dxy2ps -l 0.4,0.3,1 file | lpr -Plaser1
  905. X.TP
  906. X.B -m
  907. XEnable the manual feed on the LaserWriter (cutoff time 3 minutes).
  908. X.TP
  909. X.B -r
  910. XRotate plot(s) through 90 degrees. (The plot is made smaller)
  911. X.TP
  912. X\fB-s\fI scale\fR Scale the plot from 0.1 to 3 times its original
  913. Xsize.
  914. X.TP
  915. X\fB-x\fI offset\fR Place an X offset (in mm) in the plot.
  916. X.TP
  917. X\fB-y\fI offset\fR Place an Y offset (in mm) in the plot.
  918. X.PP
  919. X\fBNote:\fR Offsets are with respect to the 0, 0 (origin) of the HP-GL
  920. X/ RD-GL plotting commands, thus if the minimum plotting coordinates are
  921. Xbelow either the X and/or Y zero axis then a positive offset is
  922. Xapplied.  Similarly if the minimum plot coordinates are above the X
  923. Xand/or Y zero axis then a negative offset is applied.
  924. X.SH FILES
  925. X/usr/local/bin/dxy2ps
  926. X.br
  927. X/usr/local/bin/hpgl2ps
  928. X.SH AUTHOR
  929. XDon McCormick
  930. X.br
  931. XCSIRO
  932. X.br
  933. XDivision of Applied Physics
  934. X.br
  935. XPO 218, Lindfield, N.S.W., 2070
  936. X.br
  937. XAustralia
  938. X.SH BUGS
  939. XSome of the graphics commands are unimplemented and a warning will be
  940. Xdisplayed. If this command is vital then it must be written into the code.
  941. X.PP
  942. XNo interactive command is suported.
  943. X.PP
  944. XIf any bugs are found notify damc@natmlab or damc@nifty or root.
  945. SHAR_EOF
  946. chmod 0644 dxy2ps.man || echo "restore of dxy2ps.man fails"
  947. set `wc -c dxy2ps.man`;Sum=$1
  948. if test "$Sum" != "2785"
  949. then echo original size 2785, current size $Sum;fi
  950. echo "x - extracting dxycom.c (Text)"
  951. sed 's/^X//' << 'SHAR_EOF' > dxycom.c &&
  952. X/* dxycom.c */
  953. X#include "defn.h"
  954. X
  955. Xdxycom(op)
  956. Xchar    op;
  957. X{
  958. X    int intval;
  959. X
  960. X    switch (op)
  961. X    {
  962. X    case 'H':            /* HOME */
  963. X    case 'h':
  964. X    break;
  965. X
  966. X    case 'D':            /* DRAW */
  967. X    case 'd':
  968. X    plotps(DRAW);
  969. X    break;
  970. X
  971. X    case 'M':            /* MOVE */
  972. X    case 'm':
  973. X    plotps(MOVE);
  974. X    break;
  975. X
  976. X    case 'I':            /* RELATIVE DRAW */
  977. X    case 'i':
  978. X    plotps(RDRAW);
  979. X    break;
  980. X
  981. X    case 'R':            /* RELATIVE MOVE */
  982. X    case 'r':
  983. X    plotps(RMOVE);
  984. X    break;
  985. X
  986. X    case 'L':            /* LINE TYPE */
  987. X    case 'l':
  988. X    linetype(LINETYPE);
  989. X    break;
  990. X
  991. X    case 'B':            /* LINE SCALE */
  992. X    case 'b':
  993. X    linetype(LINESCALE);
  994. X    break;
  995. X
  996. X    case 'X':            /* AXIS */
  997. X    case 'x':
  998. X    {
  999. X        int     p, q, r;
  1000. X
  1001. X        p = rint(getval());
  1002. X        q = rint(getval());
  1003. X        r = rint(getval());
  1004. X        fprintf(stderr, "Warning %c not implemented yet\n", op);
  1005. X    }
  1006. X    break;
  1007. X
  1008. X    case 'P':            /* PRINT */
  1009. X    case 'p':
  1010. X    textps(TEXT);
  1011. X    break;
  1012. X
  1013. X    case 'S':            /* ALPHA SCALE */
  1014. X    case 's':
  1015. X    {
  1016. X        int n;
  1017. X
  1018. X        if (SIGNED_NUMERIC)
  1019. X            n = rint(getval());
  1020. X        else
  1021. X        n = 3;
  1022. X        char_height = (n + 1) * 0.8 * SCALE;
  1023. X        char_width = (n + 1) * 0.4 * SCALE;
  1024. X        char_space = (n + 1) * 0.2 * SCALE;
  1025. X    }
  1026. X    printf("/%s %g %g %g DefFont\n",
  1027. X        font, char_width, char_height, char_slant);
  1028. X    break;
  1029. X
  1030. X    case 'Q':            /* ALPHA ROTATE */
  1031. X    case 'q':
  1032. X    intval = rint(getval());
  1033. X    switch (intval)
  1034. X    {
  1035. X    case 0:
  1036. X        char_angle = 0.0;
  1037. X        break;
  1038. X
  1039. X    case 1:
  1040. X        char_angle = 90.0;
  1041. X        break;
  1042. X
  1043. X    case 2:
  1044. X        char_angle = 180.0;
  1045. X        break;
  1046. X
  1047. X    case 3:
  1048. X        char_angle = 270.0;
  1049. X        break;
  1050. X    }
  1051. X    break;
  1052. X
  1053. X    case 'N':            /* MARK */
  1054. X    case 'n':
  1055. X    textps(MARK);
  1056. X    break;
  1057. X
  1058. X    case 'J':            /* PEN CHANGE */
  1059. X    case 'j':
  1060. X    linesize();
  1061. X    break;
  1062. X
  1063. X    case 'C':            /* CIRCLE */
  1064. X    case 'c':
  1065. X    circle(CIRCLE);
  1066. X    break;
  1067. X
  1068. X    case 'E':            /* RELATIVE CIRCLE */
  1069. X    case 'e':
  1070. X    circle(RCIRCLE);
  1071. X    break;
  1072. X
  1073. X    case 'A':            /* CIRCLE CENTER */
  1074. X    case 'a':
  1075. X    circle(CCIRCLE);
  1076. X    break;
  1077. X
  1078. X    case 'G':            /* ARC + CIRCLE */
  1079. X    case 'g':
  1080. X    circle(ACIRCLE);
  1081. X    break;
  1082. X
  1083. X    case 'K':            /* SEGMENT AND INDICATION LINES FOR CIRCLES */
  1084. X    case 'k':
  1085. X    circle(SCIRCLE);
  1086. X    break;
  1087. X
  1088. X    case 'T':            /* HATCHING */
  1089. X    case 't':
  1090. X    rectangle();
  1091. X    break;
  1092. X
  1093. X    case '^':            /* CALL HP-GL / RD-GL COMMANDS */
  1094. X    end_draw();
  1095. X    if ((ch = getc(stream)) != EOF)
  1096. X        hpglcom(ch);
  1097. X    break;
  1098. X
  1099. X    default:
  1100. X    fprintf(stderr, "Warning: %c Unknown DXY command\n", op);
  1101. X    break;
  1102. X    }
  1103. X}
  1104. SHAR_EOF
  1105. chmod 0644 dxycom.c || echo "restore of dxycom.c fails"
  1106. set `wc -c dxycom.c`;Sum=$1
  1107. if test "$Sum" != "2329"
  1108. then echo original size 2329, current size $Sum;fi
  1109. echo "x - extracting end_draw.c (Text)"
  1110. sed 's/^X//' << 'SHAR_EOF' > end_draw.c &&
  1111. X/* end_draw.c */
  1112. X#include "defn.h"
  1113. X
  1114. Xend_draw()
  1115. X{
  1116. X    if (DRAW_FLAG)
  1117. X    {
  1118. X    if (lastXmove == absX && lastYmove == absY)
  1119. X    {
  1120. X        printf("closepath\n");
  1121. X        debugp((stderr,"closepath\n"));
  1122. X    }
  1123. X    printf("stroke\n");
  1124. X    debugp((stderr,"stroke\n"));
  1125. X    DRAW_FLAG = 0;
  1126. X    }
  1127. X    dcount = 0;
  1128. X}
  1129. SHAR_EOF
  1130. chmod 0644 end_draw.c || echo "restore of end_draw.c fails"
  1131. set `wc -c end_draw.c`;Sum=$1
  1132. if test "$Sum" != "281"
  1133. then echo original size 281, current size $Sum;fi
  1134. echo "x - extracting getval.c (Text)"
  1135. sed 's/^X//' << 'SHAR_EOF' > getval.c &&
  1136. X/* getval.c
  1137. X * Returns a real number 
  1138. X */
  1139. X
  1140. X#include "defn.h"
  1141. X
  1142. X#define ERROR "Two or more decimal places in a number"
  1143. X
  1144. Xfloat
  1145. Xgetval()
  1146. X{
  1147. X    char    valbuf[10];
  1148. X    float   value;
  1149. X    int     DECIMAL = 0;
  1150. X    int     i;
  1151. X
  1152. X    /* Null the value buffer "valbuf" */
  1153. X    for (i = 0; i < 10; i++)
  1154. X    valbuf[i] = NULL;
  1155. X
  1156. X    i = 0;
  1157. X
  1158. X    ch = getc(stream);
  1159. X
  1160. X    while ((ch == ' ') || (ch == ','))
  1161. X    {
  1162. X    debugp((stderr,"%c",ch));
  1163. X    ch = getc(stream);
  1164. X    }
  1165. X
  1166. X    while ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-' || ch == '+')
  1167. X    {
  1168. X    debugp((stderr,"%c",ch));
  1169. X    if (ch == '.')
  1170. X    {
  1171. X        if (DECIMAL)
  1172. X        {
  1173. X        fprintf(stderr,"Error: %s\n", ERROR);
  1174. X        exit(1);
  1175. X        }
  1176. X        DECIMAL = 1;
  1177. X    }
  1178. X    valbuf[i++] = ch;
  1179. X    ch = getc(stream);
  1180. X    }
  1181. X    /* remove trailing space or comma to set-up for 
  1182. X       next digit or mnemonic */
  1183. X    /* added by Gordon Jacobs so that definition of 
  1184. X       SIGNED_NUMERIC in defn.h could be made more accurate.
  1185. X       Solves problem of commands like PA,PD0,0... where
  1186. X       optional comma is present.  (Tektronix scope outputs!) */ 
  1187. X    while ((ch == ' ') || (ch == ','))
  1188. X    {
  1189. X    debugp((stderr,"%c",ch));
  1190. X    ch = getc(stream);
  1191. X    }
  1192. X
  1193. X    ungetc(ch, stream);        /* Put non numeric char back */
  1194. X    value = atof (valbuf);
  1195. X    return (value);
  1196. X}
  1197. SHAR_EOF
  1198. chmod 0644 getval.c || echo "restore of getval.c fails"
  1199. set `wc -c getval.c`;Sum=$1
  1200. if test "$Sum" != "1249"
  1201. then echo original size 1249, current size $Sum;fi
  1202. echo "x - extracting hpgl2ps.c (Text)"
  1203. sed 's/^X//' << 'SHAR_EOF' > hpgl2ps.c &&
  1204. X/* hpgl2ps.c */
  1205. X#include    "defn.h"
  1206. X
  1207. X#define USAGE "Usage: hpgl2ps [-43BAmr] [-l line sizes] [-s scale] [-x offset] [-y offset] [-w font_width] [-h font_height] [file]\n"
  1208. X
  1209. Xmain(argc, argv)
  1210. X/*
  1211. X *  hpgl2ps.c
  1212. X *
  1213. X *  Modified by J.R. Nickerson, G.W. Kokodyniak
  1214. X *  University of Toronto, Department of Mechanical Enginnering
  1215. X *
  1216. X *  Further modified by Gordon Jacobs, University of Calif, Berkeley
  1217. X *   Added Scaling,Ticks,modified userdefchar(),sizes for 8.5x11 paper
  1218. X *
  1219. X */
  1220. Xint     argc;
  1221. Xchar   *argv[];
  1222. X{
  1223. X    extern int optind;
  1224. X    extern char *optarg;
  1225. X
  1226. X    int     ch;                                 /* GWKMOD */
  1227. X    int     op;                                 /* GWKMOD */
  1228. X    /* GWK: char    op; */
  1229. X    int        MANUAL_FEED = 0;            /* DEFAULT: No manual feed */
  1230. X
  1231. X    PaperSize = "A";
  1232. X    Mode = "HPGL";
  1233. X    plotcoords();
  1234. X
  1235. X    plotinit();            /* Get other initialiasations */
  1236. X
  1237. X    while ((ch = getopt(argc, argv, "AB43l:ms:x:y:rh:w:")) != EOF)
  1238. X    {
  1239. X    switch (ch)
  1240. X    {
  1241. X    case '4':        /* HP-GL ISO A4 297mm * 210mm */
  1242. X        PaperSize = "A4";
  1243. X        plotcoords();
  1244. X        break;
  1245. X
  1246. X    case '3':        /* HP-GL ISO A3 420mm * 297mm */
  1247. X        PaperSize = "A3";
  1248. X        plotcoords();
  1249. X        break;
  1250. X
  1251. X    case 'A':        /* HP-GL ANSI A 11 * 8.5inch */
  1252. X        PaperSize = "A";
  1253. X        plotcoords();
  1254. X        break;
  1255. X
  1256. X    case 'B':        /* HP-GL ANSI B 17 * 11inch */
  1257. X        PaperSize = "B";
  1258. X        plotcoords();
  1259. X        break;
  1260. X
  1261. X    case 'l':        /* change line size option */
  1262. X        changesizes(optarg);
  1263. X        break;
  1264. X
  1265. X    case 'm':        /* enable manual feed on Laserwriter */
  1266. X        MANUAL_FEED = 1;
  1267. X        break;
  1268. X
  1269. X    case 'r':        /* rotate the plot 90 degrees */
  1270. X        LANDSCAPE = 0;
  1271. X        break;
  1272. X
  1273. X    case 's':        /* scale the plot from 0.1 to 3.0 times */
  1274. X        SCALE = atof(optarg);
  1275. X        if (SCALE < 0.1)
  1276. X        SCALE = 0.1;
  1277. X        else
  1278. X        if (SCALE > 3)
  1279. X        SCALE = 3;
  1280. X        break;
  1281. X
  1282. X    case 'h':
  1283. X        FONT_H_MULT = atof(optarg);
  1284. X        break;
  1285. X
  1286. X    case 'w':
  1287. X        FONT_W_MULT = atof(optarg);
  1288. X        break;
  1289. X
  1290. X    case 'x':        /* place an X offset (in mm) */
  1291. X        xoffset = atof(optarg);
  1292. X        break;
  1293. X
  1294. X    case 'y':        /* place an Y offset (in mm) */
  1295. X        yoffset = atof(optarg);
  1296. X        break;
  1297. X
  1298. X    default:
  1299. X        fprintf(stderr, "%s\n", USAGE);
  1300. X        exit(1);
  1301. X    }
  1302. X    }
  1303. X    if (optind == argc)
  1304. X    stream = stdin;
  1305. X    else if ((stream = fopen(argv[optind], "r")) == NULL)
  1306. X    {
  1307. X    fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]);
  1308. X    exit(1);
  1309. X    }
  1310. X    ps_macros();            /* Output PostScript Macros */
  1311. X
  1312. X    viewport();                /* Scale the viewport for the plot */
  1313. X
  1314. X    printf("/%s %g Font\n", font, char_height);
  1315. X
  1316. X    if (MANUAL_FEED)
  1317. X    manualfeed(1);
  1318. X
  1319. X    while ((op = getc(stream)) != EOF)
  1320. X    if (isalpha(op) > 0)
  1321. X        hpglcom(op);
  1322. X
  1323. X    end_draw();
  1324. X
  1325. X    printf("showpage\n");
  1326. X
  1327. X    if (MANUAL_FEED)
  1328. X    manualfeed(0);
  1329. X}
  1330. SHAR_EOF
  1331. chmod 0644 hpgl2ps.c || echo "restore of hpgl2ps.c fails"
  1332. set `wc -c hpgl2ps.c`;Sum=$1
  1333. if test "$Sum" != "2679"
  1334. then echo original size 2679, current size $Sum;fi
  1335. echo "x - extracting hpgl2ps.man (Text)"
  1336. sed 's/^X//' << 'SHAR_EOF' > hpgl2ps.man &&
  1337. X.TH HPGL2PS 1L "11 June 1990"
  1338. X.SH NAME
  1339. Xhpgl2ps - A HP (Hewlet Packard) plot command filter to PostScript
  1340. X.SH SYNOPSIS
  1341. X\fBhpgl2ps\fR
  1342. X[\fB-AB43mr\fR]
  1343. X[\fB-l \fIline sizes\fR]
  1344. X[\fB-s \fIscale\fR]
  1345. X[\fB-x \fIoffset\fR]
  1346. X[\fB-y \fIoffset\fR]
  1347. X[\fB-h \fIfont height multiplier\fR]
  1348. X[\fB-w \fIfont width multiplier\fR]
  1349. X[\fIplotfile\fR]
  1350. X.SH DESCRIPTION
  1351. XThis filter is used to convert Hewlet Packard Graphic Language (HP-GL)
  1352. X7550A plotter commands to PostScript. The HP-GL commands are a subset of the
  1353. XRoland plotter command set (RD-GL).
  1354. X.PP
  1355. XThe default conditions for \fBhpgl2ps\fR are:
  1356. X.TP
  1357. X.B A.
  1358. XThe plot translation is from an ANSI A (8.5 x 11inch) plot to ANSI A
  1359. Xpaper on the LaserWriter.  See below for other paper sizes.
  1360. X.TP
  1361. X.B B.
  1362. XLine thicknesses are in millimeters and are for lines (pens) 1 to 9:
  1363. X(0.0125, 0.025, 0.05, 0.1, 0.2, 0.4, 0.5 1.0 2.0)
  1364. X.TP
  1365. X.B C.
  1366. XThe default font is Helvetica, 14 point on the Laserwriter.
  1367. X.TP
  1368. X.B D.
  1369. XThe default font height and width multipliers are 1.2 and 3.6 respectively.
  1370. X.TP
  1371. X.B Note:
  1372. XIf the plotfile is not specified then standard input is assumed.
  1373. X.SH ARGUMENTS
  1374. X.TP
  1375. X.B -A
  1376. XDraw for an ANSI A (11 x 8.5inch) plot. 
  1377. X.TP
  1378. X.B -B
  1379. XDraw for an ANSI B (17 x 11inch) plot. 
  1380. X.TP
  1381. X.B -4
  1382. XDraw for an A4 ISO (297mm x 210mm) plot. This will give an
  1383. Xaproximate 1:1 translation to the LaserWriter.
  1384. X.TP
  1385. X.B -3
  1386. XDraw for an A3 ISO (420mm x 297mm) plot. 
  1387. X.TP
  1388. X\fB-l \fIline sizes\fR
  1389. XThis option allows the default line sizes to be replaced with different
  1390. Xsizes starting from line (pen) one through nine. The new sizes (real or
  1391. Xinteger) are entered in a comma separated string (\fIline size\fR) and
  1392. Xare in millimeters. Only the sizes entered in the string will be
  1393. Xchanged with respect to lines (pens) one to nine while nonentered line
  1394. X(pen) sizes will retain the default sizes.
  1395. X.sp
  1396. XIn the following example only the first three sizes will be changed.
  1397. X.sp
  1398. Xeg: hpgl2ps -l 0.4,0.3,1 file | lpr -Plaser1
  1399. X.TP
  1400. X.B -m
  1401. XEnable the manual feed on the LaserWriter (cutoff time 3 minutes).
  1402. X.TP
  1403. X.B -r
  1404. XRotate plot(s) through 90 degrees. (The plot is made smaller)
  1405. X.TP
  1406. X\fB-s\fI scale\fR
  1407. XScale the plot from 0.1 to 3 times its original size.
  1408. X.TP
  1409. X\fB-w\fI relative font width multiplier\fR
  1410. XWhen the SR command exists in the HP-GL file,
  1411. Xthe size of characters is scaled to be a proportion of the paper dimensions.
  1412. XThe HP7550 plotter character sizes are larger than the scaling suggests.
  1413. XThe default value of the font width multiplier scales the characters in the
  1414. Xpostscript file to appear roughly the same width as the original.
  1415. XSetting to 1.0 reverts to the original scaling.
  1416. X.TP
  1417. X\fB-w\fI relative font height multiplier\fR
  1418. XWhen the SR command exists in the HP-GL file,
  1419. Xthe size of characters is scaled to be a proportion of the paper dimensions.
  1420. XThe HP7550 plotter character sizes are larger than the scaling suggests.
  1421. XThe default value of the font height multiplier scales the characters in the
  1422. Xpostscript file to appear roughly the same width as the original.
  1423. XSetting to 1.0 reverts to the original scaling.
  1424. X.TP
  1425. X\fB-x\fI offset\fR
  1426. XPlace an X offset (in mm) in the plot.
  1427. X.TP
  1428. X\fB-y\fI offset\fR
  1429. XPlace an Y offset (in mm) in the plot.
  1430. X.PP
  1431. X\fBNote:\fR Offsets are with respect to the 0, 0 (origin) of the HP-GL
  1432. X/ RD-GL plotting commands, thus if the minimum plotting coordinates are
  1433. Xbelow either the X and/or Y zero axis then a positive offset is
  1434. Xapplied.  Similarly if the minimum plot coordinates are above the X
  1435. Xand/or Y zero axis then a negative offset is applied.
  1436. X.SH FILES
  1437. X/usr/local/bin/hpgl2ps
  1438. X.SH AUTHOR
  1439. XDon McCormick
  1440. X.br
  1441. XCSIRO
  1442. X.br
  1443. XDivision of Applied Physics
  1444. X.br
  1445. XPO 218, Lindfield, N.S.W., 2070
  1446. X.br
  1447. XAustralia
  1448. X
  1449. XScaling, Tick Marks, and other modifications by:
  1450. X.br
  1451. XGordon Jacobs, University of California, Berkeley
  1452. X
  1453. XAll HPGL commands have been added to the hpglcom.c program,
  1454. Xthough not all commands have been implemented.
  1455. XThe HPGL AA command has been implemented.
  1456. XParsing of HPGL commands has been enhanced.
  1457. XMichael L. Brown, Madison, WI.
  1458. X.SH BUGS
  1459. XSome of the graphics commands are unimplemented and a warning will be
  1460. Xdisplayed. If this command is vital then it must be written into the code.
  1461. X.PP
  1462. XNo interactive command is suported.
  1463. X
  1464. SHAR_EOF
  1465. chmod 0644 hpgl2ps.man || echo "restore of hpgl2ps.man fails"
  1466. set `wc -c hpgl2ps.man`;Sum=$1
  1467. if test "$Sum" != "4127"
  1468. then echo original size 4127, current size $Sum;fi
  1469. echo "x - extracting hpglcom.c (Text)"
  1470. sed 's/^X//' << 'SHAR_EOF' > hpglcom.c &&
  1471. X/* hpglcom.c */
  1472. X/*
  1473. X * This procedure translates RD-GL (Roland DG Graphic Language) into the
  1474. X * equivalent PostScript language. 
  1475. X *
  1476. X * The RD-GL is a superset equivalent to HP-GL 
  1477. X *
  1478. X * Don McCormick 
  1479. X *
  1480. X * Extensively modified by Michael L. Brown.
  1481. X *
  1482. X * The parser didn't get rid of the characters, up to the next possible
  1483. X * HPGL command.  Added a DEBUG, so that the commands that aren't known
  1484. X * are sent to the stderr.  By making this compilable, the screen isn't
  1485. X * clutterd with all of the many possible HPGL commands that aren't being
  1486. X * operated on.
  1487. X */
  1488. X
  1489. X#include "defn.h"
  1490. X
  1491. X/* The folowing defaults should be 0.5% and 1.0% for the respective  character
  1492. X * width and height, however this is too small when scaled to Postcript
  1493. X * charcter sizes.
  1494. X */
  1495. Xfloat DEFWIDTH = 0.0075;    /* 0.75 % of P2x - P1x for default char width */
  1496. Xfloat DEFHEIGHT = 0.015;    /* 1.5 % of P2y - P1y for default char height */
  1497. X/*
  1498. X * Values above are further multiplied by FONT_W_MULT and FONT_H_MULT
  1499. X * which can be set on command line. Defaults are 4.0 and 1.1
  1500. X * Added for better matching of relative font sizes to plotter results 
  1501. X */
  1502. X
  1503. X#define SPACE_FACTOR 0.64  /* used in computation of a character space */
  1504. X
  1505. Xhpglcom(op1)
  1506. Xchar    op1;
  1507. X{
  1508. X    char    op2;
  1509. X    int     no_op;        /* No operation value */
  1510. X
  1511. X    switch (op1)
  1512. X    {
  1513. X    case 'A':
  1514. X    case 'a':
  1515. X    op2 = getc(stream);
  1516. X    switch (op2)
  1517. X    {
  1518. X    case 'A':        /* Arc Absolute */
  1519. X    case 'a':
  1520. X        debugp((stderr,"%c%c",op1,op2));
  1521. X        PLOTARC = 1;
  1522. X        if (PENDOWN)
  1523. X        {
  1524. X        if (SIGNED_NUMERIC)
  1525. X            if (SETDOT)
  1526. X            plotdot(MOVE);
  1527. X            else if (PLOTABS)
  1528. X            arcps(ARCA);
  1529. X            else
  1530. X            arcps(ARCR);
  1531. X        }
  1532. X        dumpit(1);
  1533. X        break;
  1534. X
  1535. X    case 'F':        /* Advance Full Page */
  1536. X    case 'f':
  1537. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1538. X        dumpit(2);
  1539. X        break;
  1540. X
  1541. X    case 'H':        /* Advance Half Page */
  1542. X    case 'h':
  1543. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1544. X        dumpit(2);
  1545. X        break;
  1546. X
  1547. X    case 'P':        /* Automatic Pen Lift (HP-GL only) */
  1548. X    case 'p':
  1549. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1550. X        dumpit(2);
  1551. X        break;
  1552. X
  1553. X    case 'R':        /* Arc Relative */
  1554. X    case 'r':
  1555. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1556. X        dumpit(2);
  1557. X        break;
  1558. X
  1559. X    case 'S':        /* Acceleration Select */
  1560. X    case 's':
  1561. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1562. X        dumpit(2);
  1563. X        break;
  1564. X
  1565. X    default:
  1566. X        notimp((stderr, "%c%c: Warning: Unknown HP-GL Command\n\n", op1,op2));
  1567. X        dumpit(2);
  1568. X    }
  1569. X    break;
  1570. X
  1571. X    case 'B':
  1572. X    case 'b':
  1573. X    op2 = getc(stream);
  1574. X    switch (op2)
  1575. X    {
  1576. X    case 'L':        /* Buffered Label String */
  1577. X    case 'l':
  1578. X        while (((ch = getc(stream)) != EOF) && ch != EOL);
  1579. X        notimp((stderr, "Not Implemented: %c%c",op1,op2));
  1580. X        break;
  1581. X
  1582. X    default:
  1583. X        notimp((stderr, "%c%c: Warning: Unknown HP-GL Command\n\n", op1,op2));
  1584. X        dumpit(2);
  1585. X    }
  1586. X    break;
  1587. X
  1588. X    case 'C':
  1589. X    case 'c':
  1590. X    op2 = getc(stream);
  1591. X    switch (op2)
  1592. X    {
  1593. X    case 'A':        /* Alternate Character Set (Not Used) */
  1594. X    case 'a':
  1595. X        notimp((stderr, "Not Implemented: %c%c",op1,op2));
  1596. X        dumpit(2);
  1597. X        break;
  1598. X
  1599. X    case 'C':        /* Character Chord Angle */
  1600. X    case 'c':
  1601. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1602. X        dumpit(2);
  1603. X        break;
  1604. X
  1605. X    case 'I':        /* Circle */
  1606. X    case 'i':
  1607. X        debugp((stderr,"%c%c",op1,op2));
  1608. X        circle(RDGLCIRCLE);
  1609. X        break;
  1610. X
  1611. X    case 'M':        /* Character Selection Mode */
  1612. X    case 'm':
  1613. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1614. X        dumpit(2);
  1615. X        break;
  1616. X
  1617. X    case 'P':        /* Character Plot */
  1618. X    case 'p':
  1619. X        debugp((stderr,"%c%c",op1,op2));
  1620. X        {
  1621. X        float   xspace, yspace;
  1622. X
  1623. X        xspace = getval() * XSCALE * SCALE * (char_width + char_space);
  1624. X        yspace = getval() * YSCALE * SCALE * (char_width + char_space);
  1625. X        end_draw();
  1626. X        printf("    %g mm %g mm %s\n", xspace, yspace, RMOVE);
  1627. X        }
  1628. X        break;
  1629. X
  1630. X    case 'S':        /* Standard Character Set */
  1631. X    case 's':
  1632. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1633. X        dumpit(2);
  1634. X        break;
  1635. X
  1636. X    case 'T':        /* Chord Tolerance */
  1637. X    case 't':
  1638. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1639. X        dumpit(2);
  1640. X        break;
  1641. X
  1642. X    default:
  1643. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  1644. X        dumpit(2);
  1645. X    }
  1646. X    break;
  1647. X
  1648. X    case 'D':
  1649. X    case 'd':
  1650. X    op2 = getc(stream);
  1651. X    switch (op2)
  1652. X    {
  1653. X    case 'C':        /* Digitize Clear (Not Used) */
  1654. X    case 'c':
  1655. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1656. X        dumpit(2);
  1657. X        break;
  1658. X
  1659. X    case 'F':        /* Default */
  1660. X    case 'f':
  1661. X        debugp((stderr,"%c%c",op1,op2));
  1662. X        SETDOT = 0;
  1663. X        SYMBOL = 0;
  1664. X        PENDOWN = 0;
  1665. X        EOL = '\003';
  1666. X        char_angle = 0;
  1667. X        char_slant = 0;
  1668. X        if(LANDSCAPE) {
  1669. X        char_width = DEFWIDTH * (ymax - ymin) * YSCALE *  SCALE;
  1670. X        char_height = DEFHEIGHT * (xmax - xmin) * XSCALE *  SCALE;
  1671. X        }
  1672. X        else {
  1673. X        char_width = DEFWIDTH * (xmax - xmin) * XSCALE *  SCALE;
  1674. X        char_height = DEFHEIGHT * (ymax - ymin) * YSCALE *  SCALE;
  1675. X        }
  1676. X        char_space = char_width * (1/SPACE_FACTOR - 1);
  1677. X        printf("/%s %g %g %g DefFont\n",
  1678. X        font, char_width, char_height, char_slant);
  1679. X        dumpit(1);
  1680. X        break;
  1681. X
  1682. X    case 'I':        /* Absolute Direction */
  1683. X    case 'i':
  1684. X        debugp((stderr,"%c%c",op1,op2));
  1685. X        {
  1686. X        float   run, rise;
  1687. X
  1688. X        if (SIGNED_NUMERIC)
  1689. X        {
  1690. X            run = getval() * XSCALE;
  1691. X            rise = getval() * YSCALE;
  1692. X            char_angle = atan2(rise, run) / deg_rad;
  1693. X        }
  1694. X        else
  1695. X            char_angle = 0;
  1696. X        }
  1697. X        break;
  1698. X
  1699. X    case 'L':        /* Downloadable Character */
  1700. X    case 'l':
  1701. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1702. X        dumpit(2);
  1703. X        break;
  1704. X
  1705. X    case 'P':        /* Digitize Point (Not Used) */
  1706. X    case 'p':
  1707. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1708. X        dumpit(2);
  1709. X        break;
  1710. X
  1711. X    case 'R':        /* Relative Direction */
  1712. X    case 'r':
  1713. X        debugp((stderr,"%c%c",op1,op2));
  1714. X        {
  1715. X        float   run, rise;
  1716. X
  1717. X        if (SIGNED_NUMERIC)
  1718. X        {
  1719. X            run = getval() * XSCALE;
  1720. X            rise = getval() * YSCALE;
  1721. X            char_angle += atan2(rise, run) / deg_rad;
  1722. X        }
  1723. X        else
  1724. X            char_angle = 0;
  1725. X        }
  1726. X        break;
  1727. X
  1728. X    case 'S':        /* Designate Character Set into Slot*/
  1729. X    case 's':
  1730. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1731. X        dumpit(2);
  1732. X        break;
  1733. X
  1734. X    case 'T':        /* Define Terminator */
  1735. X    case 't':
  1736. X        debugp((stderr,"%c%c",op1,op2));
  1737. X        if ((ch = getc(stream)) != EOF)
  1738. X        EOL = ch;    /* End of label terminator */
  1739. X        dumpit(1);
  1740. X        break;
  1741. X
  1742. X    default:
  1743. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  1744. X        dumpit(2);
  1745. X    }
  1746. X    break;
  1747. X
  1748. X    case 'E':
  1749. X    case 'e':
  1750. X    op2 = getc(stream);
  1751. X    switch (op2)
  1752. X    {
  1753. X    case 'A':        /* Edge Rectangle Absolute */
  1754. X    case 'a':
  1755. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1756. X        dumpit(2);
  1757. X        break;
  1758. X
  1759. X    case 'C':        /* Enable Cut Line */
  1760. X    case 'c':
  1761. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1762. X        dumpit(2);
  1763. X        break;
  1764. X
  1765. X    case 'P':        /* Edge Polygon */
  1766. X    case 'p':
  1767. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1768. X        dumpit(2);
  1769. X        break;
  1770. X
  1771. X    case 'R':        /* Edge Rectangle Relative */
  1772. X    case 'r':
  1773. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1774. X        dumpit(2);
  1775. X        break;
  1776. X
  1777. X    case 'S':        /* Extra Space */
  1778. X    case 's':
  1779. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1780. X        dumpit(2);
  1781. X        break;
  1782. X
  1783. X    case 'W':        /* Edge Wedge */
  1784. X    case 'w':
  1785. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1786. X        dumpit(2);
  1787. X        break;
  1788. X
  1789. X    default:
  1790. X        notimp((stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2));
  1791. X        dumpit(2);
  1792. X    }
  1793. X    break;
  1794. X
  1795. X    case 'F':
  1796. X    case 'f':
  1797. X    op2 = getc(stream);
  1798. X    switch (op2)
  1799. X    {
  1800. X    case 'P':        /* Fill Polygon */
  1801. X    case 'p':
  1802. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1803. X        dumpit(2);
  1804. X        break;
  1805. X
  1806. X    case 'R':        /* Advance Frame */
  1807. X    case 'r':
  1808. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1809. X        dumpit(2);
  1810. X        break;
  1811. X
  1812. X    case 'S':        /* Force Select */
  1813. X    case 's':
  1814. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1815. X        dumpit(2);
  1816. X        break;
  1817. X
  1818. X    case 'T':        /* Fill Type */
  1819. X    case 't':
  1820. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1821. X        dumpit(2);
  1822. X        break;
  1823. X
  1824. X    default:
  1825. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  1826. X        dumpit(2);
  1827. X    }
  1828. X    break;
  1829. X
  1830. X    case 'G':
  1831. X    case 'g':
  1832. X    op2 = getc(stream);
  1833. X    switch (op2)
  1834. X    {
  1835. X    case 'P':        /* Group Pen */
  1836. X    case 'p':
  1837. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1838. X        dumpit(2);
  1839. X        break;
  1840. X
  1841. X    default:
  1842. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  1843. X        dumpit(2);
  1844. X    }
  1845. X    break;
  1846. X
  1847. X    case 'I':
  1848. X    case 'i':
  1849. X    op2 = getc(stream);
  1850. X    switch (op2)
  1851. X    {
  1852. X    case 'M':        /* Input Mask (Not Used) */
  1853. X    case 'm':
  1854. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1855. X        dumpit(2);
  1856. X        break;
  1857. X
  1858. X    case 'N':        /* Initialize */
  1859. X    case 'n':
  1860. X        debugp((stderr,"%c%c",op1,op2));
  1861. X        plotcoords();
  1862. X        SETDOT = 0;
  1863. X        SYMBOL = 0;
  1864. X        PENDOWN = 0;
  1865. X        EOL = '\003';
  1866. X        char_angle = 0;
  1867. X        char_slant = 0;
  1868. X        if(LANDSCAPE) {
  1869. X        char_width = DEFWIDTH * (ymax - ymin) * YSCALE *  SCALE;
  1870. X        char_height = DEFHEIGHT * (xmax - xmin) * XSCALE * SCALE;
  1871. X        }
  1872. X        else {
  1873. X        char_width = DEFWIDTH * (xmax - xmin) * XSCALE *  SCALE;
  1874. X        char_height = DEFHEIGHT * (ymax - ymin) * YSCALE * SCALE;
  1875. X        }
  1876. X        char_space = char_width * (1/SPACE_FACTOR - 1);
  1877. X        printf("/%s %g %g %g DefFont\n",
  1878. X        font, char_width, char_height, char_slant);
  1879. X        dumpit(1);
  1880. X        break;
  1881. X
  1882. X    case 'P':        /* Input P1 and P2 (Not Used) */
  1883. X    case 'p':
  1884. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1885. X        dumpit(2);
  1886. X        break;
  1887. X
  1888. X    case 'V':        /* Invoke Character Slot */
  1889. X    case 'v':
  1890. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1891. X        dumpit(2);
  1892. X        break;
  1893. X
  1894. X    case 'W':        /* Input Window */
  1895. X    case 'w':
  1896. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1897. X        dumpit(2);
  1898. X        break;
  1899. X
  1900. X    default:
  1901. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  1902. X        dumpit(2);
  1903. X    }
  1904. X    break;
  1905. X
  1906. X    case 'L':
  1907. X    case 'l':
  1908. X    op2 = getc(stream);
  1909. X    switch (op2)
  1910. X    {
  1911. X    case 'B':        /* Label */
  1912. X    case 'b':
  1913. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1914. X        textps(TEXT);
  1915. X        break;
  1916. X
  1917. X    case 'O':        /* Label Origin */
  1918. X    case 'o':
  1919. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1920. X        dumpit(2);
  1921. X        break;
  1922. X
  1923. X    case 'T':        /* Line Type */
  1924. X    case 't':
  1925. X        debugp((stderr,"%c%c",op1,op2));
  1926. X        linetype(LINE_TYPE_SCALE);
  1927. X        dumpit(1);
  1928. X        break;
  1929. X
  1930. X    default:
  1931. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  1932. X        dumpit(2);
  1933. X    }
  1934. X    break;
  1935. X
  1936. X    case 'N':
  1937. X    case 'n':
  1938. X    op2 = getc(stream);
  1939. X    switch (op2)
  1940. X    {
  1941. X    case 'R':        /* Not Ready */
  1942. X    case 'r':
  1943. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1944. X        dumpit(2);
  1945. X        break;
  1946. X
  1947. X    default:
  1948. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  1949. X        dumpit(2);
  1950. X    }
  1951. X    break;
  1952. X
  1953. X    case 'O':            /* NOT USED */
  1954. X    case 'o':
  1955. X    op2 = getc(stream);
  1956. X    switch (op2)
  1957. X    {
  1958. X    case 'A':        /* Output Actual Position */
  1959. X    case 'a':
  1960. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1961. X        dumpit(2);
  1962. X        break;
  1963. X
  1964. X    case 'C':        /* Output Commanded Position */
  1965. X    case 'c':
  1966. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1967. X        dumpit(2);
  1968. X        break;
  1969. X
  1970. X    case 'D':        /* Output Digitise */
  1971. X    case 'd':
  1972. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1973. X        dumpit(2);
  1974. X        break;
  1975. X
  1976. X    case 'E':        /* Output Error */
  1977. X    case 'e':
  1978. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1979. X        dumpit(2);
  1980. X        break;
  1981. X
  1982. X    case 'F':        /* Output Factors */
  1983. X    case 'f':
  1984. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1985. X        dumpit(2);
  1986. X        break;
  1987. X
  1988. X    case 'H':        /* Output Hard-Clip Limits */
  1989. X    case 'h':
  1990. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1991. X        dumpit(2);
  1992. X        break;
  1993. X
  1994. X    case 'I':        /* Output Indentification */
  1995. X    case 'i':
  1996. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  1997. X        dumpit(2);
  1998. X        break;
  1999. X
  2000. X    case 'L':        /* Output Label Length */
  2001. X    case 'l':
  2002. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2003. X        dumpit(2);
  2004. X        break;
  2005. X
  2006. X    case 'O':        /* Output Options */
  2007. X    case 'o':
  2008. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2009. X        dumpit(2);
  2010. X        break;
  2011. X
  2012. X    case 'P':        /* Output P1 and P2 */
  2013. X    case 'p':
  2014. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2015. X        dumpit(2);
  2016. X        break;
  2017. X
  2018. X    case 'S':        /* Output Status */
  2019. X    case 's':
  2020. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2021. X        dumpit(2);
  2022. X        break;
  2023. X
  2024. X    case 'T':        /* Output Carousel Type */
  2025. X    case 't':
  2026. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2027. X        dumpit(2);
  2028. X        break;
  2029. X
  2030. X    case 'W':        /* Output Window */
  2031. X    case 'w':
  2032. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2033. X        dumpit(2);
  2034. X        break;
  2035. X
  2036. X    default:
  2037. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  2038. X        dumpit(2);
  2039. X    }
  2040. X    break;
  2041. X
  2042. X    case 'P':
  2043. X    case 'p':
  2044. X    op2 = getc(stream);
  2045. X    switch (op2)
  2046. X    {
  2047. X    case 'A':        /* Plot Absolute */
  2048. X    case 'a':
  2049. X        debugp((stderr,"%c%c",op1,op2));
  2050. X        dumpcomma();
  2051. X        PLOTABS = 1;
  2052. X        if (SIGNED_NUMERIC)
  2053. X        if (SETDOT || SYMBOL)
  2054. X            plotdot(MOVE);
  2055. X        else if (PENDOWN)
  2056. X            plotps(DRAW);
  2057. X        else
  2058. X            plotps(MOVE);
  2059. X        dumpit(1);
  2060. X        break;
  2061. X
  2062. X    case 'B':        /* Print Buffered Label */
  2063. X    case 'b':
  2064. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2065. X        dumpit(2);
  2066. X        break;
  2067. X
  2068. X    case 'D':        /* Pen Down */
  2069. X    case 'd':
  2070. X        debugp((stderr,"%c%c",op1,op2));
  2071. X        dumpcomma();
  2072. X        PENDOWN = 1;
  2073. X        if (SIGNED_NUMERIC)
  2074. X        if (SETDOT)
  2075. X            plotdot(MOVE);
  2076. X        else if (PLOTABS)
  2077. X            plotps(DRAW);
  2078. X        else 
  2079. X            plotps(RDRAW);
  2080. X        dumpit(1);
  2081. X        break;
  2082. X
  2083. X    case 'G':        /* Advance Full Page */
  2084. X    case 'g':
  2085. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2086. X        dumpit(2);
  2087. X        break;
  2088. X
  2089. X    case 'M':        /* Polygon Mode */
  2090. X    case 'm':
  2091. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2092. X        dumpit(2);
  2093. X        break;
  2094. X
  2095. X    case 'R':        /* Plot Relative */
  2096. X    case 'r':
  2097. X        debugp((stderr,"%c%c",op1,op2));
  2098. X        PLOTABS = 0;
  2099. X        if (SIGNED_NUMERIC)
  2100. X        if (SETDOT || SYMBOL)
  2101. X            plotdot(RMOVE);
  2102. X        else if (PENDOWN)
  2103. X            plotps(RDRAW);
  2104. X        else
  2105. X            plotps(RMOVE);
  2106. X        dumpit(1);
  2107. X        break;
  2108. X
  2109. X    case 'T':        /* Pen Thickness */
  2110. X    case 't':
  2111. X        debugp((stderr,"%c%c",op1,op2));
  2112. X        {
  2113. X        float   linewidth;
  2114. X
  2115. X        linewidth = getval() * SCALE;        /* In mm */
  2116. X        printf("%g mm setlinewidth\n", linewidth);
  2117. X        }
  2118. X        dumpit(1);
  2119. X        break;
  2120. X
  2121. X    case 'U':        /* Pen Up */
  2122. X    case 'u':
  2123. X        debugp((stderr,"%c%c",op1,op2));
  2124. X        PENDOWN = 0;
  2125. X        if (SIGNED_NUMERIC)
  2126. X        if (SETDOT)
  2127. X            plotdot(MOVE);
  2128. X        else if (PLOTABS)
  2129. X            plotps(MOVE);
  2130. X        else
  2131. X            plotps(RMOVE);
  2132. X        dumpit(1);
  2133. X        break;
  2134. X
  2135. X    default:
  2136. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  2137. X        dumpit(2);
  2138. X    }
  2139. X    break;
  2140. X
  2141. X    case 'R':
  2142. X    case 'r':
  2143. X    op2 = getc(stream);
  2144. X    switch (op2)
  2145. X    {
  2146. X    case 'A':        /* Fill Rectange Absolute */
  2147. X    case 'a':
  2148. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2149. X        dumpit(2);
  2150. X        break;
  2151. X
  2152. X    case 'O':        /* Rotate Coordinate System */
  2153. X    case 'o':
  2154. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2155. X        dumpit(2);
  2156. X        break;
  2157. X
  2158. X    case 'R':        /* Fill Rectangle Relative */
  2159. X    case 'r':
  2160. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2161. X        dumpit(2);
  2162. X        break;
  2163. X
  2164. X    default:
  2165. X        notimp((stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2));
  2166. X        dumpit(2);
  2167. X    }
  2168. X    break;
  2169. X
  2170. X    case 'S':
  2171. X    case 's':
  2172. X    op2 = getc(stream);
  2173. X    switch (op2)
  2174. X    {
  2175. X    case 'A':        /* Select Alternate Set */
  2176. X    case 'a':
  2177. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2178. X        dumpit(2);
  2179. X        break;
  2180. X
  2181. X    case 'C':        /* Scale */
  2182. X    case 'c':        /* Scaling added by Gordon Jacobs */
  2183. X        debugp((stderr,"%c%c",op1,op2));
  2184. X        if (SIGNED_NUMERIC){
  2185. X        xmin = getval();
  2186. X        }
  2187. X        else {
  2188. X        dumpit(1);
  2189. X        break;
  2190. X        }
  2191. X
  2192. X        if (SIGNED_NUMERIC) {
  2193. X        xmax = getval();
  2194. X        }
  2195. X        if (SIGNED_NUMERIC) {
  2196. X        ymin = getval();
  2197. X        }
  2198. X        if (SIGNED_NUMERIC) {
  2199. X        ymax = getval();
  2200. X        }
  2201. X        modify_viewport();     /* new function for scaling */
  2202. X        end_draw();
  2203. X        dumpit(1);
  2204. X        break;
  2205. X
  2206. X    case 'G':        /* Select Pen Group */
  2207. X    case 'g':
  2208. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2209. X        dumpit(2);
  2210. X        break;
  2211. X
  2212. X    case 'I':        /* Absolute Character Size */
  2213. X    case 'i':
  2214. X        debugp((stderr,"%c%c",op1,op2));
  2215. X        if (SIGNED_NUMERIC)
  2216. X        {
  2217. X        char_width = getval() * 10 * SCALE;    /* In mm */
  2218. X        char_height = getval() * 10 * SCALE;    /* In mm */
  2219. X        } else
  2220. X        {
  2221. X        if ((ch = getc(stream)) == ';')
  2222. X        {
  2223. X            char_width = 2.7 * SCALE;
  2224. X            char_height = 1.9 * SCALE;
  2225. X        }
  2226. X        }
  2227. X        char_space = char_width * (1/SPACE_FACTOR - 1);
  2228. X        printf("/%s %g %g %g DefFont\n",
  2229. X        font, char_width, char_height, char_slant);
  2230. X        dumpit(1);
  2231. X        break;
  2232. X
  2233. X    case 'L':        /* Character Slant */
  2234. X    case 'l':
  2235. X        debugp((stderr,"%c%c",op1,op2));
  2236. X        if (SIGNED_NUMERIC)
  2237. X        char_slant = char_height * getval();
  2238. X        else
  2239. X        char_slant = 0;
  2240. X
  2241. X        char_space = char_width * (1/SPACE_FACTOR - 1);
  2242. X        printf("/%s %g %g %g DefFont\n",
  2243. X        font, char_width, char_height, char_slant);
  2244. X        dumpit(1);
  2245. X        break;
  2246. X
  2247. X    case 'M':        /* Symbol Mode */
  2248. X    case 'm':
  2249. X        if ((ch = getc(stream)) != EOF && ch != ';' && isgraph(ch) > 0)
  2250. X        {
  2251. X         symbol = ch;
  2252. X         debugp((stderr,"%c",ch));
  2253. X         SYMBOL = 1;
  2254. X        }
  2255. X        else
  2256. X        SYMBOL = 0;
  2257. X        dumpit(1);
  2258. X        break;
  2259. X
  2260. X    case 'P':        /* Pen Select */
  2261. X    case 'p':
  2262. X        debugp((stderr,"%c%c",op1,op2));
  2263. X        linesize();
  2264. X        dumpit(1);
  2265. X        break;
  2266. X
  2267. X    case 'R':        /* Relative Character Size */
  2268. X    case 'r':
  2269. X        debugp((stderr,"%c%c",op1,op2));
  2270. X        {
  2271. X        float   pwidth, pheight;
  2272. X
  2273. X        if (SIGNED_NUMERIC)
  2274. X        {
  2275. X            pwidth = getval() * SCALE;        /* Percent */
  2276. X            pheight = getval() * SCALE;        /* Percent */
  2277. X        } else
  2278. X        {
  2279. X            pwidth = DEFWIDTH * 100 * SCALE;
  2280. X            pheight = DEFHEIGHT * 100 * SCALE;
  2281. X        }
  2282. X        if(LANDSCAPE) {
  2283. X            char_width = FONT_W_MULT *(ymax - ymin) 
  2284. X                     * YSCALE *  pwidth / 100.0;
  2285. X            char_height = FONT_H_MULT *(xmax - xmin) 
  2286. X                     * XSCALE *  pheight / 100.0;
  2287. X        }
  2288. X        else {
  2289. X            char_width = (xmax - xmin) * XSCALE *  pwidth / 100.0;
  2290. X            char_height = (ymax - ymin) * YSCALE *  pheight / 100.0;
  2291. X        }
  2292. X        char_space = char_width * (1/SPACE_FACTOR - 1);
  2293. X        }
  2294. X        printf("/%s %g %g %g DefFont\n",
  2295. X        font, char_width, char_height, char_slant);
  2296. X        dumpit(1);
  2297. X        break;
  2298. X
  2299. X    case 'S':        /* Select Standard Set */
  2300. X    case 's':
  2301. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2302. X        dumpit(2);
  2303. X        break;
  2304. X
  2305. X    default:
  2306. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  2307. X        dumpit(2);
  2308. X    }
  2309. X    break;
  2310. X
  2311. X    case 'T':
  2312. X    case 't':
  2313. X    op2 = getc(stream);
  2314. X    switch (op2)
  2315. X    {
  2316. X    case 'L':        /* Tick Length */
  2317. X    case 'l':
  2318. X                /* Feature added by Gordon Jacobs */
  2319. X        debugp((stderr,"%c%c",op1,op2));
  2320. X        if(SIGNED_NUMERIC) {
  2321. X            tlp = 0.01 * getval();
  2322. X        if(SIGNED_NUMERIC)
  2323. X            tln = 0.01 * getval();
  2324. X        else
  2325. X            tln = 0.0;
  2326. X        }
  2327. X        else
  2328. X        tlp = tlp = 0.005;   /* defaults */
  2329. X        dumpit(1);
  2330. X        break;
  2331. X
  2332. X    default:
  2333. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  2334. X        dumpit(2);
  2335. X    }
  2336. X    break;
  2337. X
  2338. X    case 'U':
  2339. X    case 'u':
  2340. X    op2 = getc(stream);
  2341. X    switch (op2)
  2342. X    /*                                                          */
  2343. X    /* This case has been modified by Gerald William Kokodyniak */
  2344. X    /* at the University of Toronto, Department of Mechanical   */
  2345. X    /* Engineering. It is presently operational with a calls    */
  2346. X    /* made to a new subroutine/function called:                */
  2347. X    /*               userdefchar()                              */
  2348. X    /*                                 */
  2349. X    /*  Heavily modified by Gordon Jacobs. Size of user         */
  2350. X    /*  character now depends on regular character size.        */
  2351. X    /*  Orientation of character also depends on that of        */
  2352. X    /*  regular character set.                                  */
  2353. X    {
  2354. X    case 'C':        /* User Defined Character */
  2355. X    case 'c':
  2356. X        debugp((stderr,"%c%c",op1,op2));
  2357. X        userdefchar();
  2358. X        dumpit(1);
  2359. X        break;
  2360. X
  2361. X    case 'F':        /* User-defined Fill Type */
  2362. X    case 'f':
  2363. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2364. X        dumpit(2);
  2365. X        break;
  2366. X
  2367. X    default:
  2368. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  2369. X        dumpit(2);
  2370. X        }
  2371. X    break;
  2372. X
  2373. X    case 'V':
  2374. X    case 'v':
  2375. X    op2 = getc(stream);
  2376. X    switch (op2)
  2377. X    {
  2378. X    case 'S':        /* Velocity Select */
  2379. X    case 's':
  2380. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2381. X        dumpit(2);
  2382. X        break;
  2383. X
  2384. X    default:
  2385. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  2386. X        dumpit(2);
  2387. X    }
  2388. X    break;
  2389. X
  2390. X    case 'W':            /* Not HP-GL */
  2391. X    case 'w':
  2392. X    op2 = getc(stream);
  2393. X    switch (op2)
  2394. X    {
  2395. X    case 'G':        /* Fill Wedge */
  2396. X    case 'g':
  2397. X        notimp((stderr,"Not Implemented: %c%c",op1,op2));
  2398. X        dumpit(2);
  2399. X        break;
  2400. X
  2401. X    default:
  2402. X        notimp((stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2));
  2403. X        dumpit(2);
  2404. X    }
  2405. X    break;
  2406. X
  2407. X    case 'X':
  2408. X    case 'x':
  2409. X    op2 = getc(stream);
  2410. X    switch (op2)
  2411. X    {
  2412. X    case 'T':        /* X Tick */
  2413. X    case 't':
  2414. X        debugp((stderr,"%c%c",op1,op2));
  2415. X        tick(XTICK);     /* Tick() added by Gordon Jacobs */
  2416. X        dumpit(1);
  2417. X        break;
  2418. X
  2419. X    default:
  2420. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command  ", op1, op2));
  2421. X        dumpit(2);
  2422. X    }
  2423. X    break;
  2424. X
  2425. X    case 'Y':
  2426. X    case 'y':
  2427. X    op2 = getc(stream);
  2428. X    switch (op2)
  2429. X    {
  2430. X    case 'T':        /* Y Tick */
  2431. X    case 't':
  2432. X        debugp((stderr,"%c%c",op1,op2));
  2433. X        tick(YTICK);     /* Tick() added by Gordon Jacobs */
  2434. X        dumpit(1);
  2435. X        break;
  2436. X
  2437. X    default:
  2438. X        notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
  2439. X        dumpit(2);
  2440. X    }
  2441. X    break;
  2442. X
  2443. X    default:
  2444. X    op2 = getc(stream);
  2445. X    notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1,op2));
  2446. X    dumpit(2);
  2447. X    break;
  2448. X    }
  2449. X}
  2450. X
  2451. Xdumpit(x)
  2452. Xint x;
  2453. X{
  2454. X    /* Dump all characters until we get to another command letter.
  2455. X     * This is to make sure that we have a clean start for the next command
  2456. X     */
  2457. X    while (((ch = getc(stream)) != EOF) && ch < 'A')
  2458. X    {
  2459. X    if (x == 1 )
  2460. X        debugp((stderr,"%c",ch));
  2461. X    if (x == 2 )
  2462. X        notimp((stderr,"%c",ch));
  2463. X    }
  2464. X    if (x == 1 )
  2465. X    debugp((stderr,"\n"));
  2466. X    if (x == 2 )
  2467. X    notimp((stderr,"\n"));
  2468. X    ungetc(ch,stream);
  2469. X}
  2470. X
  2471. Xdumpcomma()
  2472. X{
  2473. X    /* Dump the possible comma after a plot command. */
  2474. X    while (((ch = getc(stream)) != EOF) && ch == ',')
  2475. X    debugp((stderr,"%c",ch));
  2476. X    ungetc(ch,stream);
  2477. X}
  2478. SHAR_EOF
  2479. chmod 0644 hpglcom.c || echo "restore of hpglcom.c fails"
  2480. set `wc -c hpglcom.c`;Sum=$1
  2481. if test "$Sum" != "21611"
  2482. then echo original size 21611, current size $Sum;fi
  2483. echo "x - extracting linesize.c (Text)"
  2484. sed 's/^X//' << 'SHAR_EOF' > linesize.c &&
  2485. X/* linesize.c */
  2486. X#include "defn.h"
  2487. X
  2488. Xlinesize()
  2489. X{
  2490. X    int        ipen = 0;
  2491. X    float    linewidth;
  2492. X
  2493. X   if (SIGNED_NUMERIC)
  2494. X    ipen = getval() - 1;
  2495. X
  2496. X   if (ipen < 0 || ipen > 8)
  2497. X    ipen = 0;
  2498. X
  2499. X    pen_number = ipen;
  2500. X
  2501. X    linewidth = pen_size[ipen] * SCALE;        /* In mm */
  2502. X    printf("%g mm setlinewidth\n", linewidth);
  2503. X}
  2504. SHAR_EOF
  2505. chmod 0644 linesize.c || echo "restore of linesize.c fails"
  2506. set `wc -c linesize.c`;Sum=$1
  2507. if test "$Sum" != "303"
  2508. then echo original size 303, current size $Sum;fi
  2509. echo "x - extracting linetype.c (Text)"
  2510. sed 's/^X//' << 'SHAR_EOF' > linetype.c &&
  2511. X/* linetype.c
  2512. X * Sets the line type and the scaling of the line pattern 
  2513. X *
  2514. X * Don McCormick CSIRO Division of Applied Physics National Measurements
  2515. X * Laboritory Bradfield Road Lindfield 2018 N.S.W. 
  2516. X *
  2517. X * NOTE: default length for a line pattern is approx 6.5 mm on A4 size paper. 
  2518. X */
  2519. X#include "defn.h"
  2520. X
  2521. Xfloat   linescale;
  2522. Xint     linestyle;
  2523. X
  2524. Xlinetype(line)
  2525. Xint     line;
  2526. X{
  2527. X    float   down1, down2;
  2528. X    float   up1, up2;
  2529. X    float   diagonal;
  2530. X
  2531. X    end_draw();
  2532. X
  2533. X    if (line == LINE_TYPE_SCALE)            /* HP-GL only */
  2534. X    {
  2535. X    if (SIGNED_NUMERIC)
  2536. X    {
  2537. X        if ((linestyle = rint(getval())) > 6)
  2538. X        linestyle = 6;
  2539. X        else if (linestyle < -6)
  2540. X        linestyle = -6;
  2541. X    }
  2542. X    else
  2543. X    {
  2544. X        SETDOT = 0;
  2545. X        printf("[] 0 setdash\n");
  2546. X        return;
  2547. X    }
  2548. X
  2549. X    diagonal = pow((xmax - xmin),2.0) + pow((ymax - ymin),2.0);
  2550. X    diagonal = pow(diagonal,0.5);
  2551. X    if (SIGNED_NUMERIC)
  2552. X        linescale = getval() * 0.01 * diagonal * XSCALE * SCALE * 0.2;
  2553. X    else
  2554. X        linescale = 0.015 * diagonal * XSCALE * SCALE * 0.2;
  2555. X    } else
  2556. X    if (line == LINESCALE)    /* DXY commands only */
  2557. X    {
  2558. X    if (SIGNED_NUMERIC)
  2559. X        linescale = getval() / 80 * SCALE;
  2560. X    else
  2561. X        return;
  2562. X    } else
  2563. X    if (line == LINETYPE)    /* DXY commands only */
  2564. X    {
  2565. X    if (SIGNED_NUMERIC)
  2566. X    {
  2567. X        if ((linestyle = rint(getval())) > 5)
  2568. X        linestyle = 5;
  2569. X        else if (linestyle < -5)
  2570. X        linestyle = -5;
  2571. X    }
  2572. X    else
  2573. X        return;
  2574. X    } else
  2575. X    {
  2576. X    fprintf(stderr, "Error: Unknown line flag in linetype.c\n");
  2577. X    exit(1);
  2578. X    }
  2579. X    /*
  2580. X     * select a line style/type and scale/pitch 
  2581. X     */
  2582. X    switch (linestyle)
  2583. X    {
  2584. X    case 6:
  2585. X    down1 = 2.0;
  2586. X    up1 = up2 = 1.5;
  2587. X    down2 = 1.5;
  2588. X    break;
  2589. X
  2590. X    case 5:
  2591. X    down1 = 3.0;
  2592. X    up1 = up2 = 1.0;
  2593. X    down2 = 1.5;
  2594. X    break;
  2595. X
  2596. X    case 4:
  2597. X    down1 = 4.0;
  2598. X    up1 = up2 = 0.75;
  2599. X    down2 = 1.0;
  2600. X    break;
  2601. X
  2602. X    case 3:
  2603. X    down1 = 5.0;
  2604. X    up1 = up2 = 1.0;
  2605. X    down2 = 0.5;
  2606. X    break;
  2607. X
  2608. X    case 2:
  2609. X    down1 = 5.5;
  2610. X    up1 = 1.0;
  2611. X    up2 = down2 = 0.0;
  2612. X    break;
  2613. X
  2614. X    case 1:
  2615. X    down1 = 5.0;
  2616. X    up1 = 1.5;
  2617. X    up2 = down2 = 0.0;
  2618. X    break;
  2619. X
  2620. X    case -1:
  2621. X    down1 = 1.5;
  2622. X    up1 = 3.5;
  2623. X    down2 = 1.5;
  2624. X    up2 = 0.0;
  2625. X    break;
  2626. X
  2627. X    case -2:
  2628. X    down1 = 2.0;
  2629. X    up1 = 2.5;
  2630. X    down2 = 2.0;
  2631. X    up2 = 0.0;
  2632. X    break;
  2633. X
  2634. X    case -3:
  2635. X    down1 = 2.5;
  2636. X    up1 = up2 = 1.75;
  2637. X    down2 = 0.5;
  2638. X    break;
  2639. X
  2640. X    case -4:
  2641. X    down1 = 2.5;
  2642. X    up1 = up2 = 1.5;
  2643. X    down2 = 1.5;
  2644. X    break;
  2645. X
  2646. X    case -5:
  2647. X    down1 = down2 = 2.0;
  2648. X    up1 = up2 = 1.25;
  2649. X    break;
  2650. X
  2651. X    case -6:
  2652. X    down1 = down2 = 1.75;
  2653. X    up1 = up2 = 1.5;
  2654. X    break;
  2655. X    }
  2656. X    if (linestyle == 0)
  2657. X    {
  2658. X    SETDOT = 1;        /* For HP-GL only */
  2659. X    printf("[] 0 setdash\n");    /* For DXY commands */
  2660. X    } else
  2661. X    {
  2662. X    SETDOT = 0;        /* For HP-GL only */
  2663. X    if (linescale <= 0) linescale = SCALE;
  2664. X    down1 *= linescale;
  2665. X    up2 *= linescale;
  2666. X    up1 *= linescale;
  2667. X    down2 *= linescale;
  2668. X    printf("[%g mm %g mm %g mm %g mm] 0 setdash\n",
  2669. X           down1, up1, down2, up2);
  2670. X    }
  2671. X}
  2672. X
  2673. X#ifdef SYSV
  2674. Xrint(x)
  2675. X    double x;
  2676. X    {
  2677. X    int k;
  2678. X    k = x;
  2679. X    return(k);
  2680. X    }
  2681. X#endif
  2682. SHAR_EOF
  2683. chmod 0644 linetype.c || echo "restore of linetype.c fails"
  2684. set `wc -c linetype.c`;Sum=$1
  2685. if test "$Sum" != "2811"
  2686. then echo original size 2811, current size $Sum;fi
  2687. echo "x - extracting manualfeed.c (Text)"
  2688. sed 's/^X//' << 'SHAR_EOF' > manualfeed.c &&
  2689. X/*      manualfeed.c
  2690. X *    A procedure to allow the user to use the manual feed on
  2691. X *    the LaserWriter.
  2692. X *    The default wait before timeout is 3 minutes however this
  2693. X *    is easily changed.
  2694. X *
  2695. X *    argument: 1.   Enable manual feed.
  2696. X *          0.   Disable manual feed.
  2697. X *
  2698. X *    Don McCormick
  2699. X */
  2700. Xmanualfeed(arg)
  2701. Xint     arg;
  2702. X{
  2703. X    if (arg == 1)
  2704. X    {
  2705. X    printf("statusdict /manualfeed true put\n");
  2706. X    printf("statusdict /manualfeedtimeout 180 put\n");    /* 3 minute wait */
  2707. X    } else
  2708. X    printf("statusdict /manualfeed false put\n");
  2709. X
  2710. X    printf("usertime 5000 add\n");
  2711. X    printf("{dup usertime lt {pop exit} if} loop\n");
  2712. X}
  2713. SHAR_EOF
  2714. chmod 0644 manualfeed.c || echo "restore of manualfeed.c fails"
  2715. set `wc -c manualfeed.c`;Sum=$1
  2716. if test "$Sum" != "603"
  2717. then echo original size 603, current size $Sum;fi
  2718. echo "x - extracting plotcoords.c (Text)"
  2719. sed 's/^X//' << 'SHAR_EOF' > plotcoords.c &&
  2720. X/* plotcoords.c */
  2721. X/*
  2722. X *    Define default maximum and minimum plotting coordinates.
  2723. X *        P1 (xmin, ymin),  P2 (xmax, ymax)
  2724. X *
  2725. X *    PaperSize can be:
  2726. X *            "A3" ISO (420mm by 297mm)
  2727. X *            "A4" ISO (297mm by 210mm)
  2728. X *            "A"  ANSI (11" by 8.5")
  2729. X *            "B"  ANSI (17" by 11")
  2730. X *
  2731. X *    Mode can be:    "HPGL" or "DXY"
  2732. X *
  2733. X * Don McCormick
  2734. X */
  2735. X
  2736. X#include "defn.h"
  2737. X
  2738. Xplotcoords()
  2739. X{
  2740. X    if (strcmp(Mode, "HPGL") == 0)
  2741. X    {
  2742. X    if (strcmp(PaperSize, "A3") == 0)    /* HP-GL ISO A3 420mm * 297mm */
  2743. X    {
  2744. X        xmax = 15200;
  2745. X        ymax = 10800;
  2746. X    }
  2747. X    else if(strcmp(PaperSize,"A4") == 0)    /* HP-GL ISO A4 297mm * 210mm */
  2748. X    {
  2749. X        xmax = 10800;
  2750. X        ymax = 7680;
  2751. X    }
  2752. X    else if(strcmp(PaperSize,"A") == 0)    /* HP-GL ANSI A 11 * 8.5inch */
  2753. X    {
  2754. X        xmax = 10000;
  2755. X        ymax = 7200;
  2756. X    }
  2757. X    else if(strcmp(PaperSize,"B") == 0)    /* HP-GL ANSI B 17 * 11inch */
  2758. X    {
  2759. X        xmax = 15200;
  2760. X        ymax = 10000;
  2761. X    }
  2762. X    else 
  2763. X    {
  2764. X        fprintf("Illegal paper size\n");
  2765. X        exit(-1);
  2766. X    }
  2767. X    }
  2768. X    else
  2769. X    {
  2770. X    if (strcmp(PaperSize, "A3") == 0)    /* DXY ISO A3 420mm * 297mm */
  2771. X    {
  2772. X        xmax = 3800;
  2773. X        ymax = 2700;
  2774. X    }
  2775. X    else                /* DXY ISO A4 297mm * 210mm */
  2776. X    {
  2777. X        xmax = 2700;
  2778. X        ymax = 1920;
  2779. X    }
  2780. X    }
  2781. X    /* origin at zero,zero */
  2782. X    xmin = ymin = 0.0;
  2783. X    offX = offY = 0.0;
  2784. X    /* default tick length percentage */
  2785. X    tlp = tln = 0.005;
  2786. X}
  2787. SHAR_EOF
  2788. chmod 0644 plotcoords.c || echo "restore of plotcoords.c fails"
  2789. set `wc -c plotcoords.c`;Sum=$1
  2790. if test "$Sum" != "1273"
  2791. then echo original size 1273, current size $Sum;fi
  2792. echo "x - extracting plotdot.c (Text)"
  2793. sed 's/^X//' << 'SHAR_EOF' > plotdot.c &&
  2794. X/* plotdot.c */
  2795. X/*
  2796. X * Plot a dot or symbol on the paper 
  2797. X */
  2798. X#include "defn.h"
  2799. X
  2800. Xplotdot(type)
  2801. Xchar   *type;
  2802. X{
  2803. X    end_draw();
  2804. X
  2805. X    while (SIGNED_NUMERIC)
  2806. X    {
  2807. X    xval = getval() * XSCALE;
  2808. X    yval = getval() * YSCALE;
  2809. X    if (type == RMOVE)
  2810. X    {
  2811. X        absX += xval;
  2812. X        absY += yval;
  2813. X    } else
  2814. X    if (type == MOVE)
  2815. X    {
  2816. X        absX = xval + offX;
  2817. X        absY = yval + offY;
  2818. X    } else
  2819. X    {
  2820. X        fprintf(stderr, "Error: expecting move command not %s\n", type);
  2821. X        exit(1);
  2822. X    }
  2823. X
  2824. X    if (SYMBOL)
  2825. X    {
  2826. X        printf("%g %g 5 %g (%c) Text\n", absX, absY, char_angle, symbol);
  2827. X        debugp((stderr,"%g %g 5 %g (%c) Text\n", absX, absY, char_angle, symbol));
  2828. X    }
  2829. X        else if (SETDOT)
  2830. X    {
  2831. X            printf("newpath\n");
  2832. X            debugp((stderr,"newpath\n"));
  2833. X            printf("  %g %g %s %g %g %s\n", absX, absY, MOVE, absX, absY, DRAW);
  2834. X            debugp((stderr,"  %g %g %s %g %g %s\n", absX, absY, MOVE, absX, absY, DRAW));
  2835. X        printf("stroke\n");
  2836. X        debugp((stderr,"stroke\n"));
  2837. X    }
  2838. X    }
  2839. X}
  2840. SHAR_EOF
  2841. chmod 0644 plotdot.c || echo "restore of plotdot.c fails"
  2842. set `wc -c plotdot.c`;Sum=$1
  2843. if test "$Sum" != "953"
  2844. then echo original size 953, current size $Sum;fi
  2845. echo "x - extracting plotinit.c (Text)"
  2846. sed 's/^X//' << 'SHAR_EOF' > plotinit.c &&
  2847. X/* plotinit.c */
  2848. X#include "defn.h"
  2849. X
  2850. Xplotinit()
  2851. X{
  2852. X    /*
  2853. X     * Initialisation of PostScript plot macros 
  2854. X     */
  2855. X    MOVE = "M";
  2856. X    RMOVE = "R";
  2857. X    DRAW = "D";
  2858. X    RDRAW = "I";
  2859. X    AARC = "AA";
  2860. X    RARC = "RA";
  2861. X
  2862. X    LANDSCAPE = 1;        /* Display plot in Landscape mode */
  2863. X
  2864. X    SCALE = 1;            /* Default Scale */
  2865. X
  2866. X    PLOTABS = 1;        /* Absolute plot coordinates */
  2867. X
  2868. X    PLOTARC = 0;        /* Plot arc */
  2869. X
  2870. X    PENDOWN = 0;        /* Penup */
  2871. X
  2872. X    SETDOT = 0;            /* HP-GL only for linetype = 0 */
  2873. X
  2874. X    SYMBOL = 0;            /* HP-GL only */
  2875. X
  2876. X    FONT_H_MULT = 1.2;
  2877. X    FONT_W_MULT = 3.6;        /* necessary for postscript fonts to match */
  2878. X                /*  when using relative font sizing */
  2879. X    /*
  2880. X     *       Default line/pen sizes (in mm)
  2881. X     */
  2882. X    pen_size[0] = 0.0125;
  2883. X    pen_size[1] = 0.025;
  2884. X    pen_size[2] = 0.05;
  2885. X    pen_size[3] = 0.1;
  2886. X    pen_size[4] = 0.2;
  2887. X    pen_size[5] = 0.3;
  2888. X    pen_size[6] = 0.4;
  2889. X    pen_size[7] = 0.5;
  2890. X    pen_size[8] = 1.0;
  2891. X
  2892. X    font = "Helvetica";        /* Default font */
  2893. X
  2894. X    EOL = '\003';        /* End of line terminator default */
  2895. X
  2896. X    /*
  2897. X     * Default character specifications
  2898. X     */
  2899. X    char_angle = 0;        /* Degrees  */
  2900. X    char_slant = 0;        /* tan(angle) */
  2901. X    /********** modified for larger defaults  GJ 
  2902. X    char_height = 2.7;        /* mm 
  2903. X    char_space = 0.8;        /* mm 
  2904. X    char_width = 1.9;        /* mm 
  2905. X    *********************************************/
  2906. X    char_height = 4.0;        /* mm */
  2907. X    char_space = 1.2;        /* mm */
  2908. X    char_width = 2.8;        /* mm */
  2909. X
  2910. X    /*
  2911. X     * Page offsets set to zero
  2912. X     */
  2913. X    xoffset = yoffset = 0;
  2914. X    /*
  2915. X     * Define degree to radian parameter
  2916. X     */
  2917. X    deg_rad = asin(1.0) / 90.0;
  2918. X}
  2919. SHAR_EOF
  2920. chmod 0644 plotinit.c || echo "restore of plotinit.c fails"
  2921. set `wc -c plotinit.c`;Sum=$1
  2922. if test "$Sum" != "1606"
  2923. then echo original size 1606, current size $Sum;fi
  2924. echo "x - extracting plotps.c (Text)"
  2925. sed 's/^X//' << 'SHAR_EOF' > plotps.c &&
  2926. X/* plotps.c */
  2927. X#include "defn.h"
  2928. X
  2929. X#define MAXDRAWPOINTS    100
  2930. X
  2931. Xplotps(type)
  2932. Xchar   *type;
  2933. X{
  2934. X    if (type == MOVE || type == RMOVE)
  2935. X    {
  2936. X    while (SIGNED_NUMERIC)
  2937. X    {
  2938. X        if (type == MOVE)
  2939. X        {
  2940. X        end_draw();
  2941. X        absX = lastXmove = getval() * XSCALE + offX;
  2942. X        absY = lastYmove = getval() * YSCALE + offY;
  2943. X        } else
  2944. X        if (type == RMOVE)
  2945. X        {
  2946. X        end_draw();
  2947. X        lastXmove = absX += getval() * XSCALE ;
  2948. X        lastYmove = absY += getval() * YSCALE ;
  2949. X        }
  2950. X    }
  2951. X    }
  2952. X    else            /* Must be a DRAW or RDRAW */
  2953. X    {
  2954. X    while (SIGNED_NUMERIC)
  2955. X    {
  2956. X        if (dcount++ >= MAXDRAWPOINTS)
  2957. X        {
  2958. X        end_draw();
  2959. X        printf("newpath\n");
  2960. X        debugp((stderr,"newpath\n"));
  2961. X        printf("  %g %g %s\n", absX, absY, MOVE);
  2962. X        debugp((stderr,"  %g %g %s\n", absX, absY, MOVE));
  2963. X        DRAW_FLAG = 1;
  2964. X        /* fprintf(stderr, "Warning exceeded %d draw points\n",
  2965. X              MAXDRAWPOINTS); */
  2966. X        }
  2967. X        xval = getval() * XSCALE;
  2968. X        yval = getval() * YSCALE;
  2969. X        if (!DRAW_FLAG)
  2970. X        {
  2971. X        printf("newpath\n");
  2972. X        debugp((stderr,"newpath\n"));
  2973. X        printf("  %g %g %s\n", absX, absY, MOVE);
  2974. X        debugp((stderr,"  %g %g %s\n", absX, absY, MOVE));
  2975. X        DRAW_FLAG = 1;
  2976. X        }
  2977. X        if (type == RDRAW)
  2978. X        {
  2979. X        absX += xval;
  2980. X        absY += yval;
  2981. X        printf("  %g %g %s\n", xval, yval, RDRAW);
  2982. X        debugp((stderr,"  %g %g %s\n", xval, yval, RDRAW));
  2983. X        } else
  2984. X        if (type == DRAW)
  2985. X        {
  2986. X        absX = xval + offX;
  2987. X        absY = yval + offY;
  2988. X        printf("  %g %g %s\n", absX, absY, DRAW);
  2989. X        debugp((stderr,"  %g %g %s\n", absX, absY, DRAW));
  2990. X        } else
  2991. X        {
  2992. X        fprintf(stderr, "Error: expecting draw command not %s\n", type);
  2993. X        exit(1);
  2994. X        }
  2995. X    }
  2996. X    }
  2997. X}
  2998. SHAR_EOF
  2999. chmod 0644 plotps.c || echo "restore of plotps.c fails"
  3000. set `wc -c plotps.c`;Sum=$1
  3001. if test "$Sum" != "1572"
  3002. then echo original size 1572, current size $Sum;fi
  3003. echo "x - extracting printtest (Text)"
  3004. sed 's/^X//' << 'SHAR_EOF' > printtest &&
  3005. X(%%[ pagecount: )print statusdict/pagecount get exec(                )cvs print(, 311 1 ]%%)= flush
  3006. SHAR_EOF
  3007. chmod 0644 printtest || echo "restore of printtest fails"
  3008. set `wc -c printtest`;Sum=$1
  3009. if test "$Sum" != "100"
  3010. then echo original size 100, current size $Sum;fi
  3011. echo "x - extracting ps_macros.c (Text)"
  3012. sed 's/^X//' << 'SHAR_EOF' > ps_macros.c &&
  3013. Xps_macros()
  3014. X{
  3015. X    printf("%%! PS-Adobe-1.0: For Apple LaserWriter\n");
  3016. X    printf("%% default font is 14 pt. Helvetica\n");
  3017. X    printf("/basefont {/Helvetica findfont 14 scalefont setfont} def\n");
  3018. X
  3019. X    /*printf("/mm {72.27 mul 25.4 div} def\n");    /* Specify millimeters */
  3020. X    printf("/mm {72.0 mul 25.4 div} def\n");    /* Specify millimeters */
  3021. X
  3022. X    printf("/M\n");                /* Move macro */
  3023. X    printf("{\n");
  3024. X    printf("    /Ymove exch def\n");
  3025. X    printf("    /Xmove exch def\n");
  3026. X    printf("    Xmove mm Ymove mm moveto\n");
  3027. X    printf("} def\n");
  3028. X
  3029. X    printf("/R\n");                /* Relative move macro */
  3030. X    printf("{\n");
  3031. X    printf("    /Yrmove exch def\n");
  3032. X    printf("    /Xrmove exch def\n");
  3033. X    printf("    Xrmove mm Yrmove mm rmoveto\n");
  3034. X    printf("} def\n");
  3035. X
  3036. X    printf("/D\n");                /* Draw macro */
  3037. X    printf("{\n");
  3038. X    printf("    /Ydraw exch def\n");
  3039. X    printf("    /Xdraw exch def\n");
  3040. X    printf("    Xdraw mm Ydraw mm lineto\n");
  3041. X    printf("} def\n");
  3042. X
  3043. X    printf("/I\n");                /* Relative draw macro */
  3044. X    printf("{\n");
  3045. X    printf("    /Yrdraw exch def\n");
  3046. X    printf("    /Xrdraw exch def\n");
  3047. X    printf("    Xrdraw mm Yrdraw mm rlineto\n");
  3048. X    printf("} def\n");
  3049. X
  3050. X    printf("/AA\n");                /* Arc draw macro */
  3051. X    printf("{\n");
  3052. X    printf("    /endangle exch def\n");
  3053. X    printf("    /startangle exch def\n");
  3054. X    printf("    /radius exch def\n");
  3055. X    printf("    /Ydraw exch def\n");
  3056. X    printf("    /Xdraw exch def\n");
  3057. X    printf("    Xdraw mm Ydraw mm radius mm startangle endangle arc\n");
  3058. X    printf("} def\n");
  3059. X
  3060. X    printf("/AAC\n");                /* Arc draw macro (clockwise) */
  3061. X    printf("{\n");
  3062. X    printf("    /endangle exch def\n");
  3063. X    printf("    /startangle exch def\n");
  3064. X    printf("    /radius exch def\n");
  3065. X    printf("    /Ydraw exch def\n");
  3066. X    printf("    /Xdraw exch def\n");
  3067. X    printf("    Xdraw mm Ydraw mm radius mm startangle endangle arcn\n");
  3068. X    printf("} def\n");
  3069. X    /*
  3070. X     *        Procedure to change font and size of font
  3071. X     *        ---->   font size Font    <----
  3072. X     */
  3073. X    printf("/Font\n");
  3074. X    printf("{\n");
  3075. X    printf("    /Height exch def\n");
  3076. X    printf("    /FontName exch def\n");
  3077. X    printf("    FontName findfont Height mm scalefont setfont\n");
  3078. X    printf("} def\n");
  3079. X    /*
  3080. X     *        Procedure to change font, width, slant and height
  3081. X     *        ---->   font width height slant DefFont    <----
  3082. X     *
  3083. X     *    Note: slant = height * tan( slant_angle )
  3084. X     */
  3085. X    printf("/DefFont\n");
  3086. X    printf("{\n");
  3087. X    printf("    /Slant exch def\n");
  3088. X    printf("    /Height exch def\n");
  3089. X    printf("    /Width exch def\n");
  3090. X    printf("    /FontName exch def\n");
  3091. X    printf("    FontName findfont [ Width mm 0 Slant mm Height mm 0 0] makefont setfont\n");
  3092. X    printf("} def\n");
  3093. X    /*
  3094. X     *        General Text Layout Procedure
  3095. X     *        ---->   x y pos_num angle (text) Text    <----
  3096. X     */
  3097. X    printf("/Text\n");
  3098. X    printf("{\n");
  3099. X    printf("    /String exch def\n");
  3100. X    printf("    /Angle exch def\n");
  3101. X    printf("    /Position exch def\n");
  3102. X    printf("    /Ymove exch def\n");
  3103. X    printf("    /Xmove exch def\n");
  3104. X    printf("    Position 1 lt {/hpf 0 def /lpf 0 def} if\n");
  3105. X    printf("    Position 1 eq {/hpf 0 def /lpf 0 def} if\n");
  3106. X    printf("    Position 2 eq {/hpf 0 def /lpf 0.5 def} if\n");
  3107. X    printf("    Position 3 eq {/hpf 0 def /lpf 1 def} if\n");
  3108. X    printf("    Position 4 eq {/hpf 0.5 def /lpf 0 def} if\n");
  3109. X    printf("    Position 5 eq {/hpf 0.5 def /lpf 0.5 def} if\n");
  3110. X    printf("    Position 6 eq {/hpf 0.5 def /lpf 1 def} if\n");
  3111. X    printf("    Position 7 eq {/hpf 1 def /lpf 0 def} if\n");
  3112. X    printf("    Position 8 eq {/hpf 1 def /lpf 0.5 def} if\n");
  3113. X    printf("    Position 9 eq {/hpf 1 def /lpf 1 def} if\n");
  3114. X    printf("    Position 9 gt {/hpf 1 def /lpf 1 def} if\n");
  3115. X    printf("    /StrLen String stringwidth pop lpf mul def\n");
  3116. X    printf("    /StrHt Height mm hpf mul def\n");
  3117. X    printf("    /Xdiff StrHt Angle sin mul StrLen Angle cos mul sub def\n");
  3118. X    printf("    /Ydiff StrHt Angle cos mul StrLen Angle sin mul add def\n");
  3119. X    printf("    Xmove mm Xdiff add Ymove mm Ydiff sub moveto\n");
  3120. X    printf("    gsave\n");
  3121. X    printf("        Angle rotate\n");
  3122. X    printf("        String show\n");
  3123. X    printf("    grestore\n");
  3124. X    printf("    /PosterOnly 0 def\n");
  3125. X    printf("} def\n");
  3126. X    /*
  3127. X     *        Ellipse and Circle procedure.
  3128. X     *  ---->   xcen ycen xrad yrad start_angle end_angle Ellipse   <----
  3129. X     */
  3130. X    printf("/EllipseDict 8 dict def\n");
  3131. X    printf("EllipseDict /mtrx matrix put\n");
  3132. X    printf("/Ellipse \n");
  3133. X    printf("{   EllipseDict begin\n");
  3134. X    printf("    /endangle exch def\n");
  3135. X    printf("    /startangle exch def\n");
  3136. X    printf("    /yradius exch def\n");
  3137. X    printf("    /xradius exch def\n");
  3138. X    printf("    /ycenter exch def\n");
  3139. X    printf("    /xcenter exch def\n");
  3140. X    printf("    /savematrix mtrx currentmatrix def\n");
  3141. X    printf("    xcenter mm ycenter mm translate\n");
  3142. X    printf("    xradius mm yradius mm div 1 scale\n");
  3143. X    printf("    newpath\n");
  3144. X    printf("        0 0 xradius mm startangle endangle arc\n");
  3145. X    printf("    stroke\n");
  3146. X    printf("    savematrix setmatrix\n");
  3147. X    printf("    end\n");
  3148. X    printf("} def\n");
  3149. X
  3150. X    printf("basefont\n");        /* Set the default font */
  3151. X    printf("1 setlinecap\n");        /* Use round caps */
  3152. X    printf("1 setlinejoin\n");        /* Use round joins */
  3153. X    printf("3 setmiterlimit\n");    /* Bevel small angle miters */
  3154. X}
  3155. SHAR_EOF
  3156. chmod 0644 ps_macros.c || echo "restore of ps_macros.c fails"
  3157. set `wc -c ps_macros.c`;Sum=$1
  3158. if test "$Sum" != "5403"
  3159. then echo original size 5403, current size $Sum;fi
  3160. echo "x - extracting rectangle.c (Text)"
  3161. sed 's/^X//' << 'SHAR_EOF' > rectangle.c &&
  3162. X/* rectangle.c */
  3163. X#include "defn.h"
  3164. X
  3165. Xrectangle()
  3166. X{
  3167. X    int        hatch;
  3168. X    float    width, height;
  3169. X    float    hatch_spacing;
  3170. X    float    hatch_angle;
  3171. X    
  3172. X    if (SIGNED_NUMERIC)
  3173. X    hatch = getval();
  3174. X    if (SIGNED_NUMERIC)
  3175. X    width = getval() * XSCALE;
  3176. X    if (SIGNED_NUMERIC)
  3177. X    height = getval() * YSCALE;
  3178. X    if (SIGNED_NUMERIC)
  3179. X    hatch_spacing = getval() * XSCALE;
  3180. X    if (SIGNED_NUMERIC)
  3181. X    hatch_angle = getval();
  3182. X
  3183. X    end_draw();
  3184. X    printf("%g %g M\n", xval, yval);
  3185. X    printf("%g 0 I\n", width);
  3186. X    printf("0 %g I\n", height);
  3187. X    printf("-%g 0 I\n", width);
  3188. X    printf("closepath stroke\n");
  3189. X    if (hatch != 2)
  3190. X        fprintf(stderr, "Warning: Cross hatching not implemented yet\n");
  3191. X}
  3192. SHAR_EOF
  3193. chmod 0644 rectangle.c || echo "restore of rectangle.c fails"
  3194. set `wc -c rectangle.c`;Sum=$1
  3195. if test "$Sum" != "681"
  3196. then echo original size 681, current size $Sum;fi
  3197. echo "x - extracting test.hpgl (Text)"
  3198. sed 's/^X//' << 'SHAR_EOF' > test.hpgl &&
  3199. XIN;SP3;DI0,1;SR0.70,1.90;SC0,800,0,576;PA;PU20,0;LBDSA 602 DIGITIZING SIGNAL ANALYZERPU20,320;LBPU40,0;LBdate: 18-JUL-89 time: 17:42:27PU40,320;LBPA;PU;
  3200. XSP3;SC-864,5536,-496,4112;LT
  3201. XPU2336,0;PD;PD2320,4,2320,8,2320,12,2336,16,2320,20,2320,24,2336,28,2336,32,2352,36,2336,40,2320,44,2336,48,2320,52,2336,56,2336,60,2336,64,2320,68,2320,72,2336,76,2336,80,2320,84,2336,88,2320,92,2336,96,2336,100,2336,104,2320,108,2336,112,2320,116,2320,120,2336,124,2336,128,2320,132,2352,136,2320,140,2336,144,2336,148,2320,152,2320,156,2336,160,2320,164,2320,168,2336,172,2320,176,2336,180,2336,184,2320,188,2352,192,2336,196,2336,200,2320,204,2336,208,2320,212,2336,216,2320,220,2320,224,2320,228,2320,232,2352,236,2336,240,2336,244,2320,248,2336,252,2336,256,2336,260,2336,264,2320,268,2336,272,2336,276,2320,280,2336,284,2336,288,2336,292,2320,296,2336,300,2320,304,2336,308,2320,312,2336,316,2336,320
  3202. XPD1888,3952,1872,3956,1888,3960,1872,3964,1888,3968,1872,3972,1888,3976,1888,3980,1888,3984,1888,3988,1888,3992,1904,3996,1888,4000,1888,4004,1888,4008,1888,4012,1872,4016,1888,4020,1888,4024,1872,4028,1904,4032,1872,4036,1872,4040,1872,4044,1904,4048,1904,4052,1888,4056,1904,4060,1888,4064,1888,4068,1904,4072,1888,4076,1888,4080,1872,4084,1872,4088,1888,4092
  3203. XPU;
  3204. XPA;PU;
  3205. XSP3
  3206. XPU256,0;PD;PD288,4,256,8,288,12,256,16,288,20,240,24,288,28,272,32,288,36,256,40,288,44,240,48,288,52,256,56,288,60,240,64,272,68,240,72,288,76,256,80,288,84,256,88,288,92,240,96,288,100,256,104,272,108,256,112,272,116,240,120,272,124,256,128,288,132,256,136,272,140,256,144,288,148,256,152,288,156,256,160,288,164,256,168,288,172,256,176,288,180,256,184,288,188,256,192,288,196,256,200,288,204,256,208,304,212,240,216,288,220,256,224,272,228,256,232,288,236,256,240,288,244,256,248,288,252,240,256,288,260,256,264,288,268,256,272,288,276,240,280,288,284,256,288,304,292,256,296,288,300,240,304,272,308,256,312,288,316,240,320,272,324,256,328,288,332,256,336,288,340,256,344,272,348,272,352,272,356,256,360,288,364,272,368,272,372
  3207. XPD656,3764,624,3768,640,3772,608,3776,640,3780,608,3784,656,3788,624,3792,656,3796,624,3800,656,3804,624,3808,656,3812,624,3816,656,3820,608,3824,656,3828,624,3832,640,3836,640,3840,640,3844,624,3848,640,3852,624,3856,624,3860,608,3864,624,3868,608,3872,656,3876,624,3880,656,3884,608,3888,656,3892,624,3896,656,3900,608,3904,640,3908,624,3912,640,3916,624,3920,640,3924,624,3928,640,3932,608,3936,656,3940,608,3944,640,3948,624,3952,656,3956,608,3960,672,3964,624,3968,656,3972,608,3976,640,3980,608,3984,656,3988,624,3992,640,3996,624,4000,656,4004,624,4008,656,4012,624,4016,656,4020,624,4024,656,4028,640,4032,640,4036,608,4040,656,4044,608,4048,656,4052,608,4056,640,4060,640,4064,672,4068,624,4072,640,4076,624,4080,656,4084,608,4088,656,4092
  3208. X
  3209. XPU;
  3210. XPA;PU;
  3211. XSP3
  3212. XPU1008,0;PD;PD992,4,992,8,1008,12,1008,16,992,20,992,24,992,28,992,32,992,36,992,40,976,44,976,48,992,52,1008,56,992,60,1008,64,976,68,1008,72,992,76,1008,80,992,84,992,88,1008,92,1008,96,992,100,992,104,992,108,1008,112,992,116,992,120,992,124,992,128,1008,132,992,136,976,140,976,144,976,148,992,152,992,156,1024,160,976,164,1024,168,1008,172,1008,176,992,180,992,184,992,188,992,192,992,196,992,200,1008,204,1008,208,992,212,992,216,992,220,992,224,976,228,992,232,992,236,992,240,992,244,992,248,1008,252,992,256,1008,260,992,264,992,268,1008,272,992,276,1008,280,992,284,992,288,976,292,992,296,992,300,992,304,1008,308,992,312,992,316,992,320,992,324,992,328,992,332,976,336,976,340,1008,344,1008,348,1008,352,1008,356,976,360
  3213. XPD1456,4024,1456,4028,1440,4032,1440,4036,1456,4040,1440,4044,1456,4048,1456,4052,1440,4056,1440,4060,1440,4064,1440,4068,1440,4072,1440,4076,1456,4080,1456,4084,1456,4088,1440,4092
  3214. XPU;
  3215. XPA;PU;PU2784,0;PD;PD2800,4,2784,8,2800,12,2768,16,2784,20,2784,24,2784,28,2784,32,2768,36,2784,40,2768,44,2800,48,2768,52,2784,56,2768,60,2768,64,2800,68,2768,72,2800,76,2784,80,2784,84,2800,88,2784,92,2784,96,2784,100,2784,104,2768,108,2784,112,2784,116,2800,120,2768,124,2784,128,2784,132,2784,136,2784,140,2784,144,2768,148,2784,152,2784,156,2800,160,2784,164,2784,168,2784,172,2800,176,2800,180,2784,184,2800,188,2784,192,2784,196,2768,200,2784,204,2784,208,2784,212,2784,216,2784,220,2768,224,2784,228,2784,232,2784,236,2784,240,2784,244,2784,248,2784,252,2784,256,2784,260,2784,264,2784,268,2784,272,2768,276,2784,280,2784,284,2784,288,2768,292,2784,296,2768,300,2784,304,2800,308,2784,312,2768,316,2768,320,2784,324,2800,328,2784,332,2800,336
  3216. XPD3232,3964,3232,3968,3232,3972,3232,3976,3232,3980,3216,3984,3232,3988,3216,3992,3232,3996,3232,4000,3216,4004,3248,4008,3248,4012,3248,4016,3248,4020,3216,4024,3232,4028,3232,4032,3232,4036,3216,4040,3232,4044,3232,4048,3232,4052,3232,4056,3232,4060,3232,4064,3232,4068,3216,4072,3248,4076,3216,4080,3232,4084,3232,4088,3232,4092
  3217. XPU;
  3218. X
  3219. XSP2
  3220. XPU4048,48;TL0.5,0;PR;
  3221. XPD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;
  3222. XPD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;
  3223. XTL0,0.5;PR;
  3224. XPD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;
  3225. XPD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400
  3226. XPA,PU2048,48;PR;
  3227. XPD80,0;PA;
  3228. X
  3229. XSP3;SR0.75,1.63;SC0,800,-24,552
  3230. XPU314,-20;LB/div
  3231. XPU122,-20;LB500mV
  3232. XPU298,-20;LB500mV
  3233. XPU618,-20;LB-4.5V
  3234. XPU634,10;LB-98ns
  3235. XPU634,252;LB100ns/div
  3236. XPU634,502;LB902ns
  3237. XPU444,-22;SR0.50,1.63;PR-2,2;LBtrig'd;PA;
  3238. X
  3239. XSR0.75,1.63;SC0,800,-24,552
  3240. XPU635,360;SR0.49,1.05;PR-2,0;PD-12,0,0,17,12,0,0,-17;PU-2,3;LBRT;PA;
  3241. X
  3242. XSR0.75,1.63;SC0,800,-24,552
  3243. XPU196,80;PR7,0;PD-7,15,0,-10,3,3,4,0,-7,7;PA;
  3244. X
  3245. XSP3
  3246. XPU386,116;LBacki_Cbar
  3247. X
  3248. XSP3
  3249. XPU154,96;LBReqi_IN
  3250. X
  3251. XSP3
  3252. XPU266,161;LBacki_B
  3253. XPU490,161;LBacki_ACC
  3254. XSC;PA;PU0,0;SP0;
  3255. X
  3256. SHAR_EOF
  3257. chmod 0644 test.hpgl || echo "restore of test.hpgl fails"
  3258. set `wc -c test.hpgl`;Sum=$1
  3259. if test "$Sum" != "5794"
  3260. then echo original size 5794, current size $Sum;fi
  3261. echo "x - extracting test1.dxy (Text)"
  3262. sed 's/^X//' << 'SHAR_EOF' > test1.dxy &&
  3263. XJ1
  3264. XM 1000, 1000
  3265. XI 100, 0, -200,0, 100, 0, 0,100,0, -200
  3266. XP Hi There
  3267. XC 1000, 1000, 500, 0, 250
  3268. XM 2000,1000
  3269. XI 100, 0, -200,0, 100, 0, 0,100,0, -200
  3270. XL 2
  3271. XJ5
  3272. XC 2000, 1000, 500, 250, 0
  3273. XJ3
  3274. XM 0 0
  3275. XI 3800,0,0,2700,-3800,0,0,-2700
  3276. XM 500,2000
  3277. X^SL1;S50PDXY-880
  3278. X^SL;S3
  3279. X
  3280. SHAR_EOF
  3281. chmod 0644 test1.dxy || echo "restore of test1.dxy fails"
  3282. set `wc -c test1.dxy`;Sum=$1
  3283. if test "$Sum" != "255"
  3284. then echo original size 255, current size $Sum;fi
  3285. echo "x - extracting test1.hpgl (Text)"
  3286. sed 's/^X//' << 'SHAR_EOF' > test1.hpgl &&
  3287. XDF;IN;LT;PU1000,1000;PD2000,1000,2000,2000,1000,2000,1000,1000;
  3288. XPR-100,0,0,-100,100,0,0,100;
  3289. XPU;PA0,0;PD10800,0,10800,7680,0,7680,0,0;PU;
  3290. XLT6,2;PA;PU4000,1400;PD;PR4000,0;
  3291. XLT5,2;PA;PU4000,1300;PD;PR4000,0;
  3292. XLT4,2;PA;PU4000,1200;PD;PR4000,0;
  3293. XLT3,2;PA;PU4000,1100;PD;PR4000,0;
  3294. XLT2,2;PA;PU4000,1000;PD;PR4000,0;
  3295. XLT1,2;PA;PU4000,900;PD;PR4000,0;
  3296. XLT0;PA;PU4000,800;PD;PR4000,0;
  3297. XLT-1,2;PA;PU4000,700;PD;PR4000,0;
  3298. XLT-2,2;PA;PU4000,600;PD;PR4000,0;
  3299. XLT-3,2;PA;PU4000,500;PD;PR4000,0;
  3300. XLT-4,2;PA;PU4000,400;PD;PR4000,0;
  3301. XLT-5,2;PA;PU4000,300;PD;PR4000,0;
  3302. XLT-6,2;PA;PU4000,200;PD;PR4000,0;
  3303. XPU;PA2000,4000;
  3304. XDI;LB  --   0deg --
  3305. XDI1,1;LB  --  45deg --
  3306. XDI0,1;LB  --  90deg --
  3307. XDI-1,1;LB  -- 135deg --
  3308. XDI-1,0;LB  -- 180deg --
  3309. XDI-1,-1;LB  -- 225deg --
  3310. XDI0,-1;LB  -- 270deg --
  3311. XDI1,-1;LB  -- 315deg --
  3312. XPA4000,4000;
  3313. XDI;SL1;LB SLANT of 45deg
  3314. XPA4000,3600;
  3315. XSL-1;LB SLANT of -45deg
  3316. XPA2000,6000;
  3317. XSL;SR;LB Size is relative
  3318. XPA2000,5500;
  3319. XSI;LB DEFAULT sizes
  3320. XPA2000,5000;
  3321. XSI.8,1;LBLARGE size (w=8mm, h=10mm)
  3322. XLT;        PA 9000,1000;CI500,20;CI400;CI300;CI200,1;CI100;CI50;
  3323. XIN;SM+;PA9000,1000,10000,1000;SM%;PR0,500,0,-1000;
  3324. XSM;
  3325. SHAR_EOF
  3326. chmod 0644 test1.hpgl || echo "restore of test1.hpgl fails"
  3327. set `wc -c test1.hpgl`;Sum=$1
  3328. if test "$Sum" != "1095"
  3329. then echo original size 1095, current size $Sum;fi
  3330. echo "x - extracting test3.hpgl (Text)"
  3331. sed 's/^X//' << 'SHAR_EOF' > test3.hpgl &&
  3332. XSP6;DI0,1;SR0.70,1.90;SC0,800,0,576;PA;PU20,0;LBDSA 602 DIGITIZING SIGNAL ANALYZERPU20,320;PA;PU;
  3333. XSP3;SC-864,5536,-496,4112;LT
  3334. XPU3040,0;PD;PD3056,4,3056,8,3040,12;
  3335. XPU;
  3336. X
  3337. XSP2
  3338. XPU4048,48;TL0.5,0;PR;
  3339. XPD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;XT;PD-400,0;
  3340. XPD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;YT;PD0,400;
  3341. XTL0,0.5;PR;
  3342. XPD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;XT;PD400,0;
  3343. XPD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400;YT;PD0,-400
  3344. XPA,PU2048,48;PR;
  3345. XTL0.25,0.25;PD0,80;YT;PD0,80;YT;PD0,80;YT;PD0,80;YT;PD0,80;PA;PU48,2048;PR;
  3346. XTL0.25,0.25;PD80,0;XT;PD80,0;XT;PD80,0;XT;PD80,0;XT;PD80,0;PA;
  3347. X
  3348. XSP6;SR0.75,1.63;SC0,800,-24,552
  3349. XPU682,323;LB200UC99,0.7,1,-99,0,5,99,0,-5,1,-1,1,0,1,1,-99,0,5,99,0,-6;LBs   
  3350. XPA;
  3351. X
  3352. XSP3;SR0.75,1.63;SC0,800,-24,552
  3353. XPU466,30;PR7,0;PD-7,15,0,-10,3,3,4,0,-7,7;PA;
  3354. X
  3355. XSP6
  3356. XPU391,24;PR-27,15;PD-2,-2,4,0,-2,2,0,-5,1,-1,8,0,5,-3;PU0,-4;PD-6,3,0,8,6,-3;PA;
  3357. XSC;PA;PU0,0;SP0;
  3358. X
  3359. SHAR_EOF
  3360. chmod 0644 test3.hpgl || echo "restore of test3.hpgl fails"
  3361. set `wc -c test3.hpgl`;Sum=$1
  3362. if test "$Sum" != "1116"
  3363. then echo original size 1116, current size $Sum;fi
  3364. echo "x - extracting textps.c (Text)"
  3365. sed 's/^X//' << 'SHAR_EOF' > textps.c &&
  3366. X/* textps.c */
  3367. X#include "defn.h"
  3368. X
  3369. X#define MAXBUFSIZE 100
  3370. X
  3371. Xtextps(type)
  3372. Xint     type;
  3373. X{
  3374. X    char    string[4];
  3375. X    char    buffer[MAXBUFSIZE];
  3376. X    float   Xch, Ych;
  3377. X    int        intval;
  3378. X    int     i;
  3379. X
  3380. X    end_draw();
  3381. X
  3382. X    if (type == TEXT)
  3383. X    {
  3384. X    for (i = 0 ; i < MAXBUFSIZE; i++)    /* Clear buffer */
  3385. X        buffer[i] = NULL;
  3386. X
  3387. X    i = 0;                    /* Reset buffer counter */
  3388. X
  3389. X    while (((ch = getc(stream)) != EOF)
  3390. X            && ch != CR && ch != LF && ch != EOL) {
  3391. X        buffer[i++] = ch;
  3392. X    }
  3393. X
  3394. X    printf("%g %g 1 %g (%s) Text\n", absX, absY, char_angle, buffer);
  3395. X
  3396. X    /* move to end of string */
  3397. X    absX += (i * (char_space)) * cos(char_angle * deg_rad) ;
  3398. X        absY += (i * (char_space)) * sin(char_angle * deg_rad) ;
  3399. X
  3400. X    } else            /* Must be a MARK */
  3401. X    {
  3402. X    int     symb_num;
  3403. X
  3404. X    if (SIGNED_NUMERIC)
  3405. X        symb_num = getval();
  3406. X    else
  3407. X    {
  3408. X        fprintf(stderr,
  3409. X            "Error: expecting a symbol number not %c (%d)",
  3410. X            symb_num, symb_num);
  3411. X        exit(1);
  3412. X    }
  3413. X    intval = (int)(getval() + 0.5);
  3414. X    switch (intval)
  3415. X    {
  3416. X    case 0:
  3417. X        strcpy(string, "*");
  3418. X        break;
  3419. X
  3420. X    case 1:
  3421. X        strcpy(string, "+");
  3422. X        break;
  3423. X
  3424. X    case 2:
  3425. X        strcpy(string, "#");
  3426. X        break;
  3427. X
  3428. X    case 3:
  3429. X        strcpy(string, "@");
  3430. X        break;
  3431. X
  3432. X    case 4:
  3433. X        strcpy(string, "%");
  3434. X        break;
  3435. X
  3436. X    case 5:
  3437. X        strcpy(string, "|");
  3438. X        break;
  3439. X
  3440. X    case 6:
  3441. X        strcpy(string, "=");
  3442. X        break;
  3443. X
  3444. X    case 7:
  3445. X        strcpy(string, "&");
  3446. X        break;
  3447. X
  3448. X    case 9:
  3449. X        strcpy(string, "O");
  3450. X        break;
  3451. X
  3452. X    case 10:
  3453. X        strcpy(string, "0");
  3454. X        break;
  3455. X
  3456. X    case 11:
  3457. X        strcpy(string, "Y");
  3458. X        break;
  3459. X
  3460. X    case 12:
  3461. X        strcpy(string, "X");
  3462. X        break;
  3463. X
  3464. X    case 13:
  3465. X        strcpy(string, "Z");
  3466. X        break;
  3467. X
  3468. X    case 14:
  3469. X        strcpy(string, "S");
  3470. X        break;
  3471. X
  3472. X    case 15:
  3473. X        strcpy(string, "Q");
  3474. X        break;
  3475. X
  3476. X    default:
  3477. X        fprintf(stderr, "Warning symbol number is %d\n", symb_num);
  3478. X        strcpy(string, "*");
  3479. X        break;
  3480. X    }
  3481. X    printf("%g %g 5 %g (%s) Text\n", absX, absY, char_angle, string);
  3482. X    }
  3483. X}
  3484. SHAR_EOF
  3485. chmod 0644 textps.c || echo "restore of textps.c fails"
  3486. set `wc -c textps.c`;Sum=$1
  3487. if test "$Sum" != "1896"
  3488. then echo original size 1896, current size $Sum;fi
  3489. echo "x - extracting tick.c (Text)"
  3490. sed 's/^X//' << 'SHAR_EOF' > tick.c &&
  3491. X/* tick.c */
  3492. X/*
  3493. X * tick(type)
  3494. X *
  3495. X * function for handling the XT,YT commands 
  3496. X * in Hewlett-Packard Graphics Language (HP-GL).
  3497. X *
  3498. X * Written by Gordon Jacobs 
  3499. X * University of California, Berkeley , Dept of EECS.
  3500. X */
  3501. X
  3502. X
  3503. X#include "defn.h"
  3504. X
  3505. Xtick(type)
  3506. Xint  type;
  3507. X{
  3508. X    float Xtlengthp,Xtlengthn,Ytlengthp,Ytlengthn;
  3509. X
  3510. X    /* Compute tick lengths as a function of viewport dimensions */
  3511. X    /* Xticks are in Y direction: */
  3512. X    Xtlengthp = tlp * (ymax - ymin) * XSCALE; 
  3513. X    Xtlengthn = tln * (ymax - ymin) * XSCALE; 
  3514. X    /* Yticks are in X direction */
  3515. X    Ytlengthp = tlp * (xmax - xmin) * YSCALE; 
  3516. X    Ytlengthn = tln * (xmax - xmin) * YSCALE; 
  3517. X
  3518. X    /* Ticks: Don't mess with position pointers,
  3519. X     *   just use relative draw and move commands 
  3520. X     */
  3521. X    if (type == XTICK) {
  3522. X    if(tlp != 0.0) {
  3523. X        lastYmove = absY += Xtlengthp;
  3524. X        printf("  %g %g %s\n",0.0,Xtlengthp,RMOVE);
  3525. X        printf("  %g %g %s\n",0.0,-Xtlengthp,RDRAW);
  3526. X    }
  3527. X    if(tln != 0.0) {
  3528. X        lastYmove = absY -= Xtlengthp;
  3529. X        printf("  %g %g %s\n",0.0,-Xtlengthn,RMOVE);
  3530. X        printf("  %g %g %s\n",0.0,Xtlengthn,RDRAW);
  3531. X    }
  3532. X    }
  3533. X    else {
  3534. X    if(tlp != 0.0) {
  3535. X        lastXmove = absX += Xtlengthp;
  3536. X        printf("  %g %g %s\n",Ytlengthp,0.0,RMOVE);
  3537. X        printf("  %g %g %s\n",-Ytlengthp,0.0,RDRAW);
  3538. X    }
  3539. X    if(tln != 0.0) {
  3540. X        lastXmove = absX -= Xtlengthp;
  3541. X        printf("  %g %g %s\n",-Ytlengthn,0.0,RMOVE);
  3542. X        printf("  %g %g %s\n",Ytlengthn,0.0,RDRAW);
  3543. X    }
  3544. X    }
  3545. X}
  3546. SHAR_EOF
  3547. chmod 0644 tick.c || echo "restore of tick.c fails"
  3548. set `wc -c tick.c`;Sum=$1
  3549. if test "$Sum" != "1390"
  3550. then echo original size 1390, current size $Sum;fi
  3551. echo "x - extracting userdefchar.c (Text)"
  3552. sed 's/^X//' << 'SHAR_EOF' > userdefchar.c &&
  3553. X/* userdefchar.c */
  3554. X/*
  3555. X * userdefchar(type)
  3556. X *
  3557. X * function for handling the USER DEFINED CHARACTER (UC) command
  3558. X * in Hewlett-Packard Graphics Language (HP-GL).
  3559. X *
  3560. X * Written by Gerald William Kokodyniak B.A.Sc. M.A.Sc.
  3561. X * University of Toronto, Department of Mechanical Engineering
  3562. X *
  3563. X * Heavily modified by Gordon Jacobs, University of Calif, Berkeley
  3564. X *  Now scales user character size to that of regular characters
  3565. X *  Orients user character the same as regular characters
  3566. X *  Linewidth chosed to always be 0.25mm to better match
  3567. X *  postscript font.
  3568. X *
  3569. X */
  3570. X
  3571. X#include "defn.h"
  3572. X#define MAXDRAWPOINTS    100
  3573. X
  3574. X/* standard resolution user-def character pen control numbers */
  3575. X/*     for enhanced, change to -9999,9999 */
  3576. X#define PENUPCTL -99.0
  3577. X#define PENDNCTL  99.0
  3578. X
  3579. X/* linewidth in mm for user defined characters */
  3580. X#define DEFCHAR_LINEWIDTH 0.25
  3581. X
  3582. X/* Scaling parameters */
  3583. X#define CHAR_CELL_H  5.0
  3584. X#define CHAR_CELL_W  2.5
  3585. X
  3586. Xuserdefchar()
  3587. X{
  3588. X    float   number, tmp, rad, angl;
  3589. X    float   theMagnitude(), theAngle();
  3590. X    float   first_absX = absX;
  3591. X    float   first_absY = absY;
  3592. X    PENDOWN = 0;
  3593. X    printf("%g mm setlinewidth\n", DEFCHAR_LINEWIDTH);
  3594. X
  3595. X    while (SIGNED_NUMERIC)
  3596. X    {
  3597. X    number = getval();
  3598. X    if (number >= PENDNCTL) {
  3599. X        PENDOWN = 1;
  3600. X        number = getval();
  3601. X    }
  3602. X        else if (number <= PENUPCTL) {
  3603. X        PENDOWN = 0;
  3604. X        number = getval();
  3605. X    }
  3606. X
  3607. X        if (number < PENDNCTL && number > PENUPCTL) {
  3608. X        if (PENDOWN) {
  3609. X            if (dcount++ >= MAXDRAWPOINTS) {
  3610. X            end_draw();
  3611. X            printf("newpath\n");
  3612. X            printf("  %g %g %s\n", absX, absY, MOVE);
  3613. X            DRAW_FLAG = 1;
  3614. X            }
  3615. X            xval = number / CHAR_CELL_W * char_width * XSCALE;
  3616. X            yval = getval() / CHAR_CELL_H * char_height * YSCALE;
  3617. X            if (!DRAW_FLAG) {
  3618. X            printf("newpath\n");
  3619. X            printf("  %g %g %s\n", absX, absY, MOVE);
  3620. X            DRAW_FLAG = 1;
  3621. X            }
  3622. X        /* perform rotation */
  3623. X        rad = theMagnitude(xval,yval);
  3624. X        angl = theAngle(xval,yval);
  3625. X        angl += char_angle * deg_rad;
  3626. X        xval =  rad *cos(angl);
  3627. X        yval =  rad *sin(angl);
  3628. X        absX += xval;
  3629. X            absY += yval;
  3630. X            printf("  %g %g %s\n", xval, yval, RDRAW);
  3631. X            } else {
  3632. X        end_draw();
  3633. X        xval = number  / CHAR_CELL_W * char_width *XSCALE;
  3634. X        yval = getval() / CHAR_CELL_H * char_height * YSCALE;
  3635. X
  3636. X        rad = theMagnitude(xval,yval);
  3637. X        angl = theAngle(xval,yval);
  3638. X        angl += char_angle * deg_rad;
  3639. X
  3640. X            lastXmove = absX += rad * cos(angl);
  3641. X            lastYmove = absY += rad * sin(angl);
  3642. X        }
  3643. X    }
  3644. X    else {
  3645. X        if(number >= PENDNCTL)
  3646. X        PENDOWN = 1;
  3647. X        else if(number <= PENUPCTL)
  3648. X        PENDOWN = 0;
  3649. X    }
  3650. X    }
  3651. X    PENDOWN = 0;
  3652. X    end_draw();
  3653. X    /* move a fraction of a space so next character doesn't abutt */
  3654. X    absX += 0.2 * char_space * cos(char_angle * deg_rad);
  3655. X    absY += 0.2 * char_space * sin(char_angle * deg_rad);
  3656. X    printf("%g mm setlinewidth\n", pen_size[pen_number]);
  3657. X}
  3658. X
  3659. Xfloat
  3660. XtheMagnitude(x,y)
  3661. Xfloat x,y;
  3662. X{
  3663. X    return(sqrt(x * x + y * y));
  3664. X}
  3665. X
  3666. Xfloat
  3667. XtheAngle(x,y)
  3668. Xfloat x,y;
  3669. X{
  3670. X    if(x != 0.0)
  3671. X    return(atan(y/x));
  3672. X    else
  3673. X    return((y > 0.0) ? M_PI_2 : (M_PI + M_PI_2));
  3674. X}
  3675. SHAR_EOF
  3676. chmod 0644 userdefchar.c || echo "restore of userdefchar.c fails"
  3677. set `wc -c userdefchar.c`;Sum=$1
  3678. if test "$Sum" != "3052"
  3679. then echo original size 3052, current size $Sum;fi
  3680. echo "x - extracting viewport.c (Text)"
  3681. sed 's/^X//' << 'SHAR_EOF' > viewport.c &&
  3682. X/* viewport.c */
  3683. X/*
  3684. X * This procedure sets up the variables for the translation of plotter
  3685. X * coordinates to PostScript coordinates.
  3686. X *
  3687. X * Note: the procedure "defaults" may be incorporated here, however
  3688. X *    I have not had the time to work it out properly.
  3689. X *
  3690. X * Don McCormick
  3691. X */
  3692. X#include "defn.h"
  3693. X/*  original psxmax */
  3694. X#define XWIDTH 0.90
  3695. X
  3696. Xviewport()
  3697. X{
  3698. X    /* original values for A4 */
  3699. X    /* float pagewidth = 197.0;        /* Page width for Laser Printer  */
  3700. X    /* float pageheight = 280.0;    /* Page height for Laser Printer */
  3701. X    /* float pwoffset = 12; */
  3702. X    /* float phoffset = 12; */
  3703. X
  3704. X    /*  8.5 x 11 inch paper */
  3705. X    float pagewidth = 200.0;        /* Page width for Laser Printer */
  3706. X    float pageheight = 265.0;        /* Page height for Laser Printer */
  3707. X    float pwoffset = 28;
  3708. X    float phoffset = 6;
  3709. X    /* values above selected empirically to match HP7550A plot -G.J. */
  3710. X
  3711. X    /* made global */
  3712. X    /* float psxmax, psymax;        /* Sizes scaled to the viewport */
  3713. X
  3714. X    if (LANDSCAPE)        /* Default mode */
  3715. X    {
  3716. X    psymax = pagewidth * XWIDTH;
  3717. X    psxmax = psymax * (xmax - xmin)/ (ymax - ymin);
  3718. X    xoffset += (pageheight + phoffset - psxmax) / 2.0;
  3719. X    yoffset -= (pagewidth + pwoffset + psymax) / 2.0;
  3720. X    printf("90 rotate\n"); 
  3721. X    } else
  3722. X    {
  3723. X    psxmax = pagewidth * XWIDTH;
  3724. X    psymax = psxmax * (ymax - ymin) / (xmax - xmin);
  3725. X    xoffset += (pagewidth + pwoffset - psxmax) / 2.0;
  3726. X    yoffset += (pageheight + phoffset - psymax) / 2.0;
  3727. X    }
  3728. X    printf("%g mm %g mm translate\n", xoffset, yoffset);
  3729. X    XSCALE = psxmax / (xmax - xmin) * SCALE;
  3730. X    YSCALE = psymax / (ymax - ymin) * SCALE;
  3731. X    /* fprintf(stderr,"Xscale = %g  Yscale = %g\n",XSCALE,YSCALE); */
  3732. X}
  3733. X
  3734. X/* function called when the HP-GL Scale command is received */
  3735. X/* Modifies the X,Y SCALE factors and the origin offsets */
  3736. X/*  Added by Gordon Jacobs */
  3737. X
  3738. Xmodify_viewport()
  3739. X{
  3740. X    /* re-calculate scale parameters */
  3741. X    XSCALE = psxmax / (xmax - xmin) * SCALE;
  3742. X    YSCALE = psymax / (ymax - ymin) * SCALE;
  3743. X
  3744. X    /* calculate new offset */
  3745. X    offX = -xmin * XSCALE;
  3746. X    offY = -ymin * YSCALE;
  3747. X
  3748. X    debugp((stderr,"MODIFY: Xscale = %g  Yscale = %g\n",XSCALE,YSCALE));
  3749. X    debugp((stderr,"OFFSET: offX = %g  offY = %g\n",offX,offY));
  3750. X}
  3751. SHAR_EOF
  3752. chmod 0644 viewport.c || echo "restore of viewport.c fails"
  3753. set `wc -c viewport.c`;Sum=$1
  3754. if test "$Sum" != "2171"
  3755. then echo original size 2171, current size $Sum;fi
  3756. exit 0
  3757.