Using Window Objects

To render a graphics tree to a window, call the IDLgrWindow::Draw method. The argument must be either an IDLgrView object or an IDLgrScene object.

myWindow->Draw, myView 

or

myWindow->Draw, myScene 

All objects contained within the view or scene object will be drawn to the window.

Erasing a Window

To erase the contents of a window, call the IDLgrWindow::Erase method. You can optionally supply a color to use to clear the window. By default, the window is erased to white.

For example, to erase the window to black:

myWindow->Erase, COLOR=[0,0,0]  

Exposing or Hiding a Window

To expose a window so that it is the front-most window on the screen, call the IDLgrWindow::Show method with a nonzero value as the argument:

myWindow->Show, 1 

To hide a window, call the IDLgrWindow::Show method with a zero value as the argument:

    myWindow->Show, 0 

Iconifying a Window

To iconify (minimize) a window, call the IDLgrWindow::Iconify method with a nonzero value as its argument:

myWindow->Iconify, 1 

To restore an iconified window, call the IDLgrWindow::Iconify method with a zero value as its argument:

myWindow->iconify, 0  

Setting the Window Cursor

To set the appearance of the mouse cursor in an IDLgrWindow object, call the IDLgrWindow::SetCurrentCursor method with a string argument representing the name of the cursor. Valid string values for the cursor name argument are:

ARROW

CROSSHAIR

ICON

IBEAM

MOVE

ORIGINAL

SIZE_NE

SIZE_NW

SIZE_SE

SIZE_SW

SIZE_NS

SIZE_EW

UP_ARROW

The following statement sets the cursor to an up arrow:

myWindow->SetCurrentCursor, 'UP_ARROW' 

The ORIGINAL cursor sets the cursor to the window system's default cursor.

See "IDLgrWindow::SetCurrentCursor" (IDL Reference Guide) for details on cursor values.

Saving/Restoring Windows

When an instance of an IDLgrWindow object is restored via the RESTORE procedure), it is not immediately displayed on the screen. It will be displayed as soon as one of its methods (Draw, Erase, Iconify, etc.) is called.

Saving Window Contents to a File

If you have created a scene or view containing graphical objects and wish to save the rendering to a file, you will first need to create an image object from which to retrieve the image data. The following steps render an object to a window, create an image object from the window, and save the image data as a TIFF file.

First, create the view to be rendered. Use an indexed color model for the window object, setting the background color to white and the foreground color of the plot object to black.

mywindow = OBJ_NEW('IDLgrWindow', COLOR_MODEL=1) 
myview = OBJ_NEW('IDLgrView', $ 
   VIEWPLANE_RECT=[0,-4,10,8], COLOR=255) 
mymodel = OBJ_NEW('IDLgrModel') 
myplot = OBJ_NEW('IDLgrPlot', RANDOMN(seed, 10), COLOR=0, $ 
   THICK=3) 
; Organize the object hierarchy: 
myview->Add, mymodel 
mymodel->Add, myplot 
; Draw to the window: 
mywindow->Draw, myview 
; Next, use the window object's Read method to create 
; an image object with the rendered scene as its image data: 
myimage = mywindow->Read() 
; Retrieve the image data using the GetProperty method 
; of the image object: 
myimage->GetProperty, DATA=image 
; Display the image data using Direct Graphics: 
TV, image 
; Write the image to a TIFF file named myfile.tif: 
WRITE_TIFF, 'myfile.tif', image