1 // Copyright (C) 2007-2008 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
22 // File : VISU_TimeAnimation.h
23 // Author : Vitaly SMETANNIKOV
26 #ifndef VISU_TIMEANIMATION_H
27 #define VISU_TIMEANIMATION_H
29 #include "VISUConfig.hh"
31 #include "VISU_Result_i.hh"
32 #include "SALOME_GenericObjPointer.hh"
40 class SVTK_ViewWindow;
52 VISU::VISUType myPrsType;
53 _PTR(SObject) myField; // field label
54 long myNbTimes; // number of Timestamps
55 long myNbFrames; // number of created Frames
56 std::vector<VISU::ColoredPrs3d_i*> myPrs; // Presentations
57 std::vector<VISU_Actor*> myActors; // Actors
58 std::vector<double> myTiming; // time values
59 CORBA::Float myOffset[3];
60 typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
65 class VISU_I_EXPORT VISU_TimeAnimation: public QThread
70 CORBA::Boolean _generateFrames();
72 void _visibilityOff(int num_field, int num_frame);
74 void _clearData(FieldData& theData);
75 void _startAnimation();
80 void _gotoFrame(CORBA::Long theFrame);
82 void _emitFrameChanged(long theNewFrame, double theTime);
85 void parallelAnimation( bool& theIsDumping, QList<int>& theIndexList );
86 void successiveAnimation( bool& theIsDumping, QList<int>& theIndexList );
87 void saveImages( int theFieldId, double& theOneVal, int& theNbFiles, QList<int>& theIndexList );
90 //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
91 //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);
92 //static double getTimeValue (SALOMEDS::SObject_var theTimestamp);
94 static VISU::Result_i* createPresent (_PTR(SObject) theField);
95 static double getTimeValue (_PTR(SObject) theTimestamp);
97 VISU_TimeAnimation(_PTR(Study) theStudy,
98 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
99 ~VISU_TimeAnimation();
101 virtual VISU::VISUType GetType() { return VISU::TNONE;};
103 bool addField (_PTR(SObject) theField);
104 bool addField (SALOMEDS::SObject_ptr theField);
105 FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
107 CORBA::Boolean generateFrames();
108 void generatePresentations(CORBA::Long theFieldNum);
109 void setViewer(SVTK_ViewWindow* theView) { myView = theView; _connectView(); }
110 SVTK_ViewWindow* getViewer() { return myView; }
112 void clearData(FieldData& theData);
113 void clearFieldData() { myFieldsLst.clear();};
115 void visibilityOff(int num_field, int num_frame);
116 void stopAnimation();
117 void startAnimation();
122 void gotoFrame(CORBA::Long theFrame);
124 CORBA::Long getNbFields() { return myFieldsLst.size(); }
125 CORBA::Long getNbFrames();
126 CORBA::Long getCurrentFrame() { return myFrame; }
128 long getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp);
129 std::pair<int,long> getRelativeFrameNumber(long theFrame);
131 VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
133 void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
134 VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
136 void setSpeed(CORBA::Long theSpeed);
137 CORBA::Long getSpeed() { return mySpeed; }
139 CORBA::Boolean isProportional() { return myProportional; }
141 void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
142 { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
144 CORBA::Double getMinRange() { return myTimeMinVal; }
145 CORBA::Double getMaxRange() { return myTimeMaxVal; }
146 CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
148 void setAnimationSequence(const char* theSequence);
149 char* getAnimationSequence();
150 CORBA::Boolean isSequenceDefined();
152 bool getIndicesFromSequence( QString theSequence, QList<long>& theIndices );
154 void dumpTo(const char* thePath) { myDumpPath = thePath; }
155 std::string setDumpFormat(const char* theFormat);
156 bool checkAVIMaker() const;
158 QString getLastErrorMsg() { return myLastError; }
160 CORBA::Boolean isCycling() { return myCycling; }
161 CORBA::Boolean isCleaningMemoryAtEachFrame() { return myCleaningMemoryAtEachFrame; }
163 CORBA::Double getMinTime() { return myTimeMin;}
164 CORBA::Double getMaxTime() { return myTimeMax;}
166 void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
167 void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
168 void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
170 SALOMEDS::SObject_ptr publishInStudy();
171 void restoreFromStudy(SALOMEDS::SObject_ptr theField);
172 void restoreFromStudy(_PTR(SObject) theField);
173 void saveAnimation();
174 bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
175 _PTR(Study) getStudy() const { return myStudy; }
177 void setAnimationMode(VISU::Animation::AnimationMode theMode) { myAnimationMode = theMode; }
178 VISU::Animation::AnimationMode getAnimationMode() { return myAnimationMode; }
180 void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
183 void setProportionalSlot(bool theProp) { myProportional = theProp; }
184 void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
185 void setCleaningMemoryAtEachFrameSlot(bool theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
188 void frameChanged(long theNewFrame, double theTime);
193 QString GenerateName();
196 void onViewDeleted();
201 QList<FieldData> myFieldsLst;
202 VISU::ExecutionState* myExecutionState;
204 std::vector<long> myFieldsAbsFrames;
208 bool myCleaningMemoryAtEachFrame;
211 VISU::Animation::AnimationMode myAnimationMode;
212 double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
213 double myTimeMin , myTimeMax ; //!< Range of time stams, available for animation
216 QString myDumpFormat;
219 SVTK_ViewWindow* myView;
223 static int myNBAnimations;
227 class VISU_I_EXPORT VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
228 public virtual VISU::Base_i
230 VISU_TimeAnimation* myAnim;
232 VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
233 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
234 ~VISU_TimeAnimation_i();
236 virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
237 //virtual VISU::VISUType GetType() { return VISU::TNONE; }
239 virtual bool addField(SALOMEDS::SObject_ptr theField);
240 virtual void clearFields();
242 virtual CORBA::Boolean generateFrames();
243 virtual void generatePresentations(CORBA::Long theFieldNum);
245 virtual void clearView();
247 virtual void stopAnimation();
248 virtual void startAnimation();
249 virtual void nextFrame();
250 virtual void prevFrame();
251 virtual void firstFrame();
252 virtual void lastFrame();
253 virtual void gotoFrame(CORBA::Long theFrame);
255 virtual CORBA::Long getNbFields();
256 virtual CORBA::Long getNbFrames();
257 virtual CORBA::Boolean isRunning();
258 virtual CORBA::Long getCurrentFrame();
260 virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
262 virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
263 virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
265 virtual void setSpeed(CORBA::Long theSpeed);
266 virtual CORBA::Long getSpeed();
268 virtual CORBA::Boolean isProportional();
270 virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
272 virtual CORBA::Double getMinRange();
273 virtual CORBA::Double getMaxRange();
274 virtual CORBA::Boolean isRangeDefined();
276 virtual void setAnimationSequence(const char* theSequence);
277 virtual char* getAnimationSequence();
278 virtual CORBA::Boolean isSequenceDefined();
280 virtual void dumpTo(const char* thePath);
281 virtual char* setDumpFormat(const char* theFormat);
283 virtual CORBA::Boolean isCycling();
284 virtual CORBA::Boolean isCleaningMemoryAtEachFrame();
286 virtual CORBA::Double getMinTime();
287 virtual CORBA::Double getMaxTime();
289 virtual void setProportional(CORBA::Boolean theProp);
290 virtual void setCycling(CORBA::Boolean theCycle);
291 virtual void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle);
293 virtual SALOMEDS::SObject_ptr publishInStudy();
294 virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
295 virtual CORBA::Boolean isSavedInStudy();
296 virtual void saveAnimation();
298 virtual void setAnimationMode(VISU::Animation::AnimationMode theMode);
299 virtual VISU::Animation::AnimationMode getAnimationMode();
301 virtual void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
304 #endif //VISU_TIMEANIMATION_H