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