]> Creatis software - cpPlugins.git/commitdiff
Actors updated
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 26 May 2016 17:21:04 +0000 (12:21 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 26 May 2016 17:21:04 +0000 (12:21 -0500)
appli/PipelineEditor/PipelineEditor.cxx
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpPlugins/DataObject.cxx
lib/cpPlugins/DataObject.h
lib/cpPlugins/Image.cxx
lib/cpPlugins/Image.h

index f646520..65fb82b 100644 (file)
@@ -98,7 +98,7 @@ _ShowFilterOutput(
 
   // Create and associate actor
   this->_Block( );
-  this->m_UI->Viewer->AddActor( output->CreateVTKActor( ) );
+  this->m_UI->Viewer->AddActor( output->GetVTKActor( ) );
   this->_UnBlock( );
 }
 
index 3ac1e5d..838cc84 100644 (file)
@@ -93,6 +93,7 @@ SetInputActor( vtkProp* actor, int orientation )
     dynamic_cast< vtkImageSliceMapper* >( real_actor->GetMapper( ) );
   if( real_mapper == NULL )
     return;
+  this->m_Actor = real_actor;
   this->m_Mapper = real_mapper;
   this->_ConfigureInput( orientation );
 }
index 9fd054d..e51ddaf 100644 (file)
@@ -5,7 +5,7 @@
 #include <itkDataObject.h>
 #include <vtkImageData.h>
 #include <vtkPolyData.h>
-#include <vtkRenderWindow.h>
+#include <vtkProp.h>
 
 // -------------------------------------------------------------------------
 cpPlugins::ProcessObject* cpPlugins::DataObject::
@@ -86,22 +86,42 @@ CreateQtDialog( )
 
 // -------------------------------------------------------------------------
 vtkProp* cpPlugins::DataObject::
-CreateVTKActor( )
+GetVTKActor( )
 {
-  return( NULL );
+  if( this->m_Actor == NULL )
+    this->_CreateVTKActor( );
+  return( this->m_Actor );
+}
+
+// -------------------------------------------------------------------------
+const vtkProp* cpPlugins::DataObject::
+GetVTKActor( ) const
+{
+  if( this->m_Actor == NULL )
+    this->_CreateVTKActor( );
+  return( this->m_Actor );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::DataObject::
 DataObject( )
   : Superclass( ),
-    m_Source( NULL )
+    m_Source( NULL ),
+    m_Actor( NULL )
 {
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::DataObject::
 ~DataObject( )
+{
+  if( this->m_Actor != NULL )
+    this->m_Actor->Delete( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::DataObject::
+_CreateVTKActor( ) const
 {
 }
 
index 0abc4a4..ae98879 100644 (file)
@@ -39,19 +39,23 @@ namespace cpPlugins
     virtual DataObjectVisualizationQtDialog* CreateQtDialog( );
 
     // VTK actors
-    virtual vtkProp* CreateVTKActor( );
+    vtkProp* GetVTKActor( );
+    const vtkProp* GetVTKActor( ) const;
 
   protected:
     DataObject( );
     virtual ~DataObject( );
 
+    virtual void _CreateVTKActor( ) const;
+
   private:
     // Purposely not implemented
     DataObject( const Self& );
     Self& operator=( const Self& );
 
   protected:
-    ProcessObject* m_Source;
+    ProcessObject*   m_Source;
+    mutable vtkProp* m_Actor;
   };
 
 } // ecapseman
index 04d28da..b3ff5d2 100644 (file)
@@ -28,18 +28,6 @@ SetVTK( vtkObjectBase* o )
   std::exit( 1 );
 }
 
-// -------------------------------------------------------------------------
-vtkProp* cpPlugins::Image::
-CreateVTKActor( )
-{
-  vtkImageSliceMapper* mapper = vtkImageSliceMapper::New( );
-  vtkImageActor* actor = vtkImageActor::New( );
-  mapper->SetInputData( this->GetVTK< vtkImageData >( ) );
-  actor->SetMapper( mapper );
-  mapper->Delete( );
-  return( actor );
-}
-
 // -------------------------------------------------------------------------
 cpPlugins::Image::
 Image( )
@@ -53,4 +41,22 @@ cpPlugins::Image::
 {
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Image::
+_CreateVTKActor( ) const
+{
+  vtkImageData* image =
+    const_cast< vtkImageData* >( this->GetVTK< vtkImageData >( ) );
+  if( image != NULL )
+  {
+    vtkImageSliceMapper* mapper = vtkImageSliceMapper::New( );
+    vtkImageActor* actor = vtkImageActor::New( );
+    mapper->SetInputData( image );
+    actor->SetMapper( mapper );
+    this->m_Actor = actor;
+    // TODO: mapper->Delete( );
+
+  } // fi
+}
+
 // eof - $RCSfile$
index 62b9ff1..1f2e51e 100644 (file)
@@ -27,12 +27,12 @@ namespace cpPlugins
     virtual void SetITK( itk::LightObject* o ) ITK_OVERRIDE;
     virtual void SetVTK( vtkObjectBase* o ) ITK_OVERRIDE;
 
-    virtual vtkProp* CreateVTKActor( ) ITK_OVERRIDE;
-
   protected:
     Image( );
     virtual ~Image( );
 
+    virtual void _CreateVTKActor( ) const ITK_OVERRIDE;
+
     template< unsigned int D >
       inline bool _ITK_2_VTK_0( itk::LightObject* o );