casa::Animator Class Reference
[DisplayEvents]

#include <Animator.h>

Collaboration diagram for casa::Animator:

Collaboration graph
[legend]
List of all members.

Detailed Description

Animation controller for WorldCanvasHolders.

Intended use:

Part of API

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Etymology

An Animator animates animations

Synopsis

TBW

Example

First example is making a simple movie of all the channels in a data cube

    // Create a PixelCanvas for X11 to draw on
    X11PixelCanvas(parent, xpcctbl, width, height) ;
    // and a World Coordinate  interface for this PixelCanvas
    WorldCanvas  wCnvs(&pixelCnvs);
   
    // Create a WorldCanvasHolder
    WorldCanvasHolder wCnvsHldr(&wCnvs);
   
    // Create an ImageDisplayData object of the data cube to display the 
    // channels (assuming 3rd axis is velocity in this cube) 
    ImageDisplayData cube(myDataSet, 0, 1, 2); 
    // and register this with the WorldCanvasHolder
    wCnvsHldr.addDisplayData(&cube);
   
    // Create an Animator for the WorldCanvasHolder and register the
    // WorldCanvasHolder
    Animator animator;
    animator.addWorldCanvasHolder(&wCnvsHldr);
   
    // start with first channel
    animator.setMin(0.0);            
    // last channel of cube (assuming it has 30 channels)
    animator.setMax(29.0);
    // go in steps of one channel
    animator.setStep(1.0);
    // only one channel at a time, so tolerance must be less than 1.0
    anomator.setTolerance(0.1);
    // display new channel every 0.2 sec
    animator.setUpdateInterval(0.2);
    // we want a normal boring movie
    animator.setNextMode(animator::NEXT_FORWARD); 
    // and we define the channel (ie index)
    animator.setMatchMode(Animator::MATCH_INDEX);
    // set the Update method
    animator.setUpdateMode(Animator::UPDATE_DIRECT);
    // and start the movie
    animator.startMovie();
          .
          .
          .
    // After a while we want to change to Rock & Roll mode:
    animator.setMovieMode(Animator::NEXT_ROCKandROLL);
          .
          .
          .
    // and after another while we stop
    animator.stopMovie();
Second example is that we want to blink between channel 20 of the previous cube and an optical image
    // Create an ImageDataDisplay of the image and register with
    // the WorldCanvasHolder
    ImageDataDisplay image(myImage, 0, 2);
    wCnvsHldr.addDisplayData(&image);
   
    // Create a List to contain the AttributeBuffers
    List<void *> buffList;
    // and an iterator for this list
    ListIter<void *> it(&buffList);
   
    // Create AttributeBuffers and fill them
    AttributeBuffer atBuff1;
    // This is to mark the cube. The name and value of the Attribute or 
    // Attributes that can be used is arbitrary, as long as the different 
    // AttributeBuffers in the List select different datasets (even that is
    // not really necessary, but you will be blinking between the same frames 
    // and not many people will get excited about that.\..\.)
    atBuff1.add("AjaxWordtKampioen", "yes");
    it.addRight((void *) &attBuff1);
    
    // the buffer for the image
    AttributeBuffer atBuff2;
    atBuff2.add("AjaxWordtKampioen", "of course");
    at.addRight((void *) &attBuff2);
   
    // and set this list on the Animator
    animator.setBlinkList(&buffList);
    
    // Set the same attributes on the DisplayDatas so the Attribute matching
    // mechanism between the WorldCanvasHolder and the DisplayDatas will select
    // the right data at the right time automatically
    cube.addAttribute(attBuff1);
    image.addAttribute(attBuff2);
   
    // Tell animator to use channel 20
    animator.gotoCoord(20.0);
    // The Animator should write "zIndex" to select channel 20
    animator.setMatchMode(Animator::MATCH_INDEX);
    // Because we set the UpdateMode to UPDATE_BLINK, the zIndex does
    // not change each time the timer goes off.
    animator.setUpdateMode(Animator::UPDATE_BLINK);
    // and the blinking can start:
    animator.startMovie();
          .
          .
          .
    // After a while we want to blink between channel 19 and the optical image.
    // this is done by setting NextMode to NEXT_BACKWARD and invoke nextCoord().
    // Of course we could also have used only animator.prevCoord(), but just
    // to show the principle.\..
    animator.setNextMode(Animator::NEXT_BACKWARD);
    animator.nextCoord();
   
    
    // We can add a third data set, set "AjaxWordtKampioen" to "always" for that data,
    // and the blinking is between 3 datasets: 
   
    // stop the blinking
    animator.stopMovie(); 
   
    // Create DisplayData from data
    ImageDataDisplay image2(mySecondImage, 0, 2);
   
    // Add to WorldCanvasHolder
    wCnvsHldr.addDisplayData(&image2);
   
    //Setup AttributeBuffer
    AttributeBuffer atBuff3;
    atBuff3.add("AjaxWordtKampioen", "always");
   
    // add to data
    image2.addAttribute(attBuff3);
   
    // and add to List
    at.addRight((void *) &attBuff3);
   
    // set the updated list on the animator (strictly speaking not neseccary
    // here, because animator already has the address of this List, but.\..)
    animator.setBlinkList(&buffList);
   
    //and go!!!
    animator.startMovie();
