Date: Tue, 23 Jun 87 11:27:59 edt From: David Krowitz Subject: Latest HP7570 software, part 3 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # hpplot.bld # hpplot.doc # hpplot.hlp # This archive created: Tue Jun 23 11:16:28 1987 export PATH; PATH=/bin:$PATH if test -f 'hpplot.bld' then echo shar: will not over-write existing file "'hpplot.bld'" else cat << \SHAR_EOF > 'hpplot.bld' #################################################################################### ### ### ### Command file for Compiling and Binding the HPPLOT Program ### ### ### #################################################################################### von pas hpplot.pas -opt 3 bind -b hpplot hpplot.bin voff SHAR_EOF chmod +x 'hpplot.bld' fi # end of overwriting check if test -f 'hpplot.doc' then echo shar: will not over-write existing file "'hpplot.doc'" else cat << \SHAR_EOF > 'hpplot.doc' ******************************************************************************* ***** ***** ***** HPPLOT.DOC ***** ***** Version 12 ***** ***** ***** ***** Programming Notes for the GMR vector command file to Hewlitt ***** ***** Packard Graphics Language (HPGL) command file translation ***** ***** program. ***** ***** ***** ***** Copyright (c) 1987 ***** ***** David M. Krowitz ***** ***** Massachusetts Institute of Technology ***** ***** Department of Earth, Atmospheric, and Planetary Sciences ***** ******************************************************************************* Operation of the HPPLOT program ------------------------------- The HPPLOT program reads GMR vector command files produced by the GMR routines GM_$PRINT_FILE and/or GM_$PRINT_FILE_PART and translates the GMR commands contained in the vector file into a file of Hewlitt Packard Graphics Language (HPGL) commands for the HP 7475A, 7550A, or 7570 plotters. The HPGL file can then be plotted by sending it to the plotter's print-server using the PRF -TRANSPARENT command. This provides a handy way of getting color hard-copy from a GMR program. When the GM_$PRINT_FILE or GM_$PRINT_FILE_PART command is called by a GMR program, the user specifies the size of the viewport in which the primary segment of the current GMR metafile is to be displayed. GMR then scales the metafile to fit within 95% of the viewport, resolves any segment instances and attribute blocks, and outputs a single, linear stream of GMR commands to draw the picture described by the metafile. The HPPLOT program then reads this GMR vector command file and produces a file of corresponding HPGL plotter commands. The HPGL command file can then be sent to the HP plotter print-server with the command: PRF -TRANSPARENT -PR eg. PRF -TRANSPARENT -PR HP7550 GMRTEST.HPGL HPPLOT first asks the user for the names of the GMR vector file (for input) and the HPGL command file (for output). The program then asks what type of plotter (HP 7475, HP 7550, or HP 7570) will be receiving the output file. HPPLOT then asks whether 'A' size (8 1/2" by 11") or 'B' size (11" by 17") paper (HP 7475 and HP 7550 plotters) or whether 'C' size (17" by 22"), 'D' size (22" by 34"), 'AC' architectural C size (18" by 24"), or 'AD' architectural D size paper (HP 7570 plotter) is begin used in the plotter and whether the plot axis should be rotated by 90 degrees and it calculates the plotting area available. The program then asks the user to define a box on the available plotting area by asking the origin of the box (in inches) and the size of the box (also in inches). The point (0.0,0.0) is in the lower left hand corner of the page. When 90 degree rotation has been selected, the point (0.0,0.0) is still in the 'lower left hand corner' but the page has been logically rotated so that the origin is at the top left hand corner of the physical page. Note that the plotter has about a 1/4 inch margin around the left, right, and bottom sides of the paper and about a 1/2 inch margin at the top of the paper. This leaves a maximum plotting area of about 10.0 (x) by 7.75 (y) inches when using 'A' size paper with no rotation, but if the user desires the top and bottom margins to be of equal size then the origin of the box in which the plot is to appear must be (0.0,0.25). The unequal physical margin is a result of the way the plotter gripes the paper from the top of the page. Once the box has been defined, HPPLOT will scale the GMR viewport defined by the user in the GM_$PRINT_FILE command so that it fits within the box defining the plotting area without distortion. The origin of the GMR viewport will be placed at the origin of the box defining the plotting area. HPPLOT will optionally outline the plotting area box. Since GMR has already scaled the picture to fit within 95% of the viewport, there will be a 2.5% margin along the left and bottom sides of the box. If the viewport and the plotting area box have the same shape (ie. the same x to y ratio), then there will also be a 2.5% margin along the right and top margins. Otherwise, one of the sides (the one which most constrains the size of the picture) will have a 2.5% margin and the other will have a larger margin to make the viewport fit within the box without distorting its shape. Once the plotting area has been set, HPPLOT reads and translates the GMR commands into HPGL commands. The HPGL commands are sorted according to pen color to minimize the number of pen changes required. All objects drawn with pen 1 are drawn first, followed by all objects drawn with pen 2, etc., even though the GMR picture may not have been created in that order. This sorting by color can save a great deal of time when the picture is actually plotted. When HPPLOT has finished translating and sorting the GMR vector command file, it gives the user the option of adding an another GMR picture to the same page. If the answer is 'yes', then the paper rotation and plotting area for the new GMR vector command file is determined, and the file is translated and sorted by pen color. Note that the plotting area of the new file may overlap the area of the previous file. The only restriction on the plotting area is that is must lie completely within the physical margins of the page. The GMR commands GM_$PRINT_FILE and GM_$PRINT_FILE_PART scale the user's picture to fit within a box using the width and height specified by the user in the GMR procedure call. The HPPLOT program sets the HP7550 plotter's scaling factor so that the origin (0,0) of the GMR vector file maps onto the origin (0.0,0.0) of the box defining the plotting area, and it maps the width and height of the GMR vector file (which are the values specified by the user) onto the upper left corner of the box defining the plotting area making any correction necessary to avoid distorting the plot. Because of this automatic scaling, the actual width and height values specified by the user in the GM_$PRINT_FILE procedure call aren't really important. Only their ratio, which defines the shape of the box in which GMR will draw the picture, and the size and origin of the box defining the plotting area on the page will affect how the plot looks on the paper. There is, however, another factor to consider -- the width and height specified in the GMR procedure call are integer values and all of the coordinates in the GMR vector file are also integer values. When GMR scales the user's plot to fit within the specified box, the round off errors can become quite noticeable. A height and width of (1,1) and a height and width of (1000,1000) will both give the same shape box which the HPPLOT program will scale to fit in the same plotting area on the page, but the picture in the (1,1) box will be much different than the picture in the (1000,1000) box. Any picture element in the (1,1) box which is less than half of the maximum size of the GMR metafile's coordinate system will be rounded off to a size of zero and will not appear at all in the GMR vector file! In general, it is better to use the largest possible width and height values (keeping their ratio constant) in the GMR call to GM_$PRINT_FILE and GM_$PRINT_FILE_PART. Since the HP7550-A plotter has a resolution of about 10,000 by 7,800 for a full 8 1/2" by 11" page, a width value of at least 10,000 and a height value of at least 7,800 will give the sharpest looking plot (for a full page plot - if the plotting area is smaller than the full page, then smaller width and height values will still give the best possible results). There is no problem with specifying GMR width and height values which are larger than the maximum resolution of the HP plotter - the plotter still scales the plot correctly to fit within the box defining the plotting area, and there will be no problem with GMR rounding off the coordinates in the vector file. Translation of GMR Commands into HPGL Commands ---------------------------------------------- The GMR vector command file defined in section 13 of the "Programmer's Guide to DOMAIN Graphics Metafile Resource" manual contains 22 different command types. This section describes how each of these types of GMR commands are translated into HPGL commands. END OF FILE - opcode 16#0000 HPPLOT puts away the current pen and resets the plotter. POLYLINE - opcode 16#0020 The pen whose value corresponds to the current draw-value is moved to the first coordinate pair, and a line is drawn to each of the following coordinate pairs in turn using the current draw-style. CLOSED POLYLINE - opcode 16#0021 Same as the POLYLINE command except that a line is also drawn from the last coordinate pair back to the first coordinate pair. FILLED POLYLINE - opcode 16#0022 A polygon whose vertices are defined by the specified coordinate pairs is drawn using the pen whose value corresponds to the current fill-value, and the polygon is filled with the same pen using the current fill-pattern. The fill-background is ignored. RECTANGLE - opcode 16#0030 A rectangle whose opposite corners are specified by the two coordinate pairs is drawn using the pen whose value corresponds to the current draw-value using the current draw-style. FILLED RECTANGLE - opcode 16#0031 A rectangle whose opposite corners are specified by the two coordinate pairs is drawn using the pen whose value corresponds to the current fill-value, and the rectangle is filled with the same pen using the current fill-pattern. The fill-background is ignored. CIRCLE - opcode 16#0040 A circle with the specified center and radius is drawn with the pen whose value corresponds to the current draw-value using the current draw-style. FILLED CIRCLE - opcode 16#0041 A circle with the specified center and radius is drawn with the pen whose value corresponds to the current fill-value, and the circle is filled with the same pen using the current fill-pattern. The fill background is ignored. CURVE - opcode 16#0050 If a parametric-cubic-spline curve type was given, then a spline is drawn through the specified points using ten line segments per point. The spline algorithm used is a parametric version of the algorithm given by Robert Sedgewick in "Algorithms", pp. 68-72 (Addison-Wesley 1984), with a sign correction in the spline-evaluation formula (p. 72). This gives a spline curve which is less curved than the curve drawn on the screen by GMR, but according to Apollo the GMR spline routine is based on the same reference. If the curve type is 3-point-arc, then a circular arc is drawn starting at the first coordinate pair to the third coordinate pair, passing through the second coordinate pair. The current draw-value is used for the pen value and the current draw-style is used for the line type drawn. USER-DEFINED PRIMATIVE - opcode 16#0060 This command is not implemented (see Known Deficiencies). PIXEL TEXT - opcode 16#0070 The pen whose value corresponds to the current text-value is moved to the specified starting location and the given text is drawn along a line with the specified rotation. The default character set of the HP plotter is used and is scaled to the correct size. (the current text-size is assumed to be the width of the pixel font as a percentage of the bitmap-size, and the plotter's font is scaled to be the same percentage of the plotting area's width. The height of the pixel font is assumed to be twice the width of the font.) The font-family and text-background are ignored. Note that GMR should have translated text using stroke fonts into a sequence of polylines. DRAW VALUE - opcode 16#0080 GMR color values 1 to 8 are mapped to HP plotter pen numbers 1 to 8, GMR color values 9 to 16 are mapped to HP plotter pen number 1 to 8, etc. GMR color 0 is mapped to HP pen number 8. [ie. pen-number is ((colornumber-1) mod 8)+1) rather than just (colornumber mod 8).] Note that the HP 7475 has 6 pens rather than 8 pens like the HP 7550 and the HP 7570. For the HP 7475 pen-number is done mod 6 rather than mod 8. DRAW STYLE - opcode 16#0081 For a GMR draw-style of "same line type" nothing is done; for a draw-style of "solid line" the HP line type is set to the default value (ie. solid line of the current pen color); for a draw-style of "dotted line" the HP line type is set to a value of -2 [ie. an adaptive line with solid and blank sections of equal length] with a pattern replication length which is the same percentage of the diagonal of the plotting area as twice the specified length of the solid portion of the line is to the diagonal of a 1024 by 800 pixel screen; for a draw-style of "patterned line" the HP line type is set to a value of -((replication-factor mod 6)+1) [ie. adaptive line types of -1 to -6] with a pattern replication length of the same percentage of the diagonal of the plotting area as the specified number of bits in the pattern is to the diagonal of a 1024 by 800 pixel screen. DRAW RASTER OP - opcode 16#0082 This command is not implemented (see Known Deficiencies). Raster operations can not be done with a pen plotter. PLANE MASK - opcode 16#0083 This command is not implemented (see Known Deficiencies). Raster operations can not be done with a pen plotter. FILL VALUE - opcode 16#0090 GMR color values 1 to 8 are mapped to HP plotter pen numbers 1 to 8, GMR color values 9 to 16 are mapped to HP plotter pen number 1 to 8, etc. GMR color 0 is mapped to HP pen number 8. [ie. pen-number is ((colornumber-1) mod 8)+1) rather than just (colornumber mod 8).] Note that the HP 7475 has 6 pens rather than 8 pens like the HP 7550 and the HP 7570. For the HP 7475 pen-number is done mod 6 rather than mod 8. FILL BACKGROUND VALUE - opcode 16#0091 This command is not implemented (see Known Deficiencies). Raster operations can not be done with a pen plotter. FILL PATTERN - opcode 16#0092 If the GMR fill pattern scale is 0 [ie. solid fill] then the HP plotter fill type is set to 1 [ie. solid bi-directional filling with lines spaced by the default pen thickness]; otherwise, GMR fill types 1 to 4 are mapped to HP plotter fill types 1 to 4, GMR fill types 4 to 8 are mapped to HP plotter fill types 1 to 4, etc. [ie. HP fill type is (((GMR.fill.type -1) mod 4)+1)], the spacing between the lines is the same percentage of the plotting area as the specified x-size of the GMR fill pattern is to a 1024 pixel wide screen, and the angle of the lines in the HP fill type is the specified y-size of the GMR fill pattern in degrees. TEXT VALUE - opcode 16#00A0 GMR color values 1 to 8 are mapped to HP plotter pen numbers 1 to 8, GMR color values 9 to 16 are mapped to HP plotter pen number 1 to 8, etc. GMR color 0 is mapped to HP pen number 8. [ie. pen-number is ((colornumber-1) mod 8)+1) rather than just (colornumber mod 8).] Note that the HP 7475 has 6 pens rather than 8 pens like the HP 7550 and the HP 7570. For the HP 7475 pen-number is done mod 6 rather than mod 8. TEXT BACKGROUND VALUE - opcode 16#00A1 This command is not implemented (see Known Deficiencies). Raster operations can not be done with a pen plotter. TEXT SIZE - opcode 16#00A2 The text-size width is set to the specified number of pixels. When pixel text is output, the width of the HP plotter characters as a percentage of the width of the plotting area is the same as the width of the text size in pixels is to the width of the plotting area given in the GM_$PRINT_FILE or GM_$PRINT_FILE_PART command. The height of the characters is taken to be twice the width. FONT FAMILY - opcode 16#00A3 This command is not implemented (see Known Deficiencies). This command provides no usefual information on the style of characters used in the GMR display. Known Deficiencies ------------------ The GMR fill-background-value and text-background-value commands are not implemented for the obvious reason that pen plotters can not handle bitmap patterns. The GMR raster-op and plane-mask commands are also not implemented for the same reason. The GMR font-family command is ignored. Due to a design deficiency, the GMR vector file contains no information which allows the font-family id number in the GMR font-family command to be associated with the name of any particular font. All pixel text is output in the default HP font style. The GMR user-defined-primative command is not implemented. Due to a design deficiency, the GMR vector file contains no information on how the parameters to the GMR user-defined-primative command are to be used to draw the object. The size of text characters on the page will not be the same proportion of the plotting area as the pixel text characters were on the screen. This is because the GMR text-size command which is in the GMR vector file is the text-size which the user requested (scaled into the units of the GM_$PRINT_FILE command), not the actual size of the pixel font used by GMR on the screen. When a user selects a text-size, GMR looks in the current font family file and selects one of the fonts in that file. The actual size of the font selected by GMR is not necessarily the same as the size requested by the user. The size selected is what appears on the screen - the size requested is what is stored in the GMR vector file. As a result, text which is centered on the screen will probably not be centered on the plotter's page. As of version SR9.5 of AEGIS, 2-D GMR does not output the correct text rotation angle for pixel text contained in segments which have been instanced and rotated. This is a bug in GMR, not in HPPLOT. Version 3 --------- The bug in the text-size command has been fixed. Previously, the text size was assumed to be the *height* of the characters in screen pixels (ie. 800 pixel high screen). The text-size is actually the *width* of the characters in the units of the GMR vector command file (ie. the width is scaled by the size of the plotting area given in the GM_$PRINT_FILE command). The speed of the program has been increased by about a factor of two due to a more efficient method for reading the GMR vector file and the use of a smaller buffer when the color-sorting of the HPGL commands is done. The error messages for GMR commands which are not implemented are only typed out once for each GMR vector file which is translated. A summary of the commands which could not be translated is typed out when the translation is completed. This avoids long lists of error messages when translating files which use a lot of fill-background and text-background commands. Version 7 --------- Version 7 fixes a number of bugs which were discovered after installing AEGIS version SR9.0. Some of these may be due to changes in the operation of certain GMR functions (ie. I'm not sure, but I thought I had successfully run the test which discovered this error under SR8.1) Other managed to avoid being tested until now. The GMR curve command with the circular-arc option is now drawn correctly. Previously, the curve was not drawn because a "PD" (pen down) command had not been issued before the "AA" (absolute arc) command. The GMR draw-style now works correctly for dotted-lines. It used to give solid lines instead of dashed lines. Using a GMR color value (ie. a draw-value, fill-value, or text-value) of zero no longer causes an "unopened file" error. Color 0 is now correctly mapped to pen number 8. All other GMR color values still correctly map to pen numbers 1 to 8. Version 8 --------- Version 8 corrects a bug in the GMR filled rectangle command. It used to fill the rectangle twice due to a misunderstanding of how the HPGL 'RA' command works. The rectangle is now filled once and then outlined with a solid line. Version 9 --------- Version 9 corrects a bug in the GMR pixel text command. The text angle in the GMR OUT1 format file (the vector file) is in degrees. The Pascal SIN and COS functions take radians. We now correctly convert degrees to radians before calculating the 'rise' and 'run' parameters for the HPGL text angle (DR) command. Version 10 ---------- Version 10 adds support for the 6 pen HP 7475A plotter and the 8 pen HP 7570 Draft Pro plotter (C and D size plotter). HPPLOT now takes one additional input parameter, the plotter type (eg. '7475'). Version 11 ---------- Fixed bug in GMR draw style command for HP 7475A plotter. The HP 7475 has line styles of 0 to 6, not -6 to 6 like the HP 7550A and HP 7580 plotters. Version 12 ---------- Added 'AC' and 'AD' (architectural C and architectural D) paper sizes for the HP 7570 plotter in addition to the standard 'C' and 'D' paper sizes. Files Needed to Build HPPLOT ---------------------------- The files which are provided for the HPPLOT program are: HPPLOT.DOC - This file. HPPLOT.HELP - A short explanation of how to run the HPPLOT program and the various options the program allows. HPPLOT.PAS - The Pascal sources for the program. HPPLOT.BLD - A shell script file for compiling and binding the HPPLOT program. HPPLOT - A ready to run HPPLOT. Just in case you don't have a Pascal compiler. This is the file which is produced by HPPLOT.BLD. You will also need the following standard Apollo-supplied files: /SYS/INS/BASE.INS.PAS - These are all standard insert files which /SYS/INS/MS.INS.PAS are used by HPPLOT.PAS /SYS/INS/ERROR.INS.PAS /SYS/INS/PGM.INS.PAS Bugs, Questions, and Improvements --------------------------------- If you find a bugs in the program, have questions on how to install or use it, or have a good idea for improving the program please feel free to contact me at the address below. David M. Krowitz MIT dept. of Earth, Atmospheric, and Planetary Sciences Room 54-527 Cambridge, MA 02139 (617) 253-6180 network mailing address: mit-erl!mit-kermit!krowitz@eddie.mit.edu mit-erl!mit-kermit!krowitz@mit-eddie.arpa krowitz@mit-mc.arpa (in order of decreasing preference) SHAR_EOF chmod +x 'hpplot.doc' fi # end of overwriting check if test -f 'hpplot.hlp' then echo shar: will not over-write existing file "'hpplot.hlp'" else cat << \SHAR_EOF > 'hpplot.hlp' Help for the HPPLOT Program - Version 10 ---------------------------------------- The HPPLOT program reads GMR vector command files produced by the GMR routines GM_$PRINT_FILE and GM_$PRINT_FILE_PART and translates the GMR commands in the file into a file of Hewlitt Packard Graphics Language (HPGL) commands which can then be sent to an HP 7475A, HP 7550A, or HP 7570A color pen plotter. The program will prompt you for the following: Input file name - The name of the GMR vector command file to be translated. Note that this is NOT the GMR metafile. Output file name - The name of the HPGL command file to be output. Each plot in the file is sorted by pen color to speed the actual plotting of the file. Plotter type - The type of plotter which will receive the output file. One of '7475', '7550', or '7570'. Paper size - The size of the paper being used in the plotter. Either 8 1/2" by 11" (A size) or 11" by 17" (B size) paper can be used in the HP 7475A and HP 7550A. Either 17" by 22" (C size) or 22" by 32" (D size) paper can be used in the HP 7570A. Plot rotation - The orientation of the plotting axis on the paper. Normally, the x-axis is along the long edge of the paper and the y-axis is long the shorter edge of the paper. A 90 degree rotation will reverse this for plots which are taller than they are wide. Plotting area origin - The origin of the box on the paper in which the plot is to appear. The plot will automatically be scaled to fit within this box without distortion. The point (0.0,0.0) is located in the lower left hand corner of the paper (0 rotation) about 1/4" from both edges of the paper (the physical margin of the paper). Plotting area size - The size of the box on the paper in which the plot is to appear, given in inches. If the plot is a different shape than the box, then the plot will be scaled to fit completely inside the box with the plot's origin mapped onto the box's origin. Outline plotting area - A border may be drawn around the plotting area using pen color 1. Add another plot - Additional GMR vector files may be added to the same output file, allowing multiple plots to be placed onto the same page. When HPPLOT has finished translating the GMR vector command file, a summary of the number of GMR commands which couldn't be translated is typed out before the program asks for an additional GMR vector command file to be added to the same page. Once HPPLOT has completed the translation of all of the GMR vector files, the HPGL file may be sent to the plotter's print-server with the command: PRF -PR -TRANSPARENT The command file: /USERS/USERLIB/PENPLOT may also be used to send the HPGL file to the plotter. Just type: PENPLOT ... to send up to nine different HPGL files to the plotter. If you don't give any file names to PENPLOT it will type a listing of all of the files currently waiting to be plotted. If you want more than one copy of the same page, use the option: -COPIES with either the PRF command or the PENPLOT command. SHAR_EOF chmod +x 'hpplot.hlp' fi # end of overwriting check # End of shell archive exit 0 .