1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : VISU_TimeAnimation.h
6 // Author : Vitaly SMETANNIKOV
9 #ifndef VISU_TIMEANIMATION_H
10 #define VISU_TIMEANIMATION_H
12 #include "VISUConfig.hh"
17 #include <qvaluelist.h>
20 class SVTK_ViewWindow;
30 VISU::VISUType myPrsType;
31 _PTR(SObject) myField; // field label
32 long myNbTimes; // number of Timestamps
33 long myNbFrames; // number of created Frames
34 std::vector<VISU::ColoredPrs3d_i*> myPrs; // Presentations
35 std::vector<VISU_Actor*> myActors; // Actors
36 std::vector<double> myTiming; // time values
41 class VISU_TimeAnimation: public QObject, public QThread
45 //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
46 //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);
47 //static double getTimeValue (SALOMEDS::SObject_var theTimestamp);
49 static VISU::Result_i* createPresent (_PTR(SObject) theField);
50 static VISU::Storable::TRestoringMap getMapOfValue (_PTR(SObject) theSObject);
51 static double getTimeValue (_PTR(SObject) theTimestamp);
53 VISU_TimeAnimation(_PTR(Study) theStudy,
54 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
55 ~VISU_TimeAnimation();
57 virtual VISU::VISUType GetType() { return VISU::TNONE;};
59 void addField (_PTR(SObject) theField);
60 void addField (SALOMEDS::SObject_ptr theField);
61 FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
63 CORBA::Boolean generateFrames();
64 void generatePresentations(CORBA::Long theFieldNum);
65 void setViewer(SVTK_ViewWindow* theView) { myView = theView; }
66 SVTK_ViewWindow* getViewer() { return myView; }
68 void clearData(FieldData& theData);
69 void clearFieldData() { myFieldsLst.clear();};
72 void startAnimation();
77 void gotoFrame(CORBA::Long theFrame);
79 CORBA::Long getNbFields() { return myFieldsLst.size(); }
80 CORBA::Long getNbFrames();
81 CORBA::Boolean isRunning() { return myIsActive; }
82 CORBA::Long getCurrentFrame() { return myFrame; }
84 VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
86 void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType)
87 { myFieldsLst[theFieldNum].myPrsType = theType; }
88 VISU::VISUType getPresentationType(CORBA::Long theFieldNum)
89 { return myFieldsLst[theFieldNum].myPrsType; }
91 void setSpeed(CORBA::Long theSpeed);
92 CORBA::Long getSpeed() { return mySpeed; }
94 CORBA::Boolean isProportional() { return myProportional; }
96 void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
97 { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
99 CORBA::Double getMinRange() { return myTimeMinVal; }
100 CORBA::Double getMaxRange() { return myTimeMaxVal; }
101 CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
103 void dumpTo(const char* thePath) { myDumpPath = thePath; }
104 std::string setDumpFormat(const char* theFormat);
106 QString getLastErrorMsg() { return myLastError; }
108 CORBA::Boolean isCycling() { return myCycling; }
110 CORBA::Double getMinTime() { return myTimeMin;}
111 CORBA::Double getMaxTime() { return myTimeMax;}
113 void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
114 void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
116 SALOMEDS::SObject_ptr publishInStudy();
117 void restoreFromStudy(SALOMEDS::SObject_ptr theField);
118 void restoreFromStudy(_PTR(SObject) theField);
119 void saveAnimation();
120 bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
123 void setProportionalSlot(bool theProp) { myProportional = theProp; }
124 void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
127 void frameChanged(long theNewFrame, double theTime);
132 QString GenerateName();
135 void onViewDeleted();
140 QValueList<FieldData> myFieldsLst;
148 double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
149 double myTimeMin , myTimeMax ; //!< Range of time stams, available for animation
151 QString myDumpFormat;
152 SVTK_ViewWindow* myView;
156 static int myNBAnimations;
160 class VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
161 public virtual VISU::Base_i
163 VISU_TimeAnimation* myAnim;
165 VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
166 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
167 ~VISU_TimeAnimation_i();
169 virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
170 //virtual VISU::VISUType GetType() { return VISU::TNONE; }
172 virtual void addField(SALOMEDS::SObject_ptr theField);
174 virtual CORBA::Boolean generateFrames();
175 virtual void generatePresentations(CORBA::Long theFieldNum);
177 virtual void clearView();
179 virtual void stopAnimation();
180 virtual void startAnimation();
181 virtual void nextFrame();
182 virtual void prevFrame();
183 virtual void firstFrame();
184 virtual void lastFrame();
185 virtual void gotoFrame(CORBA::Long theFrame);
187 virtual CORBA::Long getNbFields();
188 virtual CORBA::Long getNbFrames();
189 virtual CORBA::Boolean isRunning();
190 virtual CORBA::Long getCurrentFrame();
192 virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
194 virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
195 virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
197 virtual void setSpeed(CORBA::Long theSpeed);
198 virtual CORBA::Long getSpeed();
200 virtual CORBA::Boolean isProportional();
202 virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
204 virtual CORBA::Double getMinRange();
205 virtual CORBA::Double getMaxRange();
206 virtual CORBA::Boolean isRangeDefined();
208 virtual void dumpTo(const char* thePath);
209 virtual char* setDumpFormat(const char* theFormat);
211 virtual CORBA::Boolean isCycling();
213 virtual CORBA::Double getMinTime();
214 virtual CORBA::Double getMaxTime();
216 virtual void setProportional(CORBA::Boolean theProp);
217 virtual void setCycling(CORBA::Boolean theCycle);
219 virtual SALOMEDS::SObject_ptr publishInStudy();
220 virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
221 virtual CORBA::Boolean isSavedInStudy();
222 virtual void saveAnimation();
225 #endif //VISU_TIMEANIMATION_H