From 348a9e599343e89f942f99aacfd946a60d7b4a00 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Thu, 21 Apr 2016 20:12:48 -0500 Subject: [PATCH] ... --- plugins/cpPluginsWidgets/SeedWidget.cxx | 53 ++++++++++++++++++++----- plugins/cpPluginsWidgets/SeedWidget.h | 4 +- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/plugins/cpPluginsWidgets/SeedWidget.cxx b/plugins/cpPluginsWidgets/SeedWidget.cxx index 64069e4..0d4c57d 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.cxx +++ b/plugins/cpPluginsWidgets/SeedWidget.cxx @@ -1,12 +1,41 @@ #include "SeedWidget.h" +#include #include #include #include +// ------------------------------------------------------------------------- +// This callback is responsible for changing update time +namespace cpPluginsWidgets +{ + /** + */ + class SeedWidgetCallback + : public vtkCommand + { + public: + static SeedWidgetCallback* New( ) + { return( new SeedWidgetCallback ); } + virtual void Execute( vtkObject* caller, unsigned long id, void* data ) + { + if( + id == vtkCommand::CursorChangedEvent || + id == vtkCommand::PlacePointEvent + ) + this->Widget->Modified( ); + } + SeedWidget* Widget; + }; + +} // ecapseman + // ------------------------------------------------------------------------- void cpPluginsWidgets::SeedWidget::WidgetData:: -Configure( vtkRenderWindowInteractor* interactor, vtkImageActor* actor ) +Configure( + cpPluginsWidgets::SeedWidget* parent, + vtkRenderWindowInteractor* interactor, vtkImageActor* actor + ) { this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( ); this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); @@ -20,6 +49,12 @@ Configure( vtkRenderWindowInteractor* interactor, vtkImageActor* actor ) this->Seed->SetHandleRepresentation( this->Handle ); this->Widget->SetRepresentation( this->Seed ); this->Widget->SetInteractor( interactor ); + + vtkSmartPointer< SeedWidgetCallback > cb = + vtkSmartPointer< SeedWidgetCallback >::New( ); + cb->Widget = parent; + this->Widget->AddObserver( vtkCommand::PlacePointEvent, cb ); + this->Widget->AddObserver( vtkCommand::CursorChangedEvent, cb ); } // ------------------------------------------------------------------------- @@ -36,14 +71,6 @@ Off( ) this->Widget->Off( ); } -// ------------------------------------------------------------------------- -itk::ModifiedTimeType cpPluginsWidgets::SeedWidget:: -GetMTime( ) const -{ - this->Modified( ); - return( this->Superclass::GetMTime( ) ); -} - // ------------------------------------------------------------------------- cpPluginsWidgets::SeedWidget:: SeedWidget( ) @@ -63,8 +90,10 @@ cpPluginsWidgets::SeedWidget:: void cpPluginsWidgets::SeedWidget:: _GenerateData( ) { + std::cout << "seeds" << std::endl; if( this->m_Configured ) { + std::cout << "ok" << std::endl; auto points = this->_CreateVTK< vtkPoints >( ); for( auto wIt = this->m_Widgets.begin( ); @@ -112,7 +141,7 @@ _GenerateData( ) if( actor != NULL ) { WidgetData d; - d.Configure( *iIt, actor ); + d.Configure( this, *iIt, actor ); d.On( ); this->m_Widgets.push_back( d ); this->m_Configured = true; @@ -128,7 +157,9 @@ _GenerateData( ) } // rof } // fi - if( !( this->m_Configured ) ) + if( this->m_Configured ) + this->Modified( ); + else this->_Error( "Could not create valid widget: are there any valid actors?" ); diff --git a/plugins/cpPluginsWidgets/SeedWidget.h b/plugins/cpPluginsWidgets/SeedWidget.h index 74dfc0b..40813ef 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.h +++ b/plugins/cpPluginsWidgets/SeedWidget.h @@ -36,15 +36,13 @@ namespace cpPluginsWidgets vtkSmartPointer< vtkSeedRepresentation > Seed; void Configure( + cpPluginsWidgets::SeedWidget* parent, vtkRenderWindowInteractor* interactor, vtkImageActor* actor ); void On( ); void Off( ); }; - public: - virtual itk::ModifiedTimeType GetMTime( ) const ITK_OVERRIDE; - protected: SeedWidget( ); virtual ~SeedWidget( ); -- 2.47.1