Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::animation::Animation Class Reference

#include <animation.h>

+ Inheritance diagram for inviwo::animation::Animation:

Public Types

using iterator = util::IndirectIterator<typename std::vector<std::unique_ptr<Track>>::iterator>
 
using const_iterator
 

Public Member Functions

 Animation (AnimationManager *animationManager=nullptr, std::string_view name="Animation")
 
 Animation (const Animation &)
 
 Animation (Animation &&)=default
 
Animationoperator= (const Animation &that)
 
Animationoperator= (Animation &&that)=default
 
AnimationTimeState operator() (Seconds from, Seconds to, AnimationState state) const
 
bool empty () const
 
size_t size () const
 
Trackoperator[] (size_t i)
 
const Trackoperator[] (size_t i) const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void add (std::unique_ptr< Track > track)
 
BasePropertyTrackadd (Property *property)
 
KeyframeaddKeyframe (Property *property, Seconds time)
 
KeyframeSequenceaddKeyframeSequence (Property *property, Seconds time)
 
std::unique_ptr< Trackremove (size_t i)
 
std::unique_ptr< Trackremove (Track *track)
 
std::unique_ptr< Keyframeremove (Keyframe *key)
 
std::unique_ptr< KeyframeSequenceremove (KeyframeSequence *seq)
 
iterator findTrack (Property *withMe)
 
template<typename TrackType >
bool hasTrackType () const
 
template<typename TrackType >
std::ranges::view auto getTracksOfType ()
 
void clear ()
 
std::vector< Seconds > getAllTimes () const
 
Seconds getFirstTime () const
 
Seconds getLastTime () const
 
std::optional< Seconds > getPrevTime (Seconds at) const
 
std::optional< Seconds > getNextTime (Seconds at) const
 
const std::string & getName () const
 
void setName (std::string_view name)
 
virtual void serialize (Serializer &s) const override
 
virtual void deserialize (Deserializer &d) override
 
virtual void onWillRemoveProperty (Property *property, size_t index) override
 
- Public Member Functions inherited from inviwo::Observable< AnimationObserver >
 Observable (const Observable< AnimationObserver > &other)
 
 Observable (Observable< AnimationObserver > &&other) noexcept
 
Observable< AnimationObserver > & operator= (const Observable< AnimationObserver > &other)
 
Observable< AnimationObserver > & operator= (Observable< AnimationObserver > &&other) noexcept
 
void addObserver (AnimationObserver *observer)
 
