ATLAS Offline Software
Loading...
Searching...
No Matches
AnimationSequencer Class Reference

#include <AnimationSequencer.h>

Inheritance diagram for AnimationSequencer:
Collaboration diagram for AnimationSequencer:

Classes

class  Clockwork

Signals

void animationFinishedSuccessfully ()
void clipVolumePercentOfATLAS (double)

Public Member Functions

 AnimationSequencer (VP1ExaminerViewer *viewer)
 ~AnimationSequencer ()
AnimationSequencesequence ()
const AnimationSequencesequence () const
void startAnimating (bool skipFirstFrame=false)
void setMovie (bool)
void setMovieParameters (const QString &outdir, const QString &frameFileNamePrefix, int fps, int width, int height)

Private Slots

void nextAnimationFrame ()
void abortAnimation ()

Private Attributes

Clockworkm_c

Detailed Description

Definition at line 19 of file AnimationSequencer.h.

Constructor & Destructor Documentation

◆ AnimationSequencer()

AnimationSequencer::AnimationSequencer ( VP1ExaminerViewer * viewer)

Definition at line 55 of file AnimationSequencer.cxx.

55 :
56 m_c(new Clockwork)
57{
58 m_c->animationFrameNumber=0;
59 m_c->viewer=viewer;
60 m_c->sphere=NULL;
61 m_c->movieEnabled=false;
62 m_c->movieFPS=24;
63 m_c->movieWidth=100;
64 m_c->movieHeight=100;
65 m_c->movieOutdir="/tmp/vp1frames";
66 m_c->frameFileNamePrefix="vp1_frame";
67}

◆ ~AnimationSequencer()

AnimationSequencer::~AnimationSequencer ( )

Definition at line 69 of file AnimationSequencer.cxx.

70{
71 if (m_c->sphere) m_c->sphere->unref();
72 delete m_c;
73}

Member Function Documentation

◆ abortAnimation

void AnimationSequencer::abortAnimation ( )
privateslot

Definition at line 90 of file AnimationSequencer.cxx.

90 {
91 //Make sure we halt:
92 VP1Msg::messageVerbose("AnimationSequencer::abortAnimation.");
93 m_c->animationFrameNumber = m_c->animationFrameNumber>=sequence().getNumFrames() + 1;
94}
unsigned int getNumFrames() const
AnimationSequence & sequence()
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84

◆ animationFinishedSuccessfully

void AnimationSequencer::animationFinishedSuccessfully ( )
signal

◆ clipVolumePercentOfATLAS

void AnimationSequencer::clipVolumePercentOfATLAS ( double )
signal

◆ nextAnimationFrame

void AnimationSequencer::nextAnimationFrame ( )
privateslot

Definition at line 96 of file AnimationSequencer.cxx.