The third example is to run movies, selected on world coordinates on two WorldCanvasHolders in synch:
    // Create a PixelCanvas for X11 to draw on
    X11PixelCanvas(parent, xpcctbl, width, height) ;
    // and two  WorldCanvases side by side on the same PixelCanvas
    WorldCanvas wCnvs1(&pixelCanvas, 0.0, 0.25, 0.5, 0.5);
    WorldCanvas wCnvs2(&pixelCanvas, 0.5, 0.25, 0.5, 0.5);
   
    // A WorldCanvasHolder for each WorldCanvas
    WorldCanvasHolder wCnvsHldr1(&wCnvs1);
    WorldCanvasHolder wCnvsHldr2(&wCnvs2);
   
    // We have an HI data cube of an object
    ImageDisplayData HIcube(HIdata, 0, 1, 2);
    // that we display on the first WorldCanvas
    wCnvsHldr1.addDisplayData(HIcube);
    
    // and we have a CO cube of the same object that we display on the second
    // WorldCanvas
    ImageDisplayData COcube(COdata, 0, 1, 2);
    wCnvsHldr2.addDisplayData(COcube);
    
    // Create an animator and register the two WorldCanvasHolders
    Animator animator;
    animator.addWorldCanvasHolder(wCnvsHldr1);
    animator.addWorldCanvasHolder(wCnvsHldr2);
   
    // Set the movie parameters:
    // Select on world coordinate (ie velocity)
    animator.setMatchMode(Animator::MATCH_WORLD);
    // start and end velocities
    animator.setMinAndMax(1200.0, 1400.0);
    // and the tolerance to 10.0 and the step to 20.0
    animator.setTolerance(10.0):
    animator.setStep(20.0);
   
    // Set speed of movies and the mode
    animator.setUpdateInterval(0.2);
    animator.setNextMode(Animator::ROCKandROLL);
   
    // Now, on the first canvas a movie will be played of the HI data, and on
    // the second canvas a movie of the CO data. Because the selection is done
    // on world coordinate, the two movies display the data of the same 
    // velocity (within the tolerance of 10.0), in steps of 20.0, synchronized,
    // regardless of the channel separation of the two datasets:
    animator.startMovie();

Motivation

To allow for easy control of movies, possibly synchonous on more than one WorldCanvas, as well as lay the basis for the userinterface for this, a central class is needed that controls sequences of DisplayData.

To Do

Definition at line 285 of file Animator.h.

Public Types

enum  NextMode
 Defines the way the Animator calculates the Z coordinate of the next frame in the sequence. More...
enum  MatchMode
 Defines wheter the sequence is defined using the index in the sequence or by the world coordinate of the 'Z-axis' (the "zValue" or "zIndex" used by the WorldCanvasHolders and the DisplayDatas), or only by the AttributeBuffers. More...
enum  UpdateMode
 Decides whether the Z coordinate should be changed according to the NextMode before each update or not. More...

Public Member Functions

 Animator ()
 Constructor.
virtual ~Animator ()
 Destrutor.
virtual void nextCoord ()
 Go to next Z coordinate in sequence.
virtual void prevCoord ()
 Go to previous Z coordinate in sequence.
virtual void gotoCoord (Double zCoord)
 Go to Z coordinate zCoord.
virtual void setMinAndMaxCoord (Double zMin, Double zMax)
 Set the minimum and maximum Z coordinate for the movie.
virtual void setMatchMode (Animator::MatchMode match)
 Set whether "zIndex", "zValue" or none of the two should be written additionally to the AttributeBuffers.
virtual void setNextMode (Animator::NextMode mode)
 Set the way the increments are done, ie.
virtual void setUpdateMode (Animator::UpdateMode mode)
 Set whether an increment should be done before each update (UPDATE_DIRECT or UPDATE_BLINK).
virtual void setUpdateInterval (Double interval)
 Set update interval of movie in milliseconds.
virtual void setBlinkRestrictions (List< void * > *attBuffers)
 Set the list of additional Attributes that the Animator places on the WorldCanvasHolders before each update.
virtual void clearBlinkRestrictions ()
 Remove the List with AttributeBuffers.
virtual uInt getMovieLength ()
 Return the length of the movie.
virtual Int getCurrentPosition ()
 Return the current position in the movie.
virtual void reset ()
 Reset the Animator.
virtual void addWorldCanvasHolder (WorldCanvasHolder *newHolder)
 Add a WorldCanvasHolder to the list controlled by this Animator.
virtual void removeWorldCanvasHolder (WorldCanvasHolder &holder)
 Remove a WorldCanvasHolder from the list controlled by this Animator.
virtual void operator() (const WCRefreshEvent &ev)
 Refresh event handler - just used to see if resetCoordinates was set.
virtual void setStep (uInt zIncrement)
 Set increment in the Z coordinate for the movie.
virtual void setStep (Double zIncrement)
virtual void setTolerance (uInt tolerance)
 Set the tolerance in the Z coordinate.
virtual void setTolerance (Double tolerance)
virtual void startMovie ()
 Stop and start movie.
virtual void stopMovie ()

Private Member Functions

