1 #include "SeedWidget.h"
3 #include <vtkProperty.h>
4 #include <vtkRenderWindowInteractor.h>
5 #include <cpExtensions/QT/SimpleMPRWidget.h>
7 // -------------------------------------------------------------------------
8 void cpPluginsWidgets::SeedWidget::WidgetData::
9 Configure( vtkRenderWindowInteractor* interactor, vtkImageActor* actor )
11 this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( );
12 this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
13 this->Seed = vtkSmartPointer< vtkSeedRepresentation >::New( );
15 vtkSmartPointer< cpExtensions::Interaction::SeedWidget >::New( );
17 this->Placer->SetImageActor( actor );
18 this->Handle->GetProperty( )->SetColor( 1, 0, 0 );
19 this->Handle->SetPointPlacer( this->Placer );
20 this->Seed->SetHandleRepresentation( this->Handle );
21 this->Widget->SetRepresentation( this->Seed );
22 this->Widget->SetInteractor( interactor );
25 // -------------------------------------------------------------------------
26 void cpPluginsWidgets::SeedWidget::WidgetData::
32 // -------------------------------------------------------------------------
33 void cpPluginsWidgets::SeedWidget::WidgetData::
39 // -------------------------------------------------------------------------
40 itk::ModifiedTimeType cpPluginsWidgets::SeedWidget::
44 return( this->Superclass::GetMTime( ) );
47 // -------------------------------------------------------------------------
48 cpPluginsWidgets::SeedWidget::
53 this->_AddOutput< cpPlugins::DataObject >( "Output" );
56 // -------------------------------------------------------------------------
57 cpPluginsWidgets::SeedWidget::
62 // -------------------------------------------------------------------------
63 void cpPluginsWidgets::SeedWidget::
66 if( this->m_Configured )
68 auto points = this->_CreateVTK< vtkPoints >( );
70 auto wIt = this->m_Widgets.begin( );
71 wIt != this->m_Widgets.end( );
76 for( unsigned int i = 0; i < wIt->Seed->GetNumberOfSeeds( ); ++i )
78 wIt->Seed->GetSeedWorldPosition( i, pos );
79 points->InsertNextPoint( pos );
84 this->GetOutput( "Output" )->SetVTK( points );
88 std::vector< vtkRenderWindowInteractor* > ints;
89 if( this->m_MPRViewer != NULL )
91 ints.push_back( this->m_MPRViewer->GetInteractor( 0 ) );
92 ints.push_back( this->m_MPRViewer->GetInteractor( 1 ) );
93 ints.push_back( this->m_MPRViewer->GetInteractor( 2 ) );
96 if( this->m_SingleInteractor != NULL )
97 ints.push_back( this->m_SingleInteractor );
99 for( auto iIt = ints.begin( ); iIt != ints.end( ); ++iIt )
101 auto ren = ( *iIt )->GetInteractorStyle( )->GetCurrentRenderer( );
104 auto props = ren->GetViewProps( );
107 props->InitTraversal( );
109 while( ( prop = props->GetNextProp( ) ) != NULL )
111 auto actor = dynamic_cast< vtkImageActor* >( prop );
115 d.Configure( *iIt, actor );
117 this->m_Widgets.push_back( d );
118 this->m_Configured = true;
131 if( !( this->m_Configured ) )
133 "Could not create valid widget: are there any valid actors?"