97{
98 VP1Msg::messageVerbose("AnimationSequencer::nextAnimationFrame.");
99
100 if (m_c->animationFrameNumber>=sequence().getNumFrames()) {
102 VP1Msg::messageVerbose("animation succeeded!");
103 return;
104 }
105
106 SoNode * rootnode = m_c->viewer->getSceneGraph();
107 if (!rootnode) {
108 VP1Msg::messageDebug("AnimationSequencer::nextAnimationFrame WARNING: No scenegraph set. Ignoring.");
109 return;
110 }
111 if ( ! ( rootnode->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) ) {
112 VP1Msg::messageDebug("AnimationSequencer::nextAnimationFrame WARNING: Root node does not derive from SoGroup. Ignoring.");
113 return;
114 }
115
116// if (m_c->viewer->getCameraType() == SoPerspectiveCamera::getClassTypeId() ) {
117// //Fix for bad camera:
118// m_c->viewer->toggleCameraType();
119// m_c->viewer->toggleCameraType();
120// }
121
122 SoCamera * camera = m_c->viewer->getCamera();
123 if (!camera) {
124 VP1Msg::messageDebug("AnimationSequencer::nextAnimationFrame WARNING: Could not get camera. Ignoring.");
125 return;
126 }
127
128 rootnode->ref();
129 SoGroup * root = static_cast<SoGroup*>(rootnode);
130
131 unsigned int i = m_c->animationFrameNumber;
132
133
134 //Get region:
135 AnimationSequence::Frame f=sequence().getFrame(i);
136 // std::cout<<"Frame: "<<i<<" clipVolumePercentOfATLAS="<<f.clipVolPercent<<std::endl;
137
138 if (f.time==0.0&&!f.camState.isEmpty())
139 {
141 QTimer::singleShot(0, this, SLOT(nextAnimationFrame()));
142 else
143 QTimer::singleShot(0, this, SLOT(abortAnimation()));
144 } else {
145 VP1CameraHelper *helper(0);
146 if (f.camState.isEmpty()) {
147 // std::cout<<"camState empty"<<std::endl;
148 camera->ref();
149 bool notifyenabled = root->enableNotify(false);
150 SoSphere * regionsphere = m_c->getRegionSphere(AnimationSequence::REGION(f.reg),
151 camera->getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId()));
152 camera->unrefNoDelete();
153 //Get direction:
154 SbVec3f lookat=f.dir, upvec = f.upvec;
155 root->insertChild(regionsphere,0);
156 VP1Msg::messageVerbose("nextAnimationFrame Initiating zoom to region sphere.");
157 helper = VP1CameraHelper::animatedZoomToSubTree(camera,root,regionsphere,f.time,f.clipVolPercent, m_c->last_clipVolPercent,0.1,lookat,upvec,f.variableSpeed,f.forceCircular);
158
159 root->removeChild(regionsphere);
160
161 if (notifyenabled) {
162 root->enableNotify(true);
163 root->touch();
164 }
165
166 } else {
167 // std::cout<<"camState not empty"<<std::endl;
168 helper = VP1CameraHelper::animatedZoomToCameraState( camera,root,f.camState,f.time,f.clipVolPercent, m_c->last_clipVolPercent, f.variableSpeed,f.forceCircular );
169 }
170
171 if (m_c->movieEnabled)
172 helper->setOutputImagesMode(m_c->viewer, m_c->movieOutdir, m_c->movieWidth,m_c->movieHeight, m_c->movieFPS, m_c->frameFileNamePrefix);
173
174 connect(helper,SIGNAL(animationFinished()), this, SLOT(nextAnimationFrame()));
175 connect(helper,SIGNAL(animationFinishedAbnormally()), this, SLOT(abortAnimation()));
176 connect(helper,SIGNAL(clipVolumePercentageOfATLAS(double)), this, SIGNAL(clipVolumePercentOfATLAS(double)));
177
178 }
179 // std::cout<<" Setting last_clipVolPercent to "<<f.clipVolPercent<<std::endl;
180 m_c->last_clipVolPercent = f.clipVolPercent;
181
182
183 rootnode->unrefNoDelete();
184 m_c->animationFrameNumber++;
185
186}
const Frame & getFrame(unsigned int i) const
void animationFinishedSuccessfully()
void clipVolumePercentOfATLAS(double)
static VP1CameraHelper * animatedZoomToSubTree(SoCamera *camera, SoGroup *sceneroot, SoNode *subtreeroot, double duration_in_secs=1.0, double clipVolPercent=100.0, double lastClipVolPercent=100.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999), bool varySpeed=true, bool forceCircular=false)
static VP1CameraHelper * animatedZoomToCameraState(SoCamera *camera, SoGroup *sceneroot, const QByteArray &camstate, double duration_in_secs=1.0, double clipVolPercent=100.0, double lastClipVolPercent=100.0, bool varySpeed=true, bool forceCircular=false)
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
static bool deserializeSoCameraParameters(QByteArray &, SoCamera &)

◆ sequence() [1/2]

AnimationSequence & AnimationSequencer::sequence ( )

Definition at line 75 of file AnimationSequencer.cxx.

75 {
76 return m_c->animationSequence;
77}

◆ sequence() [2/2]

const AnimationSequence & AnimationSequencer::sequence ( ) const

Definition at line 79 of file AnimationSequencer.cxx.

79 {
80 return m_c->animationSequence;
81}

◆ setMovie()

void AnimationSequencer::setMovie ( bool b)

Definition at line 41 of file AnimationSequencer.cxx.

42{
43 m_c->movieEnabled = b;
44}

◆ setMovieParameters()

void AnimationSequencer::setMovieParameters ( const QString & outdir,
const QString & frameFileNamePrefix,
int fps,
int width,
int height )

Definition at line 46 of file AnimationSequencer.cxx.

47{
48 m_c->movieFPS = fps;
49 m_c->movieWidth = width;
50 m_c->movieHeight = height;
51 m_c->movieOutdir = outdir;
52 m_c->frameFileNamePrefix = frameFileNamePrefix;
53}
const double width

◆ startAnimating()

void AnimationSequencer::startAnimating ( bool skipFirstFrame = false)

Definition at line 83 of file AnimationSequencer.cxx.

83 {
84
85 m_c->animationFrameNumber=(skipFirstFrame?1:0);
86 m_c->last_clipVolPercent = 100;
88}

Member Data Documentation

◆ m_c

Clockwork* AnimationSequencer::m_c
private

Definition at line 57 of file AnimationSequencer.h.


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