]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_TimeAnimation.h
Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/visu.git] / src / VISU_I / VISU_TimeAnimation.h
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
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. 
8 // 
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. 
13 // 
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 
17 // 
18 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : VISU_TimeAnimation.h
21 //  Author : Vitaly SMETANNIKOV
22 //  Module : VISU
23
24 #ifndef VISU_TIMEANIMATION_H
25 #define VISU_TIMEANIMATION_H
26
27 #include "VISUConfig.hh"
28
29 #include <vector>
30
31 #include <qobject.h>
32 #include <qvaluelist.h>
33 #include <qthread.h>
34
35 class SVTK_ViewWindow;
36 class VISU_Actor;
37
38 namespace VISU
39 {
40   class Result_i;
41   class ColoredPrs3d_i;
42 }
43
44 struct FieldData
45 {
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];
54 };
55
56
57 class VISU_TimeAnimation: public QObject, public QThread
58 {
59   Q_OBJECT;
60  public:
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);
64
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);
68
69   VISU_TimeAnimation(_PTR(Study) theStudy,
70                      VISU::View3D_ptr theView3D = VISU::View3D::_nil());
71   ~VISU_TimeAnimation();
72
73   virtual VISU::VISUType GetType() { return VISU::TNONE;};
74
75   void addField (_PTR(SObject) theField);
76   void addField (SALOMEDS::SObject_ptr theField);
77   FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
78
79   CORBA::Boolean generateFrames();
80   void generatePresentations(CORBA::Long theFieldNum);
81   void setViewer(SVTK_ViewWindow* theView) { myView = theView; }
82   SVTK_ViewWindow* getViewer() { return myView; }
83   void clearView();
84   void clearData(FieldData& theData);
85   void clearFieldData() { myFieldsLst.clear();};
86
87   void stopAnimation();
88   void startAnimation();
89   void nextFrame();
90   void prevFrame();
91   void firstFrame();
92   void lastFrame();
93   void gotoFrame(CORBA::Long theFrame);
94
95   CORBA::Long getNbFields() { return myFieldsLst.size(); }
96   CORBA::Long getNbFrames();
97   CORBA::Boolean isRunning() { return myIsActive; }
98   CORBA::Long getCurrentFrame() { return myFrame; }
99
100   VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
101
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; }
106
107   void setSpeed(CORBA::Long theSpeed);
108   CORBA::Long getSpeed() { return mySpeed; }
109
110   CORBA::Boolean isProportional() { return myProportional; }
111
112   void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
113     { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
114
115   CORBA::Double getMinRange() { return myTimeMinVal; }
116   CORBA::Double getMaxRange() { return myTimeMaxVal; }
117   CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
118
119   void dumpTo(const char* thePath) { myDumpPath = thePath; }
120   std::string setDumpFormat(const char* theFormat);
121   bool checkAVIMaker() const;
122
123   QString getLastErrorMsg() { return myLastError; }
124
125   CORBA::Boolean isCycling() { return myCycling; }
126
127   CORBA::Double getMinTime() { return myTimeMin;}
128   CORBA::Double getMaxTime() { return myTimeMax;}
129
130   void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
131   void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
132
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(); }
138
139  public slots:
140   void setProportionalSlot(bool theProp) { myProportional = theProp; }
141   void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
142
143  signals:
144   void frameChanged(long theNewFrame, double theTime);
145   void stopped();
146
147  protected:
148   void run();
149   QString GenerateName();
150
151  private slots:
152    void onViewDeleted();
153
154  private:
155   QString myLastError;
156
157   QValueList<FieldData> myFieldsLst;
158   bool myIsActive;
159   long myFrame;
160   int mySpeed;
161   bool myProportional;
162   bool myCycling;
163   _PTR(Study) myStudy;
164
165   double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
166   double myTimeMin   , myTimeMax   ; //!< Range of time stams, available for animation
167   QString myDumpPath;
168   QString myDumpFormat;
169   QString myAVIMaker;
170   long myFileIndex;
171   SVTK_ViewWindow* myView;
172
173   QString myAnimEntry;
174
175   static int myNBAnimations;
176 };
177
178
179 class VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
180                             public virtual VISU::Base_i
181 {
182   VISU_TimeAnimation* myAnim;
183 public:
184   VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
185                        VISU::View3D_ptr theView3D = VISU::View3D::_nil());
186   ~VISU_TimeAnimation_i();
187
188   virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
189   //virtual VISU::VISUType GetType() { return VISU::TNONE; }
190
191   virtual void addField(SALOMEDS::SObject_ptr theField);
192
193   virtual CORBA::Boolean generateFrames();
194   virtual void generatePresentations(CORBA::Long theFieldNum);
195
196   virtual void clearView();
197
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);
205
206   virtual CORBA::Long getNbFields();
207   virtual CORBA::Long getNbFrames();
208   virtual CORBA::Boolean isRunning();
209   virtual CORBA::Long getCurrentFrame();
210
211   virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
212
213   virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
214   virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
215
216   virtual void setSpeed(CORBA::Long theSpeed);
217   virtual CORBA::Long getSpeed();
218
219   virtual CORBA::Boolean isProportional();
220
221   virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
222
223   virtual CORBA::Double getMinRange();
224   virtual CORBA::Double getMaxRange();
225   virtual CORBA::Boolean isRangeDefined();
226
227   virtual void dumpTo(const char* thePath);
228   virtual char* setDumpFormat(const char* theFormat);
229
230   virtual CORBA::Boolean isCycling();
231
232   virtual CORBA::Double getMinTime();
233   virtual CORBA::Double getMaxTime();
234
235   virtual void setProportional(CORBA::Boolean theProp);
236   virtual void setCycling(CORBA::Boolean theCycle);
237
238   virtual SALOMEDS::SObject_ptr publishInStudy();
239   virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
240   virtual CORBA::Boolean isSavedInStudy();
241   virtual void saveAnimation();
242 };
243
244 #endif  //VISU_TIMEANIMATION_H