1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : VISU_TimeAnimation.h
24 // Author : Vitaly SMETANNIKOV
27 #ifndef VISU_TIMEANIMATION_H
28 #define VISU_TIMEANIMATION_H
30 #include "VISUConfig.hh"
32 #include "VISU_Result_i.hh"
33 #include "SALOME_GenericObjPointer.hh"
41 class SVTK_ViewWindow;
54 VISU::VISUType myPrsType;
55 _PTR(SObject) myField; // field label
56 long myNbTimes; // number of Timestamps
57 long myNbFrames; // number of created Frames
58 std::vector<VISU::ColoredPrs3d_i*> myPrs; // Presentations
59 std::vector<VISU_Actor*> myActors; // Actors
60 std::vector<double> myTiming; // time values
61 CORBA::Float myOffset[3];
62 typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
67 class VISU_I_EXPORT VISU_TimeAnimation: public QThread
72 enum DumpMode { DM_None = 0, DM_Picture, DM_Video };
75 CORBA::Boolean _generateFrames();
77 void _visibilityOff(int num_field, int num_frame);
79 void _clearData(FieldData& theData);
80 void _startAnimation();
85 void _gotoFrame(CORBA::Long theFrame);
87 void _emitFrameChanged(long theNewFrame, double theTime);
90 void parallelAnimation( bool& theIsDumping, QList<int>& theIndexList );
91 void successiveAnimation( bool& theIsDumping, QList<int>& theIndexList );
92 void saveImages( int theFieldId, double& theOneVal, int& theNbFiles, QList<int>& theIndexList );
95 //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
96 //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);
97 //static double getTimeValue (SALOMEDS::SObject_var theTimestamp);
99 static VISU::Result_i* createPresent (_PTR(SObject) theField);
100 static double getTimeValue (_PTR(SObject) theTimestamp);
102 VISU_TimeAnimation(_PTR(Study) theStudy,
103 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
104 ~VISU_TimeAnimation();
106 virtual VISU::VISUType GetType() { return VISU::TNONE;};
108 bool addField (_PTR(SObject) theField);
109 bool addField (SALOMEDS::SObject_ptr theField);
110 FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
112 CORBA::Boolean generateFrames();
113 void generatePresentations(CORBA::Long theFieldNum);
114 void setViewer(SVTK_ViewWindow* theView) { myView = theView; _connectView(); }
115 SVTK_ViewWindow* getViewer() { return myView; }
117 void clearData(FieldData& theData);
118 void clearFieldData() { myFieldsLst.clear();};
120 void visibilityOff(int num_field, int num_frame);
121 void stopAnimation();
122 void startAnimation();
127 void gotoFrame(CORBA::Long theFrame);
129 CORBA::Long getNbFields() { return myFieldsLst.size(); }
130 CORBA::Long getNbFrames();
131 CORBA::Long getCurrentFrame() { return myFrame; }
133 long getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp);
134 std::pair<int,long> getRelativeFrameNumber(long theFrame);
136 VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
138 void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
139 VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
141 void setSpeed(CORBA::Long theSpeed);
142 CORBA::Long getSpeed() { return mySpeed; }
144 CORBA::Boolean isProportional() { return myProportional; }
146 void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
147 { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
149 CORBA::Double getMinRange() { return myTimeMinVal; }
150 CORBA::Double getMaxRange() { return myTimeMaxVal; }
151 CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
153 void setAnimationSequence(const char* theSequence);
154 char* getAnimationSequence();
155 CORBA::Boolean isSequenceDefined();
157 bool getIndicesFromSequence( QString theSequence, QList<long>& theIndices );
159 void dumpTo(const char* thePath);
160 std::string setDumpFormat(const char* theFormat);
162 void setTimeStampFrequency(CORBA::Long theFrequency);
163 CORBA::Long getTimeStampFrequency() { return myTimeStampFrequency; }
165 int getDumpMode() const { return myDumpMode; }
167 bool checkAVIMaker() const;
169 QString getLastErrorMsg() { return myLastError; }
171 CORBA::Boolean isCycling() { return myCycling; }
172 CORBA::Boolean isCleaningMemoryAtEachFrame() { return myCleaningMemoryAtEachFrame; }
174 CORBA::Double getMinTime() { return myTimeMin;}
175 CORBA::Double getMaxTime() { return myTimeMax;}
177 void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
178 void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
179 void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
181 SALOMEDS::SObject_ptr publishInStudy();
182 void restoreFromStudy(SALOMEDS::SObject_ptr theField);
183 void restoreFromStudy(_PTR(SObject) theField);
184 void saveAnimation();
185 bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
186 _PTR(Study) getStudy() const { return myStudy; }
188 void setAnimationMode(VISU::Animation::AnimationMode theMode) { myAnimationMode = theMode; }
189 VISU::Animation::AnimationMode getAnimationMode() { return myAnimationMode; }
191 void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
194 void setProportionalSlot(bool theProp) { myProportional = theProp; }
195 void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
196 void setCleaningMemoryAtEachFrameSlot(bool theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
199 void frameChanged(long theNewFrame, double theTime);
204 QString GenerateName();
207 void onViewDeleted();
212 QList<FieldData> myFieldsLst;
213 VISU::ExecutionState* myExecutionState;
215 std::vector<long> myFieldsAbsFrames;
219 bool myCleaningMemoryAtEachFrame;
222 VISU::DumpPath* myDumpPath;
224 VISU::Animation::AnimationMode myAnimationMode;
225 double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
226 double myTimeMin , myTimeMax ; //!< Range of time stams, available for animation
228 QString myDumpFormat;
231 SVTK_ViewWindow* myView;
234 int myTimeStampFrequency;
238 static int myNBAnimations;
242 class VISU_I_EXPORT VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
243 public virtual VISU::Base_i
245 VISU_TimeAnimation* myAnim;
247 VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
248 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
249 ~VISU_TimeAnimation_i();
251 virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
252 //virtual VISU::VISUType GetType() { return VISU::TNONE; }
254 virtual bool addField(SALOMEDS::SObject_ptr theField);
255 virtual void clearFields();
257 virtual CORBA::Boolean generateFrames();
258 virtual void generatePresentations(CORBA::Long theFieldNum);
260 virtual void clearView();
262 virtual void stopAnimation();
263 virtual void startAnimation();
264 virtual void nextFrame();
265 virtual void prevFrame();
266 virtual void firstFrame();
267 virtual void lastFrame();
268 virtual void gotoFrame(CORBA::Long theFrame);
270 virtual CORBA::Long getNbFields();
271 virtual CORBA::Long getNbFrames();
272 virtual CORBA::Boolean isRunning();
273 virtual CORBA::Long getCurrentFrame();
275 virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
277 virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
278 virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
280 virtual void setSpeed(CORBA::Long theSpeed);
281 virtual CORBA::Long getSpeed();
283 virtual CORBA::Boolean isProportional();
285 virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
287 virtual CORBA::Double getMinRange();
288 virtual CORBA::Double getMaxRange();
289 virtual CORBA::Boolean isRangeDefined();
291 virtual void setAnimationSequence(const char* theSequence);
292 virtual char* getAnimationSequence();
293 virtual CORBA::Boolean isSequenceDefined();
295 virtual void dumpTo(const char* thePath);
296 virtual char* setDumpFormat(const char* theFormat);
298 virtual void setTimeStampFrequency(CORBA::Long theFrequency);
299 virtual CORBA::Long getTimeStampFrequency();
301 virtual CORBA::Boolean isCycling();
302 virtual CORBA::Boolean isCleaningMemoryAtEachFrame();
304 virtual CORBA::Double getMinTime();
305 virtual CORBA::Double getMaxTime();
307 virtual void setProportional(CORBA::Boolean theProp);
308 virtual void setCycling(CORBA::Boolean theCycle);
309 virtual void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle);
311 virtual SALOMEDS::SObject_ptr publishInStudy();
312 virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
313 virtual CORBA::Boolean isSavedInStudy();
314 virtual void saveAnimation();
316 virtual void setAnimationMode(VISU::Animation::AnimationMode theMode);
317 virtual VISU::Animation::AnimationMode getAnimationMode();
319 virtual void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
322 #endif //VISU_TIMEANIMATION_H