OpenCOVER
coVRAnimationManager.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
8#ifndef COVR_ANIMATION_MANAGER_H
9#define COVR_ANIMATION_MANAGER_H
10
23namespace opencover
24{
25namespace ui
26{
27class Group;
28class Menu;
29class Action;
30class Button;
31class Slider;
32}
33}
34#include "ui/Owner.h"
35
36#include <util/coExport.h>
37#include <map>
38#include <vector>
39#include <osg/Sequence>
40
41namespace opencover
42{
43class COVEREXPORT coVRAnimationManager
44: public ui::Owner
45{
46 friend class coVRPluginList;
47
48 static coVRAnimationManager *s_instance;
50public:
53
56 {
57 Nothing, //< nothing is shown
58 Last, //< last element is shown
59 Cycle, //< previous elements are repeated periodically
60 };
61
62 struct Sequence
63 {
64 Sequence(osg::Sequence *seq, FillMode mode=Nothing): seq(seq), fill(mode) {}
65
66 osg::ref_ptr<osg::Sequence> seq;
67 FillMode fill = Nothing;
68 };
69
70 void setNumTimesteps(int);
71 void showAnimMenu(bool visible);
72
73 void addSequence(osg::Sequence *seq, FillMode mode=Nothing);
74 void removeSequence(osg::Sequence *seq);
75
76 const std::vector<Sequence> &getSequences() const;
77
79 {
80 return currentAnimationFrame;
81 }
82
83 int getNextFrame(int current = -1) const;
84
85 bool requestAnimationFrame(int currentFrame);
86 void requestAnimationTime(double t);
88 void setAnimationSpeed(float speed);
89 void setAnimationSkip(int frames);
91 void enableAnimation(bool state);
92 void setRemoteAnimationFrame(int currentFrame);
93 void setRemoteAnimate(bool state);
94 void setRemoteSynchronize(bool state);
95 void setOscillate(bool state);
96 bool isOscillating() const;
97 int getStartFrame() const;
98 void setStartFrame(int frame);
99 int getStopFrame() const;
100 void setStopFrame(int frame);
101 float getCurrentSpeed() const;
102
103 // get number of timesteps
105
106 // set number of timesteps
107 void setNumTimesteps(int, const void *who);
109
110 // remove source of timesteps
111 void removeTimestepProvider(const void *who);
112
113 void setTimestepUnit(const char *unit);
114 std::string getTimestepUnit() const;
115 void setTimestepBase(double base);
116 double getTimestepBase() const;
117 void setTimestepScale(double scale);
118 double getTimestepScale() const;
119
120 bool update();
121
122private:
123 void setAnimationFrame(int currentFrame);
124
125 void updateSequence(Sequence &seq, int currentFrame);
126 std::vector<Sequence> listOfSeq;
127 float AnimSliderMin, AnimSliderMax;
128 float timeState;
129
130 int aniDirection; // added for ping pong mode
131 int aniSkip = 1; // step width for automatic animation
132
133 int numFrames;
134 int startFrame, stopFrame;
135 float frameAngle;
136 int oldFrame;
137
138 void initAnimMenu();
139
140 // Animation menu:
141 ui::Button *animToggleItem;
142 ui::Slider *animSpeedItem;
143 ui::Action *animForwardItem;
144 ui::Action *animBackItem;
145 ui::Group *animStepGroup;
146 ui::Slider *animFrameItem;
147 ui::Button *rotateObjectsToggleItem;
148 ui::Button *animPingPongItem;
149 ui::Button *animSyncItem;
150 ui::Group *animLimitGroup;
151 ui::Slider *animStartItem, *animStopItem;
152 ui::Slider *presentationStep;
153 ui::Menu *animRowMenu;
154 ui::Slider *animSkipItem = nullptr;
155
156 bool animRunning;
157 double lastAnimationUpdate;
158 int currentAnimationFrame, requestedAnimationFrame;
159 bool updateAnimationFrame();
160
161 typedef std::map<const void *, int> TimestepMap;
162 TimestepMap timestepMap;
163
164 double timestepScale, timestepBase;
165 std::string timestepUnit;
166 bool m_animationPaused = false;
167};
168}
169#endif
Definition: ARToolKit.h:33
Definition: coVRAnimationManager.h:45
FillMode
how to handle missing elements at end of animition sequence
Definition: coVRAnimationManager.h:56
@ Cycle
Definition: coVRAnimationManager.h:59
@ Nothing
Definition: coVRAnimationManager.h:57
@ Last
Definition: coVRAnimationManager.h:58
void removeSequence(osg::Sequence *seq)
void setTimestepUnit(const char *unit)
void setNumTimesteps(int, const void *who)
bool requestAnimationFrame(int currentFrame)
const std::vector< Sequence > & getSequences() const
void setTimestepScale(double scale)
void removeTimestepProvider(const void *who)
static coVRAnimationManager * instance()
void setAnimationSkip(int frames)
void showAnimMenu(bool visible)
int getAnimationFrame() const
Definition: coVRAnimationManager.h:78
void setTimestepBase(double base)
int getNextFrame(int current=-1) const
std::string getTimestepUnit() const
void addSequence(osg::Sequence *seq, FillMode mode=Nothing)
void enableAnimation(bool state)
void setRemoteAnimate(bool state)
void setRemoteSynchronize(bool state)
void setRemoteAnimationFrame(int currentFrame)
void setAnimationSpeed(float speed)
Definition: coVRAnimationManager.h:63
Sequence(osg::Sequence *seq, FillMode mode=Nothing)
Definition: coVRAnimationManager.h:64
osg::ref_ptr< osg::Sequence > seq
Definition: coVRAnimationManager.h:66
Definition: coVRPluginList.h:53