Managing your output

This module discusses how to send your view objects to an output workstation for viewing.

Creating output workstations

After you have created a view object, in order to view the object you must create an output workstation and send your view objects to the workstation. You can create several workstations and send view objects to any or all of them.

There are three different types of workstation classes you can use for creating workstation objects for sending view objects to:

  1. XWorkstation for plotting to an X11 window.
  2. NcgmWorkstation for storing graphics in NCGM format.
  3. PSWorkstation for storing graphics in various flavors of PostScript.
Each of the above workstation objects has resources for controlling various aspects of the output, such as metafile name for NCGM output, pausing in an X11 window, selecting PS or EPS output for PostScript, and so on. Consult the reference pages for these workstations for details. All of the above classes are subclassed from the Workstation class. The Workstation class has a multitude of resources itself, such as setting color maps. See the reference page for the Workstation class for details.

Only one NcgmWorkstation can be created at a time in an application, but up to 15 independent XWorkstations or PSWorkstations can be created.

Workstations are created in NCL by using the create expression. For example, the following code would create an instance of a PostScript workstation that produces EPS.

     xworkid = create "simple" psWorkstationClass defaultapp
         "wkPSFormat" : "EPS"
         "wkBackgroundColor"  : (/ 1., 1., 1. /)
     end create

The workstation name "simple" is used as the base name for the EPS output, so that when view objects are drawn to xworkid, the output file will have the name "simple.eps".

Sending view objects to output workstations

The basic NCL procedure for sending view objects to an output device is draw. See the module Visualizing images for details.

For most applications, you will call the NCL procedure frame after a draw in order to terminate an image. For more precise control, you may want to use the NCL procedures update and clear.

Sending the same object to one or more output workstations

Sometimes you would like to send the same object to more than one workstation. The NCL draw procedure sends an object identified in its argument to the workstation whose identifier was specified in the create expression that was used to create the object. In order to send an object to a different workstation than the one identified in its creation, it is necessary to specify a new parent for the object. This can be done by using the NhlChangeWorkstation procedure.

Here is a simple example of sending the same object to two different workstations:

;
; Create a PS output workstation with a white background color.
;

psworkid = create "simple" psWorkstationClass defaultapp
    "wkBackgroundColor"  : (/ 1., 1., 1. /)
end create

;
; Create an X11 workstation.
;

xworkid = create "X11" xWorkstationClass defaultapp
    "wkPause" : "True"
    "wkBackgroundColor"  : (/ 1., 1., 1. /)
end create

;
; Create data for an XyPlot
;

dataid = create "xyData" coordArraysClass defaultapp
    "caXArray": (/0.0, 0.1, 0.5, 0.9, 1.0, 0.9, 0.5, 0.1, 0.0/)
    "caYArray": (/0.5, 0.9, 1.0, 0.9, 0.5, 0.1, 0.0, 0.1, 0.5/)
end create

;
; Create a simple XyPlot object.
;

plot_id = create "Box" xyPlotClass xworkid
   "xyCoordData": dataid
end create


;
; Send the XyPlot to the X11 workstation.
;

draw(plot_id)
frame(xworkid)

;
; Send the XyPlot to the PS workstation.
;

NhlChangeWorkstation(plot_id,psworkid)
draw(plot_id)
frame(psworkid)

User Guide Control Panel

NG4.1 Home, Index, Examples, Glossary, Feedback, UG Contents, UG WhereAmI?


$Revision: 1.6 $ $Date: 1998/06/15 22:08:46 $