#include <cInterval.h>
Inheritance diagram for CInterval:
Public Types | |
enum | EventType { ET_initialize, ET_instant, ET_step, ET_finalize, ET_reverse_initialize, ET_reverse_instant, ET_reverse_finalize, ET_interrupt } |
enum | State { S_initial, S_started, S_paused, S_final } |
Public Member Functions | |
CInterval (const string &name, double duration, bool open_ended) | |
const string & | get_name () const |
Returns the interval's name. | |
double | get_duration () const |
Returns the duration of the interval in seconds. | |
bool | get_open_ended () const |
Returns the state of the "open_ended" flag. | |
State | get_state () const |
Indicates the state the interval believes it is in: whether it has been started, is currently in the middle, or has been finalized. | |
bool | is_stopped () const |
Returns true if the interval is in either its initial or final states (but not in a running or paused state). | |
void | set_done_event (const string &event) |
Sets the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own. | |
const string & | get_done_event () const |
Returns the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own. | |
void | set_t (double t) |
Explicitly sets the time within the interval. | |
double | get_t () const |
Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize(). | |
void | set_auto_pause (bool auto_pause) |
Changes the state of the 'auto_pause' flag. | |
bool | get_auto_pause () const |
Returns the state of the 'auto_pause' flag. | |
void | set_auto_finish (bool auto_finish) |
Changes the state of the 'auto_finish' flag. | |
bool | get_auto_finish () const |
Returns the state of the 'auto_finish' flag. | |
void | set_wants_t_callback (bool wants_t_callback) |
Changes the state of the 'wants_t_callback' flag. | |
bool | get_wants_t_callback () const |
Returns the state of the 'wants_t_callback' flag. | |
void | set_manager (CIntervalManager *manager) |
Indicates the CIntervalManager object which will be responsible for playing this interval. | |
CIntervalManager * | get_manager () const |
Returns the CIntervalManager object which will be responsible for playing this interval. | |
void | start (double start_t=0.0, double end_t=-1.0, double play_rate=1.0) |
Starts the interval playing by registering it with the current CIntervalManager. | |
void | loop (double start_t=0.0, double end_t=-1.0, double play_rate=1.0) |
Starts the interval playing by registering it with the current CIntervalManager. | |
double | pause () |
Stops the interval from playing but leaves it in its current state. | |
void | resume () |
Restarts the interval from its current point after a previous call to pause(). | |
void | resume (double start_t) |
Restarts the interval from the indicated point after a previous call to pause(). | |
void | finish () |
Stops the interval from playing and sets it to its final state. | |
bool | is_playing () const |
Returns true if the interval is currently playing, false otherwise. | |
void | priv_do_event (double t, EventType event) |
Calls the appropriate event function indicated by the EventType. | |
virtual void | priv_initialize (double t) |
This replaces the first call to priv_step(), and indicates that the interval has just begun. | |
virtual void | priv_instant () |
This is called in lieu of priv_initialize() .. | |
virtual void | priv_step (double t) |
Advances the time on the interval. | |
virtual void | priv_finalize () |
This is called to stop an interval, forcing it to whatever state it would be after it played all the way through. | |
virtual void | priv_reverse_initialize (double t) |
Similar to priv_initialize(), but this is called when the interval is being played backwards; it indicates that the interval should start at the finishing state and undo any intervening intervals. | |
virtual void | priv_reverse_instant () |
This is called in lieu of priv_reverse_initialize() .. | |
virtual void | priv_reverse_finalize () |
Called generally following a priv_reverse_initialize(), this indicates the interval should set itself to the initial state. | |
virtual void | priv_interrupt () |
This is called while the interval is playing to indicate that it is about to be interrupted; that is, priv_step() will not be called for a length of time. | |
virtual void | output (ostream &out) const |
virtual void | write (ostream &out, int indent_level) const |
void | setup_play (double start_time, double end_time, double play_rate, bool do_loop) |
Called to prepare the interval for automatic timed playback, e.g. | |
void | setup_resume () |
Called to prepare the interval for restarting at the current point within the interval after an interruption. | |
bool | step_play () |
Should be called once per frame to execute the automatic timed playback begun with setup_play(). | |
void | mark_dirty () |
Called by a derived class to indicate the interval has been changed internally and must be recomputed before its duration may be returned. | |
bool | check_t_callback () |
Returns true if the wants_t_callback() flag is true and the interval's t value has changed since the last call to check_t_callback(), false otherwise. | |
virtual TypeHandle | get_type () const |
virtual TypeHandle | force_init_type () |
int | get_type_index () const |
bool | is_of_type (TypeHandle handle) const |
bool | is_exact_type (TypeHandle handle) const |
int | get_ref_count () const |
int | ref () const |
int | unref () const |
void | test_ref_count_integrity () const |
Static Public Member Functions | |
TypeHandle | get_class_type () |
void | init_type () |
Protected Member Functions | |
void | interval_done () |
Called internally whenever the interval reaches its final state. | |
void | recompute () const |
Calls do_recompute() if the dirty flag has been set. | |
virtual void | do_recompute () |
Does whatever processing is necessary to recompute the interval after a call to mark_dirty() has indicated a recomputation is necessary. | |
void | check_stopped (TypeHandle type, const char *method_name) const |
Issues a warning if our internal state is not in one of the stopped states. | |
void | check_started (TypeHandle type, const char *method_name) const |
Issues a warning if our internal state is not in one of the started states. | |
Protected Attributes | |
State | _state |
double | _curr_t |
string | _name |
string | _done_event |
double | _duration |
bool | _auto_pause |
bool | _auto_finish |
bool | _wants_t_callback |
double | _last_t_callback |
CIntervalManager * | _manager |
double | _clock_start |
double | _start_t |
double | _end_t |
bool | _end_t_at_end |
bool | _start_t_at_start |
double | _play_rate |
bool | _do_loop |
int | _loop_count |
int | _ref_count |
Private Types | |
typedef pvector< CInterval * > | Parents |
Private Attributes | |
bool | _open_ended |
bool | _dirty |
Parents | _parents |
Static Private Attributes | |
TypeHandle | _type_handle |
Friends | |
class | CMetaInterval |
A CInterval represents a single action, event, or collection of nested intervals that will be performed at some specific time or over a period of time.
This is essentially similar to the Python "Interval" class, but it is implemented in C++ (hence the name). Intervals that may be implemented in C++ will inherit from this class; Intervals that must be implemented in Python will inherit from the similar Python class.
Definition at line 57 of file cInterval.h.
|
Definition at line 180 of file cInterval.h. |
|
Definition at line 66 of file cInterval.h. |
|
Definition at line 77 of file cInterval.h. |
|
Definition at line 41 of file cInterval.cxx. References _auto_finish, _auto_pause, _clock_start, _do_loop, _duration, _end_t, _end_t_at_end, _last_t_callback, _loop_count, _manager, _play_rate, _start_t, _start_t_at_start, _wants_t_callback, CIntervalManager::get_global_ptr(), and nassertv. |
|
Issues a warning if our internal state is not in one of the started states.
Definition at line 392 of file cInterval.I. Referenced by CMetaInterval::priv_initialize(), and priv_step(). |
|
Issues a warning if our internal state is not in one of the stopped states.
Definition at line 372 of file cInterval.I. Referenced by CMetaInterval::get_interval_end_time(), is_playing(), priv_do_event(), priv_initialize(), ShowInterval::priv_instant(), HideInterval::priv_instant(), and CMetaInterval::priv_step(). |
|
Returns true if the wants_t_callback() flag is true and the interval's t value has changed since the last call to check_t_callback(), false otherwise.
Definition at line 338 of file cInterval.I. |
|
Does whatever processing is necessary to recompute the interval after a call to mark_dirty() has indicated a recomputation is necessary.
Reimplemented in CMetaInterval. Definition at line 781 of file cInterval.cxx. |
|
Stops the interval from playing and sets it to its final state.
Definition at line 216 of file cInterval.cxx. References ET_finalize, ET_interrupt, ET_reverse_finalize, ET_reverse_initialize, ET_reverse_instant, and ET_step. |
|
Reimplemented from TypedReferenceCount. Reimplemented in CLerpAnimEffectInterval, CLerpInterval, CLerpNodePathInterval, CMetaInterval, HideInterval, ShowInterval, and WaitInterval. Definition at line 195 of file cInterval.h. |
|
Returns the state of the 'auto_finish' flag. See set_auto_finish(). Definition at line 240 of file cInterval.I. |
|
Returns the state of the 'auto_pause' flag. See set_auto_pause(). Definition at line 200 of file cInterval.I. |
|
Reimplemented from TypedReferenceCount. Reimplemented in CLerpAnimEffectInterval, CLerpInterval, CLerpNodePathInterval, CMetaInterval, HideInterval, ShowInterval, and WaitInterval. Definition at line 184 of file cInterval.h. Referenced by WaitInterval::get_class_type(), CMetaInterval::get_class_type(), CLerpInterval::get_class_type(), WaitInterval::init_type(), CMetaInterval::init_type(), CLerpInterval::init_type(), is_playing(), priv_do_event(), priv_initialize(), and priv_step(). |
|
Returns the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own.
Definition at line 143 of file cInterval.I. References _auto_pause. |
|
Returns the duration of the interval in seconds.
Definition at line 45 of file cInterval.I. References _open_ended, and INLINE. Referenced by CMetaInterval::get_interval_end_time(), priv_do_event(), priv_finalize(), CMetaInterval::priv_instant(), priv_interrupt(), and priv_reverse_initialize(). |
|
Returns the CIntervalManager object which will be responsible for playing this interval. Note that this can only return a C++ object; if the particular CIntervalManager object has been extended in the scripting language, this will return the encapsulated C++ object, not the full extended object. Definition at line 321 of file cInterval.I. |
|
Returns the interval's name.
Definition at line 32 of file cInterval.I. References _duration, INLINE, and recompute(). Referenced by get_wants_t_callback(), priv_finalize(), CMetaInterval::priv_reverse_instant(), set_wants_t_callback(), and CIntervalManager::~CIntervalManager(). |
|
Returns the state of the "open_ended" flag. This is primarily intended for instantaneous intervals like FunctionIntervals; it indicates true if the interval has some lasting effect that should be applied even if the interval doesn't get started until after its finish time, or false if the interval is a transitive thing that doesn't need to be called late. Definition at line 71 of file cInterval.I. References _state, INLINE, S_final, and S_initial. Referenced by setup_play(). |
|
Indicates the state the interval believes it is in: whether it has been started, is currently in the middle, or has been finalized.
Definition at line 88 of file cInterval.I. References _done_event, and INLINE. Referenced by pause(). |
|
Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize().
Definition at line 160 of file cInterval.I. Referenced by priv_reverse_finalize(). |
|
Reimplemented from TypedReferenceCount. Reimplemented in CLerpAnimEffectInterval, CLerpInterval, CLerpNodePathInterval, CMetaInterval, HideInterval, ShowInterval, and WaitInterval. Definition at line 192 of file cInterval.h. |
|
Returns the state of the 'wants_t_callback' flag. Definition at line 277 of file cInterval.I. References _state, get_name(), TypeHandle::get_name(), INLINE, nassertv, S_paused, S_started, and verify_intervals. |
|
Reimplemented from TypedReferenceCount. Reimplemented in CLerpAnimEffectInterval, CLerpInterval, CLerpNodePathInterval, CMetaInterval, HideInterval, ShowInterval, and WaitInterval. Definition at line 187 of file cInterval.h. References INLINE. Referenced by WaitInterval::init_type(), CMetaInterval::init_type(), and CLerpInterval::init_type(). |
|
Called internally whenever the interval reaches its final state.
Definition at line 762 of file cInterval.cxx. Referenced by CMetaInterval::get_interval_end_time(), priv_do_event(), and CMetaInterval::priv_instant(). |
|
Returns true if the interval is currently playing, false otherwise.
Definition at line 246 of file cInterval.cxx. References _state, check_stopped(), get_class_type(), priv_step(), recompute(), S_started, and t. |
|
Returns true if the interval is in either its initial or final states (but not in a running or paused state).
Definition at line 105 of file cInterval.I. Referenced by setup_play(). |
|
Starts the interval playing by registering it with the current CIntervalManager. The interval will play until it is interrupted with finish() or pause(), looping back to start_t when it reaches end_t. If end_t is less than zero, it indicates the end of the interval. Definition at line 143 of file cInterval.cxx. References _manager, CIntervalManager::add_c_interval(), and setup_resume(). |
|
Called by a derived class to indicate the interval has been changed internally and must be recomputed before its duration may be returned.
Definition at line 741 of file cInterval.cxx. Referenced by CMetaInterval::add_c_interval(), CMetaInterval::add_ext_index(), and CMetaInterval::push_level(). |
|
Reimplemented in CLerpAnimEffectInterval, and CLerpNodePathInterval. Definition at line 496 of file cInterval.cxx. |
|
Stops the interval from playing but leaves it in its current state. It may later be resumed from this point by calling resume(). Definition at line 161 of file cInterval.cxx. References _manager, CIntervalManager::find_c_interval(), get_state(), priv_finalize(), priv_instant(), S_final, and S_initial. |
|
Calls the appropriate event function indicated by the EventType.
Definition at line 262 of file cInterval.cxx. References _state, check_stopped(), get_class_type(), get_duration(), interval_done(), priv_step(), recompute(), S_final, and S_started. |
|
This is called to stop an interval, forcing it to whatever state it would be after it played all the way through. It's generally invoked by set_final_t(). Reimplemented in CMetaInterval. Definition at line 381 of file cInterval.cxx. References get_duration(), and get_name(). Referenced by pause(). |
|
This replaces the first call to priv_step(), and indicates that the interval has just begun. This may be overridden by derived classes that need to do some explicit initialization on the first call. Reimplemented in CLerpNodePathInterval, and CMetaInterval. Definition at line 316 of file cInterval.cxx. References _state, check_stopped(), get_class_type(), priv_step(), recompute(), S_started, and t. Referenced by resume(). |
|
This is called in lieu of priv_initialize() .. priv_step() .. priv_finalize(), when everything is to happen within one frame. The interval should initialize itself, then leave itself in the final state. Reimplemented in CLerpNodePathInterval, CMetaInterval, HideInterval, and ShowInterval. Definition at line 338 of file cInterval.cxx. |
|
This is called while the interval is playing to indicate that it is about to be interrupted; that is, priv_step() will not be called for a length of time. But the interval should remain in its current state in anticipation of being eventually restarted when the calls to priv_step() eventually resume. The purpose of this function is to allow self-running intervals like sound intervals to stop the actual sound playback during the pause. Reimplemented in CMetaInterval. Definition at line 482 of file cInterval.cxx. References _clock_start, _end_t, _play_rate, _start_t, get_duration(), and t. |
|
Called generally following a priv_reverse_initialize(), this indicates the interval should set itself to the initial state.
Reimplemented in CMetaInterval. Definition at line 449 of file cInterval.cxx. References _clock_start, _end_t, _loop_count, _play_rate, _start_t, ClockObject::get_frame_time(), ClockObject::get_global_clock(), and get_t(). Referenced by setup_play(). |
|
Similar to priv_initialize(), but this is called when the interval is being played backwards; it indicates that the interval should start at the finishing state and undo any intervening intervals.
Reimplemented in CLerpNodePathInterval, and CMetaInterval. Definition at line 404 of file cInterval.cxx. References _start_t, _start_t_at_start, get_duration(), and nassertv. |
|
This is called in lieu of priv_reverse_initialize() .. priv_step() .. priv_reverse_finalize(), when everything is to happen within one frame. The interval should initialize itself, then leave itself in the initial state. Reimplemented in CLerpNodePathInterval, CMetaInterval, HideInterval, and ShowInterval. Definition at line 428 of file cInterval.cxx. Referenced by setup_play(). |
|
Advances the time on the interval. The time may either increase (the normal case) or decrease (e.g. if the interval is being played by a slider). Reimplemented in CLerpAnimEffectInterval, CLerpNodePathInterval, CMetaInterval, and WaitInterval. Definition at line 360 of file cInterval.cxx. References _state, check_started(), get_class_type(), and S_paused. Referenced by is_playing(), priv_do_event(), and priv_initialize(). |
|
Calls do_recompute() if the dirty flag has been set.
Definition at line 355 of file cInterval.I. Referenced by CMetaInterval::get_interval_end_time(), get_name(), is_playing(), CMetaInterval::pop_level(), priv_do_event(), priv_initialize(), CMetaInterval::priv_reverse_instant(), CMetaInterval::priv_step(), and CMetaInterval::set_interval_start_time(). |
|
Restarts the interval from the indicated point after a previous call to pause().
Definition at line 199 of file cInterval.cxx. References ET_initialize, ET_instant, priv_initialize(), priv_instant(), and t. |
|
Restarts the interval from its current point after a previous call to pause().
Definition at line 183 of file cInterval.cxx. References _manager, and CIntervalManager::remove_c_interval(). |
|
Changes the state of the 'auto_finish' flag. If this is true, the interval may be arbitrarily finished when the system needs to reset due to some external event by calling CIntervalManager::interrupt(). If this is false (the default), the interval must always be explicitly finished or paused. Definition at line 225 of file cInterval.I. References _manager. |
|
Changes the state of the 'auto_pause' flag. If this is true, the interval may be arbitrarily interrupted when the system needs to reset due to some external event by calling CIntervalManager::interrupt(). If this is false (the default), the interval must always be explicitly finished or paused. Definition at line 185 of file cInterval.I. References _last_t_callback. |
|
Sets the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own.
Definition at line 124 of file cInterval.I. References _auto_pause, and INLINE. |
|
Indicates the CIntervalManager object which will be responsible for playing this interval. This defaults to the global CIntervalManager; you should need to change this only if you have special requirements for playing this interval. Definition at line 298 of file cInterval.I. |
|
Explicitly sets the time within the interval. Normally, you would use start() .. finish() to let the time play normally, but this may be used to set the time to some particular value. Definition at line 80 of file cInterval.cxx. |
|
Changes the state of the 'wants_t_callback' flag. If this is true, the interval will be returned by CIntervalManager::get_event() each time the interval's time value has been changed, regardless of whether it has any external events. Definition at line 261 of file cInterval.I. References _state, get_name(), TypeHandle::get_name(), INLINE, nassertv, S_started, and verify_intervals. |
|
Called to prepare the interval for automatic timed playback, e.g. via a Python task. The interval will be played from start_t to end_t, at a time factor specified by play_rate. start_t must always be less than end_t (except for the exception for end_t == -1, below), but if play_rate is negative the interval will be played backwards. Specify end_t of -1 to play the entire interval from start_t. Call step_play() repeatedly to execute the interval. Definition at line 547 of file cInterval.cxx. References _loop_count, get_open_ended(), is_stopped(), priv_reverse_finalize(), and priv_reverse_instant(). |
|
Called to prepare the interval for restarting at the current point within the interval after an interruption.
Definition at line 590 of file cInterval.cxx. References _dirty, and _parents. Referenced by loop(). |
|
Starts the interval playing by registering it with the current CIntervalManager. The interval will play to the end and stop. If end_t is less than zero, it indicates the end of the interval. Definition at line 115 of file cInterval.cxx. References _manager. |
|
Should be called once per frame to execute the automatic timed playback begun with setup_play(). Returns true if the interval should continue, false if it is done and should stop. Definition at line 618 of file cInterval.cxx. References _dirty. |
|
Reimplemented in CMetaInterval. Definition at line 512 of file cInterval.cxx. |
|
Definition at line 200 of file cInterval.h. |
|
Definition at line 157 of file cInterval.h. Referenced by CInterval(). |
|
Definition at line 156 of file cInterval.h. Referenced by CInterval(), get_done_event(), and set_done_event(). |
|
Definition at line 163 of file cInterval.h. Referenced by CInterval(), priv_interrupt(), and priv_reverse_finalize(). |
|
Definition at line 151 of file cInterval.h. Referenced by CMetaInterval::get_interval_end_time(), CMetaInterval::priv_initialize(), CMetaInterval::priv_instant(), CMetaInterval::priv_reverse_initialize(), WaitInterval::priv_step(), and CMetaInterval::priv_step(). |
|
Definition at line 174 of file cInterval.h. Referenced by setup_resume(), and step_play(). |
|
Definition at line 169 of file cInterval.h. Referenced by CInterval(). |
|
Definition at line 153 of file cInterval.h. Referenced by get_state(). |
|
Definition at line 154 of file cInterval.h. Referenced by CInterval(), get_name(), and CMetaInterval::priv_interrupt(). |
|
Definition at line 165 of file cInterval.h. Referenced by CInterval(), priv_interrupt(), and priv_reverse_finalize(). |
|
Definition at line 166 of file cInterval.h. Referenced by CInterval(). |
|
Definition at line 159 of file cInterval.h. Referenced by CInterval(), and set_auto_pause(). |
|
Definition at line 170 of file cInterval.h. Referenced by CInterval(), priv_reverse_finalize(), and setup_play(). |
|
Definition at line 160 of file cInterval.h. Referenced by CInterval(), get_auto_pause(), loop(), pause(), resume(), set_auto_finish(), and start(). |
|
Definition at line 152 of file cInterval.h. Referenced by HideInterval::HideInterval(), and ShowInterval::ShowInterval(). |
|
Definition at line 173 of file cInterval.h. Referenced by get_duration(). |
|
Definition at line 181 of file cInterval.h. Referenced by CMetaInterval::push_level(), and setup_resume(). |
|
Definition at line 168 of file cInterval.h. Referenced by CInterval(), priv_interrupt(), and priv_reverse_finalize(). |
|
Definition at line 164 of file cInterval.h. Referenced by CInterval(), priv_interrupt(), priv_reverse_finalize(), and priv_reverse_initialize(). |
|
Definition at line 167 of file cInterval.h. Referenced by CInterval(), and priv_reverse_initialize(). |
|
|
Reimplemented from TypedReferenceCount. Reimplemented in CLerpAnimEffectInterval, CLerpInterval, CLerpNodePathInterval, CMetaInterval, HideInterval, ShowInterval, and WaitInterval. Definition at line 30 of file cInterval.cxx. |
|
Definition at line 158 of file cInterval.h. Referenced by CInterval(). |