Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISU_I / VISU_TimeAnimation.h
index 01de4065dbb2f9767086998e5618a55145b99e30..bb1925a80348bf7b1432a6fc46fe849038347d3f 100644 (file)
 #include <qvaluelist.h>
 #include <qthread.h>
 
-class VTKViewer_ViewFrame;
+class SVTK_ViewWindow;
 class VISU_Actor;
 
 namespace VISU{
   class Result_i;
-  class ScalarMap_i;
+  class ColoredPrs3d_i;
 }
 
 struct FieldData
 {
-  VISU::VISUType myPrsType;  
-  SALOMEDS::SObject_var myField; // field label
-  long myNbTimes;                // number of Timestamps
-  long myNbFrames;               // number of created Frames
-  std::vector<VISU::ScalarMap_i*> myPrs;         // Presentations
+  VISU::VISUType myPrsType;
+  _PTR(SObject) myField; // field label
+  long myNbTimes;        // number of Timestamps
+  long myNbFrames;       // number of created Frames
+  std::vector<VISU::ColoredPrs3d_i*> myPrs;     // Presentations
   std::vector<VISU_Actor*> myActors;         // Actors
   std::vector<double> myTiming;              // time values
+  float myOffset[3];
 };
 
 
@@ -41,24 +42,31 @@ class VISU_TimeAnimation: public QObject, public QThread
 {
   Q_OBJECT;
  public:
-  static VISU::Result_i* createPresent(SALOMEDS::SObject_var theField);
-  static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject);
-  static double getTimeValue(SALOMEDS::SObject_var theTimestamp);
-  
-  VISU_TimeAnimation(SALOMEDS::Study_ptr theStudy, VISU::View3D_ptr theView3D = VISU::View3D::_nil());
+  //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
+  //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);
+  //static double getTimeValue (SALOMEDS::SObject_var theTimestamp);
+
+  static VISU::Result_i* createPresent (_PTR(SObject) theField);
+  static VISU::Storable::TRestoringMap getMapOfValue (_PTR(SObject) theSObject);
+  static double getTimeValue (_PTR(SObject) theTimestamp);
+
+  VISU_TimeAnimation(_PTR(Study) theStudy,
+                    VISU::View3D_ptr theView3D = VISU::View3D::_nil());
   ~VISU_TimeAnimation();
-  
+
   virtual VISU::VISUType GetType() { return VISU::TNONE;};
-  
-  void addField(SALOMEDS::SObject_ptr theField);
-  FieldData& getFieldData(int theNum) { return myFieldsLst[theNum]; }
+
+  void addField (_PTR(SObject) theField);
+  void addField (SALOMEDS::SObject_ptr theField);
+  FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
 
   CORBA::Boolean generateFrames();
   void generatePresentations(CORBA::Long theFieldNum);
-  void setViewer(VTKViewer_ViewFrame* theView) { myView = theView; }
-  VTKViewer_ViewFrame* getViewer() { return myView; }
+  void setViewer(SVTK_ViewWindow* theView) { myView = theView; }
+  SVTK_ViewWindow* getViewer() { return myView; }
   void clearView();
   void clearData(FieldData& theData);
+  void clearFieldData() { myFieldsLst.clear();};
 
   void stopAnimation();
   void startAnimation();
@@ -73,10 +81,12 @@ class VISU_TimeAnimation: public QObject, public QThread
   CORBA::Boolean isRunning() { return myIsActive; }
   CORBA::Long getCurrentFrame() { return myFrame; }
 
-  VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
+  VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
 
-  void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) { myFieldsLst[theFieldNum].myPrsType = theType; }
-  VISU::VISUType getPresentationType(CORBA::Long theFieldNum) { return myFieldsLst[theFieldNum].myPrsType; }
+  void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType)
+    { myFieldsLst[theFieldNum].myPrsType = theType; }
+  VISU::VISUType getPresentationType(CORBA::Long theFieldNum)
+    { return myFieldsLst[theFieldNum].myPrsType; }
 
   void setSpeed(CORBA::Long theSpeed);
   CORBA::Long getSpeed() { return mySpeed; }
