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.
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.
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.
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.
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 .
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.
Assume the following event handler procedure exists:
WIDGET_CONTROL, /DESTROY, EV.TOP
(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'])
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
XMANAGER, 'CW_ANIMATE Demo', base, EVENT_HANDLER = 'EHANDLER'
Pressing the "End Animation" button kills the application.
CW_ANIMATE_LOAD , CW_ANIMATE_RUN , CW_ANIMATE_GETP , XINTERANIMATE