CGM Output
Computer Graphics Metafile, or CGM, is a standard for storing graphics output. To direct graphics output from PV-WAVE to a CGM file, enter the command:
SET_PLOT, 'CGM'
This causes PV-WAVE to use the CGM driver for producing graphical output, including line plots, contour plots, surface plots, and raster images. Once the CGM driver is enabled via SET_PLOT, the DEVICE procedure is used to control its actions, as described in Controlling CGM Output with DEVICE Keywords . The default settings for the CGM driver are listed in CGM Driver Default Settings .
Setting |
Default Value |
Output file name |
wave.cgm |
File status |
Closed |
Metafile type |
Clear Text |
Number of colors in color table |
254 |
Color table offset |
1 |
Clip to VDC range |
ON |
Horizontal offset |
0 Coordinates |
Vertical offset |
0 Coordinates |
Scale factor |
None |
Standard Cell Array |
Standard |
The CGM driver supports clear text and binary CGM output. To see the driver’s current settings, enter:
INFO, /Device
Note: |
If you want to send a CGM file to a hardcopy printer, and you want to modify the color table, it is a good idea to modify the color table before sending CGM graphics output to the file. For more information about modifying color tables, see the PV‑WAVE User Guide. |
Note: |
Run the MSWORD_CGM_SETUP procedure before creating CGM output that you wish to import into Microsoft Word. For example: SET_PLOT, 'CGM' DEVICE, File='myplot.cgm' MSWORD_CGM_SETUP PLOT, dist(20) DEVICE, /Close |
Controlling CGM Output with DEVICE Keywords
The following keywords to the DEVICE procedure provide control over the CGM driver:
Clip—Specifies that all coordinates will be reduced to fit within the VDC coordinate range. This keyword is primarily used with the Xoffset and Yoffset keywords to protect the metafile from containing coordinates which are outside the range of the VDC system.
Close—Closes the current CGM output file.
Colors—Specifies the number of colors in the color table. Be sure to specify the number of colors in the color table before any graphics output is written to the file.
Ct_Offset—Specifies the location (or offset) of the first element in the color table. As with the Colors keyword, this value should be specified before any graphics output is written to the file.
Filename—Specifies the name of the CGM output file to be opened. If the keyword is not specified, the default name wave.cgm is used.
Index_From_Zero—If nonzero, maps the PV‑WAVE colortable indices directly to the CGM color table indices. That is, the indices are mapped
0–>0, 1–>1, and so on. By default, the PV‑WAVE to CGM color indices are mapped 0–>1, 1–>2, and so on. This keyword disables the Color and Ct_Offset keywords.
Metafile_Type—Specifies the metafile type. Options are clear_text and binary. The default value is clear_text. The binary type is machine-specific and is more difficult to transfer.
Scale_Factor—Includes a floating-point value in the metafile for the Scale Mode Metric command. This allows for CGM interpreters to scale the graphics output appropriately for “exact sizing”. The metric scale-factor represents the distance (in millimeters) in the displayed picture—this corresponds to one VDC unit.
Std_Cell_Array—Specifies that images created with the binary output (CELL_ARRAY commands) are compliant with the CGM standard. Std_Cell_Array is enabled by default. Disabling this keyword may result in some non-standard cell array commands for odd-sized images. The non-standard cell array option is provided for downward compatibility.
Xoffset—Specifies the number of horizontal coordinate units to offset the graphics output. Xoffset is specified by a positive normalized coordinate in the range {0.0...1.0}.
Yoffset—Specifies the number of vertical coordinate units to offset the graphics output. Yoffset is specified by a positive normalized coordinate in the range {0.0...1.0}.
Using the CGM Driver
The CGM output file is automatically opened when the CGM driver is selected and PV-WAVE commands are issued that result in graphics output; there is no explicit OPEN command. If more than one CGM file is to be created, use the following command sequence:
; Select the CGM driver for graphics output.
SET_PLOT, 'CGM'
; Open the first file.
DEVICE, Filename='filename1'
; Graphics output commands here.
...
; Close the first file.
DEVICE, /Close
; Open another file.
DEVICE, Filename='filename2'
; Graphics output commands here.
...
; Close the second file, etc.
DEVICE, /Close
Note also that color table changes should be made every time a new CGM file is opened. In the absence of changes, the new CGM file contains the default color table, rather than the current color table.
Using Color with CGM Output
To create and load a color table with four elements, black, red, green, and blue:
TVLCT, [0,255,0,0], [0,0,255,0], [0,0,0,255]
Drawing text or graphics with a color index of 1 results in black, 2 in red, 3 in green, and 4 in blue.
Changing the Image Background Color
Images that are displayed with a black background on a monitor frequently look better in hardcopy form if the background is changed to white. This is easily accomplished with CGM output by issuing the statement, where A is the image variable:
A(WHERE(A EQ 0B)) = 255B
Changing the CGM Background Color
To set the background color for a CGM metafile, use the ERASE command with a color index. The index is used to define the background color. For example:
ERASE, 150