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;
46 VISU::VISUType myPrsType;
47 _PTR(SObject) myField; // field label
48 long myNbTimes; // number of Timestamps
49 long myNbFrames; // number of created Frames
50 std::vector<VISU::ColoredPrs3d_i*> myPrs; // Presentations
51 std::vector<VISU_Actor*> myActors; // Actors
52 std::vector<double> myTiming; // time values
53 CORBA::Float myOffset[3];
57 class VISU_TimeAnimation: public QObject, public QThread
61 //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
62 //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);
63 //static double getTimeValue (SALOMEDS::SObject_var theTimestamp);
65 static VISU::Result_i* createPresent (_PTR(SObject) theField);
66 static VISU::Storable::TRestoringMap getMapOfValue (_PTR(SObject) theSObject);
67 static double getTimeValue (_PTR(SObject) theTimestamp);
69 VISU_TimeAnimation(_PTR(Study) theStudy,
70 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
71 ~VISU_TimeAnimation();
73 virtual VISU::VISUType GetType() { return VISU::TNONE;};
75 void addField (_PTR(SObject) theField);
76 void addField (SALOMEDS::SObject_ptr theField);
77 FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
79 CORBA::Boolean generateFrames();
80 void generatePresentations(CORBA::Long theFieldNum);
81 void setViewer(SVTK_ViewWindow* theView) { myView = theView; }
82 SVTK_ViewWindow* getViewer() { return myView; }
84 void clearData(FieldData& theData);
85 void clearFieldData() { myFieldsLst.clear();};
88 void startAnimation();
93 void gotoFrame(CORBA::Long theFrame);
95 CORBA::Long getNbFields() { return myFieldsLst.size(); }
96 CORBA::Long getNbFrames();
97 CORBA::Boolean isRunning() { return myIsActive; }
98 CORBA::Long getCurrentFrame() { return myFrame; }
100 VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
102 void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType)
103 { myFieldsLst[theFieldNum].myPrsType = theType; }
104 VISU::VISUType getPresentationType(CORBA::Long theFieldNum)
105 { return myFieldsLst[theFieldNum].myPrsType; }
107 void setSpeed(CORBA::Long theSpeed);
108 CORBA::Long getSpeed() { return mySpeed; }
110 CORBA::Boolean isProportional() { return myProportional; }
112 void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
113 { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
115 CORBA::Double getMinRange() { return myTimeMinVal; }
116 CORBA::Double getMaxRange() { return myTimeMaxVal; }
117 CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
119 void dumpTo(const char* thePath) { myDumpPath = thePath; }
120 std::string setDumpFormat(const char* theFormat);
121 bool checkAVIMaker() const;
123 QString getLastErrorMsg() { return myLastError; }
125 CORBA::Boolean isCycling() { return myCycling; }
127 CORBA::Double getMinTime() { return myTimeMin;}
128 CORBA::Double getMaxTime() { return myTimeMax;}
130 void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
131 void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
133 SALOMEDS::SObject_ptr publishInStudy();
134 void restoreFromStudy(SALOMEDS::SObject_ptr theField);
135 void restoreFromStudy(_PTR(SObject) theField);
136 void saveAnimation();
137 bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
140 void setProportionalSlot(bool theProp) { myProportional = theProp; }
141 void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
144 void frameChanged(long theNewFrame, double theTime);
149 QString GenerateName();
152 void onViewDeleted();
157 QValueList<FieldData> myFieldsLst;
165 double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
166 double myTimeMin , myTimeMax ; //!< Range of time stams, available for animation
168 QString myDumpFormat;
171 SVTK_ViewWindow* myView;
175 static int myNBAnimations;
179 class VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
180 public virtual VISU::Base_i
182 VISU_TimeAnimation* myAnim;
184 VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
185 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
186 ~VISU_TimeAnimation_i();
188 virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
189 //virtual VISU::VISUType GetType() { return VISU::TNONE; }
191 virtual void addField(SALOMEDS::SObject_ptr theField);
193 virtual CORBA::Boolean generateFrames();
194 virtual void generatePresentations(CORBA::Long theFieldNum);
196 virtual void clearView();
198 virtual void stopAnimation();
199 virtual void startAnimation();
200 virtual void nextFrame();
201 virtual void prevFrame();
202 virtual void firstFrame();
203 virtual void lastFrame();
204 virtual void gotoFrame(CORBA::Long theFrame);
206 virtual CORBA::Long getNbFields();
207 virtual CORBA::Long getNbFrames();
208 virtual CORBA::Boolean isRunning();
209 virtual CORBA::Long getCurrentFrame();
211 virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
213 virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
214 virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
216 virtual void setSpeed(CORBA::Long theSpeed);
217 virtual CORBA::Long getSpeed();
219 virtual CORBA::Boolean isProportional();
221 virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
223 virtual CORBA::Double getMinRange();
224 virtual CORBA::Double getMaxRange();
225 virtual CORBA::Boolean isRangeDefined();
227 virtual void dumpTo(const char* thePath);
228 virtual char* setDumpFormat(const char* theFormat);
230 virtual CORBA::Boolean isCycling();
232 virtual CORBA::Double getMinTime();
233 virtual CORBA::Double getMaxTime();
235 virtual void setProportional(CORBA::Boolean theProp);
236 virtual void setCycling(CORBA::Boolean theCycle);
238 virtual SALOMEDS::SObject_ptr publishInStudy();
239 virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
240 virtual CORBA::Boolean isSavedInStudy();
241 virtual void saveAnimation();
244 #endif //VISU_TIMEANIMATION_H