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);
71 void startAnimation();
76 void gotoFrame(CORBA::Long theFrame);
78 CORBA::Long getNbFields() { return myFieldsLst.size(); }
79 CORBA::Long getNbFrames();
80 CORBA::Boolean isRunning() { return myIsActive; }
81 CORBA::Long getCurrentFrame() { return myFrame; }
83 VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
85 void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType)
86 { myFieldsLst[theFieldNum].myPrsType = theType; }
87 VISU::VISUType getPresentationType(CORBA::Long theFieldNum)
88 { return myFieldsLst[theFieldNum].myPrsType; }
90 void setSpeed(CORBA::Long theSpeed);
91 CORBA::Long getSpeed() { return mySpeed; }
93 CORBA::Boolean isProportional() { return myProportional; }
95 void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
96 { myMaxVal = theMax; myMinVal = theMin; }
98 CORBA::Double getMinRange() { return myMinVal; }
99 CORBA::Double getMaxRange() { return myMaxVal; }
100 CORBA::Boolean isRangeDefined() { return !((myMaxVal==0) && (myMinVal == myMaxVal)); }
102 void dumpTo(const char* thePath) { myDumpPath = thePath; }
103 std::string setDumpFormat(const char* theFormat);
105 QString getLastErrorMsg() { return myLastError; }
107 CORBA::Boolean isCycling() { return myCycling; }
109 CORBA::Double getMinTime() { return myTimeMin;}
110 CORBA::Double getMaxTime() { return myTimeMax;}
112 void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
113 void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
115 SALOMEDS::SObject_ptr publishInStudy();
116 void restoreFromStudy(SALOMEDS::SObject_ptr theField);
117 void restoreFromStudy(_PTR(SObject) theField);
118 void saveAnimation();
119 bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
122 void setProportionalSlot(bool theProp) { myProportional = theProp; }
123 void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
126 void frameChanged(long theNewFrame, double theTime);
131 QString GenerateName();
134 void onViewDeleted();
139 QValueList<FieldData> myFieldsLst;
147 double myMaxVal, myMinVal;
148 double myTimeMin, myTimeMax;
150 QString myDumpFormat;
151 SVTK_ViewWindow* myView;
155 static int myNBAnimations;
159 class VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
160 public virtual VISU::Base_i
162 VISU_TimeAnimation* myAnim;
164 VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
165 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
166 ~VISU_TimeAnimation_i();
168 virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
169 //virtual VISU::VISUType GetType() { return VISU::TNONE; }
171 virtual void addField(SALOMEDS::SObject_ptr theField);
173 virtual CORBA::Boolean generateFrames();
174 virtual void generatePresentations(CORBA::Long theFieldNum);
176 virtual void clearView();
178 virtual void stopAnimation();
179 virtual void startAnimation();
180 virtual void nextFrame();
181 virtual void prevFrame();
182 virtual void firstFrame();
183 virtual void lastFrame();
184 virtual void gotoFrame(CORBA::Long theFrame);
186 virtual CORBA::Long getNbFields();
187 virtual CORBA::Long getNbFrames();
188 virtual CORBA::Boolean isRunning();
189 virtual CORBA::Long getCurrentFrame();
191 virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
193 virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
194 virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
196 virtual void setSpeed(CORBA::Long theSpeed);
197 virtual CORBA::Long getSpeed();
199 virtual CORBA::Boolean isProportional();
201 virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
203 virtual CORBA::Double getMinRange();
204 virtual CORBA::Double getMaxRange();
205 virtual CORBA::Boolean isRangeDefined();
207 virtual void dumpTo(const char* thePath);
208 virtual char* setDumpFormat(const char* theFormat);
210 virtual CORBA::Boolean isCycling();
212 virtual CORBA::Double getMinTime();
213 virtual CORBA::Double getMaxTime();
215 virtual void setProportional(CORBA::Boolean theProp);
216 virtual void setCycling(CORBA::Boolean theCycle);
218 virtual SALOMEDS::SObject_ptr publishInStudy();
219 virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
220 virtual CORBA::Boolean isSavedInStudy();
221 virtual void saveAnimation();
224 #endif //VISU_TIMEANIMATION_H