]> 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 f646520e93159e9af103afc8ee7c2ce8d9dccfbd..65fb82b7f816cd9c8403844a6c5e05b4bae47b7d 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 3ac1e5d909afd1530a394419bc724edfb515e999..838cc848535e3e8473a32f80aefe46ab07be4b4d 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 9fd054d8a7f2b07b64b454ad6a54d237d971a859..e51ddaf5fd6d354605076015edc080f7a54a4cc2 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 0abc4a4defe3ab9c909453e56026654cff1455c1..ae98879f94e2eb1ded5ff9e284c6928419fd2938 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 04d28da6069585e16d8aacf162fa065d8fd2deaf..b3ff5d2976eeea96a786ceb7546b2afb4db2579e 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 62b9ff183fd7dc71c6fe64220724853b8428d19c..1f2e51e0830d7ff251878322f509ba289f1cb9e5 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 );