The CW_ZOOM function creates a compound widget that displays two images: an original image in one window and a portion of the original image in another. The user can select the center of the zoom region, the zoom scale, the interpolation style, and the method of indicating the zoom center.
The returned value of this function is the widget ID of the newly-created zoom widget.
This routine is written in the IDL language. Its source code can be found in the file
cw_zoom.pro
in the
lib
subdirectory of the IDL distribution.
The value of the CW_ZOOM widget is the original, un-zoomed image to be displayed (a two-dimensional array). To change the contents of the CW_ZOOM widget, use the command:
WIDGET_CONTROL, id, SET_VALUE = array
where
id
is the widget ID of the CW_ZOOM widget and
array
is the image array. The value of CW_ZOOM cannot be set until the widget has been realized. Note that the size of the original window, set with the XSIZE and YSIZE keywords to CW_ZOOM, must be the size of the input array.
To return the current zoomed image as displayed by CW_ZOOM in the variable
array
, use the command:
Set this keyword to zero, one, or two to specify how backing store should be handled for both windows. RETAIN=0 specifies no backing store. RETAIN=1 requests that the server or window system provide backing store. RETAIN=2 specifies that IDL provide backing store directly. See Backing Store for details.
Set to zero for bilinear interpolation, or to a non-zero value for nearest neighbor interpolation. Bilinear interpolation gives higher quality results, but requires more time. The default is 0.
The initial integer scale factor to use for the zoomed image. The default is SCALE = 4. The scale must be greater than or equal to 1.
Set this keyword and events will be generated continuously as the cursor is moved across the original image. If not set, events will only be generated when the mouse button is released. Note: On slow systems, /TRACK performance can be inadequate. The default is 0.
The width of the window (in pixels) for the original image. The default is XSIZE = 500. Note that XSIZE must be set to the width of the original image array for the image to display properly.
The width of the visible part of the original image. This may be smaller than the actual width controlled by the XSIZE keyword. The default is 0, for no scroll bar.
The height of the window (in pixels) for the original image. The default is 500. Note that YSIZE must be set to the height of the original image array for the image to display properly.
The widget ID returned by most compound widgets is actually the ID of the compound widget's base widget. This means that many keywords to the WIDGET_CONTROL and WIDGET_INFO routines that affect or return information on base widgets can be used with compound widgets.
In addition, you can use the GET_VALUE and SET_VALUE keywords to WIDGET_CONTROL to obtain or set the value of the zoom widget. The value of the CW_ZOOM widget is the original, un-zoomed image to be displayed (a two-dimensional array). To change the contents of the CW_ZOOM widget, use the command:
WIDGET_CONTROL, id, SET_VALUE = array
where
id
is the widget ID of the CW_ZOOM widget and
array
is the image array. The value of CW_ZOOM cannot be set until the widget has been realized. Note that the size of the original window, set with the XSIZE and YSIZE keywords to CW_ZOOM, must be the size of the input array.
To return the current zoomed image as displayed by CW_ZOOM in the variable
array
, use the command:
WIDGET_CONTROL, id, GET_VALUE = array
See Compound Widgets for a more complete discussion of controlling compound widgets using WIDGET_CONTROL and WIDGET_INFO .
When the "Report Zoom to Parent" button is pressed, this widget generates event structures with the following definition:
event = {ZOOM_EVENT, ID:0L, TOP:0L, HANDLER:0L, $
XSIZE:0L, YSIZE:0L, X0:0L, Y0:0L, X1:0L, Y1:0L }
The XSIZE and YSIZE fields contain the dimensions of the zoomed image. The X0 and Y0 fields contain the coordinates of the lower left corner of the original image, and the X1 and Y1 fields contain the coordinates of the upper right corner of the original image.
The following code samples illustrate a use of the CW_ZOOM widget.
First, create an event-handler. Note that clicking on the widget's "Zoom" button displays IDL's help output on the console.
WIDGET_CONTROL, event.id, GET_UVALUE=uvalue
'DONE': WIDGET_CONTROL, event.top, /DESTROY
Next, create the widget program:
OPENR, lun, FILEPATH('people.dat', SUBDIR = ['examples','data']), $
zoom=CW_ZOOM(base, XSIZE=sz[1], YSIZE=sz[2], UVALUE='ZOOM')
done=WIDGET_BUTTON(base, VALUE='Done', UVALUE='DONE')
WIDGET_CONTROL, base, /REALIZE
WIDGET_CONTROL, zoom, SET_VALUE=image
Once you have entered these programs, type "widzoom" at the IDL command prompt to run the widget application.