This module shows you how to create output workstations and how to send view objects to them for viewing. You will also see how you can send the same object to different output workstation.
There are three different types of workstation classes you can use for creating workstation objects for sending view objects to:
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".
Here is a simple example:
; ; NCL script that creates an output workstation and sends view ; objects to it. ; ; Create an X11 output workstation. ; xworkid = create "x_work" xWorkstationClass defaultapp "wkPause" : "True" end create ; ; Create a couple of TextItem objects. ; text_id1 = create "Text" textItemClass xworkid "txPosXF": 0.5 "txPosYF": 0.4 "txString": "Text String 1" end create text_id2 = create "Text" textItemClass xworkid "txPosXF": 0.5 "txPosYF": 0.6 "txString": "Text String 2" end create ; ; Draw one string on the workstation and pause. ; draw(text_id1) frame(xworkid) ; ; Draw both strings on the workstation and pause. ; draw((/text_id1,text_id2/)) frame(xworkid)
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.
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)
NG4.1 Home, Index, Examples, Glossary, Feedback, UG Contents, UG WhereAmI?