From: Leonardo Florez-Valencia Date: Thu, 26 May 2016 17:21:04 +0000 (-0500) Subject: Actors updated X-Git-Tag: v0.1~157 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e6f0b27971bbd8175ec5e8615e90b8fba9fa07c9;p=cpPlugins.git Actors updated --- diff --git a/appli/PipelineEditor/PipelineEditor.cxx b/appli/PipelineEditor/PipelineEditor.cxx index f646520..65fb82b 100644 --- a/appli/PipelineEditor/PipelineEditor.cxx +++ b/appli/PipelineEditor/PipelineEditor.cxx @@ -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( ); } diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 3ac1e5d..838cc84 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -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 ); } diff --git a/lib/cpPlugins/DataObject.cxx b/lib/cpPlugins/DataObject.cxx index 9fd054d..e51ddaf 100644 --- a/lib/cpPlugins/DataObject.cxx +++ b/lib/cpPlugins/DataObject.cxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include // ------------------------------------------------------------------------- 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 { } diff --git a/lib/cpPlugins/DataObject.h b/lib/cpPlugins/DataObject.h index 0abc4a4..ae98879 100644 --- a/lib/cpPlugins/DataObject.h +++ b/lib/cpPlugins/DataObject.h @@ -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 diff --git a/lib/cpPlugins/Image.cxx b/lib/cpPlugins/Image.cxx index 04d28da..b3ff5d2 100644 --- a/lib/cpPlugins/Image.cxx +++ b/lib/cpPlugins/Image.cxx @@ -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$ diff --git a/lib/cpPlugins/Image.h b/lib/cpPlugins/Image.h index 62b9ff1..1f2e51e 100644 --- a/lib/cpPlugins/Image.h +++ b/lib/cpPlugins/Image.h @@ -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 );