]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_TimeAnimation.h
Salome HOME
0331f2f773b52e8bd94c2f763a7c31aa44330f74
[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 class VTKViewer_ViewFrame;
15 class VISU_Actor;
16
17 #include <qobject.h>
18 #include <qvaluelist.h>
19 #include <qthread.h>
20
21 namespace VISU{
22   class Result_i;
23   class ScalarMap_i;
24 }
25
26 struct FieldData
27 {
28   VISU::VISUType myPrsType;  
29   SALOMEDS::SObject_var myField; // field label
30   long myNbTimes;                // number of Timestamps
31   long myNbFrames;               // number of created Frames
32   VISU::ScalarMap_i** myPrs;         // Presentations
33   VISU_Actor** myActors;         // Actors
34   double* myTiming;              // time values
35 };
36
37
38 class VISU_TimeAnimation: public QObject, public QThread,
39                           public virtual POA_VISU::Animation,
40                           public virtual VISU::Base_i
41 {
42   Q_OBJECT;
43  public:
44   static VISU::Result_i* createPresent(SALOMEDS::SObject_var theField);
45   static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject);
46   static double getTimeValue(SALOMEDS::SObject_var theTimestamp);
47   
48   VISU_TimeAnimation(SALOMEDS::Study_var theStudy, VISU::View3D_ptr theView3D = VISU::View3D::_nil());
49   ~VISU_TimeAnimation();
50   
51   virtual VISU::VISUType GetType() { return VISU::TNONE;};
52   
53   void addField(SALOMEDS::SObject_ptr theField);
54   FieldData& getFieldData(int theNum) { return myFieldsLst[theNum]; }
55
56   CORBA::Boolean generateFrames();
57   void generatePresentations(CORBA::Long theFieldNum);
58   void setViewer(VTKViewer_ViewFrame* theView) { myView = theView; }
59   VTKViewer_ViewFrame* getViewer() { return myView; }
60   void clearView();
61   void clearData(FieldData& theData);
62
63   void stopAnimation();
64   void startAnimation();
65   void nextFrame();
66   void prevFrame();
67   void firstFrame();
68   void lastFrame();
69   void gotoFrame(CORBA::Long theFrame);
70
71   CORBA::Long getNbFields() { return myFieldsLst.size(); }
72   CORBA::Long getNbFrames();
73   CORBA::Boolean isRunning() { return myIsActive; }
74   CORBA::Long getCurrentFrame() { return myFrame; }
75
76   VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
77
78   void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) { myFieldsLst[theFieldNum].myPrsType = theType; }
79   VISU::VISUType getPresentationType(CORBA::Long theFieldNum) { return myFieldsLst[theFieldNum].myPrsType; }
80
81   void setSpeed(CORBA::Long theSpeed);
82   CORBA::Long getSpeed() { return mySpeed; }
83
84   CORBA::Boolean isProportional() { return myProportional; }
85
86   void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
87     { myMaxVal = theMax; myMinVal = theMin; }
88
89   CORBA::Double getMinRange() { return myMinVal; }
90   CORBA::Double getMaxRange() { return myMaxVal; } 
91   CORBA::Boolean isRangeDefined() { return !((myMaxVal==0) && (myMinVal == myMaxVal)); }
92
93   void dumpTo(const char* thePath) { myDumpPath = thePath; }
94
95   QString getLastErrorMsg() { return myLastError; }
96
97   CORBA::Boolean isCycling() { return myCycling; }
98
99   CORBA::Double getMinTime() { return myTimeMin;}
100   CORBA::Double getMaxTime() { return myTimeMax;}
101
102   void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
103   void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
104
105  public slots:
106   void setProportionalSlot(bool theProp) { myProportional = theProp; }
107   void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
108
109  signals:
110   void frameChanged(long theNewFrame, double theTime);
111   void stopped();
112
113  protected:
114   void run();
115
116  private:
117   QString myLastError;
118
119   QValueList<FieldData> myFieldsLst;
120   bool myIsActive;
121   long myFrame;
122   int mySpeed;
123   bool myProportional;
124   bool myCycling;
125   SALOMEDS::Study_var myStudy;
126
127   double myMaxVal, myMinVal;
128   double myTimeMin, myTimeMax;
129   QString myDumpPath;
130   VTKViewer_ViewFrame* myView;
131 };
132
133 #endif  //VISU_TIMEANIMATION_H