Salome HOME
Fix for the bug #255: VTK viewer is not updated after modification of objects.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_VTKPrs.h
index d679856a466197351ac1fd6aab13d177cd73fbe9..f5a3f86fc8db2ebd2c3cd004d6e0b801c0ffae3d 100644 (file)
 #define HYDROGUI_VTKPrs_H
 
 #include <HYDROData_Entity.h>
+#include <HYDROData_AltitudeObject.h>
 
 #include <SALOME_InteractiveObject.hxx>
 #include <SVTK_Prs.h>
+#include <vtkActorCollection.h>
+
+class vtkMapper;
+
+template <class ActorType> ActorType* getActor(SVTK_Prs* thePrs);
+
+/**
+ * Get a VTK actor of the given presentation. Create a new one if there is no actor yet.
+ */
+template <class ActorType>
+ActorType* getActor(SVTK_Prs* thePrs)
+{
+  ActorType* anActor = 0;
+  vtkActorCollection* aContent = thePrs->GetObjects();
+  if ( aContent )
+  {
+    // Remove old actor because of the problem of GEOM_Actor updating.
+    //anActor = dynamic_cast<ActorType*>( aContent->GetLastActor() );
+    aContent->RemoveAllItems();
+  }
+  if ( !anActor )
+  {
+    anActor = ActorType::New();
+    thePrs->AddObject( anActor );
+    anActor->Delete();
+  }
+  return anActor;
+}
+
 
 /*
   Class       : HYDROGUI_VTKPrs
@@ -39,6 +69,9 @@ public:
   virtual ~HYDROGUI_VTKPrs();
 
   virtual void                     compute();
+  virtual bool                     needScalarBar() { return false; }
+
+  static double InvalidZValue() { return HYDROData_AltitudeObject::GetInvalidAltitude(); }
 
 public:
   Handle(HYDROData_Entity)         getObject() const { return myObject; }
@@ -46,11 +79,29 @@ public:
 
   bool                             getIsToUpdate() const { return myIsToUpdate; }
   void                             setIsToUpdate( bool theState ) { myIsToUpdate = theState; }
+  /**
+   * \brief Set the range of Z values for the color mapping.
+   */
+  virtual void                     setZRange( double theRange[] );
+  /**
+   * \brief Get the range of Z values for the color mapping.
+   */
+  virtual double*                 getZRange() { return myZRange; }
+  /**
+   * \brief Get an actual Z values range of the presented object.
+   */
+  virtual double*                 getInternalZRange() { return myInternalZRange; }
+
+protected:
+  virtual vtkMapper*               mapper() { return 0; }
+
+  double                           myInternalZRange[2]; //!< Actual Z values range of the presented object
 
 private:
   Handle(HYDROData_Entity)         myObject;
   Handle(SALOME_InteractiveObject) myIO;
   bool                             myIsToUpdate;
+  double                           myZRange[2];         //!< Imposed Z values range for colors mapping
 };
 
 #endif