Salome HOME
debug of local CS
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_VTKPrs.h
index 558d7ba54c120f592c8c232ed6abbd5d4a4c1454..f5a3f86fc8db2ebd2c3cd004d6e0b801c0ffae3d 100644 (file)
 
 #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
   Description : Base class for all HYDRO presentation in VTK viewer