1 // Copyright (C) 2007-2010 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;
53 VISU::VISUType myPrsType;
54 _PTR(SObject) myField; // field label
55 long myNbTimes; // number of Timestamps
56 long myNbFrames; // number of created Frames
57 std::vector<VISU::ColoredPrs3d_i*> myPrs; // Presentations
58 std::vector<VISU_Actor*> myActors; // Actors
59 std::vector<double> myTiming; // time values
60 CORBA::Float myOffset[3];
61 typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
66 class VISU_I_EXPORT VISU_TimeAnimation: public QThread
71 enum DumpMode { DM_None = 0, DM_Picture, DM_Video };
74 CORBA::Boolean _generateFrames();
76 void _visibilityOff(int num_field, int num_frame);
78 void _clearData(FieldData& theData);
79 void _startAnimation();
84 void _gotoFrame(CORBA::Long theFrame);
86 void _emitFrameChanged(long theNewFrame, double theTime);
89 void parallelAnimation( bool& theIsDumping, QList<int>& theIndexList );
90 void successiveAnimation( bool& theIsDumping, QList<int>& theIndexList );
91 void saveImages( int theFieldId, double& theOneVal, int& theNbFiles, QList<int>& theIndexList );
94 //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
95 //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);
96 //static double getTimeValue (SALOMEDS::SObject_var theTimestamp);
98 static VISU::Result_i* createPresent (_PTR(SObject) theField);
99 static double getTimeValue (_PTR(SObject) theTimestamp);
101 VISU_TimeAnimation(_PTR(Study) theStudy,
102 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
103 ~VISU_TimeAnimation();
105 virtual VISU::VISUType GetType() { return VISU::TNONE;};
107 bool addField (_PTR(SObject) theField);
108 bool addField (SALOMEDS::SObject_ptr theField);
109 FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
111 CORBA::Boolean generateFrames();
112 void generatePresentations(CORBA::Long theFieldNum);
113 void setViewer(SVTK_ViewWindow* theView) { myView = theView; _connectView(); }
114 SVTK_ViewWindow* getViewer() { return myView; }
116 void clearData(FieldData& theData);
117 void clearFieldData() { myFieldsLst.clear();};
119 void visibilityOff(int num_field, int num_frame);
120 void stopAnimation();
121 void startAnimation();
126 void gotoFrame(CORBA::Long theFrame);
128 CORBA::Long getNbFields() { return myFieldsLst.size(); }
129 CORBA::Long getNbFrames();
130 CORBA::Long getCurrentFrame() { return myFrame; }
132 long getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp);
133 std::pair<int,long> getRelativeFrameNumber(long theFrame);
135 VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
137 void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
138 VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
140 void setSpeed(CORBA::Long theSpeed);
141 CORBA::Long getSpeed() { return mySpeed; }
143 CORBA::Boolean isProportional() { return myProportional; }
145 void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
146 { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
148 CORBA::Double getMinRange() { return myTimeMinVal; }
149 CORBA::Double getMaxRange() { return myTimeMaxVal; }
150 CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
152 void setAnimationSequence(const char* theSequence);
153 char* getAnimationSequence();
154 CORBA::Boolean isSequenceDefined();
156 bool getIndicesFromSequence( QString theSequence, QList<long>& theIndices );
158 void dumpTo(const char* thePath) { myDumpPath = thePath; }
159 std::string setDumpFormat(const char* theFormat);
161 void setTimeStampFrequency(CORBA::Long theFrequency);
162 CORBA::Long getTimeStampFrequency() { return myTimeStampFrequency; }
164 int getDumpMode() const { return myDumpMode; }
166 bool checkAVIMaker() const;
168 QString getLastErrorMsg() { return myLastError; }
170 CORBA::Boolean isCycling() { return myCycling; }
171 CORBA::Boolean isCleaningMemoryAtEachFrame() { return myCleaningMemoryAtEachFrame; }
173 CORBA::Double getMinTime() { return myTimeMin;}
174 CORBA::Double getMaxTime() { return myTimeMax;}
176 void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
177 void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
178 void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
180 SALOMEDS::SObject_ptr publishInStudy();
181 void restoreFromStudy(SALOMEDS::SObject_ptr theField);
182 void restoreFromStudy(_PTR(SObject) theField);
183 void saveAnimation();
184 bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
185 _PTR(Study) getStudy() const { return myStudy; }
187 void setAnimationMode(VISU::Animation::AnimationMode theMode) { myAnimationMode = theMode; }
188 VISU::Animation::AnimationMode getAnimationMode() { return myAnimationMode; }
190 void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
193 void setProportionalSlot(bool theProp) { myProportional = theProp; }
194 void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
195 void setCleaningMemoryAtEachFrameSlot(bool theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
198 void frameChanged(long theNewFrame, double theTime);
203 QString GenerateName();
206 void onViewDeleted();
211 QList<FieldData> myFieldsLst;
212 VISU::ExecutionState* myExecutionState;
214 std::vector<long> myFieldsAbsFrames;
218 bool myCleaningMemoryAtEachFrame;
221 VISU::Animation::AnimationMode myAnimationMode;
222 double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
223 double myTimeMin , myTimeMax ; //!< Range of time stams, available for animation
226 QString myDumpFormat;
229 SVTK_ViewWindow* myView;
232 int myTimeStampFrequency;
236 static int myNBAnimations;
240 class VISU_I_EXPORT VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
241 public virtual VISU::Base_i
243 VISU_TimeAnimation* myAnim;
245 VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
246 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
247 ~VISU_TimeAnimation_i();
249 virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
250 //virtual VISU::VISUType GetType() { return VISU::TNONE; }
252 virtual bool addField(SALOMEDS::SObject_ptr theField);
253 virtual void clearFields();
255 virtual CORBA::Boolean generateFrames();
256 virtual void generatePresentations(CORBA::Long theFieldNum);
258 virtual void clearView();
260 virtual void stopAnimation();
261 virtual void startAnimation();
262 virtual void nextFrame();
263 virtual void prevFrame();
264 virtual void firstFrame();
265 virtual void lastFrame();
266 virtual void gotoFrame(CORBA::Long theFrame);
268 virtual CORBA::Long getNbFields();
269 virtual CORBA::Long getNbFrames();
270 virtual CORBA::Boolean isRunning();
271 virtual CORBA::Long getCurrentFrame();
273 virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
275 virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
276 virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
278 virtual void setSpeed(CORBA::Long theSpeed);
279 virtual CORBA::Long getSpeed();
281 virtual CORBA::Boolean isProportional();
283 virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
285 virtual CORBA::Double getMinRange();
286 virtual CORBA::Double getMaxRange();
287 virtual CORBA::Boolean isRangeDefined();
289 virtual void setAnimationSequence(const char* theSequence);
290 virtual char* getAnimationSequence();
291 virtual CORBA::Boolean isSequenceDefined();
293 virtual void dumpTo(const char* thePath);
294 virtual char* setDumpFormat(const char* theFormat);
296 virtual void setTimeStampFrequency(CORBA::Long theFrequency);
297 virtual CORBA::Long getTimeStampFrequency();
299 virtual CORBA::Boolean isCycling();
300 virtual CORBA::Boolean isCleaningMemoryAtEachFrame();
302 virtual CORBA::Double getMinTime();
303 virtual CORBA::Double getMaxTime();
305 virtual void setProportional(CORBA::Boolean theProp);
306 virtual void setCycling(CORBA::Boolean theCycle);
307 virtual void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle);
309 virtual SALOMEDS::SObject_ptr publishInStudy();
310 virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
311 virtual CORBA::Boolean isSavedInStudy();
312 virtual void saveAnimation();
314 virtual void setAnimationMode(VISU::Animation::AnimationMode theMode);
315 virtual VISU::Animation::AnimationMode getAnimationMode();
317 virtual void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
320 #endif //VISU_TIMEANIMATION_H