#include <cpExtensions/Interaction/ImageInteractorStyle.h>
+#include <vtkCommand.h>
#include <vtkImageActor.h>
+#include <vtkPropCollection.h>
+#include <vtkProperty.h>
#include <vtkRenderWindowInteractor.h>
+// -------------------------------------------------------------------------
+cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+TSeedWidget( vtkRenderWindowInteractor* interactor, vtkImageActor* actor )
+{
+ this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( );
+ this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
+ this->Representation = vtkSmartPointer< vtkSeedRepresentation >::New( );
+ this->Widget = vtkSmartPointer< SeedWidget >::New( );
+
+ this->Placer->SetImageActor( actor );
+ this->Handle->GetProperty( )->SetColor( 1, 0, 0 );
+ this->Handle->SetPointPlacer( this->Placer );
+ this->Representation->SetHandleRepresentation( this->Handle );
+ this->Widget->SetRepresentation( this->Representation );
+ this->Widget->SetInteractor( interactor );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+On( )
+{
+ this->Widget->On( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::TSeedWidget::
+Off( )
+{
+ this->Widget->Off( );
+}
+
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageInteractorStyle::
Self* cpExtensions::Interaction::ImageInteractorStyle::
} // fi
}
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+SeedWidgetOn( )
+{
+ if( this->m_SeedWidget != NULL ) delete this->m_SeedWidget;
+
+ this->m_PropPicker->GetPickList( )->InitTraversal( );
+ this->m_SeedWidget = new TSeedWidget(
+ this->Interactor,
+ dynamic_cast< vtkImageActor* >(
+ this->m_PropPicker->GetPickList( )->GetNextProp( )
+ )
+ );
+ this->m_SeedWidget->On( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+SeedWidgetOff( )
+{
+ if( this->m_SeedWidget != NULL )
+ {
+ this->m_SeedWidget->Off( );
+ delete this->m_SeedWidget;
+ this->m_SeedWidget = NULL;
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+SetSeedWidgetCommand( vtkCommand* cmd )
+{
+ if( cmd == NULL || this->m_SeedWidget == NULL )
+ return;
+ this->m_SeedWidget->Widget->
+ AddObserver( vtkCommand::PlacePointEvent, cmd );
+}
+
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageInteractorStyle::
ImageInteractorStyle( )
- : Superclass( )
+ : Superclass( ),
+ m_SeedWidget( NULL )
{
this->m_PropPicker = vtkSmartPointer< vtkPropPicker >::New( );
this->m_PropPicker->PickFromListOn( );
cpExtensions::Interaction::ImageInteractorStyle::
~ImageInteractorStyle( )
{
+ if( this->m_SeedWidget != NULL ) delete this->m_SeedWidget;
}
// -------------------------------------------------------------------------