@@ -84,13 +94,14 @@ class VISU_TimeAnimation: public QObject, public QThread
   CORBA::Boolean isProportional() { return myProportional; }
 
   void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
-    { myMaxVal = theMax; myMinVal = theMin; }
+    { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
 
-  CORBA::Double getMinRange() { return myMinVal; }
-  CORBA::Double getMaxRange() { return myMaxVal; } 
-  CORBA::Boolean isRangeDefined() { return !((myMaxVal==0) && (myMinVal == myMaxVal)); }
+  CORBA::Double getMinRange() { return myTimeMinVal; }
+  CORBA::Double getMaxRange() { return myTimeMaxVal; }
+  CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
 
   void dumpTo(const char* thePath) { myDumpPath = thePath; }
+  std::string setDumpFormat(const char* theFormat);
 
   QString getLastErrorMsg() { return myLastError; }
 
@@ -102,6 +113,12 @@ class VISU_TimeAnimation: public QObject, public QThread
   void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
   void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
 
+  SALOMEDS::SObject_ptr publishInStudy();
+  void restoreFromStudy(SALOMEDS::SObject_ptr theField);
+  void restoreFromStudy(_PTR(SObject) theField);
+  void saveAnimation();
+  bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
+
  public slots:
   void setProportionalSlot(bool theProp) { myProportional = theProp; }
   void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
@@ -112,6 +129,10 @@ class VISU_TimeAnimation: public QObject, public QThread
 
  protected:
   void run();
+  QString GenerateName();
+
+ private slots:
+   void onViewDeleted();
 
  private:
   QString myLastError;
@@ -122,12 +143,17 @@ class VISU_TimeAnimation: public QObject, public QThread
   int mySpeed;
   bool myProportional;
   bool myCycling;
-  SALOMEDS::Study_var myStudy;
+  _PTR(Study) myStudy;
 
-  double myMaxVal, myMinVal;
-  double myTimeMin, myTimeMax;
+  double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
+  double myTimeMin   , myTimeMax   ; //!< Range of time stams, available for animation
   QString myDumpPath;
-  VTKViewer_ViewFrame* myView;
+  QString myDumpFormat;
+  SVTK_ViewWindow* myView;
+
+  QString myAnimEntry;
+
+  static int myNBAnimations;
 };
 
 
@@ -136,17 +162,18 @@ class VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
 {
   VISU_TimeAnimation* myAnim;
 public:
-  VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy, 
+  VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
                        VISU::View3D_ptr theView3D = VISU::View3D::_nil());
   ~VISU_TimeAnimation_i();
 
-  virtual VISU::VISUType GetType(){ return VISU::TNONE;}
+  virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
+  //virtual VISU::VISUType GetType() { return VISU::TNONE; }
 
   virtual void addField(SALOMEDS::SObject_ptr theField);
 
   virtual CORBA::Boolean generateFrames();
   virtual void generatePresentations(CORBA::Long theFieldNum);
-  
+
   virtual void clearView();
 
   virtual void stopAnimation();
@@ -162,7 +189,7 @@ public:
   virtual CORBA::Boolean isRunning();
   virtual CORBA::Long getCurrentFrame();
 
-  virtual VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
+  virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
 
   virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
   virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
@@ -179,6 +206,7 @@ public:
   virtual CORBA::Boolean isRangeDefined();
 
   virtual void dumpTo(const char* thePath);
+  virtual char* setDumpFormat(const char* theFormat);
 
   virtual CORBA::Boolean isCycling();
 
@@ -187,7 +215,11 @@ public:
 
   virtual void setProportional(CORBA::Boolean theProp);
   virtual void setCycling(CORBA::Boolean theCycle);
-};
 
+  virtual SALOMEDS::SObject_ptr publishInStudy();
+  virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
+  virtual CORBA::Boolean isSavedInStudy();
+  virtual void saveAnimation();
+};
 
 #endif  //VISU_TIMEANIMATION_H