(* Routines to generate Postscript files *) INTERFACE PSPlot; IMPORT Wr; TYPE Axis = {X, Y}; BOOL = BOOLEAN; LONG = LONGREAL; TYPE File <: PubFile; PubFile = OBJECT METHODS beginSection(title: TEXT); (* Starts a new section of the plot. The "title" is a comment *) endSection(); (* Ends the current section of the plot. *) setPenColor(gray: REAL); setPenWidth(width: REAL); setPenDash(length: REAL; space: REAL); (* Sets pen parameters and ink color for line drawing. Dimensions are in mm *) (* The "draw" methods below will draw the outline of the specified figure with the current pen paramters. The "paint" methods will paint the interior of the figure with the given gray value, and then, if the "draw" parameter is TRUE, also perform the corresponding "draw" action. *) drawSegment(xa, ya, xb, yb: LONG); (* A segment from "(xa,ya)" to "(xb,yb)". *) drawRectangle(xlo, xhi, ylo, yhi: LONG); paintRectangle(xlo, xhi, ylo, yhi: LONG; gray: REAL; draw: BOOL := FALSE); (* The rectangle [xlo..xhi] x [ylo..yhi]. *) drawCircle(xc, yc, radius: LONG); paintCircle(xc, yc, radius: LONG; gray: REAL; draw: BOOL := FALSE); (* The circle with center "xc,yc" and given "radius". *) drawTriangle (xc, yc, radius: LONG); paintTriangle(xa, ya, xb, yb, xc, yc: LONG; gray: REAL; draw: BOOL := FALSE); ); (* The triangle "a,b,c". *) drawGridCell (xi, yi: CARDINAL); paintGridCell (xi, yi: CARDINAL; gray: REAL; draw: BOOL := FALSE); (* The specified cell of the cell grid. *) drawCoordLine (axis: Axis; coord: LONG); (* Draws a reference line perpendicular to the given axis at the given coordinate value. *) drawGridLines (); (* Draws the all cell grid lines with the current pen and gray level. *) drawFrame (); (* Draws a frame around the plotting area. *) close(); (* MUST be called to write the file trailers and close the file. *) END; EPSFile <: PubEPSFile; PubEPSFile = File OBJECT METHODS END; PSFile <: PubPSFile; PubPSFile = File OBJECT METHODS beginPage( xmin, xmax, ymin, ymax: LONG; hmin, hmax, vmin, vmax: LONG; xn, yn: CARDINAL := 1 ); (* Intializes a new page: writes page header line, sets the default scale to "[0__1]x[0__1]", with one cell. *) endPage(); (* Finalizes a page: Writes page trailer line, etc. *) addCaption (txt: TEXT); (* Appends a caption line under the drawing. For multi-line captions, use multiple calls and/or embedded newlines. *) END; PROCEDURE OpenEPSFile( name: TEXT; xmin, xmax, ymin, ymax: LONG; hmin, hmax, vmin, vmax: LONG; xn, yn: CARDINAL := 1 ): EPSFile; (* Opens an Encapsulated PostScript file with the given name, and writes the file header and procedure sets. The extension ".eps" is recommended. The plotting area will be the rectangle "[xmin__xmax]x[ymin__ymax]" in client coordinates, and "[hmin__hmax]x[vmin__vmax]" in the default printer coordinates (points from lower left corner) The plotting area is divided implicitly into a grid of "xn" by "yn" rectangular cells. *) PROCEDURE OpenPSFile(name: TEXT): PSFile; (* Opens a plain (i.e. multi-page, non-encapsulated) PostScript file with the given name, and writes the file header and procedure sets. The extension ".ps" is recommended. *) END PSPlot.