Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/visu.git] / src / VISU_I / VISU_TimeAnimation.h
1 //  File      : VISU_TimeAnimation.h
2 //  Created   : 10 / 04 / 2003
3 //  Author    : Vitaly SMETANNIKOV
4 //  Project   : SALOME 
5 //  Module    : VISU_I
6 //  Copyright : Open CASCADE 
7
8 #ifndef VISU_TIMEANIMATION_H
9 #define VISU_TIMEANIMATION_H
10
11 #include <qobject.h>
12 #include <qvaluelist.h>
13 #include <qthread.h>
14 #include "VISU_Actor.h"
15 #include "VISU_PrsObject_i.hh"
16 #include "VTKViewer_ViewFrame.h"
17
18
19 struct FieldData
20 {
21   VISU::VISUType myPrsType;  
22   SALOMEDS::SObject_var myField; // field label
23   long myNbTimes;                // number of Timestamps
24   VISU::ScalarMap_i** myPrs;         // Presentations
25   VISU_Actor** myActors;         // Actors
26   double* myTiming;              // time values
27 };
28
29
30 class VISU_TimeAnimation: public QObject, public QThread
31 {
32     Q_OBJECT
33  public:
34   static VISU::Result_i* createPresent(SALOMEDS::SObject_var theField);
35   static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject);
36   static double getTimeValue(SALOMEDS::SObject_var theTimestamp);
37   
38   VISU_TimeAnimation(SALOMEDS::Study_var theStudy);
39   ~VISU_TimeAnimation();
40
41   void addField(SALOMEDS::SObject_var theField);
42   FieldData& getFieldData(int theNum) { return myFieldsLst[theNum]; }
43
44   bool generateFrames();
45   void generatePresentations(int theFieldNum);
46   void setViewer(VTKViewer_ViewFrame* theView) { myView = theView; }
47   VTKViewer_ViewFrame* getViewer() { return myView; }
48   void clearView();
49   void clearData(FieldData& theData);
50
51   void stopAnimation();
52   void startAnimation();
53   void nextFrame();
54   void prevFrame();
55   void firstFrame();
56   void lastFrame();
57   void gotoFrame(long theFrame);
58
59   int getNbFields() { return myFieldsLst.size(); }
60   long getNbFrames();
61   bool isRunning() { return myIsActive; }
62   long getCurrentFrame() { return myFrame; }
63
64   VISU::ScalarMap_i* getPresentation(int theField, long theFrame);
65
66   void setPresentationType(int theFieldNum, VISU::VISUType theType) { myFieldsLst[theFieldNum].myPrsType = theType; }
67   VISU::VISUType getPresentationType(int theFieldNum) { return myFieldsLst[theFieldNum].myPrsType; }
68
69   void setSpeed(int theSpeed);
70   int getSpeed() { return mySpeed; }
71
72   bool isProportional() { return myProportional; }
73
74   void setAnimationRange(double theMin, double theMax)
75     { myMaxVal = theMax; myMinVal = theMin; }
76
77   double getMinRange() { return myMinVal; }
78   double getMaxRange() { return myMaxVal; } 
79   bool isRangeDefined() { return ((myMaxVal!=0) && (myMinVal != 0)); }
80
81   void dumpTo(QString thePath) { myDumpPath = thePath; }
82
83  public slots:
84   void setProportional(bool theProp) { myProportional = theProp; }
85
86  signals:
87   void frameChanged(long theNewFrame, double theTime);
88
89  protected:
90   void run();
91
92  private:
93
94   QValueList<FieldData> myFieldsLst;
95   bool myIsActive;
96   long myFrame;
97   int mySpeed;
98   bool myProportional;
99   SALOMEDS::Study_var myStudy;
100
101   double myMaxVal, myMinVal;
102   QString myDumpPath;
103   VTKViewer_ViewFrame* myView;
104 };
105
106 #endif  //VISU_TIMEANIMATION_H