From 098f94c899285851651a2d457fb104dfca660668 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 5 Oct 2016 21:40:47 -0500 Subject: [PATCH] ... --- plugins/Widgets/LineWidget.cxx | 33 +++++++++++++++++++++++---------- plugins/Widgets/SeedWidget.cxx | 9 ++++++++- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/plugins/Widgets/LineWidget.cxx b/plugins/Widgets/LineWidget.cxx index f73e100..8887463 100644 --- a/plugins/Widgets/LineWidget.cxx +++ b/plugins/Widgets/LineWidget.cxx @@ -21,6 +21,13 @@ Clear( ) void cpPluginsWidgets::LineWidget:: SetEnabled( bool v ) { + auto wdg = this->GetVTK< vtkLineWidget2 >( ); + if( wdg != NULL ) + { + wdg->SetEnabled( v ); + wdg->GetInteractor( )->Render( ); + + } // fi } // ------------------------------------------------------------------------- @@ -118,17 +125,23 @@ _GD_Image( vtkImageData* image ) vtkSmartPointer< vtkLineWidget2 > wdg = this->GetVTK< vtkLineWidget2 >( ); if( wdg.GetPointer( ) == NULL ) { - auto rep = vtkSmartPointer< vtkLineRepresentation >::New( ); + auto vIt = valid_props.begin( ); + auto actor = dynamic_cast< vtkImageSlice* >( *( vIt->second.begin( ) ) ); + + double bnds[ 6 ]; + actor->GetBounds( bnds ); + double p0[ 3 ], p1[ 3 ]; + p0[ 0 ] = bnds[ 0 ]; + p0[ 1 ] = bnds[ 2 ]; + p0[ 2 ] = bnds[ 4 ]; + p1[ 0 ] = bnds[ 1 ]; + p1[ 1 ] = bnds[ 3 ]; + p1[ 2 ] = bnds[ 5 ]; - /* TODO - p[ 0 ] = 0.0; p[ 1 ] = -1.0; p[ 2 ] = 0.0; - rep->SetPoint1WorldPosition( p ); - p[ 0 ] = 0.0; p[ 1 ] = 1.0; p[ 2 ] = 0.0; - rep->SetPoint2WorldPosition( p ); - rep->PlaceWidget( pl3d_block0->GetBounds( ) ); - rep->GetPolyData( seeds ); - rep->DistanceAnnotationVisibilityOn( ); - */ + auto rep = vtkSmartPointer< vtkLineRepresentation >::New( ); + rep->SetPoint1WorldPosition( p0 ); + rep->SetPoint2WorldPosition( p1 ); + rep->PlaceWidget( bnds ); wdg = this->_CreateVTK< vtkLineWidget2 >( ); wdg->SetInteractor( valid_props.begin( )->first ); diff --git a/plugins/Widgets/SeedWidget.cxx b/plugins/Widgets/SeedWidget.cxx index dc5b6a5..f0c9094 100644 --- a/plugins/Widgets/SeedWidget.cxx +++ b/plugins/Widgets/SeedWidget.cxx @@ -26,6 +26,14 @@ Clear( ) void cpPluginsWidgets::SeedWidget:: SetEnabled( bool v ) { + for( auto w = this->m_Widgets.begin( ); w != this->m_Widgets.end( ); ++w ) + { + if( v ) w->second->RestartInteraction( ); + else w->second->CompleteInteraction( ); + w->second->SetEnabled( v ); + w->second->Render( ); + + } // rof } // ------------------------------------------------------------------------- @@ -130,7 +138,6 @@ _GD0_Image( vtkImageData* image ) act->AddObserver( vtkCommand::InteractionEvent, this->m_Command ); wdg->AddObserver( vtkCommand::PlacePointEvent, this->m_Command ); wdg->AddObserver( vtkCommand::CursorChangedEvent, this->m_Command ); - wdg->EnabledOn( ); this->m_Widgets[ *inIt ] = wdg; } // fi -- 2.45.1