]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_TimeAnimation.h
Salome HOME
SMH: 3.0.0 preparation - merged and adopted version (POLYWORK+HEAD)
[modules/visu.git] / src / VISU_I / VISU_TimeAnimation.h
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : VISU_TimeAnimation.h
6 //  Author : Vitaly SMETANNIKOV
7 //  Module : VISU
8
9 #ifndef VISU_TIMEANIMATION_H
10 #define VISU_TIMEANIMATION_H
11
12 #include "VISUConfig.hh"
13
14 #include <vector>
15
16 #include <qobject.h>
17 #include <qvaluelist.h>
18 #include <qthread.h>
19
20 class SVTK_ViewWindow;
21 class VISU_Actor;
22
23 namespace VISU{
24   class Result_i;
25   class ScalarMap_i;
26 }
27
28 struct FieldData
29 {
30   VISU::VISUType myPrsType;  
31   //SALOMEDS::SObject_var myField; // field label
32   _PTR(SObject) myField; // field label
33   long myNbTimes;                // number of Timestamps
34   long myNbFrames;               // number of created Frames
35   std::vector<VISU::ScalarMap_i*> myPrs;         // Presentations
36   std::vector<VISU_Actor*> myActors;         // Actors
37   std::vector<double> myTiming;              // time values
38 };
39
40
41 class VISU_TimeAnimation: public QObject, public QThread
42 {
43   Q_OBJECT;
44  public:
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);
48   
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);
52   
53   //VISU_TimeAnimation(SALOMEDS::Study_ptr theStudy,
54   VISU_TimeAnimation(_PTR(Study) theStudy,
55                      VISU::View3D_ptr theView3D = VISU::View3D::_nil());
56   ~VISU_TimeAnimation();
57   
58   virtual VISU::VISUType GetType() { return VISU::TNONE;};
59   
60   void addField (_PTR(SObject) theField);
61   void addField (SALOMEDS::SObject_ptr theField);
62   FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
63
64   CORBA::Boolean generateFrames();
65   void generatePresentations(CORBA::Long theFieldNum);
66   void setViewer(SVTK_ViewWindow* theView) { myView = theView; }
67   SVTK_ViewWindow* getViewer() { return myView; }
68   void clearView();
69   void clearData(FieldData& theData);
70
71   void stopAnimation();
72   void startAnimation();
73   void nextFrame();
74   void prevFrame();
75   void firstFrame();
76   void lastFrame();
77   void gotoFrame(CORBA::Long theFrame);
78
79   CORBA::Long getNbFields() { return myFieldsLst.size(); }
80   CORBA::Long getNbFrames();
81   CORBA::Boolean isRunning() { return myIsActive; }
82   CORBA::Long getCurrentFrame() { return myFrame; }
83
84   VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
85
86   void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) { myFieldsLst[theFieldNum].myPrsType = theType; }
87   VISU::VISUType getPresentationType(CORBA::Long theFieldNum) { return myFieldsLst[theFieldNum].myPrsType; }
88
89   void setSpeed(CORBA::Long theSpeed);
90   CORBA::Long getSpeed() { return mySpeed; }
91
92   CORBA::Boolean isProportional() { return myProportional; }
93
94   void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
95     { myMaxVal = theMax; myMinVal = theMin; }
96
97   CORBA::Double getMinRange() { return myMinVal; }
98   CORBA::Double getMaxRange() { return myMaxVal; } 
99   CORBA::Boolean isRangeDefined() { return !((myMaxVal==0) && (myMinVal == myMaxVal)); }
100
101   void dumpTo(const char* thePath) { myDumpPath = thePath; }
102
103   QString getLastErrorMsg() { return myLastError; }
104
105   CORBA::Boolean isCycling() { return myCycling; }
106
107   CORBA::Double getMinTime() { return myTimeMin;}
108   CORBA::Double getMaxTime() { return myTimeMax;}
109
110   void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
111   void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
112
113  public slots:
114   void setProportionalSlot(bool theProp) { myProportional = theProp; }
115   void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
116
117  signals:
118   void frameChanged(long theNewFrame, double theTime);
119   void stopped();
120
121  protected:
122   void run();
123
124  private:
125   QString myLastError;
126
127   QValueList<FieldData> myFieldsLst;
128   bool myIsActive;
129   long myFrame;
130   int mySpeed;
131   bool myProportional;
132   bool myCycling;
133   //SALOMEDS::Study_var myStudy;
134   _PTR(Study) myStudy;
135
136   double myMaxVal, myMinVal;
137   double myTimeMin, myTimeMax;
138   QString myDumpPath;
139   SVTK_ViewWindow* myView;
140 };
141
142
143 class VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
144                             public virtual VISU::Base_i
145 {
146   VISU_TimeAnimation* myAnim;
147 public:
148   VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy, 
149                        VISU::View3D_ptr theView3D = VISU::View3D::_nil());
150   ~VISU_TimeAnimation_i();
151
152   virtual VISU::VISUType GetType(){ return VISU::TNONE;}
153
154   virtual void addField(SALOMEDS::SObject_ptr theField);
155
156   virtual CORBA::Boolean generateFrames();
157   virtual void generatePresentations(CORBA::Long theFieldNum);
158   
159   virtual void clearView();
160
161   virtual void stopAnimation();
162   virtual void startAnimation();
163   virtual void nextFrame();
164   virtual void prevFrame();
165   virtual void firstFrame();
166   virtual void lastFrame();
167   virtual void gotoFrame(CORBA::Long theFrame);
168
169   virtual CORBA::Long getNbFields();
170   virtual CORBA::Long getNbFrames();
171   virtual CORBA::Boolean isRunning();
172   virtual CORBA::Long getCurrentFrame();
173
174   virtual VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
175
176   virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
177   virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
178
179   virtual void setSpeed(CORBA::Long theSpeed);
180   virtual CORBA::Long getSpeed();
181
182   virtual CORBA::Boolean isProportional();
183
184   virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
185
186   virtual CORBA::Double getMinRange();
187   virtual CORBA::Double getMaxRange();
188   virtual CORBA::Boolean isRangeDefined();
189
190   virtual void dumpTo(const char* thePath);
191
192   virtual CORBA::Boolean isCycling();
193
194   virtual CORBA::Double getMinTime();
195   virtual CORBA::Double getMaxTime();
196
197   virtual void setProportional(CORBA::Boolean theProp);
198   virtual void setCycling(CORBA::Boolean theCycle);
199 };
200
201
202 #endif  //VISU_TIMEANIMATION_H