1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VISU_TimeAnimation.h
21 // Author : Vitaly SMETANNIKOV
24 #ifndef VISU_TIMEANIMATION_H
25 #define VISU_TIMEANIMATION_H
27 #include "VISUConfig.hh"
32 #include <qvaluelist.h>
35 class SVTK_ViewWindow;
47 VISU::VISUType myPrsType;
48 _PTR(SObject) myField; // field label
49 long myNbTimes; // number of Timestamps
50 long myNbFrames; // number of created Frames
51 std::vector<VISU::ColoredPrs3d_i*> myPrs; // Presentations
52 std::vector<VISU_Actor*> myActors; // Actors
53 std::vector<double> myTiming; // time values
54 CORBA::Float myOffset[3];
58 class VISU_I_EXPORT VISU_TimeAnimation: public QObject, public QThread
63 CORBA::Boolean _generateFrames();
64 void _visibilityOff(int num_field, int num_frame);
66 void _clearData(FieldData& theData);
67 void _startAnimation();
72 void _gotoFrame(CORBA::Long theFrame);
74 void _emitFrameChanged(long theNewFrame, double theTime);
77 void parallelAnimation( bool& theIsDumping, QValueList<int>& theIndexList );
78 void successiveAnimation( bool& theIsDumping, QValueList<int>& theIndexList );
79 void saveImages( int theFieldId, double& theOneVal, int& theNbFiles, QValueList<int>& theIndexList );
82 //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
83 //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);
84 //static double getTimeValue (SALOMEDS::SObject_var theTimestamp);
86 static VISU::Result_i* createPresent (_PTR(SObject) theField);
87 static double getTimeValue (_PTR(SObject) theTimestamp);
89 VISU_TimeAnimation(_PTR(Study) theStudy,
90 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
91 ~VISU_TimeAnimation();
93 virtual VISU::VISUType GetType() { return VISU::TNONE;};
95 bool addField (_PTR(SObject) theField);
96 bool addField (SALOMEDS::SObject_ptr theField);
97 FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
99 CORBA::Boolean generateFrames();
100 void generatePresentations(CORBA::Long theFieldNum);
101 void setViewer(SVTK_ViewWindow* theView) { myView = theView; }
102 SVTK_ViewWindow* getViewer() { return myView; }
104 void clearData(FieldData& theData);
105 void clearFieldData() { myFieldsLst.clear();};
107 void visibilityOff(int num_field, int num_frame);
108 void stopAnimation();
109 void startAnimation();
114 void gotoFrame(CORBA::Long theFrame);
116 CORBA::Long getNbFields() { return myFieldsLst.size(); }
117 CORBA::Long getNbFrames();
118 CORBA::Boolean isRunning();
119 CORBA::Long getCurrentFrame() { return myFrame; }
121 long getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp);
122 std::pair<int,long> getRelativeFrameNumber(long theFrame);
124 VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
126 void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType)
127 { myFieldsLst[theFieldNum].myPrsType = theType; }
128 VISU::VISUType getPresentationType(CORBA::Long theFieldNum)
129 { return myFieldsLst[theFieldNum].myPrsType; }
131 void setSpeed(CORBA::Long theSpeed);
132 CORBA::Long getSpeed() { return mySpeed; }
134 CORBA::Boolean isProportional() { return myProportional; }
136 void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
137 { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
139 CORBA::Double getMinRange() { return myTimeMinVal; }
140 CORBA::Double getMaxRange() { return myTimeMaxVal; }
141 CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
143 void setAnimationSequence(const char* theSequence);
144 char* getAnimationSequence();
145 CORBA::Boolean isSequenceDefined();
147 bool getIndicesFromSequence( QString theSequence, QValueList<long>& theIndices );
149 void dumpTo(const char* thePath) { myDumpPath = thePath; }
150 std::string setDumpFormat(const char* theFormat);
151 bool checkAVIMaker() const;
153 QString getLastErrorMsg() { return myLastError; }
155 CORBA::Boolean isCycling() { return myCycling; }
156 CORBA::Boolean isCleaningMemoryAtEachFrame() { return myCleaningMemoryAtEachFrame; }
158 CORBA::Double getMinTime() { return myTimeMin;}
159 CORBA::Double getMaxTime() { return myTimeMax;}
161 void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
162 void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
163 void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
165 SALOMEDS::SObject_ptr publishInStudy();
166 void restoreFromStudy(SALOMEDS::SObject_ptr theField);
167 void restoreFromStudy(_PTR(SObject) theField);
168 void saveAnimation();
169 bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
170 _PTR(Study) getStudy() const { return myStudy; }
172 void setAnimationMode(VISU::Animation::AnimationMode theMode) { myAnimationMode = theMode; }
173 VISU::Animation::AnimationMode getAnimationMode() { return myAnimationMode; }
175 void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
178 void setProportionalSlot(bool theProp) { myProportional = theProp; }
179 void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
180 void setCleaningMemoryAtEachFrameSlot(bool theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
183 void frameChanged(long theNewFrame, double theTime);
188 QString GenerateName();
191 void onViewDeleted();
196 QValueList<FieldData> myFieldsLst;
197 VISU::ExecutionState* myExecutionState;
199 std::vector<long> myFieldsAbsFrames;
203 bool myCleaningMemoryAtEachFrame;
206 VISU::Animation::AnimationMode myAnimationMode;
207 double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
208 double myTimeMin , myTimeMax ; //!< Range of time stams, available for animation
211 QString myDumpFormat;
214 SVTK_ViewWindow* myView;
218 static int myNBAnimations;
222 class VISU_I_EXPORT VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
223 public virtual VISU::Base_i
225 VISU_TimeAnimation* myAnim;
227 VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
228 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
229 ~VISU_TimeAnimation_i();
231 virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
232 //virtual VISU::VISUType GetType() { return VISU::TNONE; }
234 virtual bool addField(SALOMEDS::SObject_ptr theField);
235 virtual void clearFields();
237 virtual CORBA::Boolean generateFrames();
238 virtual void generatePresentations(CORBA::Long theFieldNum);
240 virtual void clearView();
242 virtual void stopAnimation();
243 virtual void startAnimation();
244 virtual void nextFrame();
245 virtual void prevFrame();
246 virtual void firstFrame();
247 virtual void lastFrame();
248 virtual void gotoFrame(CORBA::Long theFrame);
250 virtual CORBA::Long getNbFields();
251 virtual CORBA::Long getNbFrames();
252 virtual CORBA::Boolean isRunning();
253 virtual CORBA::Long getCurrentFrame();
255 virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
257 virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
258 virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
260 virtual void setSpeed(CORBA::Long theSpeed);
261 virtual CORBA::Long getSpeed();
263 virtual CORBA::Boolean isProportional();
265 virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
267 virtual CORBA::Double getMinRange();
268 virtual CORBA::Double getMaxRange();
269 virtual CORBA::Boolean isRangeDefined();
271 virtual void setAnimationSequence(const char* theSequence);
272 virtual char* getAnimationSequence();
273 virtual CORBA::Boolean isSequenceDefined();
275 virtual void dumpTo(const char* thePath);
276 virtual char* setDumpFormat(const char* theFormat);
278 virtual CORBA::Boolean isCycling();
279 virtual CORBA::Boolean isCleaningMemoryAtEachFrame();
281 virtual CORBA::Double getMinTime();
282 virtual CORBA::Double getMaxTime();
284 virtual void setProportional(CORBA::Boolean theProp);
285 virtual void setCycling(CORBA::Boolean theCycle);
286 virtual void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle);
288 virtual SALOMEDS::SObject_ptr publishInStudy();
289 virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
290 virtual CORBA::Boolean isSavedInStudy();
291 virtual void saveAnimation();
293 virtual void setAnimationMode(VISU::Animation::AnimationMode theMode);
294 virtual VISU::Animation::AnimationMode getAnimationMode();
296 virtual void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
299 #endif //VISU_TIMEANIMATION_H