diff options
Diffstat (limited to 'src/preproc/grn/hgraph.cpp')
-rw-r--r-- | src/preproc/grn/hgraph.cpp | 245 |
1 files changed, 125 insertions, 120 deletions
diff --git a/src/preproc/grn/hgraph.cpp b/src/preproc/grn/hgraph.cpp index ad051ea0e..9ed81a449 100644 --- a/src/preproc/grn/hgraph.cpp +++ b/src/preproc/grn/hgraph.cpp @@ -1,7 +1,7 @@ /* Last non-groff version: hgraph.c 1.14 (Berkeley) 84/11/27 * - * This file contains the graphics routines for converting gremlin pictures - * to troff input. + * This file contains the graphics routines for converting gremlin + * pictures to troff input. */ #include "lib.h" @@ -24,7 +24,7 @@ extern int style[]; /* line and character styles */ extern double thick[]; extern char *tfont[]; extern int tsize[]; -extern int stipple_index[]; /* stipple font index for stipples 0 - 16 */ +extern int stipple_index[]; /* stipple font idx for stipples 0-16 */ extern char *stipple; /* stipple type (cf or ug) */ @@ -72,13 +72,13 @@ void NaturalEndSpline(double h[], int z[], -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: HGPrintElt (element_pointer, baseline) | | Results: Examines a picture element and calls the appropriate - | routine(s) to print them according to their type. After the - | picture is drawn, current position is (lastx, lasty). - *----------------------------------------------------------------------------*/ + | routine(s) to print them according to their type. After + | the picture is drawn, current position is (lastx,lasty). + *--------------------------------------------------------------------*/ void HGPrintElt(ELT *element, @@ -154,11 +154,11 @@ HGPrintElt(ELT *element, /* brushf = style of outline; size = color of fill: * on first pass (polyfill=FILL), do the interior using 'P' * unless size=0 - * on second pass (polyfill=OUTLINE), do the outline using a series - * of vectors. It might make more sense to use \D'p ...', - * but there is no uniform way to specify a 'fill character' - * that prints as 'no fill' on all output devices (and - * stipple fonts). + * on second pass (polyfill=OUTLINE), do the outline using a + * series of vectors. It might make more sense to use \D'p + * ...', but there is no uniform way to specify a 'fill + * character' that prints as 'no fill' on all output + * devices (and stipple fonts). * If polyfill=BOTH, just use the \D'p ...' command. */ double firstx = p1->x; @@ -266,16 +266,16 @@ HGPrintElt(ELT *element, } /* end PrintElt */ -/*----------------------------------------------------------------------------* +/*---------------------------------------------------------------------* | Routine: HGPutText (justification, position_point, string) | | Results: Given the justification, a point to position with, and a | string to put, HGPutText first sends the string into a | diversion, moves to the positioning point, then outputs - | local vertical and horizontal motions as needed to justify - | the text. After all motions are done, the diversion is - | printed out. - *----------------------------------------------------------------------------*/ + | local vertical and horizontal motions as needed to + | justify the text. After all motions are done, the + | diversion is printed out. + *--------------------------------------------------------------------*/ void HGPutText(int justify, @@ -300,8 +300,8 @@ HGPutText(int justify, tmove(&pnt); /* move to positioning point */ switch (justify) { - /* local vertical motions */ - /* (the numbers here are used to be somewhat compatible with gprint) */ + /* local vertical motions--the numbers here are used to be + somewhat compatible with gprint */ case CENTLEFT: case CENTCENT: case CENTRIGHT: @@ -330,18 +330,18 @@ HGPutText(int justify, printf("\\&\\*(g9\n"); /* now print the text. */ printf(".sp |\\n(g8u\n"); /* restore vertical position */ - lasty = savelasty; /* vertical position restored to where it */ - lastx = xleft; /* was before text, also horizontal is at */ - /* left */ + lasty = savelasty; /* vertical position restored to */ + lastx = xleft; /* where it was before text, also */ + /* horizontal is at left */ } /* end HGPutText */ -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: doarc (center_point, start_point, angle) | | Results: Produces either drawarc command or a drawcircle command | depending on the angle needed to draw through. - *----------------------------------------------------------------------------*/ + *--------------------------------------------------------------------*/ void doarc(POINT cp, @@ -357,14 +357,14 @@ doarc(POINT cp, } -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: HGSetFont (font_number, Point_size) | - | Results: ALWAYS outputs a .ft and .ps directive to troff. This is - | done because someone may change stuff inside a text string. - | Changes thickness back to default thickness. Default - | thickness depends on font and pointsize. - *----------------------------------------------------------------------------*/ + | Results: ALWAYS outputs a .ft and .ps directive to troff. This + | is done because someone may change stuff inside a text + | string. Changes thickness back to default thickness. + | Default thickness depends on font and point size. + *--------------------------------------------------------------------*/ void HGSetFont(int font, @@ -376,15 +376,15 @@ HGSetFont(int font, } -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: HGSetBrush (line_mode) | - | Results: Generates the troff commands to set up the line width and - | style of subsequent lines. Does nothing if no change is - | needed. + | Results: Generates the troff commands to set up the line width + | and style of subsequent lines. Does nothing if no + | change is needed. | - | Side Efct: Sets 'linmode' and 'linethicknes'. - *----------------------------------------------------------------------------*/ + | Side Efct: Sets 'linmode' and 'linethickness'. + *--------------------------------------------------------------------*/ void HGSetBrush(int mode) @@ -407,14 +407,14 @@ HGSetBrush(int mode) } -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: deltax (x_destination) | | Results: Scales and outputs a number for delta x (with a leading | space) given 'lastx' and x_destination. | | Side Efct: Resets 'lastx' to x_destination. - *----------------------------------------------------------------------------*/ + *--------------------------------------------------------------------*/ void deltax(double x) @@ -426,15 +426,16 @@ deltax(double x) } -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: deltay (y_destination) | | Results: Scales and outputs a number for delta y (with a leading | space) given 'lastyline' and y_destination. | - | Side Efct: Resets 'lastyline' to y_destination. Since 'line' vertical - | motions don't affect 'page' ones, 'lasty' isn't updated. - *----------------------------------------------------------------------------*/ + | Side Efct: Resets 'lastyline' to y_destination. Since 'line' + | vertical motions don't affect 'page' ones, 'lasty' isn't + | updated. + *--------------------------------------------------------------------*/ void deltay(double y) @@ -446,14 +447,14 @@ deltay(double y) } -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: tmove2 (px, py) | - | Results: Produces horizontal and vertical moves for troff given the - | pair of points to move to and knowing the current position. - | Also puts out a horizontal move to start the line. This is - | a variation without the .sp command. - *----------------------------------------------------------------------------*/ + | Results: Produces horizontal and vertical moves for troff given + | the pair of points to move to and knowing the current + | position. Also puts out a horizontal move to start the + | line. This is a variation without the .sp command. + *--------------------------------------------------------------------*/ void tmove2(int px, @@ -473,14 +474,14 @@ tmove2(int px, } -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: tmove (point_pointer) | - | Results: Produces horizontal and vertical moves for troff given the - | pointer of a point to move to and knowing the current - | position. Also puts out a horizontal move to start the - | line. - *----------------------------------------------------------------------------*/ + | Results: Produces horizontal and vertical moves for troff given + | the pointer of a point to move to and knowing the + | current position. Also puts out a horizontal move to + | start the line. + *--------------------------------------------------------------------*/ void tmove(POINT * ptr) @@ -501,14 +502,16 @@ tmove(POINT * ptr) } -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: cr ( ) | - | Results: Ends off an input line. '.sp -1' is also added to counteract - | the vertical move done at the end of text lines. + | Results: Ends off an input line. '.sp -1' is also added to + | counteract the vertical move done at the end of text + | lines. | - | Side Efct: Sets 'lastx' to 'xleft' for troff's return to left margin. - *----------------------------------------------------------------------------*/ + | Side Efct: Sets 'lastx' to 'xleft' for troff's return to left + | margin. + *--------------------------------------------------------------------*/ void cr() @@ -518,11 +521,11 @@ cr() } -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: line ( ) | | Results: Draws a single solid line to (x,y). - *----------------------------------------------------------------------------*/ + *--------------------------------------------------------------------*/ void line(int px, @@ -536,14 +539,14 @@ line(int px, } -/*---------------------------------------------------------------------------- +/*--------------------------------------------------------------------* | Routine: drawwig (ptr, type) | - | Results: The point sequence found in the structure pointed by ptr is - | placed in integer arrays for further manipulation by the - | existing routing. With the corresponding type parameter, - | either picurve or HGCurve are called. - *----------------------------------------------------------------------------*/ + | Results: The point sequence found in the structure pointed by ptr + | is placed in integer arrays for further manipulation by + | the existing routing. With the corresponding type + | parameter, either picurve or HGCurve are called. + *--------------------------------------------------------------------*/ void drawwig(POINT * ptr, @@ -565,15 +568,16 @@ drawwig(POINT * ptr, } -/*---------------------------------------------------------------------------- +/*--------------------------------------------------------------------* | Routine: HGArc (xcenter, ycenter, xstart, ystart, angle) | - | Results: This routine plots an arc centered about (cx, cy) counter - | clockwise starting from the point (px, py) through 'angle' - | degrees. If angle is 0, a full circle is drawn. It does so - | by creating a draw-path around the arc whose density of - | points depends on the size of the arc. - *----------------------------------------------------------------------------*/ + | Results: This routine plots an arc centered about (cx, cy) + | counter-clockwise starting from the point (px, py) + | through 'angle' degrees. If angle is 0, a full circle + | is drawn. It does so by creating a draw-path around the + | arc whose density of points depends on the size of the + | arc. + *--------------------------------------------------------------------*/ void HGArc(int cx, @@ -598,7 +602,7 @@ HGArc(int cx, resolution = (1.0 + groff_hypot(xs, ys) / res) * PointsPerInterval; /* mask = (1 << (int) log10(resolution + 1.0)) - 1; */ - (void) frexp(resolution, &m); /* A bit more elegant than log10 */ + (void) frexp(resolution, &m); /* more elegant than log10 */ for (mask = 1; mask < m; mask = mask << 1); mask -= 1; @@ -626,13 +630,13 @@ HGArc(int cx, } /* end HGArc */ -/*---------------------------------------------------------------------------- +/*--------------------------------------------------------------------* | Routine: picurve (xpoints, ypoints, num_of_points) | - | Results: Draws a curve delimited by (not through) the line segments - | traced by (xpoints, ypoints) point list. This is the 'Pic' - | style curve. - *----------------------------------------------------------------------------*/ + | Results: Draws a curve delimited by (not through) the line + | segments traced by (xpoints, ypoints) point list. This + | is the 'Pic'-style curve. + *--------------------------------------------------------------------*/ void picurve(int *x, @@ -695,15 +699,15 @@ picurve(int *x, } -/*---------------------------------------------------------------------------- +/*--------------------------------------------------------------------* | Routine: HGCurve(xpoints, ypoints, num_points) | | Results: This routine generates a smooth curve through a set of - | points. The method used is the parametric spline curve on - | unit knot mesh described in 'Spline Curve Techniques' by - | Patrick Baudelaire, Robert Flegal, and Robert Sproull -- - | Xerox Parc. - *----------------------------------------------------------------------------*/ + | points. The method used is the parametric spline curve + | on unit knot mesh described in 'Spline Curve Techniques' + | by Patrick Baudelaire, Robert Flegal, and Robert Sproull + | -- Xerox Parc. + *--------------------------------------------------------------------*/ void HGCurve(int *x, @@ -725,8 +729,8 @@ HGCurve(int *x, tmove2(lx, ly); /* - * Solve for derivatives of the curve at each point separately for x and y - * (parametric). + * Solve for derivatives of the curve at each point separately for x + * and y (parametric). */ Parameterize(x, y, h, numpoints); @@ -740,8 +744,8 @@ HGCurve(int *x, } /* - * generate the curve using the above information and PointsPerInterval - * vectors between each specified knot. + * Generate the curve using the above information and + * PointsPerInterval vectors between each specified knot. */ for (j = 1; j < numpoints; ++j) { @@ -763,15 +767,15 @@ HGCurve(int *x, } /* end HGCurve */ -/*---------------------------------------------------------------------------- - | Routine: Paramaterize (xpoints, ypoints, hparams, num_points) +/*--------------------------------------------------------------------* + | Routine: Parameterize (xpoints, ypoints, hparams, num_points) | - | Results: This routine calculates parameteric values for use in + | Results: This routine calculates parametric values for use in | calculating curves. The parametric values are returned | in the array h. The values are an approximation of | cumulative arc lengths of the curve (uses cord length). | For additional information, see paper cited below. - *----------------------------------------------------------------------------*/ + *--------------------------------------------------------------------*/ void Parameterize(int x[], @@ -797,21 +801,21 @@ Parameterize(int x[], } for (i = 1; i < n; ++i) h[i] = u[i + 1] - u[i]; -} /* end Paramaterize */ +} /* end Parameterize */ -/*---------------------------------------------------------------------------- +/*--------------------------------------------------------------------* | Routine: PeriodicSpline (h, z, dz, d2z, d3z, npoints) | - | Results: This routine solves for the cubic polynomial to fit a spline - | curve to the points specified by the list of values. - | The Curve generated is periodic. The algorithms for this - | curve are from the 'Spline Curve Techniques' paper cited - | above. - *----------------------------------------------------------------------------*/ + | Results: This routine solves for the cubic polynomial to fit a + | spline curve to the points specified by the list of + | values. The curve generated is periodic. The + | algorithms for this curve are from the 'Spline Curve + | Techniques' paper cited above. + *--------------------------------------------------------------------*/ void -PeriodicSpline(double h[], /* paramaterization */ +PeriodicSpline(double h[], /* parameterization */ int z[], /* point list */ double dz[], /* to return the 1st derivative */ double d2z[], /* 2nd derivative */ @@ -873,14 +877,14 @@ PeriodicSpline(double h[], /* paramaterization */ } /* end PeriodicSpline */ -/*---------------------------------------------------------------------------- +/*-------------------------------------------------------------------- | Routine: NaturalEndSpline (h, z, dz, d2z, d3z, npoints) | - | Results: This routine solves for the cubic polynomial to fit a spline - | curve the points specified by the list of values. The - | algorithms for this curve are from the 'Spline Curve + | Results: This routine solves for the cubic polynomial to fit a + | spline curve the points specified by the list of values. + | The algorithms for this curve are from the 'Spline Curve | Techniques' paper cited above. - *----------------------------------------------------------------------------*/ + *--------------------------------------------------------------------*/ void NaturalEndSpline(double h[], /* parameterization */ @@ -929,15 +933,15 @@ NaturalEndSpline(double h[], /* parameterization */ } /* end NaturalEndSpline */ -/*----------------------------------------------------------------------------* +/*--------------------------------------------------------------------* | Routine: change (x_position, y_position, visible_flag) | | Results: As HGtline passes from the invisible to visible (or vice - | versa) portion of a line, change is called to either draw - | the line, or initialize the beginning of the next one. - | Change calls line to draw segments if visible_flag is set - | (which means we're leaving a visible area). - *----------------------------------------------------------------------------*/ + | versa) portion of a line, change is called to either + | draw the line, or initialize the beginning of the next + | one. Change calls line to draw segments if visible_flag + | is set (which means we're leaving a visible area). + *--------------------------------------------------------------------*/ void change(int x, @@ -952,19 +956,20 @@ change(int x, length = 0; printf("\\\n"); } - } else { /* otherwise, we're entering one, remember */ - /* beginning */ + } else { /* otherwise entering one; remember */ + /* beginning */ tmove2(x, y); } } -/*---------------------------------------------------------------------------- +/*--------------------------------------------------------------------* | Routine: HGtline (xstart, ystart, xend, yend) | - | Results: Draws a line from current position to (x1,y1) using line(x1, - | y1) to place individual segments of dotted or dashed lines. - *----------------------------------------------------------------------------*/ + | Results: Draws a line from current position to (x1,y1) using + | line(x1, y1) to place individual segments of dotted or + | dashed lines. + *--------------------------------------------------------------------*/ void HGtline(int x_1, |