Next: Atom
Up: Molecule objects
Previous: Molecule objects
  Contents
Subsections
Animation
Files: |
Animation.h,
Animation.C |
Derived from: |
none |
Global instance (if any): |
none |
Used in optional component: |
Part of main VMD code |
Animation is a base class for all Molecule objects in VMD.
It is responsible for storing the dynamic data for molecule - those
items which vary with time, instead of remaining constant. Animation
stores an animation list, and has controls to add new data to the
end of the list, as well as to position a current frame pointer in
the list. Each time a Molecule is prepared (by calling it's
virtual prepare routine since Molecule is derived from
Displayable), the current position in the animation list is updated.
The Animation consists of basically an array of Timestep
objects. Each Timestep contains the data for the molecule for a
single step in the trajectory of the system.
The AnimDir enumeration lists the different directions in which the
animation can be moving:
- FORWARD: Animation proceeds continually forward each update.
- FORWARD1: Animation goes to the next step, then is PAUSEd.
- REVERSE: Animation proceeds continually backward each update.
- REVERSE1: Animation goes to the prev step, then is PAUSEd.
- PAUSE: Updates to not change the current position in the list.
The AnimPos enumeration lists different positions in the list to which
the animation position can jump, or can have new elements inserted or deleted:
- END: The end of the animation list.
- START: The start of the animation list.
- BEFORE: The frame before a specified frame.
- AFTER: The frame after a specified frame.
- DELETE: Unused.
- WRITE: Unused.
The AnimFrames enumeration lists the different ways in which frames
can be added or deleted. It is either ALL, or SELECTION.
The AnimStyle enumeration lists the different ways in which animation
can be done:
- ONCE: When the animation gets to the end or beginning, it will
then pause.
- LOOP: When the animation gets to the end or beginning, loop
around to the other end and continue through again in the same direction.
- ROCK: When the animation gets to the end or beginning, reverse
direction and continue animating.
- double lastTime - the clock time when the last position was
determined. This is used to determine if the animation should proceed to
a new frame, to control the speed.
- int frameChanged - whether the animation has changed to a
new frame recently.
- int needSetFrameChanged - when this flag is set, then the
frameChanged flag should be changed the next time it is possible to do
so.
- ResizeArray<Timestep *> tsList - the frames themselves.
- int currFrame - the current frame, an index into tsList.
- int frameSkip - if we are jumping to a new frame, this
indicates the frame to jump to.
- float Speed - the animation speed, from 0 (slowest) to 1
(fastest).
- AnimPos appendPos - the method to use the next time a frame
is to be appended.
- int appendFrame - if we are inserting frames, the frame which
we are to append before or after.
- AnimDir animDir - the current animation direction.
- AnimStyle animStyle - the method for doing animation.
- int moveTo - if this is not negative, this indicates a frame
to which we are to jump the next time the animation position is updated.
- float currTime - the time which has elapsed since the
beginning of the animation.
- int num(void) - returns current number of frames in the list.
- int frame(void) - returns the current frame number.
- int is_current(void) - returns whether there is a
current frame.
- Timestep *current(void) - returns the current frame itself,
or NULL if there is none.
- Timestep *item(int) - returns the Nth frame.
- void goto_frame(int) - jump to the specified frame.
- int has_frame_changed(void) - returns whether the current
frame has been changed recently.
- void delete_animation(void) - deletes all the currently
stored frames.
- void delete_frame(int) - delete the Nth frame.
- int append_frame(Timestep *) - adds the given frame to the
end of the animation list (or wherever has been previously determined for it
to be placed).
- int anim_update(void) - updates the current position of the
animation in the list, based on the current animation mode, and returns the
index of the new current frame. Also sets the flags indicating whether the
frame has changed. This is called during each call to prepare in the
Molecule object.
- void append_end(void) - indicate to append the next frame at
the end of the list.
- void append_start(void) - indicate to append the next frame at
the start of the list.
- void append_after(int) - indicate to append the next frame
after the specified frame.
- void append_before(int) - indicate to append the next frame
before the specified frame.
- void skip(int) - set the current frame skip rate (the increment
by which the current frame pointer is changed).
- int skip(void) - return the current frame skip rate.
- void anim_dir(AnimDir) - set the current animation direction.
- AnimDir anim_dir(void) - return the animation direction.
- void anim_style(AnimStyle) - set the animation method.
- AnimSTyle anim_style(void) - return the animation method.
- float speed(float) - set the speed of the animation.
- float speed(void) - return the current animation speed.
To add new frames, do the following:
- Set the method for appending, either at the end, or beginning, or
before or after some current frame.
- Call the append routine.
The anim_update routine
changes the current position based on the current animation direction
and style. It also sets flags indicating whether the current frame was
changed any. It will return the index of the new current frame, which
can be used to get the actual Timestep object for that frame.
Right now, this is very top-level base class for Molecule, even higher
than the BaseMolecule level. The functionality here could probably
be rolled into BaseMolecule, so that a single class would have info
about the structure and size of the molecule is was storing dynamic data for.
Basically, it's backwards to have Animate above BaseMolecule.
Next: Atom
Up: Molecule objects
Previous: Molecule objects
  Contents
vmd@ks.uiuc.edu