void computeNextCoord (Int addOrSubtract)
 Compute, based on the UPDATE_MODE and NEXT_MODE, the Z coordinate of the new frame to display (ie.
void increment (Int &number, Int addOrSubtract)
 Helper routine for computeNewCoord().
void decrement (Int &number, Int addOrSubtract)
 Helper routine for computeNewCoord().
void increment (Double &number, Int addOrSubtract)
 Helper routine for computeNewCoord().
void decrement (Double &number, Int addOrSubtract)
 Helper routine for computeNewCoord().
void writeRestrictions ()
 Write the necessary Attributes to all the WorldCanvasHolders.
void refresh ()
 Invoke refresh() on all the WorldCanvasHolders registered with the Animator.
Int listLen ()
 Return the number of AttributeBuffers in the List of AttributeBuffer.

Private Attributes

List< void * > holderList
 List of WorldCanvasHolders.
List< void * > * attBufList
 List of the AttributeBuffers.
Double minCoord
 parameters of movies
Double maxCoord
Double movieStep
 Increment for computing currentCoord.
Double coordTolerance
 State variables Tolerance for coordinate Restriction.
Double currentCoord
 Current Z coordiante.
Animator::MatchMode matchMode
 the MatchMode
Animator::NextMode nextMode
 the NextMode
Animator::UpdateMode updateMode
 The UpdateMode.
Double updateInterval
 and the interval of the timer
Int numberInList
 The number of the AttributeBuffer to use.
Int movieDirection
 In which direction the movie is currently going.
AnimatorRefEHitsAnimatorRefEH
 refresh event handler


Member Enumeration Documentation

enum casa::Animator::NextMode

Defines the way the Animator calculates the Z coordinate of the next frame in the sequence.

This defines the behaviour of the member nextCoord().

Definition at line 292 of file Animator.h.

enum casa::Animator::MatchMode

Defines wheter the sequence is defined using the index in the sequence or by the world coordinate of the 'Z-axis' (the "zValue" or "zIndex" used by the WorldCanvasHolders and the DisplayDatas), or only by the AttributeBuffers.

Definition at line 311 of file Animator.h.

enum casa::Animator::UpdateMode

Decides whether the Z coordinate should be changed according to the NextMode before each update or not.

Definition at line 327 of file Animator.h.


Constructor & Destructor Documentation

casa::Animator::Animator (  ) 

Constructor.

virtual casa::Animator::~Animator (  )  [virtual]

Destrutor.


Member Function Documentation

virtual void casa::Animator::nextCoord (  )  [virtual]

Go to next Z coordinate in sequence.

virtual void casa::Animator::prevCoord (  )  [virtual]

Go to previous Z coordinate in sequence.

virtual void casa::Animator::gotoCoord ( Double  zCoord  )  [virtual]

Go to Z coordinate zCoord.

virtual void casa::Animator::setStep ( uInt  zIncrement  )  [virtual]

Set increment in the Z coordinate for the movie.

virtual void casa::Animator::setStep ( Double  zIncrement  )  [virtual]

virtual void casa::Animator::setTolerance ( uInt  tolerance  )  [virtual]

Set the tolerance in the Z coordinate.

virtual void casa::Animator::setTolerance ( Double  tolerance  )  [virtual]

virtual void casa::Animator::setMinAndMaxCoord ( Double  zMin,
Double  zMax 
) [virtual]

Set the minimum and maximum Z coordinate for the movie.

virtual void casa::Animator::setMatchMode ( Animator::MatchMode  match  )  [virtual]

Set whether "zIndex", "zValue" or none of the two should be written additionally to the AttributeBuffers.

virtual void casa::Animator::setNextMode ( Animator::NextMode  mode  )  [virtual]

Set the way the increments are done, ie.

it defines the action of nextCoord() (options NEXT_FORWARD, NEXT_BACKWARD, UPDATE_ROCKANDROLL)

virtual void casa::Animator::setUpdateMode ( Animator::UpdateMode  mode  )  [virtual]

Set whether an increment should be done before each update (UPDATE_DIRECT or UPDATE_BLINK).

virtual void casa::Animator::setUpdateInterval ( Double  interval  )  [virtual]

Set update interval of movie in milliseconds.

virtual void casa::Animator::setBlinkRestrictions ( List< void * > *  attBuffers  )  [virtual]

Set the list of additional Attributes that the Animator places on the WorldCanvasHolders before each update.

virtual void casa::Animator::clearBlinkRestrictions (  )  [virtual]

Remove the List with AttributeBuffers.

virtual void casa::Animator::startMovie (  )  [virtual]

Stop and start movie.

virtual void casa::Animator::stopMovie (  )  [virtual]

virtual uInt casa::Animator::getMovieLength (  )  [virtual]

Return the length of the movie.

In UpdateMode UPDATE_DIRECT this is the number of frames that follow from the minimum and maximum Z coordiante and the step. In UPDATE_BLINK mode this is the length of the List of AttributeBuffers set on the Animator using setBlinkAttributes

virtual Int casa::Animator::getCurrentPosition (  )  [virtual]

Return the current position in the movie.

This is really a bad thing, but needed in the interim for the viewer.

virtual void casa::Animator::reset (  )  [virtual]

Reset the Animator.

This will set the minimum coordiante to 0, the maximum to the number of elements registered with the WorldCanvasHolders, the step to 1.0 and the update mode to MATCH_INDEX

Referenced by casa::AniPosEH::resetAnimator().

virtual void casa::Animator::addWorldCanvasHolder ( WorldCanvasHolder newHolder  )  [virtual]

Add a WorldCanvasHolder to the list controlled by this Animator.

virtual void casa::Animator::removeWorldCanvasHolder ( WorldCanvasHolder holder  )  [virtual]

Remove a WorldCanvasHolder from the list controlled by this Animator.

virtual void casa::Animator::operator() ( const WCRefreshEvent ev  )  [virtual]

Refresh event handler - just used to see if resetCoordinates was set.

If so, then we should partially reset the animator.

void casa::Animator::computeNextCoord ( Int  addOrSubtract  )  [private]

Compute, based on the UPDATE_MODE and NEXT_MODE, the Z coordinate of the new frame to display (ie.

the new currentCoord). If the updateMode == UPDATE_BLINK, nothing happens. If the updateMode == UPDATE_DIRECT, the value of currentCoord is incremented or decremented with the absolute value of movieStep, depending in whether the next_Mode is NEXT_FORWARD, NEXT_BACKWARD or NEXT_ROCKANDROLL and whether the new value goes outside the bounds set by minCoord and maxCoord.

void casa::Animator::increment ( Int number,
Int  addOrSubtract 
) [private]

Helper routine for computeNewCoord().

If addOrSubtract > 0, 1 is added to number, if addOrSubtract < 0, 1 is subtracted

void casa::Animator::decrement ( Int number,
Int  addOrSubtract 
) [private]

Helper routine for computeNewCoord().

The inverse of increment(Int&, Int)

void casa::Animator::increment ( Double number,
Int  addOrSubtract 
) [private]

Helper routine for computeNewCoord().

If addOrSubtract > 0, movieStep is added to number, if addOrSubtract < 0, movieStep is subtracted

void casa::Animator::decrement ( Double number,
Int  addOrSubtract 
) [private]

Helper routine for computeNewCoord().

The inverse of increment(Double&, Int)

void casa::Animator::writeRestrictions (  )  [private]

Write the necessary Attributes to all the WorldCanvasHolders.

The content of one of the registered AttributeBuffer is always written. If the updateMode == UPDATE_DIRECT the n-th AttributeBuffer is written, where n is the sequence number of the frame, based on minCoord and movieStep. If the updateMode == UPDATE_BLINK the Animator just loops through the list of AttributeBuffers based on numberInList. If MatchMode == MATCH_INDEX also an Attribute is written with name "zIndex" and with the value of currentCoord. If MatchMode == MATCH_COORD also an Attribute is written with name "zValue" and with the value of currentCoord.

void casa::Animator::refresh (  )  [private]

Invoke refresh() on all the WorldCanvasHolders registered with the Animator.

Int casa::Animator::listLen (  )  [private]

Return the number of AttributeBuffers in the List of AttributeBuffer.


Member Data Documentation

List<void *> casa::Animator::holderList [private]

List of WorldCanvasHolders.

Definition at line 427 of file Animator.h.

List<void *>* casa::Animator::attBufList [private]

List of the AttributeBuffers.

Definition at line 430 of file Animator.h.

Double casa::Animator::minCoord [private]

parameters of movies

Definition at line 433 of file Animator.h.

Double casa::Animator::maxCoord [private]

Definition at line 434 of file Animator.h.

Double casa::Animator::movieStep [private]

Increment for computing currentCoord.

Always postive

Definition at line 437 of file Animator.h.

Double casa::Animator::coordTolerance [private]

State variables Tolerance for coordinate Restriction.

Definition at line 441 of file Animator.h.

Double casa::Animator::currentCoord [private]

Current Z coordiante.

Definition at line 443 of file Animator.h.

Animator::MatchMode casa::Animator::matchMode [private]

the MatchMode

Definition at line 445 of file Animator.h.

Animator::NextMode casa::Animator::nextMode [private]

the NextMode

Definition at line 447 of file Animator.h.

Animator::UpdateMode casa::Animator::updateMode [private]

The UpdateMode.

Definition at line 449 of file Animator.h.

Double casa::Animator::updateInterval [private]

and the interval of the timer

Definition at line 451 of file Animator.h.

Int casa::Animator::numberInList [private]

The number of the AttributeBuffer to use.

Computed by computeNewCoord() Has to be Int, not uInt! (because I sometimes subtract 1!)

Definition at line 455 of file Animator.h.

Int casa::Animator::movieDirection [private]

In which direction the movie is currently going.

Definition at line 458 of file Animator.h.

AnimatorRefEH* casa::Animator::itsAnimatorRefEH [private]

refresh event handler

Definition at line 506 of file Animator.h.


The documentation for this class was generated from the following file:
Generated on Mon Sep 1 22:48:27 2008 for NRAOCASA by  doxygen 1.5.1