home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-14 | 97.3 KB | 3,757 lines |
- ---- Cut Here and unpack ----
- #!/bin/sh
- # shar: Shell Archiver (v1.22)
- #
- # Run the following text with /bin/sh to create:
- # Makefile
- # README
- # arcps.c
- # changesizes.c
- # circle.c
- # defn.h
- # dxy2ps.c
- # dxy2ps.man
- # dxycom.c
- # end_draw.c
- # getval.c
- # hpgl2ps.c
- # hpgl2ps.man
- # hpglcom.c
- # linesize.c
- # linetype.c
- # manualfeed.c
- # plotcoords.c
- # plotdot.c
- # plotinit.c
- # plotps.c
- # printtest
- # ps_macros.c
- # rectangle.c
- # test.hpgl
- # test1.dxy
- # test1.hpgl
- # test3.hpgl
- # textps.c
- # tick.c
- # userdefchar.c
- # viewport.c
- #
- echo "x - extracting Makefile (Text)"
- sed 's/^X//' << 'SHAR_EOF' > Makefile &&
- X# 1.0 dxy2ps and hpgl2ps (Copyright) D McCormick
- X# Commercial reproduction prohibited.
- X#
- X# Obtained from UUCP Newsgroup comp.sources.unix
- X# Spring 1988
- X#
- X# Modified by Gordon Jacobs, July 1989
- X#
- X# Modified by Michael L. Brown, June, 1990
- X#
- XSHELL= /bin/sh
- XFILTER1= dxy2ps
- XFILTER2= hpgl2ps
- XINCLUDE= defn.h
- XLOCALLIB= libroland.a
- XAR= ar
- XARFLAGS= ru
- X
- X#
- X# If compiling on a SystemV computer, add -DSYSV to the CFLAGS, or if
- X# your computer doesn't have rint() as part of math.h. A simple rint()
- X# is defined in linetype.c
- X#
- X# Add -DNOTIMP to list the non-implemented HPGL commands.
- X#
- X# Add -DDEBUG for listing the HPGL implemented commands and the PostScript
- X# output that goes with it.
- X#
- XCFLAGS= -O -DNOTIMP -DSYSV
- X
- X# For a Sun computer, activate the following two lines by replacing the
- X# names sake above.
- X#
- XINSDIR= /usr/local/bin
- XLOADLIBES= -lm
- X
- X# For a Mips computer, activate the following two lines by replacing the
- X# names sake above.
- X#
- X# INSDIR= /home/zion1/jac/bin
- X# LOADLIBES= -lm
- X# CFLAGS= -O0 -signed
- X
- X# For BSD computers that have ranlib, remove the # before the ranlib below.
- X# For systems that don't have ranlib, put a # in the first column before ranlib.
- X
- XOBJ1= dxy2ps.o
- X
- XOBJ2= hpgl2ps.o
- X
- XOBJC= arcps.o changesizes.o circle.o dxycom.o end_draw.o\
- X getval.o hpglcom.o linesize.o linetype.o\
- X manualfeed.o plotdot.o plotinit.o plotps.o\
- X userdefchar.o ps_macros.o rectangle.o textps.o\
- X viewport.o plotcoords.o tick.o
- X
- Xall: $(FILTER1) $(FILTER2) install
- X
- X$(FILTER1): $(LOCALLIB) $(OBJ1)
- X $(CC) $(CFLAGS) -o $@ $(OBJ1) $(LOCALLIB) $(LOADLIBES)
- X
- X$(FILTER2): $(OBJC) $(OBJ2)
- X $(CC) $(CFLAGS) -o $@ $(OBJ2) $(OBJC) $(LOADLIBES)
- X
- X$(LOCALLIB): $(OBJC)
- X $(AR) $(ARFLAGS) $@ $(OBJC)
- X# ranlib $(LOCALLIB)
- X
- X$(OBJC): $(INCLUDE)
- X
- X$(OBJ1): $(INCLUDE)
- X
- X$(OBJ2): $(INCLUDE)
- X
- Xinstall: install1 install2
- X
- Xinstall1: $(FILTER1)
- X install -s $(FILTER1) $(INSDIR)
- X
- Xinstall2: $(FILTER2)
- X install -s $(FILTER2) $(INSDIR)
- X
- Xclean:
- X rm -f *.o a.out core libroland.a
- X
- SHAR_EOF
- chmod 0644 Makefile || echo "restore of Makefile fails"
- set `wc -c Makefile`;Sum=$1
- if test "$Sum" != "2020"
- then echo original size 2020, current size $Sum;fi
- echo "x - extracting README (Text)"
- sed 's/^X//' << 'SHAR_EOF' > README &&
- X/* hpgl2ps.pckd - enhanced version */
- X/* hpgl2ps.ucb - Further enhanced version */
- X/* hpgl2ps.mlb - Enhanced even further */
- X
- XThere are two filters in this package which are based on the Roland
- Xplotter command set.
- X
- X1. DXY: A simple command set which is used with all DXY plotters
- X
- X2. RD-GL: This command set is a superset of the HP (Hewlet Packard)
- X graphics language.
- X
- XNot all the commands of DXY or RD-GL (HPGL) are implemented (approx 95%
- Xare) and those commands that are not are skipped and a warning given.
- XIt is very easy to add to this filter if a particular unimplemented
- Xcommand is desired.
- X
- XIf you wish to implement a command go to the relevant portion in the
- Xcommand switch "dxycom.c" or "hpglcom.c" and call an appropriate user
- Xwritten procedure. (You will need a good knowledge of writing
- XPostScript programs)
- X
- XThe filters use the the procedure "getopt" which is used to interpret
- Xcommand line options and arguments and is normally available on 4.3 bsd
- Xand Sys V Unix. For those sites running 4.1 or 4.2 it may be available
- Xas a local library and must be written into the Makefile.
- X
- XIF YOU DONT HAVE GETOPT YOU WILL HAVE REWRITE THE CODE THAT INTERPRETS
- XCOMMAND LINE OPTIONS AND ARGUMENTS.
- X
- XNOTE 1: The method of writing text is not fully compatible with HPGL
- Xand will be changed at a later date.
- X
- XNOTE 2: The PostScript macros are written into a C procedure to allow
- Xeach filter to be a single stand alone program. These macros can easily
- Xbe incorporated into other filter programs.
- X
- XI have written some test procedures for the testing of each filter they
- Xare "test1.hpgl" for hpgl2ps and "test1.dxy" for dxy2ps.
- X
- XDon McCormick.
- X
- X-------------------------
- XNotes on first enhancement:
- X
- XSupport for user defined characters added by
- XGerald William Kokodyniak B.A.Sc. M.A.Sc.
- XUniversity of Toronto, Department of Mechanical Engineering
- X
- X-------------------------
- XNotes on second enhancement:
- XSupport for Scaling, tickmarks, and better user defined characters
- Xadded by Gordon Jacobs, (Ph.D., since we're into titles above)
- XUniversity of California, Berkeley in July 1989.
- X
- XMods were made ONLY for the hpgl2ps program and are not guaranteed
- Xto work for dxy2ps. HP-GL code from the Tektronix DSA 602
- XDigitizing Signal Analyzer (scope) were used as a test.
- XLaserwriter output was compared directly with plots from a
- XHP7550A plotter reading the same HP-GL file.
- X
- XSupport for scaling was added.
- XThe Scaling involves re-setting the coordinate
- Xsystem by re-calculating the XSCALE and YSCALE numbers and adding
- Xan offset to the origin. The offset had to be added to all files
- Xthat make use of the scaling parameters.
- X
- XTick marks were added with tick.c. Uses relative draw commands
- Xto make the tick marks and adds two global variables which are
- Xthe tick length as a percentage of the overall dimensions.
- X
- XThe parser was changed. The SIGNED_NUMERIC macro recognized a comma
- Xas a valid character which does not make sense. The HP-GL code from
- Xthe DSA 602 often contains a mnemonic followed by a comma, but with
- Xno parameters. This is valid code although most sources will not
- Xplace a comma unless optional parameters actually follow. The comma
- Xwas removed as a valid SIGNED_NUMERIC character and the function
- Xgetval() was modified to read all trailing commas and spaces. In this way
- Xthe parser works for both the standard and odd case mentioned above.
- X
- XThe user defined character routine was modified heavily. Original
- Xfunction did not take into account the angle of characters. The
- Xnew function reads the current angle of characters and orients
- Xthe user defined character in the same way. The scaling, which was
- Xoriginally huge for some reason now is dynamically set to a
- Xproportion of the size of regular text character. The linewidth
- Xof the user defined character is arbitrarily set to 0.25mm and
- Xthen the restored to the previous value. This width seems to fit
- Xthe "linewidth" of the characters in the postscript helvetica
- Xfont sized for the DSA 602 output.
- X
- XThe default paper size is changed to be 8.5 x 11 inch paper with
- Xcommand line options added to support all others.
- X
- XThe command line options -w and -h were added because the relative
- Xscaling of fonts with the "SR" HP-GL command, while implemented
- Xcorrectly, gives much smaller character sizes than the HP7550A plotter.
- XThe defaults were set empirically to match plotter output.
- X
- XThe sizes in viewport.c were modified to get correct positioning
- Xon the 8.5 x 11 paper when compared to a plot directly from the
- XHP7550A on the same type of paper.
- X
- XThe textps() routine was modified to move the position pointers to
- Xthe end of a string when a string is drawn. This was commented out
- Xin the code that I received, but needed to be restored for the
- Xuser defined character to be in the correct place. The results
- Xmatch the HP plotter for the same code.
- X
- X----------------------
- XNotes on third enhancement:
- XAll changes pertain to HPGL stuff only.
- X
- XThe removale of the comma in the SIGNED_NUMBER function was incorrect.
- XThe problem was that some programs put out a comma after the PD command
- Xand before the set of numbers. This problem was fixed when the parser
- Xwas enhanced. For some reason the change mentioned above in the previous
- Xenhancement didn't work when the comma was followed by valid numbers.
- X
- XThe hpglcom.c parser was changed so that:
- X 1. All of the known HPGL commands (1984 HP 7580 plotter manual) have
- X been added to the parser list, making it easier for someone to
- X implement a command.
- X 2. All unknown commands had the data following that command, up until
- X the next command, dumped. This cleaned up the parser problem that
- X I was seeing.
- X 3. Three new compilable options have been added:
- X DEBUG: When turned on, all PostScript output (after the macros)
- X is put out on stderr, along with the HPGL commands. This
- X allows the programmer to see the input HPGL commands and
- X the PostScript output. The new AA command also puts out
- X many of its computations.
- X NOTIMP: Output all HGPL commands that are unknown. If you don't
- X want this list, turn off this compiler option.
- X SYSV: Many AT&T System V Unix systems don't have rint(). This
- X option will use the very simple one that I included.
- X 4. The HPGL Absolute Arc (AA) command has been implemented. The Arc
- X Relative (AR) one has not (yet). See the new routine arcps.c for
- X further comments on what was done.
- X
- XThe default line sizes have been changed. See the man page for the complete
- Xlist.
- SHAR_EOF
- chmod 0644 README || echo "restore of README fails"
- set `wc -c README`;Sum=$1
- if test "$Sum" != "6466"
- then echo original size 6466, current size $Sum;fi
- echo "x - extracting arcps.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > arcps.c &&
- X/* arcps.c */
- X/*
- X * HPGL supplies the needed arc as:
- X * AA xcenter,ycenter,angle,chord
- X *
- X * PostScript needs it as:
- X * xcenter ycenter radius start_deg end_deg arc stroke
- X *
- X * where the drawing starting point has no relationship to the current point,
- X * which is set by the HPGL PA command. The start and ending degree values
- X * need to be computed. PostScript arc moves counterclockwise, while arcn
- X * moves clockwise from start to end degree locations.
- X *
- X * A positive HPGL angle means counterclockwise arc, while negative means
- X * a clockwise arc (PS arcn).
- X *
- X * The radius is determined by:
- X * sqrt(x*x + y*y)
- X *
- X * where x and y are the distances from the current point to the center.
- X *
- X * The starting offset angle between the current point and the arc center:
- X * 180/pi(atan(x/y)) [the atan returns radians]
- X *
- X * The angle quadrant needs to be determined as well, and will be an offset
- X * starting base angle. The PostScript base is along the X axis, to the right.
- X * The angle increases its value in the counterclockwise direction. It is
- X * determined by the signs of the differences between the current point
- X * and arc center:
- X * X Y start arc
- X * + + 90
- X * + - 0
- X * - - 180
- X * - + 270
- X */
- X
- X#include "defn.h"
- X
- Xarcps(type)
- Xint type;
- X{
- X float radius;
- X float angle = 0;
- X float start_deg = 0;
- X float end_deg = 0;
- X float offset_deg = 0;
- X float chord_angle = 0;
- X float Xc, Yc;
- X float Xdiff, Ydiff;
- X
- X end_draw();
- X
- X switch (type)
- X {
- X case ARCA:
- X if (SIGNED_NUMERIC)
- X lastXmove = Xc = getval() * XSCALE + offX;
- X if (SIGNED_NUMERIC)
- X lastYmove = Yc = getval() * YSCALE + offY;
- X if (SIGNED_NUMERIC)
- X angle = getval();
- X if (SIGNED_NUMERIC)
- X chord_angle = getval();
- X if (PENDOWN)
- X {
- X printf("newpath\n");
- X debugp((stderr,"newpath\n"));
- X printf(" %g %g %s\n", absX, absY, MOVE);
- X debugp((stderr," %g %g %s\n", absX, absY, MOVE));
- X }
- X Xdiff = absX - Xc;
- X Ydiff = absY - Yc;
- X if (Xdiff < 0 && Ydiff > 0 )
- X offset_deg = 90;
- X if (Xdiff < 0 && Ydiff < 0 )
- X offset_deg = 180;
- X if (Xdiff > 0 && Ydiff < 0 )
- X offset_deg = 270;
- X radius = sqrt(fabs(Xdiff*Xdiff) + fabs(Ydiff*Ydiff));
- X if (Xdiff == 0 || Ydiff == 0)
- X {
- X if (Ydiff > 0)
- X start_deg = 90;
- X if (Xdiff < 0)
- X start_deg = 180;
- X if (Ydiff < 0)
- X start_deg = 270;
- X }
- X else if (fabs(Xdiff) < fabs(Ydiff))
- X start_deg = 180/M_PI*(fabs(atan(Xdiff/Ydiff)));
- X else
- X start_deg = (180/M_PI*(fabs(atan(Ydiff/Xdiff)))) + 45;
- X start_deg += offset_deg;
- X if (angle > 0)
- X end_deg = start_deg + angle;
- X else
- X end_deg = start_deg - fabs(angle);
- X if (end_deg >= 360)
- X end_deg -= 360;
- X if (end_deg < 0)
- X end_deg += 360;
- X
- X DRAW_FLAG = 1;
- X
- X break;
- X
- X case ARCR:
- X
- X break;
- X
- X default:
- X
- X debugp((stderr,"Unknown ARC command\n"));
- X
- X }
- X if (angle < 0)
- X AARC = "AAC";
- X else
- X AARC = "AA";
- X
- X printf("%g %g %g %g %g %s\n",Xc,Yc,radius,start_deg,end_deg,AARC);
- X debugp((stderr,"%g %g %g %g %g %s\n",Xc,Yc,radius,start_deg,end_deg,AARC));
- X
- X debugp((stderr,"\tabsX=%g\tabsY=%g\tXc=%g\tYc=%g\n",absX,absY,Xc,Yc));
- X debugp((stderr,"\tXdiff=%g\tYdiff=%g\n",Xdiff,Ydiff));
- X debugp((stderr,"\tradius=%g\tstart_deg=%g\tend_deg=%g\tangle=%g\n",radius,start_deg,end_deg,angle));
- X}
- SHAR_EOF
- chmod 0644 arcps.c || echo "restore of arcps.c fails"
- set `wc -c arcps.c`;Sum=$1
- if test "$Sum" != "3251"
- then echo original size 3251, current size $Sum;fi
- echo "x - extracting changesizes.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > changesizes.c &&
- X/* changesizes.c
- X * This utility will take a string of real numbers seperated by commas and
- X * put them in an array.
- X *
- X * Don McCormick
- X */
- X#include "defn.h"
- X
- X#define ERROR1 "Only 9 line sizes allowed"
- X#define ERROR2 "Too many decimal points in number"
- X#define ERROR3 "line size specification incorrect"
- X#define ERROR4 "Max no of characters for each line size is 5"
- X
- Xchangesizes(sizebuf)
- Xchar sizebuf[50];
- X{
- X int i;
- X int j = 0;
- X int k = 0;
- X int DECIMAL = 0;
- X float number;
- X char numbuf[5];
- X
- X for (i = 0; i < 50; i++)
- X {
- X if (sizebuf[i] == ',' || sizebuf[i] == NULL)
- X {
- X if ((number = atof(numbuf)) >= 0.01 && number <= 10)
- X pen_size[j] = number; /* Put number in array */
- X else
- X fprintf(stderr, "Warning: line size too large ignored \n");
- X
- X if (sizebuf[i] == NULL) return;
- X
- X if (j++ > 8)
- X {
- X fprintf(stderr, "Error: %s\n", ERROR1);
- X exit(1);
- X }
- X for (k = 0; k < 5; k++)
- X numbuf[k] = NULL; /* Clear number buffer */
- X
- X k = 0;
- X DECIMAL = 0; /* One decimal per number */
- X
- X while (sizebuf[i + 1] == ',' && sizebuf[i + 1] != NULL)
- X i++; /* Get rid of extra commas */
- X } else
- X {
- X if ((sizebuf[i] >= '0' && sizebuf[i] <= '9')
- X || sizebuf[i] == '.')
- X {
- X if (sizebuf[i] == '.')
- X {
- X if (DECIMAL == 1)
- X {
- X fprintf(stderr, "Error: %s\n", ERROR2);
- X exit(1);
- X }
- X DECIMAL = 1;
- X }
- X numbuf[k] = sizebuf[i];
- X } else
- X {
- X fprintf(stderr, "Error: %s\n", ERROR3);
- X exit(1);
- X }
- X if (k++ > 5)
- X {
- X fprintf(stderr, "Error: %s\n", ERROR4);
- X exit(1);
- X }
- X }
- X }
- X}
- SHAR_EOF
- chmod 0644 changesizes.c || echo "restore of changesizes.c fails"
- set `wc -c changesizes.c`;Sum=$1
- if test "$Sum" != "1613"
- then echo original size 1613, current size $Sum;fi
- echo "x - extracting circle.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > circle.c &&
- X/* circle.c */
- X#include "defn.h"
- X
- Xcircle(type)
- Xint type;
- X{
- X float radius;
- X float start_angle = 0;
- X float end_angle = 360;
- X float chord_angle = 0;
- X float Xc, Yc;
- X float percent;
- X float distance;
- X float length;
- X float angle;
- X
- X end_draw();
- X
- X switch (type)
- X {
- X case RDGLCIRCLE:
- X if (SIGNED_NUMERIC)
- X radius = getval() * XSCALE;
- X if (SIGNED_NUMERIC)
- X chord_angle = getval();
- X Xc = absX;
- X Yc = absY;
- X break;
- X
- X case CIRCLE:
- X if (SIGNED_NUMERIC)
- X absX = Xc = getval() * XSCALE + offX;
- X if (SIGNED_NUMERIC)
- X absY = Yc = getval() * YSCALE + offY;
- X if (SIGNED_NUMERIC)
- X radius = getval() * XSCALE;
- X if (SIGNED_NUMERIC)
- X start_angle = getval();
- X if (SIGNED_NUMERIC)
- X end_angle = getval();
- X if (SIGNED_NUMERIC)
- X chord_angle = getval();
- X break;
- X
- X case RCIRCLE:
- X if (SIGNED_NUMERIC)
- X radius = getval() * XSCALE;
- X if (SIGNED_NUMERIC)
- X start_angle = getval();
- X if (SIGNED_NUMERIC)
- X end_angle = getval();
- X if (SIGNED_NUMERIC)
- X chord_angle = getval();
- X angle = deg_rad * (90.0 - start_angle);
- X Xc = absX - radius * cos(angle);
- X angle = deg_rad * (90.0 - start_angle);
- X Yc = absY + radius * sin(angle);
- X break;
- X
- X case CCIRCLE:
- X if (SIGNED_NUMERIC)
- X absX = getval() * XSCALE;
- X if (SIGNED_NUMERIC)
- X absY = getval() * YSCALE;
- X break;
- X
- X case ACIRCLE:
- X Xc = absX;
- X Yc = absY;
- X if (SIGNED_NUMERIC)
- X radius = getval() * XSCALE;
- X if (SIGNED_NUMERIC)
- X start_angle = getval();
- X if (SIGNED_NUMERIC)
- X end_angle = getval();
- X if (SIGNED_NUMERIC)
- X chord_angle = getval();
- X break;
- X
- X case SCIRCLE:
- X if (SIGNED_NUMERIC)
- X percent = getval();
- X if (SIGNED_NUMERIC)
- X distance = getval();
- X if (SIGNED_NUMERIC)
- X length = getval();
- X fprintf("Warning: segment and indication lines not available yet\n");
- X break;
- X }
- X
- X printf("%g %g %g %g %g %g Ellipse\n",
- X Xc, Yc, radius, radius, start_angle, end_angle);
- X}
- SHAR_EOF
- chmod 0644 circle.c || echo "restore of circle.c fails"
- set `wc -c circle.c`;Sum=$1
- if test "$Sum" != "1904"
- then echo original size 1904, current size $Sum;fi
- echo "x - extracting defn.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > defn.h &&
- X/*
- X *
- X * The following definations allow for the efficient
- X * translation of DXY and RD-GL codes to PostScript code
- X *
- X */
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include <ctype.h>
- X
- X#define CR '\015'
- X#define LF '\012'
- X#define SPACE '\040'
- X
- X/* the definition below was modified by Gordon Jacobs to remove
- X * the validity of a comma in a Signed Numeric quantity. The
- X * definition below is more accurate and the comma is now removed
- X * after reading the digit in getval()
- X */
- X#define SIGNED_NUMERIC (ungetc(( ch = getc(stream)),stream) != EOF ) &&\
- X (((ch>='0') && (ch<='9')) || (ch=='-') || (ch=='+')\
- X || (ch==' ') || (ch == '.'))
- X
- X/* The debug stuff was added to trace what is going on during the conversion
- X * process to PostScript.
- X */
- X
- X#ifdef DEBUG
- X#define debugp(x) {fprintf x; (void) fflush(stderr);}
- X#else
- X#define debugp(x)
- X#endif
- X
- X#ifdef NOTIMP
- X#define notimp(x) {fprintf x; (void) fflush(stderr);}
- X#else
- X#define notimp(x)
- X#endif
- X
- X#define CIRCLE 21 /* DXY Circle */
- X#define RCIRCLE 22 /* DXY Relative Circle */
- X#define CCIRCLE 23 /* DXY Centered Circle */
- X#define ACIRCLE 24 /* DXY Arc plus Circle */
- X#define SCIRCLE 25 /* DXY Segment Circle */
- X#define RDGLCIRCLE 26 /* RD-GL Circle */
- X#define ARCA 27 /* HPGL Absolute Arc */
- X#define ARCR 28 /* HPGL Relative Arc */
- X
- X#define TEXT 31
- X#define MARK 32
- X
- X#define LINETYPE 41
- X#define LINESCALE 42
- X#define LINE_TYPE_SCALE 43
- X
- X#define XTICK 0
- X#define YTICK 1
- X/*
- X * Files to open if any
- X */
- XFILE *stream;
- XFILE *fopen();
- X/*
- X * Plotting Parameters that will contain the necessary PostScript
- X * commands to plot (see dxy2ps.c for the initialisation) and
- X * ps_macros.c for the plotting macros).
- X */
- Xchar *MOVE;
- Xchar *RMOVE;
- Xchar *DRAW;
- Xchar *RDRAW;
- Xchar *ADRAW;
- Xchar *AARC;
- Xchar *RARC;
- X/*
- X * Definition of "ch" used in SIGNED_NUMERIC
- X */
- Xchar ch;
- X/*
- X * Define the function getval() which returns a real number.
- X */
- Xfloat getval();
- X/*
- X * Scaling parameters used for translation from DXY and RD-GL
- X * coordinate sytem to the PostScript coordinate system which
- X * has been defined in millimeters. (See above)
- X */
- Xfloat SCALE;
- Xfloat XSCALE;
- Xfloat YSCALE;
- Xfloat xmax, xmin;
- Xfloat ymax, ymin;
- Xfloat psxmax,psymax; /* max postscript dimensions */
- Xfloat tlp,tln; /* HP-GL tick length parameters */
- Xfloat FONT_H_MULT; /* fudge factor for font height */
- Xfloat FONT_W_MULT; /* fudge factor for font width */
- X/*
- X * End of line terminator (RD-GL / HP-GL)
- X */
- Xchar EOL;
- X/*
- X * PostScript Coordinate parameters
- X */
- Xfloat lastXmove;
- Xfloat lastYmove;
- Xfloat absX;
- Xfloat absY;
- Xfloat offX,offY; /* used for Scale command */
- Xfloat xval;
- Xfloat yval;
- Xfloat xoffset, yoffset;
- X/*
- X * Extra parameters
- X */
- Xfloat char_angle;
- Xfloat char_height;
- Xfloat char_width;
- Xfloat char_space;
- Xfloat char_slant;
- X
- Xchar *font;
- X
- Xchar symbol;
- X
- Xint dcount;
- X/*
- X * Degree radian conversion parameter ie: deg_rad = asin(1) / 90.0;
- X * ( Defined in dxy2ps.c or rdgl2ps.c )
- X */
- Xfloat deg_rad;
- X/*
- X * Line / pen size parameter (max 9 sizes)
- X */
- Xfloat pen_size[9];
- Xint pen_number;
- X/*
- X * Paper size (ie A3 or A4) and Mode (HPGL or DXY)
- X */
- Xchar *PaperSize;
- Xchar *Mode;
- X/*
- X * Flags
- X */
- Xint LANDSCAPE;
- Xint DRAW_FLAG;
- Xint PLOTABS;
- Xint PLOTARC;
- Xint PENDOWN;
- Xint SETDOT; /* HP-GL commands only */
- Xint SYMBOL; /* HP-GL commands only */
- SHAR_EOF
- chmod 0644 defn.h || echo "restore of defn.h fails"
- set `wc -c defn.h`;Sum=$1
- if test "$Sum" != "3258"
- then echo original size 3258, current size $Sum;fi
- echo "x - extracting dxy2ps.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > dxy2ps.c &&
- X/* dxy2ps.c */
- X#include "defn.h"
- X
- X#define USAGE "Usage: dxy2ps [-amr] [-l line sizes] [-s scale] [-x offset] [-y offset] [file]\n"
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X extern int optind;
- X extern char *optarg;
- X
- X int ch; /* GWKMOD */
- X int op; /* GWKMOD */
- X /* GWK: char op; */
- X int MANUAL_FEED = 0; /* DEFAULT: No manual feed */
- X
- X PaperSize = "A3";
- X Mode = "DXY";
- X plotcoords(); /* Set up plotter coordinates */
- X
- X plotinit(); /* Get other initialisations */
- X
- X while ((ch = getopt(argc, argv, "al:ms:x:y:r")) != EOF)
- X {
- X switch (ch)
- X {
- X case 'a': /* DXY ISO A4 297mm * 210mm */
- X PaperSize = "A4";
- X plotcoords();
- X break;
- X
- X case 'l':
- X changesizes(optarg);
- X break;
- X
- X case 'm':
- X MANUAL_FEED = 1;
- X break;
- X
- X case 'r':
- X LANDSCAPE = 0;
- X break;
- X
- X case 's':
- X SCALE = atof(optarg);
- X if (SCALE < 0.1)
- X SCALE = 0.1;
- X else
- X if (SCALE > 3)
- X SCALE = 3;
- X break;
- X
- X case 'x':
- X xoffset = atof(optarg);
- X break;
- X
- X case 'y':
- X yoffset = atof(optarg);
- X break;
- X
- X default:
- X fprintf(stderr, "%s\n", USAGE);
- X exit(1);
- X }
- X }
- X if (optind == argc)
- X stream = stdin;
- X else if ((stream = fopen(argv[optind], "r")) == NULL)
- X {
- X fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]);
- X exit(1);
- X }
- X ps_macros(); /* Output PostScript Macros */
- X
- X viewport(); /* Scale the viewport for the plot */
- X
- X printf("/%s %g Font\n", font, char_height);
- X
- X if (MANUAL_FEED)
- X manualfeed(1);
- X
- X while ((op = getc(stream)) != EOF)
- X if ((isalpha(op) > 0) || op == '^')
- X dxycom(op);
- X
- X end_draw();
- X
- X printf("showpage\n");
- X
- X if (MANUAL_FEED)
- X manualfeed(0);
- X}
- SHAR_EOF
- chmod 0644 dxy2ps.c || echo "restore of dxy2ps.c fails"
- set `wc -c dxy2ps.c`;Sum=$1
- if test "$Sum" != "1775"
- then echo original size 1775, current size $Sum;fi
- echo "x - extracting dxy2ps.man (Text)"
- sed 's/^X//' << 'SHAR_EOF' > dxy2ps.man &&
- X.TH DXY2PS (1L) "25 September 1987"
- X.SH NAME
- Xdxy2ps - A Roland DXY plot command filter to PostScript
- X.SH SYNOPSIS
- X\fBdxy2ps\fR
- X[\fB-amr\fR]
- X[\fB-l \fIline sizes\fR]
- X[\fB-s \fIscale\fR]
- X[\fB-x \fIoffset\fR]
- X[\fB-y \fIoffset\fR]
- X[\fIplotfile\fR]
- X.SH DESCRIPTION
- XThis filter is used to convert the Roland DXY and the Roland
- XGraphics Language (RD-GL) (which is a superset of the Hewlet Packard
- XGraphics Language (HP-GL)) commands to PostScript.
- X.PP
- XThe RD-GL commands are only operated on if each command is prefixed with
- Xa "^", therfore if your plotfile only contains HP-GL or RD-GL commands
- Xuse the filter \fBhpgl2ps\fR.
- X.PP
- XThe default conditions for \fBdxy2ps\fR are:
- X.TP
- X.B 1.
- XThe plot translation is from ISO A3 (420mm x 297mm) to ISO A4
- X(297mm x 210mm) on the LaserWriter.
- X.TP
- X.B 2.
- XLine thicknesses are in millimeters and are for lines (pens) 1 to 9:
- X( 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 1.0, 1.25, 1.5 )
- X.TP
- X.B Note:
- XIf the plotfile is not specified then standard input is assumed.
- X.SH ARGUMENTS
- X.TP
- X.B -a
- XDraw on an A4 ISO (297mm x 210mm) sheet of paper. This will give an
- Xaproximate 1:1 translation to the LaserWriter.
- X.TP
- X\fB-l \fIline sizes\fR
- XThis option allows the default line sizes to be replaced with different
- Xsizes starting from line (pen) one through nine. The new sizes (real or
- Xinteger) are entered in a comma seperated string (\fIline size\fR) and
- Xare in millimeters. Only the sizes entered in the string will be
- Xchanged with respect to lines (pens) one to nine while nonentered line
- X(pen) sizes will retain the default sizes.
- X.sp
- XIn the following example only the first three sizes will be changed.
- X.sp
- Xeg: dxy2ps -l 0.4,0.3,1 file | lpr -Plaser1
- X.TP
- X.B -m
- XEnable the manual feed on the LaserWriter (cutoff time 3 minutes).
- X.TP
- X.B -r
- XRotate plot(s) through 90 degrees. (The plot is made smaller)
- X.TP
- X\fB-s\fI scale\fR Scale the plot from 0.1 to 3 times its original
- Xsize.
- X.TP
- X\fB-x\fI offset\fR Place an X offset (in mm) in the plot.
- X.TP
- X\fB-y\fI offset\fR Place an Y offset (in mm) in the plot.
- X.PP
- X\fBNote:\fR Offsets are with respect to the 0, 0 (origin) of the HP-GL
- X/ RD-GL plotting commands, thus if the minimum plotting coordinates are
- Xbelow either the X and/or Y zero axis then a positive offset is
- Xapplied. Similarly if the minimum plot coordinates are above the X
- Xand/or Y zero axis then a negative offset is applied.
- X.SH FILES
- X/usr/local/bin/dxy2ps
- X.br
- X/usr/local/bin/hpgl2ps
- X.SH AUTHOR
- XDon McCormick
- X.br
- XCSIRO
- X.br
- XDivision of Applied Physics
- X.br
- XPO 218, Lindfield, N.S.W., 2070
- X.br
- XAustralia
- X.SH BUGS
- XSome of the graphics commands are unimplemented and a warning will be
- Xdisplayed. If this command is vital then it must be written into the code.
- X.PP
- XNo interactive command is suported.
- X.PP
- XIf any bugs are found notify damc@natmlab or damc@nifty or root.
- SHAR_EOF
- chmod 0644 dxy2ps.man || echo "restore of dxy2ps.man fails"
- set `wc -c dxy2ps.man`;Sum=$1
- if test "$Sum" != "2785"
- then echo original size 2785, current size $Sum;fi
- echo "x - extracting dxycom.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > dxycom.c &&
- X/* dxycom.c */
- X#include "defn.h"
- X
- Xdxycom(op)
- Xchar op;
- X{
- X int intval;
- X
- X switch (op)
- X {
- X case 'H': /* HOME */
- X case 'h':
- X break;
- X
- X case 'D': /* DRAW */
- X case 'd':
- X plotps(DRAW);
- X break;
- X
- X case 'M': /* MOVE */
- X case 'm':
- X plotps(MOVE);
- X break;
- X
- X case 'I': /* RELATIVE DRAW */
- X case 'i':
- X plotps(RDRAW);
- X break;
- X
- X case 'R': /* RELATIVE MOVE */
- X case 'r':
- X plotps(RMOVE);
- X break;
- X
- X case 'L': /* LINE TYPE */
- X case 'l':
- X linetype(LINETYPE);
- X break;
- X
- X case 'B': /* LINE SCALE */
- X case 'b':
- X linetype(LINESCALE);
- X break;
- X
- X case 'X': /* AXIS */
- X case 'x':
- X {
- X int p, q, r;
- X
- X p = rint(getval());
- X q = rint(getval());
- X r = rint(getval());
- X fprintf(stderr, "Warning %c not implemented yet\n", op);
- X }
- X break;
- X
- X case 'P': /* PRINT */
- X case 'p':
- X textps(TEXT);
- X break;
- X
- X case 'S': /* ALPHA SCALE */
- X case 's':
- X {
- X int n;
- X
- X if (SIGNED_NUMERIC)
- X n = rint(getval());
- X else
- X n = 3;
- X char_height = (n + 1) * 0.8 * SCALE;
- X char_width = (n + 1) * 0.4 * SCALE;
- X char_space = (n + 1) * 0.2 * SCALE;
- X }
- X printf("/%s %g %g %g DefFont\n",
- X font, char_width, char_height, char_slant);
- X break;
- X
- X case 'Q': /* ALPHA ROTATE */
- X case 'q':
- X intval = rint(getval());
- X switch (intval)
- X {
- X case 0:
- X char_angle = 0.0;
- X break;
- X
- X case 1:
- X char_angle = 90.0;
- X break;
- X
- X case 2:
- X char_angle = 180.0;
- X break;
- X
- X case 3:
- X char_angle = 270.0;
- X break;
- X }
- X break;
- X
- X case 'N': /* MARK */
- X case 'n':
- X textps(MARK);
- X break;
- X
- X case 'J': /* PEN CHANGE */
- X case 'j':
- X linesize();
- X break;
- X
- X case 'C': /* CIRCLE */
- X case 'c':
- X circle(CIRCLE);
- X break;
- X
- X case 'E': /* RELATIVE CIRCLE */
- X case 'e':
- X circle(RCIRCLE);
- X break;
- X
- X case 'A': /* CIRCLE CENTER */
- X case 'a':
- X circle(CCIRCLE);
- X break;
- X
- X case 'G': /* ARC + CIRCLE */
- X case 'g':
- X circle(ACIRCLE);
- X break;
- X
- X case 'K': /* SEGMENT AND INDICATION LINES FOR CIRCLES */
- X case 'k':
- X circle(SCIRCLE);
- X break;
- X
- X case 'T': /* HATCHING */
- X case 't':
- X rectangle();
- X break;
- X
- X case '^': /* CALL HP-GL / RD-GL COMMANDS */
- X end_draw();
- X if ((ch = getc(stream)) != EOF)
- X hpglcom(ch);
- X break;
- X
- X default:
- X fprintf(stderr, "Warning: %c Unknown DXY command\n", op);
- X break;
- X }
- X}
- SHAR_EOF
- chmod 0644 dxycom.c || echo "restore of dxycom.c fails"
- set `wc -c dxycom.c`;Sum=$1
- if test "$Sum" != "2329"
- then echo original size 2329, current size $Sum;fi
- echo "x - extracting end_draw.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > end_draw.c &&
- X/* end_draw.c */
- X#include "defn.h"
- X
- Xend_draw()
- X{
- X if (DRAW_FLAG)
- X {
- X if (lastXmove == absX && lastYmove == absY)
- X {
- X printf("closepath\n");
- X debugp((stderr,"closepath\n"));
- X }
- X printf("stroke\n");
- X debugp((stderr,"stroke\n"));
- X DRAW_FLAG = 0;
- X }
- X dcount = 0;
- X}
- SHAR_EOF
- chmod 0644 end_draw.c || echo "restore of end_draw.c fails"
- set `wc -c end_draw.c`;Sum=$1
- if test "$Sum" != "281"
- then echo original size 281, current size $Sum;fi
- echo "x - extracting getval.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > getval.c &&
- X/* getval.c
- X * Returns a real number
- X */
- X
- X#include "defn.h"
- X
- X#define ERROR "Two or more decimal places in a number"
- X
- Xfloat
- Xgetval()
- X{
- X char valbuf[10];
- X float value;
- X int DECIMAL = 0;
- X int i;
- X
- X /* Null the value buffer "valbuf" */
- X for (i = 0; i < 10; i++)
- X valbuf[i] = NULL;
- X
- X i = 0;
- X
- X ch = getc(stream);
- X
- X while ((ch == ' ') || (ch == ','))
- X {
- X debugp((stderr,"%c",ch));
- X ch = getc(stream);
- X }
- X
- X while ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-' || ch == '+')
- X {
- X debugp((stderr,"%c",ch));
- X if (ch == '.')
- X {
- X if (DECIMAL)
- X {
- X fprintf(stderr,"Error: %s\n", ERROR);
- X exit(1);
- X }
- X DECIMAL = 1;
- X }
- X valbuf[i++] = ch;
- X ch = getc(stream);
- X }
- X /* remove trailing space or comma to set-up for
- X next digit or mnemonic */
- X /* added by Gordon Jacobs so that definition of
- X SIGNED_NUMERIC in defn.h could be made more accurate.
- X Solves problem of commands like PA,PD0,0... where
- X optional comma is present. (Tektronix scope outputs!) */
- X while ((ch == ' ') || (ch == ','))
- X {
- X debugp((stderr,"%c",ch));
- X ch = getc(stream);
- X }
- X
- X ungetc(ch, stream); /* Put non numeric char back */
- X value = atof (valbuf);
- X return (value);
- X}
- SHAR_EOF
- chmod 0644 getval.c || echo "restore of getval.c fails"
- set `wc -c getval.c`;Sum=$1
- if test "$Sum" != "1249"
- then echo original size 1249, current size $Sum;fi
- echo "x - extracting hpgl2ps.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > hpgl2ps.c &&
- X/* hpgl2ps.c */
- X#include "defn.h"
- X
- X#define USAGE "Usage: hpgl2ps [-43BAmr] [-l line sizes] [-s scale] [-x offset] [-y offset] [-w font_width] [-h font_height] [file]\n"
- X
- Xmain(argc, argv)
- X/*
- X * hpgl2ps.c
- X *
- X * Modified by J.R. Nickerson, G.W. Kokodyniak
- X * University of Toronto, Department of Mechanical Enginnering
- X *
- X * Further modified by Gordon Jacobs, University of Calif, Berkeley
- X * Added Scaling,Ticks,modified userdefchar(),sizes for 8.5x11 paper
- X *
- X */
- Xint argc;
- Xchar *argv[];
- X{
- X extern int optind;
- X extern char *optarg;
- X
- X int ch; /* GWKMOD */
- X int op; /* GWKMOD */
- X /* GWK: char op; */
- X int MANUAL_FEED = 0; /* DEFAULT: No manual feed */
- X
- X PaperSize = "A";
- X Mode = "HPGL";
- X plotcoords();
- X
- X plotinit(); /* Get other initialiasations */
- X
- X while ((ch = getopt(argc, argv, "AB43l:ms:x:y:rh:w:")) != EOF)
- X {
- X switch (ch)
- X {
- X case '4': /* HP-GL ISO A4 297mm * 210mm */
- X PaperSize = "A4";
- X plotcoords();
- X break;
- X
- X case '3': /* HP-GL ISO A3 420mm * 297mm */
- X PaperSize = "A3";
- X plotcoords();
- X break;
- X
- X case 'A': /* HP-GL ANSI A 11 * 8.5inch */
- X PaperSize = "A";
- X plotcoords();
- X break;
- X
- X case 'B': /* HP-GL ANSI B 17 * 11inch */
- X PaperSize = "B";
- X plotcoords();
- X break;
- X
- X case 'l': /* change line size option */
- X changesizes(optarg);
- X break;
- X
- X case 'm': /* enable manual feed on Laserwriter */
- X MANUAL_FEED = 1;
- X break;
- X
- X case 'r': /* rotate the plot 90 degrees */
- X LANDSCAPE = 0;
- X break;
- X
- X case 's': /* scale the plot from 0.1 to 3.0 times */
- X SCALE = atof(optarg);
- X if (SCALE < 0.1)
- X SCALE = 0.1;
- X else
- X if (SCALE > 3)
- X SCALE = 3;
- X break;
- X
- X case 'h':
- X FONT_H_MULT = atof(optarg);
- X break;
- X
- X case 'w':
- X FONT_W_MULT = atof(optarg);
- X break;
- X
- X case 'x': /* place an X offset (in mm) */
- X xoffset = atof(optarg);
- X break;
- X
- X case 'y': /* place an Y offset (in mm) */
- X yoffset = atof(optarg);
- X break;
- X
- X default:
- X fprintf(stderr, "%s\n", USAGE);
- X exit(1);
- X }
- X }
- X if (optind == argc)
- X stream = stdin;
- X else if ((stream = fopen(argv[optind], "r")) == NULL)
- X {
- X fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]);
- X exit(1);
- X }
- X ps_macros(); /* Output PostScript Macros */
- X
- X viewport(); /* Scale the viewport for the plot */
- X
- X printf("/%s %g Font\n", font, char_height);
- X
- X if (MANUAL_FEED)
- X manualfeed(1);
- X
- X while ((op = getc(stream)) != EOF)
- X if (isalpha(op) > 0)
- X hpglcom(op);
- X
- X end_draw();
- X
- X printf("showpage\n");
- X
- X if (MANUAL_FEED)
- X manualfeed(0);
- X}
- SHAR_EOF
- chmod 0644 hpgl2ps.c || echo "restore of hpgl2ps.c fails"
- set `wc -c hpgl2ps.c`;Sum=$1
- if test "$Sum" != "2679"
- then echo original size 2679, current size $Sum;fi
- echo "x - extracting hpgl2ps.man (Text)"
- sed 's/^X//' << 'SHAR_EOF' > hpgl2ps.man &&
- X.TH HPGL2PS 1L "11 June 1990"
- X.SH NAME
- Xhpgl2ps - A HP (Hewlet Packard) plot command filter to PostScript
- X.SH SYNOPSIS
- X\fBhpgl2ps\fR
- X[\fB-AB43mr\fR]
- X[\fB-l \fIline sizes\fR]
- X[\fB-s \fIscale\fR]
- X[\fB-x \fIoffset\fR]
- X[\fB-y \fIoffset\fR]
- X[\fB-h \fIfont height multiplier\fR]
- X[\fB-w \fIfont width multiplier\fR]
- X[\fIplotfile\fR]
- X.SH DESCRIPTION
- XThis filter is used to convert Hewlet Packard Graphic Language (HP-GL)
- X7550A plotter commands to PostScript. The HP-GL commands are a subset of the
- XRoland plotter command set (RD-GL).
- X.PP
- XThe default conditions for \fBhpgl2ps\fR are:
- X.TP
- X.B A.
- XThe plot translation is from an ANSI A (8.5 x 11inch) plot to ANSI A
- Xpaper on the LaserWriter. See below for other paper sizes.
- X.TP
- X.B B.
- XLine thicknesses are in millimeters and are for lines (pens) 1 to 9:
- X(0.0125, 0.025, 0.05, 0.1, 0.2, 0.4, 0.5 1.0 2.0)
- X.TP
- X.B C.
- XThe default font is Helvetica, 14 point on the Laserwriter.
- X.TP
- X.B D.
- XThe default font height and width multipliers are 1.2 and 3.6 respectively.
- X.TP
- X.B Note:
- XIf the plotfile is not specified then standard input is assumed.
- X.SH ARGUMENTS
- X.TP
- X.B -A
- XDraw for an ANSI A (11 x 8.5inch) plot.
- X.TP
- X.B -B
- XDraw for an ANSI B (17 x 11inch) plot.
- X.TP
- X.B -4
- XDraw for an A4 ISO (297mm x 210mm) plot. This will give an
- Xaproximate 1:1 translation to the LaserWriter.
- X.TP
- X.B -3
- XDraw for an A3 ISO (420mm x 297mm) plot.
- X.TP
- X\fB-l \fIline sizes\fR
- XThis option allows the default line sizes to be replaced with different
- Xsizes starting from line (pen) one through nine. The new sizes (real or
- Xinteger) are entered in a comma separated string (\fIline size\fR) and
- Xare in millimeters. Only the sizes entered in the string will be
- Xchanged with respect to lines (pens) one to nine while nonentered line
- X(pen) sizes will retain the default sizes.
- X.sp
- XIn the following example only the first three sizes will be changed.
- X.sp
- Xeg: hpgl2ps -l 0.4,0.3,1 file | lpr -Plaser1
- X.TP
- X.B -m
- XEnable the manual feed on the LaserWriter (cutoff time 3 minutes).
- X.TP
- X.B -r
- XRotate plot(s) through 90 degrees. (The plot is made smaller)
- X.TP
- X\fB-s\fI scale\fR
- XScale the plot from 0.1 to 3 times its original size.
- X.TP
- X\fB-w\fI relative font width multiplier\fR
- XWhen the SR command exists in the HP-GL file,
- Xthe size of characters is scaled to be a proportion of the paper dimensions.
- XThe HP7550 plotter character sizes are larger than the scaling suggests.
- XThe default value of the font width multiplier scales the characters in the
- Xpostscript file to appear roughly the same width as the original.
- XSetting to 1.0 reverts to the original scaling.
- X.TP
- X\fB-w\fI relative font height multiplier\fR
- XWhen the SR command exists in the HP-GL file,
- Xthe size of characters is scaled to be a proportion of the paper dimensions.
- XThe HP7550 plotter character sizes are larger than the scaling suggests.
- XThe default value of the font height multiplier scales the characters in the
- Xpostscript file to appear roughly the same width as the original.
- XSetting to 1.0 reverts to the original scaling.
- X.TP
- X\fB-x\fI offset\fR
- XPlace an X offset (in mm) in the plot.
- X.TP
- X\fB-y\fI offset\fR
- XPlace an Y offset (in mm) in the plot.
- X.PP
- X\fBNote:\fR Offsets are with respect to the 0, 0 (origin) of the HP-GL
- X/ RD-GL plotting commands, thus if the minimum plotting coordinates are
- Xbelow either the X and/or Y zero axis then a positive offset is
- Xapplied. Similarly if the minimum plot coordinates are above the X
- Xand/or Y zero axis then a negative offset is applied.
- X.SH FILES
- X/usr/local/bin/hpgl2ps
- X.SH AUTHOR
- XDon McCormick
- X.br
- XCSIRO
- X.br
- XDivision of Applied Physics
- X.br
- XPO 218, Lindfield, N.S.W., 2070
- X.br
- XAustralia
- X
- XScaling, Tick Marks, and other modifications by:
- X.br
- XGordon Jacobs, University of California, Berkeley
- X
- XAll HPGL commands have been added to the hpglcom.c program,
- Xthough not all commands have been implemented.
- XThe HPGL AA command has been implemented.
- XParsing of HPGL commands has been enhanced.
- XMichael L. Brown, Madison, WI.
- X.SH BUGS
- XSome of the graphics commands are unimplemented and a warning will be
- Xdisplayed. If this command is vital then it must be written into the code.
- X.PP
- XNo interactive command is suported.
- X
- SHAR_EOF
- chmod 0644 hpgl2ps.man || echo "restore of hpgl2ps.man fails"
- set `wc -c hpgl2ps.man`;Sum=$1
- if test "$Sum" != "4127"
- then echo original size 4127, current size $Sum;fi
- echo "x - extracting hpglcom.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > hpglcom.c &&
- X/* hpglcom.c */
- X/*
- X * This procedure translates RD-GL (Roland DG Graphic Language) into the
- X * equivalent PostScript language.
- X *
- X * The RD-GL is a superset equivalent to HP-GL
- X *
- X * Don McCormick
- X *
- X * Extensively modified by Michael L. Brown.
- X *
- X * The parser didn't get rid of the characters, up to the next possible
- X * HPGL command. Added a DEBUG, so that the commands that aren't known
- X * are sent to the stderr. By making this compilable, the screen isn't
- X * clutterd with all of the many possible HPGL commands that aren't being
- X * operated on.
- X */
- X
- X#include "defn.h"
- X
- X/* The folowing defaults should be 0.5% and 1.0% for the respective character
- X * width and height, however this is too small when scaled to Postcript
- X * charcter sizes.
- X */
- Xfloat DEFWIDTH = 0.0075; /* 0.75 % of P2x - P1x for default char width */
- Xfloat DEFHEIGHT = 0.015; /* 1.5 % of P2y - P1y for default char height */
- X/*
- X * Values above are further multiplied by FONT_W_MULT and FONT_H_MULT
- X * which can be set on command line. Defaults are 4.0 and 1.1
- X * Added for better matching of relative font sizes to plotter results
- X */
- X
- X#define SPACE_FACTOR 0.64 /* used in computation of a character space */
- X
- Xhpglcom(op1)
- Xchar op1;
- X{
- X char op2;
- X int no_op; /* No operation value */
- X
- X switch (op1)
- X {
- X case 'A':
- X case 'a':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'A': /* Arc Absolute */
- X case 'a':
- X debugp((stderr,"%c%c",op1,op2));
- X PLOTARC = 1;
- X if (PENDOWN)
- X {
- X if (SIGNED_NUMERIC)
- X if (SETDOT)
- X plotdot(MOVE);
- X else if (PLOTABS)
- X arcps(ARCA);
- X else
- X arcps(ARCR);
- X }
- X dumpit(1);
- X break;
- X
- X case 'F': /* Advance Full Page */
- X case 'f':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'H': /* Advance Half Page */
- X case 'h':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'P': /* Automatic Pen Lift (HP-GL only) */
- X case 'p':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'R': /* Arc Relative */
- X case 'r':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'S': /* Acceleration Select */
- X case 's':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "%c%c: Warning: Unknown HP-GL Command\n\n", op1,op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'B':
- X case 'b':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'L': /* Buffered Label String */
- X case 'l':
- X while (((ch = getc(stream)) != EOF) && ch != EOL);
- X notimp((stderr, "Not Implemented: %c%c",op1,op2));
- X break;
- X
- X default:
- X notimp((stderr, "%c%c: Warning: Unknown HP-GL Command\n\n", op1,op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'C':
- X case 'c':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'A': /* Alternate Character Set (Not Used) */
- X case 'a':
- X notimp((stderr, "Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'C': /* Character Chord Angle */
- X case 'c':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'I': /* Circle */
- X case 'i':
- X debugp((stderr,"%c%c",op1,op2));
- X circle(RDGLCIRCLE);
- X break;
- X
- X case 'M': /* Character Selection Mode */
- X case 'm':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'P': /* Character Plot */
- X case 'p':
- X debugp((stderr,"%c%c",op1,op2));
- X {
- X float xspace, yspace;
- X
- X xspace = getval() * XSCALE * SCALE * (char_width + char_space);
- X yspace = getval() * YSCALE * SCALE * (char_width + char_space);
- X end_draw();
- X printf(" %g mm %g mm %s\n", xspace, yspace, RMOVE);
- X }
- X break;
- X
- X case 'S': /* Standard Character Set */
- X case 's':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'T': /* Chord Tolerance */
- X case 't':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'D':
- X case 'd':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'C': /* Digitize Clear (Not Used) */
- X case 'c':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'F': /* Default */
- X case 'f':
- X debugp((stderr,"%c%c",op1,op2));
- X SETDOT = 0;
- X SYMBOL = 0;
- X PENDOWN = 0;
- X EOL = '\003';
- X char_angle = 0;
- X char_slant = 0;
- X if(LANDSCAPE) {
- X char_width = DEFWIDTH * (ymax - ymin) * YSCALE * SCALE;
- X char_height = DEFHEIGHT * (xmax - xmin) * XSCALE * SCALE;
- X }
- X else {
- X char_width = DEFWIDTH * (xmax - xmin) * XSCALE * SCALE;
- X char_height = DEFHEIGHT * (ymax - ymin) * YSCALE * SCALE;
- X }
- X char_space = char_width * (1/SPACE_FACTOR - 1);
- X printf("/%s %g %g %g DefFont\n",
- X font, char_width, char_height, char_slant);
- X dumpit(1);
- X break;
- X
- X case 'I': /* Absolute Direction */
- X case 'i':
- X debugp((stderr,"%c%c",op1,op2));
- X {
- X float run, rise;
- X
- X if (SIGNED_NUMERIC)
- X {
- X run = getval() * XSCALE;
- X rise = getval() * YSCALE;
- X char_angle = atan2(rise, run) / deg_rad;
- X }
- X else
- X char_angle = 0;
- X }
- X break;
- X
- X case 'L': /* Downloadable Character */
- X case 'l':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'P': /* Digitize Point (Not Used) */
- X case 'p':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'R': /* Relative Direction */
- X case 'r':
- X debugp((stderr,"%c%c",op1,op2));
- X {
- X float run, rise;
- X
- X if (SIGNED_NUMERIC)
- X {
- X run = getval() * XSCALE;
- X rise = getval() * YSCALE;
- X char_angle += atan2(rise, run) / deg_rad;
- X }
- X else
- X char_angle = 0;
- X }
- X break;
- X
- X case 'S': /* Designate Character Set into Slot*/
- X case 's':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'T': /* Define Terminator */
- X case 't':
- X debugp((stderr,"%c%c",op1,op2));
- X if ((ch = getc(stream)) != EOF)
- X EOL = ch; /* End of label terminator */
- X dumpit(1);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'E':
- X case 'e':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'A': /* Edge Rectangle Absolute */
- X case 'a':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'C': /* Enable Cut Line */
- X case 'c':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'P': /* Edge Polygon */
- X case 'p':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'R': /* Edge Rectangle Relative */
- X case 'r':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'S': /* Extra Space */
- X case 's':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'W': /* Edge Wedge */
- X case 'w':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'F':
- X case 'f':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'P': /* Fill Polygon */
- X case 'p':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'R': /* Advance Frame */
- X case 'r':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'S': /* Force Select */
- X case 's':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'T': /* Fill Type */
- X case 't':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'G':
- X case 'g':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'P': /* Group Pen */
- X case 'p':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'I':
- X case 'i':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'M': /* Input Mask (Not Used) */
- X case 'm':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'N': /* Initialize */
- X case 'n':
- X debugp((stderr,"%c%c",op1,op2));
- X plotcoords();
- X SETDOT = 0;
- X SYMBOL = 0;
- X PENDOWN = 0;
- X EOL = '\003';
- X char_angle = 0;
- X char_slant = 0;
- X if(LANDSCAPE) {
- X char_width = DEFWIDTH * (ymax - ymin) * YSCALE * SCALE;
- X char_height = DEFHEIGHT * (xmax - xmin) * XSCALE * SCALE;
- X }
- X else {
- X char_width = DEFWIDTH * (xmax - xmin) * XSCALE * SCALE;
- X char_height = DEFHEIGHT * (ymax - ymin) * YSCALE * SCALE;
- X }
- X char_space = char_width * (1/SPACE_FACTOR - 1);
- X printf("/%s %g %g %g DefFont\n",
- X font, char_width, char_height, char_slant);
- X dumpit(1);
- X break;
- X
- X case 'P': /* Input P1 and P2 (Not Used) */
- X case 'p':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'V': /* Invoke Character Slot */
- X case 'v':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'W': /* Input Window */
- X case 'w':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'L':
- X case 'l':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'B': /* Label */
- X case 'b':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X textps(TEXT);
- X break;
- X
- X case 'O': /* Label Origin */
- X case 'o':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'T': /* Line Type */
- X case 't':
- X debugp((stderr,"%c%c",op1,op2));
- X linetype(LINE_TYPE_SCALE);
- X dumpit(1);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'N':
- X case 'n':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'R': /* Not Ready */
- X case 'r':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'O': /* NOT USED */
- X case 'o':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'A': /* Output Actual Position */
- X case 'a':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'C': /* Output Commanded Position */
- X case 'c':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'D': /* Output Digitise */
- X case 'd':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'E': /* Output Error */
- X case 'e':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'F': /* Output Factors */
- X case 'f':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'H': /* Output Hard-Clip Limits */
- X case 'h':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'I': /* Output Indentification */
- X case 'i':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'L': /* Output Label Length */
- X case 'l':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'O': /* Output Options */
- X case 'o':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'P': /* Output P1 and P2 */
- X case 'p':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'S': /* Output Status */
- X case 's':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'T': /* Output Carousel Type */
- X case 't':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'W': /* Output Window */
- X case 'w':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'P':
- X case 'p':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'A': /* Plot Absolute */
- X case 'a':
- X debugp((stderr,"%c%c",op1,op2));
- X dumpcomma();
- X PLOTABS = 1;
- X if (SIGNED_NUMERIC)
- X if (SETDOT || SYMBOL)
- X plotdot(MOVE);
- X else if (PENDOWN)
- X plotps(DRAW);
- X else
- X plotps(MOVE);
- X dumpit(1);
- X break;
- X
- X case 'B': /* Print Buffered Label */
- X case 'b':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'D': /* Pen Down */
- X case 'd':
- X debugp((stderr,"%c%c",op1,op2));
- X dumpcomma();
- X PENDOWN = 1;
- X if (SIGNED_NUMERIC)
- X if (SETDOT)
- X plotdot(MOVE);
- X else if (PLOTABS)
- X plotps(DRAW);
- X else
- X plotps(RDRAW);
- X dumpit(1);
- X break;
- X
- X case 'G': /* Advance Full Page */
- X case 'g':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'M': /* Polygon Mode */
- X case 'm':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'R': /* Plot Relative */
- X case 'r':
- X debugp((stderr,"%c%c",op1,op2));
- X PLOTABS = 0;
- X if (SIGNED_NUMERIC)
- X if (SETDOT || SYMBOL)
- X plotdot(RMOVE);
- X else if (PENDOWN)
- X plotps(RDRAW);
- X else
- X plotps(RMOVE);
- X dumpit(1);
- X break;
- X
- X case 'T': /* Pen Thickness */
- X case 't':
- X debugp((stderr,"%c%c",op1,op2));
- X {
- X float linewidth;
- X
- X linewidth = getval() * SCALE; /* In mm */
- X printf("%g mm setlinewidth\n", linewidth);
- X }
- X dumpit(1);
- X break;
- X
- X case 'U': /* Pen Up */
- X case 'u':
- X debugp((stderr,"%c%c",op1,op2));
- X PENDOWN = 0;
- X if (SIGNED_NUMERIC)
- X if (SETDOT)
- X plotdot(MOVE);
- X else if (PLOTABS)
- X plotps(MOVE);
- X else
- X plotps(RMOVE);
- X dumpit(1);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'R':
- X case 'r':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'A': /* Fill Rectange Absolute */
- X case 'a':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'O': /* Rotate Coordinate System */
- X case 'o':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'R': /* Fill Rectangle Relative */
- X case 'r':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'S':
- X case 's':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'A': /* Select Alternate Set */
- X case 'a':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'C': /* Scale */
- X case 'c': /* Scaling added by Gordon Jacobs */
- X debugp((stderr,"%c%c",op1,op2));
- X if (SIGNED_NUMERIC){
- X xmin = getval();
- X }
- X else {
- X dumpit(1);
- X break;
- X }
- X
- X if (SIGNED_NUMERIC) {
- X xmax = getval();
- X }
- X if (SIGNED_NUMERIC) {
- X ymin = getval();
- X }
- X if (SIGNED_NUMERIC) {
- X ymax = getval();
- X }
- X modify_viewport(); /* new function for scaling */
- X end_draw();
- X dumpit(1);
- X break;
- X
- X case 'G': /* Select Pen Group */
- X case 'g':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X case 'I': /* Absolute Character Size */
- X case 'i':
- X debugp((stderr,"%c%c",op1,op2));
- X if (SIGNED_NUMERIC)
- X {
- X char_width = getval() * 10 * SCALE; /* In mm */
- X char_height = getval() * 10 * SCALE; /* In mm */
- X } else
- X {
- X if ((ch = getc(stream)) == ';')
- X {
- X char_width = 2.7 * SCALE;
- X char_height = 1.9 * SCALE;
- X }
- X }
- X char_space = char_width * (1/SPACE_FACTOR - 1);
- X printf("/%s %g %g %g DefFont\n",
- X font, char_width, char_height, char_slant);
- X dumpit(1);
- X break;
- X
- X case 'L': /* Character Slant */
- X case 'l':
- X debugp((stderr,"%c%c",op1,op2));
- X if (SIGNED_NUMERIC)
- X char_slant = char_height * getval();
- X else
- X char_slant = 0;
- X
- X char_space = char_width * (1/SPACE_FACTOR - 1);
- X printf("/%s %g %g %g DefFont\n",
- X font, char_width, char_height, char_slant);
- X dumpit(1);
- X break;
- X
- X case 'M': /* Symbol Mode */
- X case 'm':
- X if ((ch = getc(stream)) != EOF && ch != ';' && isgraph(ch) > 0)
- X {
- X symbol = ch;
- X debugp((stderr,"%c",ch));
- X SYMBOL = 1;
- X }
- X else
- X SYMBOL = 0;
- X dumpit(1);
- X break;
- X
- X case 'P': /* Pen Select */
- X case 'p':
- X debugp((stderr,"%c%c",op1,op2));
- X linesize();
- X dumpit(1);
- X break;
- X
- X case 'R': /* Relative Character Size */
- X case 'r':
- X debugp((stderr,"%c%c",op1,op2));
- X {
- X float pwidth, pheight;
- X
- X if (SIGNED_NUMERIC)
- X {
- X pwidth = getval() * SCALE; /* Percent */
- X pheight = getval() * SCALE; /* Percent */
- X } else
- X {
- X pwidth = DEFWIDTH * 100 * SCALE;
- X pheight = DEFHEIGHT * 100 * SCALE;
- X }
- X if(LANDSCAPE) {
- X char_width = FONT_W_MULT *(ymax - ymin)
- X * YSCALE * pwidth / 100.0;
- X char_height = FONT_H_MULT *(xmax - xmin)
- X * XSCALE * pheight / 100.0;
- X }
- X else {
- X char_width = (xmax - xmin) * XSCALE * pwidth / 100.0;
- X char_height = (ymax - ymin) * YSCALE * pheight / 100.0;
- X }
- X char_space = char_width * (1/SPACE_FACTOR - 1);
- X }
- X printf("/%s %g %g %g DefFont\n",
- X font, char_width, char_height, char_slant);
- X dumpit(1);
- X break;
- X
- X case 'S': /* Select Standard Set */
- X case 's':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'T':
- X case 't':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'L': /* Tick Length */
- X case 'l':
- X /* Feature added by Gordon Jacobs */
- X debugp((stderr,"%c%c",op1,op2));
- X if(SIGNED_NUMERIC) {
- X tlp = 0.01 * getval();
- X if(SIGNED_NUMERIC)
- X tln = 0.01 * getval();
- X else
- X tln = 0.0;
- X }
- X else
- X tlp = tlp = 0.005; /* defaults */
- X dumpit(1);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'U':
- X case 'u':
- X op2 = getc(stream);
- X switch (op2)
- X /* */
- X /* This case has been modified by Gerald William Kokodyniak */
- X /* at the University of Toronto, Department of Mechanical */
- X /* Engineering. It is presently operational with a calls */
- X /* made to a new subroutine/function called: */
- X /* userdefchar() */
- X /* */
- X /* Heavily modified by Gordon Jacobs. Size of user */
- X /* character now depends on regular character size. */
- X /* Orientation of character also depends on that of */
- X /* regular character set. */
- X {
- X case 'C': /* User Defined Character */
- X case 'c':
- X debugp((stderr,"%c%c",op1,op2));
- X userdefchar();
- X dumpit(1);
- X break;
- X
- X case 'F': /* User-defined Fill Type */
- X case 'f':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'V':
- X case 'v':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'S': /* Velocity Select */
- X case 's':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'W': /* Not HP-GL */
- X case 'w':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'G': /* Fill Wedge */
- X case 'g':
- X notimp((stderr,"Not Implemented: %c%c",op1,op2));
- X dumpit(2);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown RD-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'X':
- X case 'x':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'T': /* X Tick */
- X case 't':
- X debugp((stderr,"%c%c",op1,op2));
- X tick(XTICK); /* Tick() added by Gordon Jacobs */
- X dumpit(1);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command ", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X case 'Y':
- X case 'y':
- X op2 = getc(stream);
- X switch (op2)
- X {
- X case 'T': /* Y Tick */
- X case 't':
- X debugp((stderr,"%c%c",op1,op2));
- X tick(YTICK); /* Tick() added by Gordon Jacobs */
- X dumpit(1);
- X break;
- X
- X default:
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1, op2));
- X dumpit(2);
- X }
- X break;
- X
- X default:
- X op2 = getc(stream);
- X notimp((stderr, "Warning: %c%c Unknown HP-GL Command\n", op1,op2));
- X dumpit(2);
- X break;
- X }
- X}
- X
- Xdumpit(x)
- Xint x;
- X{
- X /* Dump all characters until we get to another command letter.
- X * This is to make sure that we have a clean start for the next command
- X */
- X while (((ch = getc(stream)) != EOF) && ch < 'A')
- X {
- X if (x == 1 )
- X debugp((stderr,"%c",ch));
- X if (x == 2 )
- X notimp((stderr,"%c",ch));
- X }
- X if (x == 1 )
- X debugp((stderr,"\n"));
- X if (x == 2 )
- X notimp((stderr,"\n"));
- X ungetc(ch,stream);
- X}
- X
- Xdumpcomma()
- X{
- X /* Dump the possible comma after a plot command. */
- X while (((ch = getc(stream)) != EOF) && ch == ',')
- X debugp((stderr,"%c",ch));
- X ungetc(ch,stream);
- X}
- SHAR_EOF
- chmod 0644 hpglcom.c || echo "restore of hpglcom.c fails"
- set `wc -c hpglcom.c`;Sum=$1
- if test "$Sum" != "21611"
- then echo original size 21611, current size $Sum;fi
- echo "x - extracting linesize.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > linesize.c &&
- X/* linesize.c */
- X#include "defn.h"
- X
- Xlinesize()
- X{
- X int ipen = 0;
- X float linewidth;
- X
- X if (SIGNED_NUMERIC)
- X ipen = getval() - 1;
- X
- X if (ipen < 0 || ipen > 8)
- X ipen = 0;
- X
- X pen_number = ipen;
- X
- X linewidth = pen_size[ipen] * SCALE; /* In mm */
- X printf("%g mm setlinewidth\n", linewidth);
- X}
- SHAR_EOF
- chmod 0644 linesize.c || echo "restore of linesize.c fails"
- set `wc -c linesize.c`;Sum=$1
- if test "$Sum" != "303"
- then echo original size 303, current size $Sum;fi
- echo "x - extracting linetype.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > linetype.c &&
- X/* linetype.c
- X * Sets the line type and the scaling of the line pattern
- X *
- X * Don McCormick CSIRO Division of Applied Physics National Measurements
- X * Laboritory Bradfield Road Lindfield 2018 N.S.W.
- X *
- X * NOTE: default length for a line pattern is approx 6.5 mm on A4 size paper.
- X */
- X#include "defn.h"
- X
- Xfloat linescale;
- Xint linestyle;
- X
- Xlinetype(line)
- Xint line;
- X{
- X float down1, down2;
- X float up1, up2;
- X float diagonal;
- X
- X end_draw();
- X
- X if (line == LINE_TYPE_SCALE) /* HP-GL only */
- X {
- X if (SIGNED_NUMERIC)
- X {
- X if ((linestyle = rint(getval())) > 6)
- X linestyle = 6;
- X else if (linestyle < -6)
- X linestyle = -6;
- X }
- X else
- X {
- X SETDOT = 0;
- X printf("[] 0 setdash\n");
- X return;
- X }
- X
- X diagonal = pow((xmax - xmin),2.0) + pow((ymax - ymin),2.0);
- X diagonal = pow(diagonal,0.5);
- X if (SIGNED_NUMERIC)
- X linescale = getval() * 0.01 * diagonal * XSCALE * SCALE * 0.2;
- X else
- X linescale = 0.015 * diagonal * XSCALE * SCALE * 0.2;
- X } else
- X if (line == LINESCALE) /* DXY commands only */
- X {
- X if (SIGNED_NUMERIC)
- X linescale = getval() / 80 * SCALE;
- X else
- X return;
- X } else
- X if (line == LINETYPE) /* DXY commands only */
- X {
- X if (SIGNED_NUMERIC)
- X {
- X if ((linestyle = rint(getval())) > 5)
- X linestyle = 5;
- X else if (linestyle < -5)
- X linestyle = -5;
- X }
- X else
- X return;
- X } else
- X {
- X fprintf(stderr, "Error: Unknown line flag in linetype.c\n");
- X exit(1);
- X }
- X /*
- X * select a line style/type and scale/pitch
- X */
- X switch (linestyle)
- X {
- X case 6:
- X down1 = 2.0;
- X up1 = up2 = 1.5;
- X down2 = 1.5;
- X break;
- X
- X case 5:
- X down1 = 3.0;
- X up1 = up2 = 1.0;
- X down2 = 1.5;
- X break;
- X
- X case 4:
- X down1 = 4.0;
- X up1 = up2 = 0.75;
- X down2 = 1.0;
- X break;
- X
- X case 3:
- X down1 = 5.0;
- X up1 = up2 = 1.0;
- X down2 = 0.5;
- X break;
- X
- X case 2:
- X down1 = 5.5;
- X up1 = 1.0;
- X up2 = down2 = 0.0;
- X break;
- X
- X case 1:
- X down1 = 5.0;
- X up1 = 1.5;
- X up2 = down2 = 0.0;
- X break;
- X
- X case -1:
- X down1 = 1.5;
- X up1 = 3.5;
- X down2 = 1.5;
- X up2 = 0.0;
- X break;
- X
- X case -2:
- X down1 = 2.0;
- X up1 = 2.5;
- X down2 = 2.0;
- X up2 = 0.0;
- X break;
- X
- X case -3:
- X down1 = 2.5;
- X up1 = up2 = 1.75;
- X down2 = 0.5;
- X break;
- X
- X case -4:
- X down1 = 2.5;
- X up1 = up2 = 1.5;
- X down2 = 1.5;
- X break;
- X
- X case -5:
- X down1 = down2 = 2.0;
- X up1 = up2 = 1.25;
- X break;
- X
- X case -6:
- X down1 = down2 = 1.75;
- X up1 = up2 = 1.5;
- X break;
- X }
- X if (linestyle == 0)
- X {
- X SETDOT = 1; /* For HP-GL only */
- X printf("[] 0 setdash\n"); /* For DXY commands */
- X } else
- X {
- X SETDOT = 0; /* For HP-GL only */
- X if (linescale <= 0) linescale = SCALE;
- X down1 *= linescale;
- X up2 *= linescale;
- X up1 *= linescale;
- X down2 *= linescale;
- X printf("[%g mm %g mm %g mm %g mm] 0 setdash\n",
- X down1, up1, down2, up2);
- X }
- X}
- X
- X#ifdef SYSV
- Xrint(x)
- X double x;
- X {
- X int k;
- X k = x;
- X return(k);
- X }
- X#endif
- SHAR_EOF
- chmod 0644 linetype.c || echo "restore of linetype.c fails"
- set `wc -c linetype.c`;Sum=$1
- if test "$Sum" != "2811"
- then echo original size 2811, current size $Sum;fi
- echo "x - extracting manualfeed.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > manualfeed.c &&
- X/* manualfeed.c
- X * A procedure to allow the user to use the manual feed on
- X * the LaserWriter.
- X * The default wait before timeout is 3 minutes however this
- X * is easily changed.
- X *
- X * argument: 1. Enable manual feed.
- X * 0. Disable manual feed.
- X *
- X * Don McCormick
- X */
- Xmanualfeed(arg)
- Xint arg;
- X{
- X if (arg == 1)
- X {
- X printf("statusdict /manualfeed true put\n");
- X printf("statusdict /manualfeedtimeout 180 put\n"); /* 3 minute wait */
- X } else
- X printf("statusdict /manualfeed false put\n");
- X
- X printf("usertime 5000 add\n");
- X printf("{dup usertime lt {pop exit} if} loop\n");
- X}
- SHAR_EOF
- chmod 0644 manualfeed.c || echo "restore of manualfeed.c fails"
- set `wc -c manualfeed.c`;Sum=$1
- if test "$Sum" != "603"
- then echo original size 603, current size $Sum;fi
- echo "x - extracting plotcoords.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > plotcoords.c &&
- X/* plotcoords.c */
- X/*
- X * Define default maximum and minimum plotting coordinates.
- X * P1 (xmin, ymin), P2 (xmax, ymax)
- X *
- X * PaperSize can be:
- X * "A3" ISO (420mm by 297mm)
- X * "A4" ISO (297mm by 210mm)
- X * "A" ANSI (11" by 8.5")
- X * "B" ANSI (17" by 11")
- X *
- X * Mode can be: "HPGL" or "DXY"
- X *
- X * Don McCormick
- X */
- X
- X#include "defn.h"
- X
- Xplotcoords()
- X{
- X if (strcmp(Mode, "HPGL") == 0)
- X {
- X if (strcmp(PaperSize, "A3") == 0) /* HP-GL ISO A3 420mm * 297mm */
- X {
- X xmax = 15200;
- X ymax = 10800;
- X }
- X else if(strcmp(PaperSize,"A4") == 0) /* HP-GL ISO A4 297mm * 210mm */
- X {
- X xmax = 10800;
- X ymax = 7680;
- X }
- X else if(strcmp(PaperSize,"A") == 0) /* HP-GL ANSI A 11 * 8.5inch */
- X {
- X xmax = 10000;
- X ymax = 7200;
- X }
- X else if(strcmp(PaperSize,"B") == 0) /* HP-GL ANSI B 17 * 11inch */
- X {
- X xmax = 15200;
- X ymax = 10000;
- X }
- X else
- X {
- X fprintf("Illegal paper size\n");
- X exit(-1);
- X }
- X }
- X else
- X {
- X if (strcmp(PaperSize, "A3") == 0) /* DXY ISO A3 420mm * 297mm */
- X {
- X xmax = 3800;
- X ymax = 2700;
- X }
- X else /* DXY ISO A4 297mm * 210mm */
- X {
- X xmax = 2700;
- X ymax = 1920;
- X }
- X }
- X /* origin at zero,zero */
- X xmin = ymin = 0.0;
- X offX = offY = 0.0;
- X /* default tick length percentage */
- X tlp = tln = 0.005;
- X}
- SHAR_EOF
- chmod 0644 plotcoords.c || echo "restore of plotcoords.c fails"
- set `wc -c plotcoords.c`;Sum=$1
- if test "$Sum" != "1273"
- then echo original size 1273, current size $Sum;fi
- echo "x - extracting plotdot.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > plotdot.c &&
- X/* plotdot.c */
- X/*
- X * Plot a dot or symbol on the paper
- X */
- X#include "defn.h"
- X
- Xplotdot(type)
- Xchar *type;
- X{
- X end_draw();
- X
- X while (SIGNED_NUMERIC)
- X {
- X xval = getval() * XSCALE;
- X yval = getval() * YSCALE;
- X if (type == RMOVE)
- X {
- X absX += xval;
- X absY += yval;
- X } else
- X if (type == MOVE)
- X {
- X absX = xval + offX;
- X absY = yval + offY;
- X } else
- X {
- X fprintf(stderr, "Error: expecting move command not %s\n", type);
- X exit(1);
- X }
- X
- X if (SYMBOL)
- X {
- X printf("%g %g 5 %g (%c) Text\n", absX, absY, char_angle, symbol);
- X debugp((stderr,"%g %g 5 %g (%c) Text\n", absX, absY, char_angle, symbol));
- X }
- X else if (SETDOT)
- X {
- X printf("newpath\n");
- X debugp((stderr,"newpath\n"));
- X printf(" %g %g %s %g %g %s\n", absX, absY, MOVE, absX, absY, DRAW);
- X debugp((stderr," %g %g %s %g %g %s\n", absX, absY, MOVE, absX, absY, DRAW));
- X printf("stroke\n");
- X debugp((stderr,"stroke\n"));
- X }
- X }
- X}
- SHAR_EOF
- chmod 0644 plotdot.c || echo "restore of plotdot.c fails"
- set `wc -c plotdot.c`;Sum=$1
- if test "$Sum" != "953"
- then echo original size 953, current size $Sum;fi
- echo "x - extracting plotinit.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > plotinit.c &&
- X/* plotinit.c */
- X#include "defn.h"
- X
- Xplotinit()
- X{
- X /*
- X * Initialisation of PostScript plot macros
- X */
- X MOVE = "M";
- X RMOVE = "R";
- X DRAW = "D";
- X RDRAW = "I";
- X AARC = "AA";
- X RARC = "RA";
- X
- X LANDSCAPE = 1; /* Display plot in Landscape mode */
- X
- X SCALE = 1; /* Default Scale */
- X
- X PLOTABS = 1; /* Absolute plot coordinates */
- X
- X PLOTARC = 0; /* Plot arc */
- X
- X PENDOWN = 0; /* Penup */
- X
- X SETDOT = 0; /* HP-GL only for linetype = 0 */
- X
- X SYMBOL = 0; /* HP-GL only */
- X
- X FONT_H_MULT = 1.2;
- X FONT_W_MULT = 3.6; /* necessary for postscript fonts to match */
- X /* when using relative font sizing */
- X /*
- X * Default line/pen sizes (in mm)
- X */
- X pen_size[0] = 0.0125;
- X pen_size[1] = 0.025;
- X pen_size[2] = 0.05;
- X pen_size[3] = 0.1;
- X pen_size[4] = 0.2;
- X pen_size[5] = 0.3;
- X pen_size[6] = 0.4;
- X pen_size[7] = 0.5;
- X pen_size[8] = 1.0;
- X
- X font = "Helvetica"; /* Default font */
- X
- X EOL = '\003'; /* End of line terminator default */
- X
- X /*
- X * Default character specifications
- X */
- X char_angle = 0; /* Degrees */
- X char_slant = 0; /* tan(angle) */
- X /********** modified for larger defaults GJ
- X char_height = 2.7; /* mm
- X char_space = 0.8; /* mm
- X char_width = 1.9; /* mm
- X *********************************************/
- X char_height = 4.0; /* mm */
- X char_space = 1.2; /* mm */
- X char_width = 2.8; /* mm */
- X
- X /*
- X * Page offsets set to zero
- X */
- X xoffset = yoffset = 0;
- X /*
- X * Define degree to radian parameter
- X */
- X deg_rad = asin(1.0) / 90.0;
- X}
- SHAR_EOF
- chmod 0644 plotinit.c || echo "restore of plotinit.c fails"
- set `wc -c plotinit.c`;Sum=$1
- if test "$Sum" != "1606"
- then echo original size 1606, current size $Sum;fi
- echo "x - extracting plotps.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > plotps.c &&
- X/* plotps.c */
- X#include "defn.h"
- X
- X#define MAXDRAWPOINTS 100
- X
- Xplotps(type)
- Xchar *type;
- X{
- X if (type == MOVE || type == RMOVE)
- X {
- X while (SIGNED_NUMERIC)
- X {
- X if (type == MOVE)
- X {
- X end_draw();
- X absX = lastXmove = getval() * XSCALE + offX;
- X absY = lastYmove = getval() * YSCALE + offY;
- X } else
- X if (type == RMOVE)
- X {
- X end_draw();
- X lastXmove = absX += getval() * XSCALE ;
- X lastYmove = absY += getval() * YSCALE ;
- X }
- X }
- X }
- X else /* Must be a DRAW or RDRAW */
- X {
- X while (SIGNED_NUMERIC)
- X {
- X if (dcount++ >= MAXDRAWPOINTS)
- X {
- X end_draw();
- X printf("newpath\n");
- X debugp((stderr,"newpath\n"));
- X printf(" %g %g %s\n", absX, absY, MOVE);
- X debugp((stderr," %g %g %s\n", absX, absY, MOVE));
- X DRAW_FLAG = 1;
- X /* fprintf(stderr, "Warning exceeded %d draw points\n",
- X MAXDRAWPOINTS); */
- X }
- X xval = getval() * XSCALE;
- X yval = getval() * YSCALE;
- X if (!DRAW_FLAG)
- X {
- X printf("newpath\n");
- X debugp((stderr,"newpath\n"));
- X printf(" %g %g %s\n", absX, absY, MOVE);
- X debugp((stderr," %g %g %s\n", absX, absY, MOVE));
- X DRAW_FLAG = 1;
- X }
- X if (type == RDRAW)
- X {
- X absX += xval;
- X absY += yval;
- X printf(" %g %g %s\n", xval, yval, RDRAW);
- X debugp((stderr," %g %g %s\n", xval, yval, RDRAW));
- X } else
- X if (type == DRAW)
- X {
- X absX = xval + offX;
- X absY = yval + offY;
- X printf(" %g %g %s\n", absX, absY, DRAW);
- X debugp((stderr," %g %g %s\n", absX, absY, DRAW));
- X } else
- X {
- X fprintf(stderr, "Error: expecting draw command not %s\n", type);
- X exit(1);
- X }
- X }
- X }
- X}
- SHAR_EOF
- chmod 0644 plotps.c || echo "restore of plotps.c fails"
- set `wc -c plotps.c`;Sum=$1
- if test "$Sum" != "1572"
- then echo original size 1572, current size $Sum;fi
- echo "x - extracting printtest (Text)"
- sed 's/^X//' << 'SHAR_EOF' > printtest &&
- X(%%[ pagecount: )print statusdict/pagecount get exec( )cvs print(, 311 1 ]%%)= flush
- SHAR_EOF
- chmod 0644 printtest || echo "restore of printtest fails"
- set `wc -c printtest`;Sum=$1
- if test "$Sum" != "100"
- then echo original size 100, current size $Sum;fi
- echo "x - extracting ps_macros.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ps_macros.c &&
- Xps_macros()
- X{
- X printf("%%! PS-Adobe-1.0: For Apple LaserWriter\n");
- X printf("%% default font is 14 pt. Helvetica\n");
- X printf("/basefont {/Helvetica findfont 14 scalefont setfont} def\n");
- X
- X /*printf("/mm {72.27 mul 25.4 div} def\n"); /* Specify millimeters */
- X printf("/mm {72.0 mul 25.4 div} def\n"); /* Specify millimeters */
- X
- X printf("/M\n"); /* Move macro */
- X printf("{\n");
- X printf(" /Ymove exch def\n");
- X printf(" /Xmove exch def\n");
- X printf(" Xmove mm Ymove mm moveto\n");
- X printf("} def\n");
- X
- X printf("/R\n"); /* Relative move macro */
- X printf("{\n");
- X printf(" /Yrmove exch def\n");
- X printf(" /Xrmove exch def\n");
- X printf(" Xrmove mm Yrmove mm rmoveto\n");
- X printf("} def\n");
- X
- X printf("/D\n"); /* Draw macro */
- X printf("{\n");
- X printf(" /Ydraw exch def\n");
- X printf(" /Xdraw exch def\n");
- X printf(" Xdraw mm Ydraw mm lineto\n");
- X printf("} def\n");
- X
- X printf("/I\n"); /* Relative draw macro */
- X printf("{\n");
- X printf(" /Yrdraw exch def\n");
- X printf(" /Xrdraw exch def\n");
- X printf(" Xrdraw mm Yrdraw mm rlineto\n");
- X printf("} def\n");
- X
- X printf("/AA\n"); /* Arc draw macro */
- X printf("{\n");
- X printf(" /endangle exch def\n");
- X printf(" /startangle exch def\n");
- X printf(" /radius exch def\n");
- X printf(" /Ydraw exch def\n");
- X printf(" /Xdraw exch def\n");
- X printf(" Xdraw mm Ydraw mm radius mm startangle endangle arc\n");
- X printf("} def\n");
- X
- X printf("/AAC\n"); /* Arc draw macro (clockwise) */
- X printf("{\n");
- X printf(" /endangle exch def\n");
- X printf(" /startangle exch def\n");
- X printf(" /radius exch def\n");
- X printf(" /Ydraw exch def\n");
- X printf(" /Xdraw exch def\n");
- X printf(" Xdraw mm Ydraw mm radius mm startangle endangle arcn\n");
- X printf("} def\n");
- X /*
- X * Procedure to change font and size of font
- X * ----> font size Font <----
- X */
- X printf("/Font\n");
- X printf("{\n");
- X printf(" /Height exch def\n");
- X printf(" /FontName exch def\n");
- X printf(" FontName findfont Height mm scalefont setfont\n");
- X printf("} def\n");
- X /*
- X * Procedure to change font, width, slant and height
- X * ----> font width height slant DefFont <----
- X *
- X * Note: slant = height * tan( slant_angle )
- X */
- X printf("/DefFont\n");
- X printf("{\n");
- X printf(" /Slant exch def\n");
- X printf(" /Height exch def\n");
- X printf(" /Width exch def\n");
- X printf(" /FontName exch def\n");
- X printf(" FontName findfont [ Width mm 0 Slant mm Height mm 0 0] makefont setfont\n");
- X printf("} def\n");
- X /*
- X * General Text Layout Procedure
- X * ----> x y pos_num angle (text) Text <----
- X */
- X printf("/Text\n");
- X printf("{\n");
- X printf(" /String exch def\n");
- X printf(" /Angle exch def\n");
- X printf(" /Position exch def\n");
- X printf(" /Ymove exch def\n");
- X printf(" /Xmove exch def\n");
- X printf(" Position 1 lt {/hpf 0 def /lpf 0 def} if\n");
- X printf(" Position 1 eq {/hpf 0 def /lpf 0 def} if\n");
- X printf(" Position 2 eq {/hpf 0 def /lpf 0.5 def} if\n");
- X printf(" Position 3 eq {/hpf 0 def /lpf 1 def} if\n");
- X printf(" Position 4 eq {/hpf 0.5 def /lpf 0 def} if\n");
- X printf(" Position 5 eq {/hpf 0.5 def /lpf 0.5 def} if\n");
- X printf(" Position 6 eq {/hpf 0.5 def /lpf 1 def} if\n");
- X printf(" Position 7 eq {/hpf 1 def /lpf 0 def} if\n");
- X printf(" Position 8 eq {/hpf 1 def /lpf 0.5 def} if\n");
- X printf(" Position 9 eq {/hpf 1 def /lpf 1 def} if\n");
- X printf(" Position 9 gt {/hpf 1 def /lpf 1 def} if\n");
- X printf(" /StrLen String stringwidth pop lpf mul def\n");
- X printf(" /StrHt Height mm hpf mul def\n");
- X printf(" /Xdiff StrHt Angle sin mul StrLen Angle cos mul sub def\n");
- X printf(" /Ydiff StrHt Angle cos mul StrLen Angle sin mul add def\n");
- X printf(" Xmove mm Xdiff add Ymove mm Ydiff sub moveto\n");
- X printf(" gsave\n");
- X printf(" Angle rotate\n");
- X printf(" String show\n");
- X printf(" grestore\n");
- X printf(" /PosterOnly 0 def\n");
- X printf("} def\n");
- X /*
- X * Ellipse and Circle procedure.
- X * ----> xcen ycen xrad yrad start_angle end_angle Ellipse <----
- X */
- X printf("/EllipseDict 8 dict def\n");
- X printf("EllipseDict /mtrx matrix put\n");
- X printf("/Ellipse \n");
- X printf("{ EllipseDict begin\n");
- X printf(" /endangle exch def\n");
- X printf(" /startangle exch def\n");
- X printf(" /yradius exch def\n");
- X printf(" /xradius exch def\n");
- X printf(" /ycenter exch def\n");
- X printf(" /xcenter exch def\n");
- X printf(" /savematrix mtrx currentmatrix def\n");
- X printf(" xcenter mm ycenter mm translate\n");
- X printf(" xradius mm yradius mm div 1 scale\n");
- X printf(" newpath\n");
- X printf(" 0 0 xradius mm startangle endangle arc\n");
- X printf(" stroke\n");
- X printf(" savematrix setmatrix\n");
- X printf(" end\n");
- X printf("} def\n");
- X
- X printf("basefont\n"); /* Set the default font */
- X printf("1 setlinecap\n"); /* Use round caps */
- X printf("1 setlinejoin\n"); /* Use round joins */
- X printf("3 setmiterlimit\n"); /* Bevel small angle miters */
- X}
- SHAR_EOF
- chmod 0644 ps_macros.c || echo "restore of ps_macros.c fails"
- set `wc -c ps_macros.c`;Sum=$1
- if test "$Sum" != "5403"
- then echo original size 5403, current size $Sum;fi
- echo "x - extracting rectangle.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > rectangle.c &&
- X/* rectangle.c */
- X#include "defn.h"
- X
- Xrectangle()
- X{
- X int hatch;
- X float width, height;
- X float hatch_spacing;
- X float hatch_angle;
- X
- X if (SIGNED_NUMERIC)
- X hatch = getval();
- X if (SIGNED_NUMERIC)
- X width = getval() * XSCALE;
- X if (SIGNED_NUMERIC)
- X height = getval() * YSCALE;
- X if (SIGNED_NUMERIC)
- X hatch_spacing = getval() * XSCALE;
- X if (SIGNED_NUMERIC)
- X hatch_angle = getval();
- X
- X end_draw();
- X printf("%g %g M\n", xval, yval);
- X printf("%g 0 I\n", width);
- X printf("0 %g I\n", height);
- X printf("-%g 0 I\n", width);
- X printf("closepath stroke\n");
- X if (hatch != 2)
- X fprintf(stderr, "Warning: Cross hatching not implemented yet\n");
- X}
- SHAR_EOF
- chmod 0644 rectangle.c || echo "restore of rectangle.c fails"
- set `wc -c rectangle.c`;Sum=$1
- if test "$Sum" != "681"
- then echo original size 681, current size $Sum;fi
- echo "x - extracting test.hpgl (Text)"
- sed 's/^X//' << 'SHAR_EOF' > test.hpgl &&
- 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;
- XSP3;SC-864,5536,-496,4112;LT
- 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
- 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
- XPU;
- XPA;PU;
- XSP3
- 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
- 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
- X
- XPU;
- XPA;PU;
- XSP3
- 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
- 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
- XPU;
- 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
- 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
- XPU;
- X
- XSP2
- XPU4048,48;TL0.5,0;PR;
- 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;
- 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;
- XTL0,0.5;PR;
- 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;
- 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
- XPA,PU2048,48;PR;
- XPD80,0;PA;
- X
- XSP3;SR0.75,1.63;SC0,800,-24,552
- XPU314,-20;LB/div
- XPU122,-20;LB500mV
- XPU298,-20;LB500mV
- XPU618,-20;LB-4.5V
- XPU634,10;LB-98ns
- XPU634,252;LB100ns/div
- XPU634,502;LB902ns
- XPU444,-22;SR0.50,1.63;PR-2,2;LBtrig'd;PA;
- X
- XSR0.75,1.63;SC0,800,-24,552
- XPU635,360;SR0.49,1.05;PR-2,0;PD-12,0,0,17,12,0,0,-17;PU-2,3;LBRT;PA;
- X
- XSR0.75,1.63;SC0,800,-24,552
- XPU196,80;PR7,0;PD-7,15,0,-10,3,3,4,0,-7,7;PA;
- X
- XSP3
- XPU386,116;LBacki_Cbar
- X
- XSP3
- XPU154,96;LBReqi_IN
- X
- XSP3
- XPU266,161;LBacki_B
- XPU490,161;LBacki_ACC
- XSC;PA;PU0,0;SP0;
- X
- SHAR_EOF
- chmod 0644 test.hpgl || echo "restore of test.hpgl fails"
- set `wc -c test.hpgl`;Sum=$1
- if test "$Sum" != "5794"
- then echo original size 5794, current size $Sum;fi
- echo "x - extracting test1.dxy (Text)"
- sed 's/^X//' << 'SHAR_EOF' > test1.dxy &&
- XJ1
- XM 1000, 1000
- XI 100, 0, -200,0, 100, 0, 0,100,0, -200
- XP Hi There
- XC 1000, 1000, 500, 0, 250
- XM 2000,1000
- XI 100, 0, -200,0, 100, 0, 0,100,0, -200
- XL 2
- XJ5
- XC 2000, 1000, 500, 250, 0
- XJ3
- XM 0 0
- XI 3800,0,0,2700,-3800,0,0,-2700
- XM 500,2000
- X^SL1;S50PDXY-880
- X^SL;S3
- X
- SHAR_EOF
- chmod 0644 test1.dxy || echo "restore of test1.dxy fails"
- set `wc -c test1.dxy`;Sum=$1
- if test "$Sum" != "255"
- then echo original size 255, current size $Sum;fi
- echo "x - extracting test1.hpgl (Text)"
- sed 's/^X//' << 'SHAR_EOF' > test1.hpgl &&
- XDF;IN;LT;PU1000,1000;PD2000,1000,2000,2000,1000,2000,1000,1000;
- XPR-100,0,0,-100,100,0,0,100;
- XPU;PA0,0;PD10800,0,10800,7680,0,7680,0,0;PU;
- XLT6,2;PA;PU4000,1400;PD;PR4000,0;
- XLT5,2;PA;PU4000,1300;PD;PR4000,0;
- XLT4,2;PA;PU4000,1200;PD;PR4000,0;
- XLT3,2;PA;PU4000,1100;PD;PR4000,0;
- XLT2,2;PA;PU4000,1000;PD;PR4000,0;
- XLT1,2;PA;PU4000,900;PD;PR4000,0;
- XLT0;PA;PU4000,800;PD;PR4000,0;
- XLT-1,2;PA;PU4000,700;PD;PR4000,0;
- XLT-2,2;PA;PU4000,600;PD;PR4000,0;
- XLT-3,2;PA;PU4000,500;PD;PR4000,0;
- XLT-4,2;PA;PU4000,400;PD;PR4000,0;
- XLT-5,2;PA;PU4000,300;PD;PR4000,0;
- XLT-6,2;PA;PU4000,200;PD;PR4000,0;
- XPU;PA2000,4000;
- XDI;LB -- 0deg --
- XDI1,1;LB -- 45deg --
- XDI0,1;LB -- 90deg --
- XDI-1,1;LB -- 135deg --
- XDI-1,0;LB -- 180deg --
- XDI-1,-1;LB -- 225deg --
- XDI0,-1;LB -- 270deg --
- XDI1,-1;LB -- 315deg --
- XPA4000,4000;
- XDI;SL1;LB SLANT of 45deg
- XPA4000,3600;
- XSL-1;LB SLANT of -45deg
- XPA2000,6000;
- XSL;SR;LB Size is relative
- XPA2000,5500;
- XSI;LB DEFAULT sizes
- XPA2000,5000;
- XSI.8,1;LBLARGE size (w=8mm, h=10mm)
- XLT; PA 9000,1000;CI500,20;CI400;CI300;CI200,1;CI100;CI50;
- XIN;SM+;PA9000,1000,10000,1000;SM%;PR0,500,0,-1000;
- XSM;
- SHAR_EOF
- chmod 0644 test1.hpgl || echo "restore of test1.hpgl fails"
- set `wc -c test1.hpgl`;Sum=$1
- if test "$Sum" != "1095"
- then echo original size 1095, current size $Sum;fi
- echo "x - extracting test3.hpgl (Text)"
- sed 's/^X//' << 'SHAR_EOF' > test3.hpgl &&
- XSP6;DI0,1;SR0.70,1.90;SC0,800,0,576;PA;PU20,0;LBDSA 602 DIGITIZING SIGNAL ANALYZERPU20,320;PA;PU;
- XSP3;SC-864,5536,-496,4112;LT
- XPU3040,0;PD;PD3056,4,3056,8,3040,12;
- XPU;
- X
- XSP2
- XPU4048,48;TL0.5,0;PR;
- 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;
- 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;
- XTL0,0.5;PR;
- 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;
- 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
- XPA,PU2048,48;PR;
- XTL0.25,0.25;PD0,80;YT;PD0,80;YT;PD0,80;YT;PD0,80;YT;PD0,80;PA;PU48,2048;PR;
- XTL0.25,0.25;PD80,0;XT;PD80,0;XT;PD80,0;XT;PD80,0;XT;PD80,0;PA;
- X
- XSP6;SR0.75,1.63;SC0,800,-24,552
- 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
- XPA;
- X
- XSP3;SR0.75,1.63;SC0,800,-24,552
- XPU466,30;PR7,0;PD-7,15,0,-10,3,3,4,0,-7,7;PA;
- X
- XSP6
- 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;
- XSC;PA;PU0,0;SP0;
- X
- SHAR_EOF
- chmod 0644 test3.hpgl || echo "restore of test3.hpgl fails"
- set `wc -c test3.hpgl`;Sum=$1
- if test "$Sum" != "1116"
- then echo original size 1116, current size $Sum;fi
- echo "x - extracting textps.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > textps.c &&
- X/* textps.c */
- X#include "defn.h"
- X
- X#define MAXBUFSIZE 100
- X
- Xtextps(type)
- Xint type;
- X{
- X char string[4];
- X char buffer[MAXBUFSIZE];
- X float Xch, Ych;
- X int intval;
- X int i;
- X
- X end_draw();
- X
- X if (type == TEXT)
- X {
- X for (i = 0 ; i < MAXBUFSIZE; i++) /* Clear buffer */
- X buffer[i] = NULL;
- X
- X i = 0; /* Reset buffer counter */
- X
- X while (((ch = getc(stream)) != EOF)
- X && ch != CR && ch != LF && ch != EOL) {
- X buffer[i++] = ch;
- X }
- X
- X printf("%g %g 1 %g (%s) Text\n", absX, absY, char_angle, buffer);
- X
- X /* move to end of string */
- X absX += (i * (char_space)) * cos(char_angle * deg_rad) ;
- X absY += (i * (char_space)) * sin(char_angle * deg_rad) ;
- X
- X } else /* Must be a MARK */
- X {
- X int symb_num;
- X
- X if (SIGNED_NUMERIC)
- X symb_num = getval();
- X else
- X {
- X fprintf(stderr,
- X "Error: expecting a symbol number not %c (%d)",
- X symb_num, symb_num);
- X exit(1);
- X }
- X intval = (int)(getval() + 0.5);
- X switch (intval)
- X {
- X case 0:
- X strcpy(string, "*");
- X break;
- X
- X case 1:
- X strcpy(string, "+");
- X break;
- X
- X case 2:
- X strcpy(string, "#");
- X break;
- X
- X case 3:
- X strcpy(string, "@");
- X break;
- X
- X case 4:
- X strcpy(string, "%");
- X break;
- X
- X case 5:
- X strcpy(string, "|");
- X break;
- X
- X case 6:
- X strcpy(string, "=");
- X break;
- X
- X case 7:
- X strcpy(string, "&");
- X break;
- X
- X case 9:
- X strcpy(string, "O");
- X break;
- X
- X case 10:
- X strcpy(string, "0");
- X break;
- X
- X case 11:
- X strcpy(string, "Y");
- X break;
- X
- X case 12:
- X strcpy(string, "X");
- X break;
- X
- X case 13:
- X strcpy(string, "Z");
- X break;
- X
- X case 14:
- X strcpy(string, "S");
- X break;
- X
- X case 15:
- X strcpy(string, "Q");
- X break;
- X
- X default:
- X fprintf(stderr, "Warning symbol number is %d\n", symb_num);
- X strcpy(string, "*");
- X break;
- X }
- X printf("%g %g 5 %g (%s) Text\n", absX, absY, char_angle, string);
- X }
- X}
- SHAR_EOF
- chmod 0644 textps.c || echo "restore of textps.c fails"
- set `wc -c textps.c`;Sum=$1
- if test "$Sum" != "1896"
- then echo original size 1896, current size $Sum;fi
- echo "x - extracting tick.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > tick.c &&
- X/* tick.c */
- X/*
- X * tick(type)
- X *
- X * function for handling the XT,YT commands
- X * in Hewlett-Packard Graphics Language (HP-GL).
- X *
- X * Written by Gordon Jacobs
- X * University of California, Berkeley , Dept of EECS.
- X */
- X
- X
- X#include "defn.h"
- X
- Xtick(type)
- Xint type;
- X{
- X float Xtlengthp,Xtlengthn,Ytlengthp,Ytlengthn;
- X
- X /* Compute tick lengths as a function of viewport dimensions */
- X /* Xticks are in Y direction: */
- X Xtlengthp = tlp * (ymax - ymin) * XSCALE;
- X Xtlengthn = tln * (ymax - ymin) * XSCALE;
- X /* Yticks are in X direction */
- X Ytlengthp = tlp * (xmax - xmin) * YSCALE;
- X Ytlengthn = tln * (xmax - xmin) * YSCALE;
- X
- X /* Ticks: Don't mess with position pointers,
- X * just use relative draw and move commands
- X */
- X if (type == XTICK) {
- X if(tlp != 0.0) {
- X lastYmove = absY += Xtlengthp;
- X printf(" %g %g %s\n",0.0,Xtlengthp,RMOVE);
- X printf(" %g %g %s\n",0.0,-Xtlengthp,RDRAW);
- X }
- X if(tln != 0.0) {
- X lastYmove = absY -= Xtlengthp;
- X printf(" %g %g %s\n",0.0,-Xtlengthn,RMOVE);
- X printf(" %g %g %s\n",0.0,Xtlengthn,RDRAW);
- X }
- X }
- X else {
- X if(tlp != 0.0) {
- X lastXmove = absX += Xtlengthp;
- X printf(" %g %g %s\n",Ytlengthp,0.0,RMOVE);
- X printf(" %g %g %s\n",-Ytlengthp,0.0,RDRAW);
- X }
- X if(tln != 0.0) {
- X lastXmove = absX -= Xtlengthp;
- X printf(" %g %g %s\n",-Ytlengthn,0.0,RMOVE);
- X printf(" %g %g %s\n",Ytlengthn,0.0,RDRAW);
- X }
- X }
- X}
- SHAR_EOF
- chmod 0644 tick.c || echo "restore of tick.c fails"
- set `wc -c tick.c`;Sum=$1
- if test "$Sum" != "1390"
- then echo original size 1390, current size $Sum;fi
- echo "x - extracting userdefchar.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > userdefchar.c &&
- X/* userdefchar.c */
- X/*
- X * userdefchar(type)
- X *
- X * function for handling the USER DEFINED CHARACTER (UC) command
- X * in Hewlett-Packard Graphics Language (HP-GL).
- X *
- X * Written by Gerald William Kokodyniak B.A.Sc. M.A.Sc.
- X * University of Toronto, Department of Mechanical Engineering
- X *
- X * Heavily modified by Gordon Jacobs, University of Calif, Berkeley
- X * Now scales user character size to that of regular characters
- X * Orients user character the same as regular characters
- X * Linewidth chosed to always be 0.25mm to better match
- X * postscript font.
- X *
- X */
- X
- X#include "defn.h"
- X#define MAXDRAWPOINTS 100
- X
- X/* standard resolution user-def character pen control numbers */
- X/* for enhanced, change to -9999,9999 */
- X#define PENUPCTL -99.0
- X#define PENDNCTL 99.0
- X
- X/* linewidth in mm for user defined characters */
- X#define DEFCHAR_LINEWIDTH 0.25
- X
- X/* Scaling parameters */
- X#define CHAR_CELL_H 5.0
- X#define CHAR_CELL_W 2.5
- X
- Xuserdefchar()
- X{
- X float number, tmp, rad, angl;
- X float theMagnitude(), theAngle();
- X float first_absX = absX;
- X float first_absY = absY;
- X PENDOWN = 0;
- X printf("%g mm setlinewidth\n", DEFCHAR_LINEWIDTH);
- X
- X while (SIGNED_NUMERIC)
- X {
- X number = getval();
- X if (number >= PENDNCTL) {
- X PENDOWN = 1;
- X number = getval();
- X }
- X else if (number <= PENUPCTL) {
- X PENDOWN = 0;
- X number = getval();
- X }
- X
- X if (number < PENDNCTL && number > PENUPCTL) {
- X if (PENDOWN) {
- X if (dcount++ >= MAXDRAWPOINTS) {
- X end_draw();
- X printf("newpath\n");
- X printf(" %g %g %s\n", absX, absY, MOVE);
- X DRAW_FLAG = 1;
- X }
- X xval = number / CHAR_CELL_W * char_width * XSCALE;
- X yval = getval() / CHAR_CELL_H * char_height * YSCALE;
- X if (!DRAW_FLAG) {
- X printf("newpath\n");
- X printf(" %g %g %s\n", absX, absY, MOVE);
- X DRAW_FLAG = 1;
- X }
- X /* perform rotation */
- X rad = theMagnitude(xval,yval);
- X angl = theAngle(xval,yval);
- X angl += char_angle * deg_rad;
- X xval = rad *cos(angl);
- X yval = rad *sin(angl);
- X absX += xval;
- X absY += yval;
- X printf(" %g %g %s\n", xval, yval, RDRAW);
- X } else {
- X end_draw();
- X xval = number / CHAR_CELL_W * char_width *XSCALE;
- X yval = getval() / CHAR_CELL_H * char_height * YSCALE;
- X
- X rad = theMagnitude(xval,yval);
- X angl = theAngle(xval,yval);
- X angl += char_angle * deg_rad;
- X
- X lastXmove = absX += rad * cos(angl);
- X lastYmove = absY += rad * sin(angl);
- X }
- X }
- X else {
- X if(number >= PENDNCTL)
- X PENDOWN = 1;
- X else if(number <= PENUPCTL)
- X PENDOWN = 0;
- X }
- X }
- X PENDOWN = 0;
- X end_draw();
- X /* move a fraction of a space so next character doesn't abutt */
- X absX += 0.2 * char_space * cos(char_angle * deg_rad);
- X absY += 0.2 * char_space * sin(char_angle * deg_rad);
- X printf("%g mm setlinewidth\n", pen_size[pen_number]);
- X}
- X
- Xfloat
- XtheMagnitude(x,y)
- Xfloat x,y;
- X{
- X return(sqrt(x * x + y * y));
- X}
- X
- Xfloat
- XtheAngle(x,y)
- Xfloat x,y;
- X{
- X if(x != 0.0)
- X return(atan(y/x));
- X else
- X return((y > 0.0) ? M_PI_2 : (M_PI + M_PI_2));
- X}
- SHAR_EOF
- chmod 0644 userdefchar.c || echo "restore of userdefchar.c fails"
- set `wc -c userdefchar.c`;Sum=$1
- if test "$Sum" != "3052"
- then echo original size 3052, current size $Sum;fi
- echo "x - extracting viewport.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > viewport.c &&
- X/* viewport.c */
- X/*
- X * This procedure sets up the variables for the translation of plotter
- X * coordinates to PostScript coordinates.
- X *
- X * Note: the procedure "defaults" may be incorporated here, however
- X * I have not had the time to work it out properly.
- X *
- X * Don McCormick
- X */
- X#include "defn.h"
- X/* original psxmax */
- X#define XWIDTH 0.90
- X
- Xviewport()
- X{
- X /* original values for A4 */
- X /* float pagewidth = 197.0; /* Page width for Laser Printer */
- X /* float pageheight = 280.0; /* Page height for Laser Printer */
- X /* float pwoffset = 12; */
- X /* float phoffset = 12; */
- X
- X /* 8.5 x 11 inch paper */
- X float pagewidth = 200.0; /* Page width for Laser Printer */
- X float pageheight = 265.0; /* Page height for Laser Printer */
- X float pwoffset = 28;
- X float phoffset = 6;
- X /* values above selected empirically to match HP7550A plot -G.J. */
- X
- X /* made global */
- X /* float psxmax, psymax; /* Sizes scaled to the viewport */
- X
- X if (LANDSCAPE) /* Default mode */
- X {
- X psymax = pagewidth * XWIDTH;
- X psxmax = psymax * (xmax - xmin)/ (ymax - ymin);
- X xoffset += (pageheight + phoffset - psxmax) / 2.0;
- X yoffset -= (pagewidth + pwoffset + psymax) / 2.0;
- X printf("90 rotate\n");
- X } else
- X {
- X psxmax = pagewidth * XWIDTH;
- X psymax = psxmax * (ymax - ymin) / (xmax - xmin);
- X xoffset += (pagewidth + pwoffset - psxmax) / 2.0;
- X yoffset += (pageheight + phoffset - psymax) / 2.0;
- X }
- X printf("%g mm %g mm translate\n", xoffset, yoffset);
- X XSCALE = psxmax / (xmax - xmin) * SCALE;
- X YSCALE = psymax / (ymax - ymin) * SCALE;
- X /* fprintf(stderr,"Xscale = %g Yscale = %g\n",XSCALE,YSCALE); */
- X}
- X
- X/* function called when the HP-GL Scale command is received */
- X/* Modifies the X,Y SCALE factors and the origin offsets */
- X/* Added by Gordon Jacobs */
- X
- Xmodify_viewport()
- X{
- X /* re-calculate scale parameters */
- X XSCALE = psxmax / (xmax - xmin) * SCALE;
- X YSCALE = psymax / (ymax - ymin) * SCALE;
- X
- X /* calculate new offset */
- X offX = -xmin * XSCALE;
- X offY = -ymin * YSCALE;
- X
- X debugp((stderr,"MODIFY: Xscale = %g Yscale = %g\n",XSCALE,YSCALE));
- X debugp((stderr,"OFFSET: offX = %g offY = %g\n",offX,offY));
- X}
- SHAR_EOF
- chmod 0644 viewport.c || echo "restore of viewport.c fails"
- set `wc -c viewport.c`;Sum=$1
- if test "$Sum" != "2171"
- then echo original size 2171, current size $Sum;fi
- exit 0
-