allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (01/22/89)
Posting-number: Volume 6, Issue 4 Submitted-by: federico@actisb.UUCP (Federico Heinz) Archive-name: yahp2ps/part02 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 2 (of 6)." # Contents: defs.h dispatch.c global.c io.h math.c mchinery.h tick.c # Wrapped by federico@actisb on Wed Jan 4 13:34:45 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'defs.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'defs.h'\" else echo shar: Extracting \"'defs.h'\" \(3976 characters\) sed "s/^X//" >'defs.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/*************************************************************************** X X Yet Another HPGL to PostScript Converter. X X X***************************************************************************/ X X X/************************************************************************** X X System-dependent constants. X X**************************************************************************/ X X#define DEFAULT_PRELUDE "/usr/lib/yahp2ps.pre" /* default prelude file */ X X X/************************************************************************** X X Define the Number data type. It represents the Scaled Decimal X format of HPGL. In order to get a Number out of a normal integer, X multiply it by the constant One. X X**************************************************************************/ X X X X#define Number long int X X#define IntPlaces 5 X#define DecPlaces 4 X X X/* A CoordinatePair contains an X and a Y component */ X X#define X 0 X#define Y 1 X Xtypedef Number CoordinatePair[2]; X X Xextern Number RelativeCharWidth; /* Width of each char */ Xextern Number RelativeCharHeigth; /* Heigth of each char */ Xextern Number CharacterDirection; /* Text writing angle */ Xextern Number CharacterSlant; /* Textual slant angle */ X Xextern Number TN; /* Temporary storage for avoiding side effects X in Number-handling macros */ X X X/* Some constants in our numbering system */ X X#define One 10000L X#define Zero 0L X X/* Divide a Number by another (a Number may be divided by an integer the X usual way) */ X X Xextern Number divNum(); X X X/* Multiply a Number by another (again, multiplication by an integer is X as usual) */ X X Xextern Number mulNum(); X X X/* Truncate a number according to the HPGL rules */ X X#define trunc(x) (((TN = (x)) % One) ? \ X ((TN = (TN/One) * One) < 0 ? \ X (TN - One) : TN) : TN) X X X/*************************************************************************** X X Define the Boolean data type. X X***************************************************************************/ X X X#define Boolean int X X#define True 1 X#define False 0 X X X X X X X/* Special character predicates */ X X#define isSeparator(x) (((x) == ',') || ((x) == ' ')) X#define isTerminator(x) (((x) == ';') || ((x) == '\n')) X X X X/*************************************************************************** X X Error handling functions. X X***************************************************************************/ X Xextern void warning(); Xextern void error(); X X X X END_OF_FILE if test 3976 -ne `wc -c <'defs.h'`; then echo shar: \"'defs.h'\" unpacked with wrong size! fi # end of 'defs.h' fi if test -f 'dispatch.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dispatch.c'\" else echo shar: Extracting \"'dispatch.c'\" \(3258 characters\) sed "s/^X//" >'dispatch.c' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************** X X Main loop. Here's where the decoding takes place. X X**************************************************************************/ X X X X#include "defs.h" X#include "dispatch.h" X#include "mchinery.h" X#include "io.h" X X X/* X X A command that does not make sense in a PostScript environment. X X*/ X XCommandImplementation notImplemented() X X{ warning("Useless command skipped."); X endCommand(); X} X X X X/* X X A command that requires Plotter-Computer interaction in real time. X X*/ X XCommandImplementation interactive() X X{ error("Cannot handle commands requiring Plotter-Computer interaction."); X} X X X Xtypedef CommandImplementation (*CommandPointer)(); X X Xstatic CommandPointer DoCommand[] = X { notImplemented, X interactive, X arcAbsolute, X arcRelative, X setAlternateChar, X circle, X characterPlot, X setStandardChar, X setDefaults, X setAbsoluteDirection, X setRelativeDirection, X setLabelTerminator, X rectangleAbsolute, X rectangleRelative, X wedge, X setFillType, X initialize, X inputP1P2, X inputWindow, X putASCIILabel, X setLineType, X setAbsolutePlot, X penDown, X setRelativePlot, X setPaperSize, X penUp, X shadeRectAbsolute, X rotateCoordSys, X shadeRectRelative, X selectAlternate, X setScale, X setAbsoluteCharSize, X setAbsoluteCharSlant, X setSymbolMode, X selectPen, X setRelativeCharSize, X selectStandard, X setTickLength, X userChar, X shadeWedge, X xTick, X yTick, X penThickness X }; X X X X/* X X Process a whole HPGL document. X X*/ X Xvoid dispatch() X X{ skipSeparator(); X while (LookAhead != EOF) (*DoCommand[getCommand()])(); X} X X END_OF_FILE if test 3258 -ne `wc -c <'dispatch.c'`; then echo shar: \"'dispatch.c'\" unpacked with wrong size! fi # end of 'dispatch.c' fi if test -f 'global.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'global.c'\" else echo shar: Extracting \"'global.c'\" \(4058 characters\) sed "s/^X//" >'global.c' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************ X X Commands affecting the virtual plotter's global state. X X************************************************************************/ X X#include "defs.h" X#include "dispatch.h" X#include "io.h" X#include "mchinery.h" X#include "penctrl.h" X#include "circle.h" X#include "shade.h" X#include "tick.h" X#include "global.h" X#include "char.h" X X X/* X X Set the default values for the parameters controlled by this module. X X*/ X Xvoid globalInit() X X{ resetWindow(); X turnScalingOff(); X} X X X/* X X Restore default values of all modules. X X*/ X Xvoid restoreDefaults() X X{ globalInit(); X basicInit(); X shadeInit(); X tickInit(); X charInit(); X} X X X/* X X Reset default values for plotter opeartion. X X*/ X XCommandImplementation setDefaults() X X{ restoreDefaults(); X endCommand(); X} X X X/* X X Restart plotter. X X*/ X XCommandImplementation initialize() X X{ penctrlInit(); X restoreDefaults(); X endCommand(); X} X X XCommandImplementation inputP1P2() X X{ CoordinatePair newPlotterP1, newPlotterP2; X X if (isTerminator(LookAhead)) X resetP1P2(); X else if (getCoordinatePair(newPlotterP1)) X { if (isTerminator(LookAhead) || !getCoordinatePair(newPlotterP2)) X { newPlotterP2[X] += newPlotterP1[X] - PlotterP1[X]; X newPlotterP2[Y] += newPlotterP1[Y] - PlotterP1[Y]; X } X changeP1P2(newPlotterP1, newPlotterP2); X } X endCommand(); X} X X X X/* X X Set the clipping rectangle. X X*/ X XCommandImplementation inputWindow() X X{ CoordinatePair corner1, corner2; X X if (isTerminator(LookAhead) || !getCoordinatePair(corner1) || X !getCoordinatePair(corner2)) X resetWindow(); X else X { corner1[X] = trunc(corner1[X]); X corner1[Y] = trunc(corner1[Y]); X corner2[X] = trunc(corner2[X]); X corner2[Y] = trunc(corner2[Y]); X setWindow(corner1,corner2); X } X endCommand(); X} X X X XCommandImplementation setPaperSize() X X{ Number temp; X X if (getInteger(&temp)) X if (temp < PaperSizeLimit) X warning("Sorry, only DIN A4 paper currently supported."); X} X X X X/* X X Rotate the coordinate system. X X*/ X XCommandImplementation rotateCoordSys() X X{ Number angle; X X if (isTerminator(LookAhead)) X unRotate(); X else if (getNumber(&angle)) X if (angle == Zero) X unRotate(); X else if (angle == OneSquare) X rotate(); X else X warning("Erroneous rotation angle."); X endCommand(); X} X X X XCommandImplementation setScale() X X{ CoordinatePair newUserP1, newUserP2; X X if (isTerminator(LookAhead)) X turnScalingOff(); X else if (getNumber(&newUserP1[X]) && getNumber(&newUserP2[X]) && X getNumber(&newUserP1[Y]) && getNumber(&newUserP2[Y])) X turnScalingOn(newUserP1, newUserP2); X endCommand(); X} X X X X END_OF_FILE if test 4058 -ne `wc -c <'global.c'`; then echo shar: \"'global.c'\" unpacked with wrong size! fi # end of 'global.c' fi if test -f 'io.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'io.h'\" else echo shar: Extracting \"'io.h'\" \(2983 characters\) sed "s/^X//" >'io.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************** X X Input/Output definitions. X X***************************************************************************/ X X#ifndef EOF X X#define EOF (-1) X X#endif X X/* Check whether char can be beginning of a number */ X X#define isNumeric(x) (isdigit(x) || ((x) == '+') || \ X ((x) == '-') || ((x) == '.')) X X/* One-char lookahead buffer */ X Xextern int LookAhead; X X Xextern void skipSeparator(); /* Skip over one or more HPGL separators */ Xextern void skipTerminator();/* Skip over one or more HPGL terminators */ Xextern int getChar(); /* Get the next char from the input stream */ Xextern void putChar(); /* Put a char to the output stream */ Xextern Boolean getNumber(); /* Get a Number from the input stream */ Xextern Boolean ASCIIToNumber(); /* Get a Number from an alpha string */ Xextern Boolean getInteger(); /* Get an Integer from the in stream */ X /* Get a CoordinatePair from the in stream */ Xextern Boolean getCoordinatePair(); Xextern void endCommand(); /* Check for excess parameters & skip Term.*/ Xextern void writeNumber(); /* Put a Number to the output stream */ X /* Put a CoordinatePair to the out stream */ Xextern void writeCoordinatePair(); Xextern void writeString(); /* Put a string to the output stream */ X Xextern Boolean setInput(); /* Reassign the input stream */ Xextern Boolean setOutput(); /* Reassign the output stream */ X END_OF_FILE if test 2983 -ne `wc -c <'io.h'`; then echo shar: \"'io.h'\" unpacked with wrong size! fi # end of 'io.h' fi if test -f 'math.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'math.c'\" else echo shar: Extracting \"'math.c'\" \(3532 characters\) sed "s/^X//" >'math.c' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/********************************************************************** X X Number multiplication & division. X X**********************************************************************/ X X X#include "defs.h" X X X/* X X Make both operands positive, return True if result will be negative. X X*/ X Xstatic Boolean makePositive(a, b) X XNumber *a, *b; X X{ Boolean negative; X X if (negative = (*a < Zero)) *a = -*a; X if (*b < Zero) X { *b = -*b; X negative = !negative; X } X return(negative); X} X X X X/* X X Return a * b. X X Algorithm: multiply (m 10^4 + n) (p 10^4 + q) , then divide by 10^4 X to realign the decimal point. X X [ m 10^4 p 10^4 + m 10^4 q + n p 10^4 + n q ] / 10^-4 = X m p 10^4 + m q + n p + n q 10-4 X X Since I keep 4 decimal digit precision, only digits overflowing X 9999 in the term (n q 10^-4) are taken into account. X X*/ X XNumber mulNum(a, b) X XNumber a, b; X X{ Number n, p, q; X Boolean negative; X Number result, carry; X X negative = makePositive(&a, &b); X n = a % One; X p = b / One; q = b % One; X result = (a / One) * (p * One + q) + n * p + ((n * q) / One); X return(negative ? -result : result); X} X X X X/* X X Return a / b. X X Algorithm: In case b has no dec places, then simply divide a by (b/10^4). X Otherwise, a must be multiplyed by 10^4 before the division in order X to get the decimals places right. But that can lead to overflow. X So let a = m 10^4 + n X X [(m 10^4 + n) 10^4 ] / b = (m 10^8) / b + (n 10^4) / b X X [(n 10^4) / b] is easily computed. Now let (m 10^4) = (q b + r). X Then, X X (m 10^8) / b = [(q b + r) 10^4] / b = [(q b 10^4) / b] + [(r 10^4) / b] = X (q 10^4) + [(r 10^4) / b] X X Where both terms are easily computed. The complete formula is then X X a / b = q 10^4 + (r 10^4) / b + (n 10^4) / b = X q 10^4 + [(r + n) 10^4] / b X X [ Phew! ] X X*/ X XNumber divNum(a, b) X XNumber a, b; X X{ Number q, m, result; X Boolean negative; X X if (!(b % One)) /* Easy case: no decimals in divisor */ X return(a / (b / One)); X negative = makePositive(&a, &b); X m = trunc(a); X q = m / b; X result = q * One + (((m - q * b) + (a % One)) * One) / b; X return(negative ? -result : result); X} END_OF_FILE if test 3532 -ne `wc -c <'math.c'`; then echo shar: \"'math.c'\" unpacked with wrong size! fi # end of 'math.c' fi if test -f 'mchinery.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mchinery.h'\" else echo shar: Extracting \"'mchinery.h'\" \(2712 characters\) sed "s/^X//" >'mchinery.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************** X X Definition of the plotter's "hardware" functions. X X**************************************************************************/ X X X/* Draws a dot at the curent position */ X Xextern void drawDot(); X X X/* Draws a line to the indicated point in User Space */ X Xextern void drawLine(); X X X X/* Positions the physical pen to the indicated point (User Space) */ X Xextern void setCurrentPoint(); X X X/* Draws an arc at maximum resolution */ X Xextern void doHRArc(); X X X/* Draw a horizontal tick */ X Xextern void doYTick(); X X X/* Draw a vertical tick */ X Xextern void doXTick(); X X X/* Set a new plotting window */ X Xextern void setClip(); X X X/* Set the plotting window again */ X Xextern void correctClip(); X X X/* Do the real ink-dropping if needed */ X Xextern void stroke(); X X X/* Set the pen's width */ X Xextern void setPenWidth(); X X X X/* Set the pen's color */ X Xextern void setPenColor(); X X X X/* Set the line pattern */ X Xextern void setPattern(); X X X X/* Shade a rectangle */ X Xextern void doShadeRectangle(); X X X X/* Shade a wedge */ X Xextern void doShadeWedge(); X X X X/* Do the machinery's startup work */ X Xextern void initializeMachinery(); X X X X/* Do anything that might be pending */ X Xextern void shutdownMachinery(); X X X/* Prelude file name */ X Xextern char *PreludeFile; END_OF_FILE if test 2712 -ne `wc -c <'mchinery.h'`; then echo shar: \"'mchinery.h'\" unpacked with wrong size! fi # end of 'mchinery.h' fi if test -f 'tick.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tick.c'\" else echo shar: Extracting \"'tick.c'\" \(3067 characters\) sed "s/^X//" >'tick.c' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/*********************************************************************** X X Draw vertical or horizontal ticks. X X***********************************************************************/ X X X#include "defs.h" X#include "dispatch.h" X#include "io.h" X#include "mchinery.h" X#include "penctrl.h" X#include "tick.h" X X X /* Percentages of P2-P1 */ Xstatic Number PositiveTick, NegativeTick; X X /* Lengths of the corresponding ticks */ Xstatic Number PositiveXTick, NegativeXTick, X PositiveYTick, NegativeYTick; X X X X/* X X Adjust tick parameters to a new environment. X X*/ X Xvoid updateTicks() X X{ Number deltaX, deltaY; X X if ((deltaX = PlotterP2[X] - PlotterP1[X]) < 0) deltaX = -deltaX; X if ((deltaY = PlotterP2[Y] - PlotterP1[Y]) < 0) deltaY = -deltaY; X PositiveXTick = mulNum(PositiveTick, deltaY / 100); X NegativeXTick = mulNum(NegativeTick, deltaY / 100); X PositiveYTick = mulNum(PositiveTick, deltaX / 100); X NegativeYTick = mulNum(NegativeTick, deltaX / 100); X} X X X X/* X X Reset tick parameters to default values. X X*/ X Xvoid tickInit() X X{ PositiveTick = InitialTick; X NegativeTick = InitialTick; X updateTicks(); X} X X X X/* X X Change the relative tick length. X X*/ X XCommandImplementation setTickLength() X X{ if (isTerminator(LookAhead) || !getInteger(&PositiveTick)) X tickInit(); X else X { if (isTerminator(LookAhead) || !getInteger(&NegativeTick)) X NegativeTick = Zero; X updateTicks(); X } X endCommand(); X} X X X X/* X X Do a X-axis tick. X X*/ X XCommandImplementation xTick() X X{ doXTick(PositiveXTick, NegativeXTick); X endCommand(); X} X X X X/* X X Do a Y-axis tick. X X*/ X XCommandImplementation yTick() X X{ doYTick(PositiveYTick, NegativeYTick); X endCommand(); X} X X X X END_OF_FILE if test 3067 -ne `wc -c <'tick.c'`; then echo shar: \"'tick.c'\" unpacked with wrong size! fi # end of 'tick.c' fi echo shar: End of archive 2 \(of 6\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0