CW_ANIMATE

The CW_ANIMATE function creates a compound widget that displays an animated sequence of images using off-screen windows knows as pixmaps . The speed and direction of the display can be adjusted using the widget interface.

CW_ANIMATE provides the graphical interface used by the XINTERANIMATE procedure, which is the preferred routine for displaying animation sequences in most situations. Use this widget instead of XINTERANIMATE when you need to run multiple instances of the animation widget simultaneously. Note that if more than one animation widget is running, they will have to share resources and will display images more slowly than a single instance of the widget.

The returned value of this function is the widget ID of the newly-created animation widget.

This routine is written in the IDL language. Its source code can be found in the file cw_animate.pro in the lib subdirectory of the IDL distribution.

Using CW_ANIMATE

Unlike XINTERANIMATE, using the CW_ANIMATE widget requires calls to two separate procedures, CW_ANIMATE_LOAD and CW_ANIMATE_RUN, to load the images to be animated and to run the animation. Alternatively, you can supply a vector of pre-existing pixmap window IDs, eliminating the need to use CW_ANIMATE_LOAD. The vector of pixmaps is commonly obtained from a call to CW_ANIMATE_GETP applied to a previous animation widget. Once the images are loaded, they are displayed by copying the images from the pixmap or buffer to the visible draw widget.

See the documentation for CW_ANIMATE_LOAD, CW_ANIMATE_RUN, and CW_ANIMATE_GETP for more information.

The only event returned by CW_ANIMATE indicates that the user has clicked on the "End Animation" button. The parent application should use this as a signal to kill the animation widget via WIDGET_CONTROL. When the widget is destroyed, the pixmaps used in the animation are destroyed as well, unless they were saved by a call to CW_ANIMATE_GETP.

See the animation widget's help file (available by clicking the "Help" button on the widget) for more information about the widget's controls.

Calling Sequence

Result = CW_ANIMATE( Parent, Sizex, Sizey, Nframes )

Arguments

Parent

The widget ID of the parent widget.

Sizex

The width of the displayed image, in pixels.

Sizey

The height of the displayed image, in pixels

Nframes

The number of frames in the animation sequence.

Keywords

NO_KILL

Set this keyword to omit the "End Animation" button from the animation widget.

OPEN_FUNC

Set this keyword equal to a scalar string specifying the name of a user-written function that loads animation data. If a function is specified, an "Open ..." button is added to the animation widget.

For an example showing the format and use of an animation-loading function, see the file animate.pro in the general subdirectory of the examples subdirectory of the IDL distribution.

PIXMAPS

Use this keyword to provide the animation widget with a vector of pre-existing pixmap (off screen window) IDs. This vector is usually obtained from a call to CW_ANIMATE_GETP applied to a previous animation widget.

TRACK

Set this keyword to cause the frame slider to track the frame number of the currently-displayed frame.

UVALUE

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

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.

See Compound Widgets for a more complete discussion of controlling compound widgets using WIDGET_CONTROL and WIDGET_INFO .

Widget Events Returned by the CW_ANIMATE Widget

The only event returned by this widget indicates that the user has pressed the DONE button. The parent application should use this as a signal to kill the animation widget via WIDGET_CONTROL.

Example

Assume the following event handler procedure exists:

PRO EHANDLER, EV

WIDGET_CONTROL, /DESTROY, EV.TOP

end

(If you wish to create this event handler starting from the IDL command prompt, remember to begin with the .RUN command.)

Enter the following commands to open the file ABNORM.DAT (a series of images of a human heart) and load the images it contains into an array H .

OPENR, 1, FILEPATH('abnorm.dat', SUBDIR = ['examples','data'])

H = BYTARR(64, 64, 16)

READU, 1, H

CLOSE, 1

H = REBIN(H, 128, 128, 16)

Create an instance of the animation widget and load the frames. Note that because the animation widget is realized before the call to CW_ANIMATE_LOAD, the frames are displayed as they are loaded. This provides the user with an indication of how things are progressing.

base = WIDGET_BASE(TITLE = 'Animation Widget')

animate = CW_ANIMATE(base, 128, 128, 16)

WIDGET_CONTROL, /REALIZE, base

FOR I=0,15 DO CW_ANIMATE_LOAD, animate, FRAME=I, IMAGE=H[*,*,I]

Save the pixmap window IDs for future use:

CW_ANIMATE_GETP, animate, pixmap_vect

Start the animation:

CW_ANIMATE_RUN, animate

XMANAGER, 'CW_ANIMATE Demo', base, EVENT_HANDLER = 'EHANDLER'

Pressing the "End Animation" button kills the application.

See Also

CW_ANIMATE_LOAD , CW_ANIMATE_RUN , CW_ANIMATE_GETP , XINTERANIMATE