From 54c595023e35fd457b707be67fa3cabce01896e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Fri, 30 Sep 2016 17:54:18 -0500 Subject: [PATCH] ... --- plugins/Widgets/SeedWidget.cxx | 73 ++++++++++++++++++++-------------- plugins/Widgets/SeedWidget.h | 9 +++-- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/plugins/Widgets/SeedWidget.cxx b/plugins/Widgets/SeedWidget.cxx index 2b11821..91d10a1 100644 --- a/plugins/Widgets/SeedWidget.cxx +++ b/plugins/Widgets/SeedWidget.cxx @@ -11,6 +11,7 @@ #include #include #include +#include // ------------------------------------------------------------------------- // This callback is responsible for changing update time @@ -26,27 +27,35 @@ namespace cpPluginsWidgets { return( new SeedWidgetCallback ); } virtual void Execute( vtkObject* caller, unsigned long id, void* data ) { - /* TODO - typedef cpPluginsWidgets::SeedWidget::TImageActor _TImageActor; - auto actor = dynamic_cast< _TImageActor* >( caller ); - */ - /* TODO - if( id == vtkCommand::InteractionEvent && actor != NULL ) - { - int slice = actor->GetSliceNumber( ); - if( this->Data->ActualWidgetId != slice ) - { - this->Data->Widgets[ this->Data->ActualWidgetId ]->EnabledOff( ); - this->Data->Widgets[ slice ]->EnabledOn( ); - this->Data->ActualWidgetId = slice; - } // fi - } - else - */ - // id == vtkCommand::CursorChangedEvent || - if( id == vtkCommand::PlacePointEvent ) + if( id == vtkCommand::InteractionEvent ) { - auto wdg = dynamic_cast< cpExtensions::Interaction::SeedWidget* >( caller ); + std::cout << id << std::endl; + auto actor = dynamic_cast< SeedWidget::TImageActor* >( caller ); + if( actor != NULL ) + { + int slice = actor->GetSliceNumber( ); + + std::cout << slice << std::endl; + + } // fi + /* TODO + typedef cpPluginsWidgets::SeedWidget::TImageActor _TImageActor; + */ + /* TODO + if( this->Data->ActualWidgetId != slice ) + { + this->Data->Widgets[ this->Data->ActualWidgetId ]->EnabledOff( ); + this->Data->Widgets[ slice ]->EnabledOn( ); + this->Data->ActualWidgetId = slice; + } // fi + } + else + */ + } + else if( id == vtkCommand::PlacePointEvent ) + { + // TODO: id == vtkCommand::CursorChangedEvent || + auto wdg = dynamic_cast< SeedWidget::TWidget* >( caller ); if( wdg != NULL ) { auto rep = @@ -320,14 +329,18 @@ _GD0_Image( vtkImageData* image ) } } // elihw + } // elihw } // fi if( all_props.size( ) == 1 ) { this->m_Data[ *inIt ] = - new TWidgetData( this, *( all_props.begin( ) ), *inIt, this->m_Command ); - } + new TWidgetData( + this, *( all_props.begin( ) ), *inIt, this->m_Command + ); + + } // fi } // rof } @@ -348,13 +361,13 @@ TWidgetData( ) { auto cb = dynamic_cast< SeedWidgetCallback* >( cmd ); -/* - auto cb = vtkSmartPointer< SeedWidgetCallback >::New( ); - cb->Widget = seedWidget; - cb->Data = this; - this->Command = cb; actor->AddObserver( vtkCommand::InteractionEvent, cb ); -*/ + /* TODO + auto cb = vtkSmartPointer< SeedWidgetCallback >::New( ); + cb->Widget = seedWidget; + cb->Data = this; + this->Command = cb; + */ /* TODO auto image = actor->GetImage( ); int ori = actor->GetOrientation( ); @@ -366,7 +379,7 @@ TWidgetData( this->Placer = vtkSmartPointer< _TPlacer >::New( ); this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); this->Representation = vtkSmartPointer< vtkSeedRepresentation >::New( ); - this->Widget = vtkSmartPointer< _TWidget >::New( ); + this->Widget = vtkSmartPointer< TWidget >::New( ); this->Placer->SetImageSlice( actor ); this->Handle->GetProperty( )->SetColor( 1, 0, 0 ); @@ -410,7 +423,7 @@ TWidgetData( auto placer = vtkSmartPointer< _TPlacer >::New( ); auto handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); auto rep = vtkSmartPointer< vtkSeedRepresentation >::New( ); - auto wdg = vtkSmartPointer< _TWidget >::New( ); + auto wdg = vtkSmartPointer< TWidget >::New( ); placer->SetImageSlice( actor ); handle->GetProperty( )->SetColor( 1, 0, 0 ); diff --git a/plugins/Widgets/SeedWidget.h b/plugins/Widgets/SeedWidget.h index 94101de..0f56596 100644 --- a/plugins/Widgets/SeedWidget.h +++ b/plugins/Widgets/SeedWidget.h @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -13,6 +12,10 @@ #include #include +// ------------------------------------------------------------------------- +namespace cpExtensions { namespace Interaction { class SeedWidget; } } + +// ------------------------------------------------------------------------- namespace cpPluginsWidgets { /** @@ -23,6 +26,7 @@ namespace cpPluginsWidgets cpPluginsObject( SeedWidget, cpPlugins::BaseObjects::Widget, Widgets ); public: + typedef cpExtensions::Interaction::SeedWidget TWidget; typedef cpExtensions::Visualization::WindowLevelImageActor TImageActor; public: @@ -50,10 +54,9 @@ namespace cpPluginsWidgets struct TWidgetData { - typedef cpExtensions::Interaction::SeedWidget _TWidget; typedef cpExtensions::Interaction::ImageSlicePointPlacer _TPlacer; - vtkSmartPointer< _TWidget > Widget; + vtkSmartPointer< TWidget > Widget; vtkSmartPointer< _TPlacer > Placer; vtkSmartPointer< vtkPointHandleRepresentation3D > Handle; vtkSmartPointer< vtkSeedRepresentation > Representation; -- 2.47.1