CW_ZOOM

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.

Using CW_ZOOM

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

Calling Sequence

Result = CW_ZOOM( Parent )

Arguments

Parent

The widget ID of the parent widget.

Keywords

FRAME

If set, a frame will be drawn around the widget. The default is FRAME = 0.

MAX

The maximum zoom scale, which must be greater than or equal to 1. The default is 20.

MIN

The minimum zoom scale, which must be greater than or equal to 1. The default is 1.

RETAIN

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.

SAMPLE

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.

SCALE

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.

TRACK

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.

UVALUE

The "user value" to be assigned to the widget.

XSIZE

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.

X_SCROLL_SIZE

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.

X_ZSIZE

The width of the window for the zoomed image. The default is 250.

YSIZE

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.

Y_SCROLL_SIZE

The height of the visible part of the original image. This may be smaller than the actual height controlled by the YSIZE keyword. The default is 0, for no scroll bar.

Y_ZSIZE

The height of the window for the zoomed image. The default is 250.

Keywords to WIDGET_CONTROL and WIDGET_INFO

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 .

Widget Events Returned by the CW_ZOOM Widget

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.

Example

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.

PRO widzoom_event, event

 

WIDGET_CONTROL, event.id, GET_UVALUE=uvalue

CASE uvalue OF

   'ZOOM': HELP, /STRUCT, event

   'DONE': WIDGET_CONTROL, event.top, /DESTROY

ENDCASE

 

END

 

Next, create the widget program:

PRO widzoom

 

OPENR, lun, FILEPATH('people.dat', SUBDIR = ['examples','data']), $

    /GET_LUN

image=BYTARR(192,192)

READU, lun, image

FREE_LUN, lun

sz = SIZE(image)

 

base=WIDGET_BASE(/COLUMN)

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

XMANAGER, 'widzoom', base

 

END

Once you have entered these programs, type "widzoom" at the IDL command prompt to run the widget application.

See Also

ZOOM , ZOOM_24