INET Framework for OMNeT++/OMNEST
inet::visualizer::AnimationSpeedInterpolator Class Reference

#include <AnimationSpeedInterpolator.h>

Public Member Functions

double getCurrentAnimationSpeed () const
 
void setCurrentAnimationSpeed (double currentAnimationSpeed)
 
AnimationPosition::TimeType getTargetType () const
 
double getTargetTime () const
 
double getTargetAnimationSpeed () const
 
void setTargetAnimationSpeed (AnimationPosition::TimeType targetType, double targetTime, double targetAnimationSpeed)
 
void setAnimationSpeed (double animationSpeed)
 

Protected Attributes

double lastAnimationSpeed = NaN
 
AnimationPosition lastAnimationPosition
 
AnimationPosition::TimeType targetType
 
double targetTime = NaN
 
double targetAnimationSpeed = NaN
 

Member Function Documentation

double inet::visualizer::AnimationSpeedInterpolator::getCurrentAnimationSpeed ( ) const

Referenced by inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed().

31 {
32  AnimationPosition currentAnimationPosition;
33  double currentTime = currentAnimationPosition.getTime(targetType);
34  if (currentTime >= targetTime)
35  return targetAnimationSpeed;
36  else {
37  double lastTime = lastAnimationPosition.getTime(targetType);
38  double alpha = smootherstep(lastTime, targetTime, currentTime);
39  return (1 - alpha) * lastAnimationSpeed + alpha * targetAnimationSpeed;
40  }
41 }
double getTime(TimeType type) const
Definition: AnimationPosition.cc:38
double lastAnimationSpeed
Definition: AnimationSpeedInterpolator.h:31
double targetAnimationSpeed
Definition: AnimationSpeedInterpolator.h:36
AnimationPosition lastAnimationPosition
Definition: AnimationSpeedInterpolator.h:32
double targetTime
Definition: AnimationSpeedInterpolator.h:35
AnimationPosition::TimeType targetType
Definition: AnimationSpeedInterpolator.h:34
const value< double, units::unit > alpha(7.2973525376e-3)
double inet::visualizer::AnimationSpeedInterpolator::getTargetAnimationSpeed ( ) const
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed().

45 { return targetAnimationSpeed; }
double targetAnimationSpeed
Definition: AnimationSpeedInterpolator.h:36
double inet::visualizer::AnimationSpeedInterpolator::getTargetTime ( ) const
inline
43 { return targetTime; }
double targetTime
Definition: AnimationSpeedInterpolator.h:35
AnimationPosition::TimeType inet::visualizer::AnimationSpeedInterpolator::getTargetType ( ) const
inline
42 { return targetType; }
AnimationPosition::TimeType targetType
Definition: AnimationSpeedInterpolator.h:34
void inet::visualizer::AnimationSpeedInterpolator::setAnimationSpeed ( double  animationSpeed)

Referenced by inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed().

57 {
58  setCurrentAnimationSpeed(animationSpeed);
60 }
void setTargetAnimationSpeed(AnimationPosition::TimeType targetType, double targetTime, double targetAnimationSpeed)
Definition: AnimationSpeedInterpolator.cc:49
Definition: AnimationPosition.h:33
void setCurrentAnimationSpeed(double currentAnimationSpeed)
Definition: AnimationSpeedInterpolator.cc:43
void inet::visualizer::AnimationSpeedInterpolator::setCurrentAnimationSpeed ( double  currentAnimationSpeed)

Referenced by inet::visualizer::MediumCanvasVisualizer::initialize(), setAnimationSpeed(), and inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed().

44 {
45  lastAnimationPosition = AnimationPosition();
46  lastAnimationSpeed = currentAnimationSpeed;
47 }
double lastAnimationSpeed
Definition: AnimationSpeedInterpolator.h:31
AnimationPosition lastAnimationPosition
Definition: AnimationSpeedInterpolator.h:32
void inet::visualizer::AnimationSpeedInterpolator::setTargetAnimationSpeed ( AnimationPosition::TimeType  targetType,
double  targetTime,
double  targetAnimationSpeed 
)

Referenced by inet::visualizer::MediumCanvasVisualizer::initialize(), setAnimationSpeed(), and inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed().

50 {
51  this->targetType = targetType;
52  this->targetTime = targetTime;
54 }
double targetAnimationSpeed
Definition: AnimationSpeedInterpolator.h:36
double targetTime
Definition: AnimationSpeedInterpolator.h:35
AnimationPosition::TimeType targetType
Definition: AnimationSpeedInterpolator.h:34

Member Data Documentation

AnimationPosition inet::visualizer::AnimationSpeedInterpolator::lastAnimationPosition
protected
double inet::visualizer::AnimationSpeedInterpolator::lastAnimationSpeed = NaN
protected
double inet::visualizer::AnimationSpeedInterpolator::targetAnimationSpeed = NaN
protected
double inet::visualizer::AnimationSpeedInterpolator::targetTime = NaN
protected
AnimationPosition::TimeType inet::visualizer::AnimationSpeedInterpolator::targetType
protected

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