void removeObserver (AnimationObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::ObservableInterface
- Public Member Functions inherited from inviwo::Serializable
- Public Member Functions inherited from inviwo::animation::TrackObserver
virtual void onKeyframeSequenceAdded (Track *, KeyframeSequence *)
 
virtual void onKeyframeSequenceRemoved (Track *, KeyframeSequence *)
 
virtual void onEnabledChanged (Track *)
 
virtual void onNameChanged (Track *)
 
- Public Member Functions inherited from inviwo::Observer
 Observer (const Observer &other)
 
 Observer (Observer &&other)
 
Observeroperator= (Observer &&other)
 
Observeroperator= (const Observer &other)
 
virtual ~Observer ()
 
void removeObservation (ObservableInterface *observable)
 
void removeObservations ()
 
- Public Member Functions inherited from inviwo::PropertyOwnerObserver
virtual void onWillAddProperty (PropertyOwner *owner, Property *property, size_t index)
 
virtual void onDidAddProperty (Property *property, size_t index)
 
virtual void onDidRemoveProperty (PropertyOwner *owner, Property *property, size_t index)
 

Additional Inherited Members

- Public Attributes inherited from inviwo::PropertyOwnerObserver
friend PropertyOwnerObservable
 
- Protected Member Functions inherited from inviwo::animation::AnimationObservable
void notifyTrackAdded (Track *track)
 
void notifyTrackRemoved (Track *track)
 
void notifyFirstMoved ()
 
void notifyLastMoved ()
 
void notifyNameChanged (Animation *anim)
 
- Protected Member Functions inherited from inviwo::Observable< AnimationObserver >
void forEachObserver (C callback)
 
- Protected Member Functions inherited from inviwo::ObservableInterface
void addObservationHelper (Observer *observer)
 
void removeObservationHelper (Observer *observer)
 
- Protected Member Functions inherited from inviwo::Observer
void addObservation (ObservableInterface *observable)
 
- Protected Attributes inherited from inviwo::Observer
std::unordered_set< ObservableInterface * > observables_
 

Detailed Description

Animation data structure, owns a list of tracks. Each Track usually represents a value to be animated.

Member Typedef Documentation

◆ const_iterator

Initial value:
util::IndirectIterator<typename std::vector<std::unique_ptr<Track>>::const_iterator>

Constructor & Destructor Documentation

◆ Animation()

inviwo::animation::Animation::Animation ( AnimationManager * animationManager = nullptr,
std::string_view name = "Animation" )

Creates an empty Animation. AnimationManager is required only for the Property-based adding convenience functions: add(Property* property) addKeyframe(Property* property, Seconds time) addKeyframeSequence(Property* property, Seconds time) Trying to use these functions with an invalid AnimationManager will throw Exceptions.

Note
nullptr to AnimationManager should mainly be used for unit testing and the likes.
Parameters
animationManagerused for creating PropertyTrack/KeyframeSequence/Keyframe.
namedefault Animation

Member Function Documentation

◆ add()

BasePropertyTrack * inviwo::animation::Animation::add ( Property * property)

Adds a PropertyTrack, or returns an existing it has one for the property. The added PropertyTrack will be removed if the property is removed.

Returns
BasePropertyTrack if added, nullptr otherwise.
See also
BasePropertyTrack
Exceptions
Exceptionif no AnimationManager has been supplied.

◆ addKeyframe()

Keyframe * inviwo::animation::Animation::addKeyframe ( Property * property,
Seconds time )

Add keyframe at specified time. Creates a new track if no track with the supplied property exists. The PropertyTrack will be removed if the property is removed.

Returns
Keyframe if successsfully added, nullptr otherwise.
Exceptions
Exceptionif no AnimationManager has been supplied.

◆ addKeyframeSequence()

KeyframeSequence * inviwo::animation::Animation::addKeyframeSequence ( Property * property,
Seconds time )

Add sequence at specified time. Creates a new track if no track with the supplied property exists. The PropertyTrack will be removed if the property is removed.

Returns
KeyframeSequence if successsfully added, nullptr otherwise.
Exceptions
Exceptionif no AnimationManager has been supplied.

◆ clear()

void inviwo::animation::Animation::clear ( )

Remove all tracks. Calls TrackObserver::notifyTrackRemoved for each removed track.

◆ deserialize()

virtual void inviwo::animation::Animation::deserialize ( Deserializer & d)
overridevirtual

Implements inviwo::Serializable.

◆ findTrack()

iterator inviwo::animation::Animation::findTrack ( Property * withMe)

Find PropertyTrack containing the property.

Returns
iterator to the first PropertyTrack containing the specified property, or end() if not found.
See also
BasePropertyTrack

◆ getAllTimes()

std::vector< Seconds > inviwo::animation::Animation::getAllTimes ( ) const

Return a sorted list, in ascending order, of all Keyframe times existing in the animation.

◆ getFirstTime()

Seconds inviwo::animation::Animation::getFirstTime ( ) const

Return time of first Keyframe in all tracks, or 0 if no track exist.

◆ getLastTime()

Seconds inviwo::animation::Animation::getLastTime ( ) const

Return time of last Keyframe in all tracks, or 0 if no track exist.

◆ getName()

const std::string & inviwo::animation::Animation::getName ( ) const

Return the name of the Animation. Used for display in the GUI.

◆ getNextTime()

std::optional< Seconds > inviwo::animation::Animation::getNextTime ( Seconds at) const

Return time of closest next Keyframe in all tracks if found.

◆ getPrevTime()

std::optional< Seconds > inviwo::animation::Animation::getPrevTime ( Seconds at) const

Return time of closest previous Keyframe in all tracks if found.

◆ getTracksOfType()

template<typename TrackType >
std::ranges::view auto inviwo::animation::Animation::getTracksOfType ( )

Find Track of a given type.

Returns
View of all tracks of the specified type.

◆ hasTrackType()

template<typename TrackType >
bool inviwo::animation::Animation::hasTrackType ( ) const

Check if any track of TrackType has been added.

Returns
True if any of the tracks are of the provided type, false otherwise.

◆ onWillRemoveProperty()

virtual void inviwo::animation::Animation::onWillRemoveProperty ( Property * property,
size_t index )
overridevirtual

Reimplemented from inviwo::PropertyOwnerObserver.

◆ remove() [1/4]

std::unique_ptr< Keyframe > inviwo::animation::Animation::remove ( Keyframe * key)

Remove Keyframe if matching any of the Keyframes in the tracks. Calls TrackObserver::notifyKeyframeRemoved after removing Keyframe. Removes the KeyFrameSequence owning the Keyframe if it does not contain any Keyframe after removal, thereby calling KeyFrameSequenceObserver::notifyKeyframeSequenceRemoved Does nothing if no match was found.

Note
Keyframe will be deleted if removed so do not use pointer after calling this function.

◆ remove() [2/4]

std::unique_ptr< KeyframeSequence > inviwo::animation::Animation::remove ( KeyframeSequence * seq)

Remove KeyframeSequence if matching any of the Sequences in the tracks. Calls KeyFrameSequenceObserver::notifyKeyframeSequenceRemoved for the sequence removed and TrackObserver::notifyKeyframeRemoved for every removed keyframe. Does nothing if no match was found.

Note
KeyframeSequences and its Keyframes will be deleted if removed so do not use pointer after calling this function.

◆ remove() [3/4]

std::unique_ptr< Track > inviwo::animation::Animation::remove ( size_t i)

Remove tracks at index i, indicating the order in which the track was added, not the order in which they are sorted by Track priority. No range check is done. Calls TrackObserver::notifyTrackRemoved after removing track.

◆ remove() [4/4]

std::unique_ptr< Track > inviwo::animation::Animation::remove ( Track * track)

Remove Track if matching any of the tracks. Calls AnimationObservable::notifyTrackRemoved after removing Track.

Note
Track will be deleted if removed so do not use pointer after calling this function.

◆ serialize()

virtual void inviwo::animation::Animation::serialize ( Serializer & s) const
overridevirtual

Implements inviwo::Serializable.

◆ setName()

void inviwo::animation::Animation::setName ( std::string_view name)

Set new name and notify observers if different from old name.


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