casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
casa::Animator Class Reference

Animation controller for WorldCanvasHolders. More...

#include <Animator.h>

Public Types

enum  NextMode {
  NEXT_FORWARD,
  NEXT_BACKWARD,
  NEXT_ROCKANDROLL
}
 Defines the way the Animator calculates the Z coordinate of the next frame in the sequence. More...
 
enum  MatchMode {
  MATCH_INDEX,
  MATCH_WORLD,
  MATCH_LIST_ONLY
}
 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 {
  UPDATE_DIRECT,
  UPDATE_BLINK
}
 Decides whether the Z coordinate should be changed according to the NextMode before each update or not. More...
 

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

Animation controller for WorldCanvasHolders.

Intended use:

Public interface

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 casacore::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 casacore::List to contain the AttributeBuffers
// and an iterator for this list
// 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 casacore::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 casacore::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.

Member Enumeration Documentation

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.

Enumerator
MATCH_INDEX 

casacore::Sequence is defined by writing Attribute "zIndex" with the value of the Z coordinate to WorldCanvasHolders, plus the ones from the casacore::List of AttributeBuffers.

This is the default

MATCH_WORLD 

casacore::Sequence is defined by writing Attribute "zValue"with the value of the Z coordinate to WorldCanvasHolders, plus the ones from the casacore::List of AttributeBuffers

MATCH_LIST_ONLY 

Only the Attributes from the casacore::List of AttributeBuffers are written.

Definition at line 311 of file Animator.h.

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

This defines the behaviour of the member nextCoord().

Enumerator
NEXT_FORWARD 

Movie in forward direction.

Step is added, if the Z coordinate is larger than maximum then display minimum, increment again until maximum, etc. This is the default.

NEXT_BACKWARD 

Movie in backward direction.

Step is subtracted, if Z coordinate is smaller than mimnimum then display maximum, decrement until minimum, etc etc

NEXT_ROCKANDROLL 

Movie goes up and down the sequence.

Step is added until the Z coordinate is larger than maximum, then step is subtracted until the Z coordinate is smaller than minimum, then step is added, and so on, and so on

Definition at line 292 of file Animator.h.

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

Enumerator
UPDATE_DIRECT 

Do change the Z coordinate before each update.

Use this for 'normal movies'. This is the default.

UPDATE_BLINK 

Do not change Z coordinate, but rely on the AttributeBuffers to change what is displayed.

Use this for blinking.

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::addWorldCanvasHolder ( WorldCanvasHolder newHolder)
virtual

Add a WorldCanvasHolder to the list controlled by this Animator.

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

Remove the casacore::List with AttributeBuffers.

void casa::Animator::computeNextCoord ( casacore::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::decrement ( casacore::Int number,
casacore::Int  addOrSubtract 
)
private

Helper routine for computeNewCoord().

The inverse of increment(casacore::Int&, casacore::Int)

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

Helper routine for computeNewCoord().

The inverse of increment(casacore::Double&, casacore::Int)

virtual casacore::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 casacore::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 casacore::List of AttributeBuffers set on the Animator using setBlinkAttributes

virtual void casa::Animator::gotoCoord ( casacore::Double  zCoord)
virtual

Go to Z coordinate zCoord.

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

Helper routine for computeNewCoord().

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

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

Helper routine for computeNewCoord().

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

casacore::Int casa::Animator::listLen ( )
private

Return the number of AttributeBuffers in the casacore::List of AttributeBuffer.

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

Go to next Z coordinate in sequence.

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.

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

Go to previous Z coordinate in sequence.

void casa::Animator::refresh ( )
private

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

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

Remove a WorldCanvasHolder from the list controlled by this Animator.

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::setBlinkRestrictions ( std::list< void * > *  attBuffers)
virtual

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

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::setMinAndMaxCoord ( casacore::Double  zMin,
casacore::Double  zMax 
)
virtual

Set the minimum and maximum Z coordinate for the movie.

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::setStep ( casacore::uInt  zIncrement)
virtual

Set increment in the Z coordinate for the movie.

virtual void casa::Animator::setStep ( casacore::Double  zIncrement)
virtual
virtual void casa::Animator::setTolerance ( casacore::uInt  tolerance)
virtual

Set the tolerance in the Z coordinate.

virtual void casa::Animator::setTolerance ( casacore::Double  tolerance)
virtual
virtual void casa::Animator::setUpdateInterval ( casacore::Double  interval)
virtual

Set update interval of movie in milliseconds.

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::startMovie ( )
virtual

Stop and start movie.

virtual void casa::Animator::stopMovie ( )
virtual
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.

Member Data Documentation

std::list<void *>* casa::Animator::attBufList
private

casacore::List of the AttributeBuffers

Definition at line 430 of file Animator.h.

casacore::Double casa::Animator::coordTolerance
private

State variables Tolerance for coordinate Restriction.

Definition at line 441 of file Animator.h.

casacore::Double casa::Animator::currentCoord
private

Current Z coordiante.

Definition at line 443 of file Animator.h.

std::list<void *> casa::Animator::holderList
private

casacore::List of WorldCanvasHolders

Definition at line 427 of file Animator.h.

AnimatorRefEH* casa::Animator::itsAnimatorRefEH
private

refresh event handler

Definition at line 506 of file Animator.h.

Animator::MatchMode casa::Animator::matchMode
private

the MatchMode

Definition at line 445 of file Animator.h.

casacore::Double casa::Animator::maxCoord
private

Definition at line 434 of file Animator.h.

casacore::Double casa::Animator::minCoord
private

parameters of movies

Definition at line 433 of file Animator.h.

casacore::Int casa::Animator::movieDirection
private

In which direction the movie is currently going.

Definition at line 458 of file Animator.h.

casacore::Double casa::Animator::movieStep
private

Increment for computing currentCoord.

Always postive

Definition at line 437 of file Animator.h.

Animator::NextMode casa::Animator::nextMode
private

the NextMode

Definition at line 447 of file Animator.h.

casacore::Int casa::Animator::numberInList
private

The number of the AttributeBuffer to use.

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

Definition at line 455 of file Animator.h.

casacore::Double casa::Animator::updateInterval
private

and the interval of the timer

Definition at line 451 of file Animator.h.

Animator::UpdateMode casa::Animator::updateMode
private

The UpdateMode.

Definition at line 449 of file Animator.h.


The documentation for this class was generated from the following file: