1 #include "SeedWidget.h"
3 #include <cpPlugins/Interface/Image.h>
4 #include <cpPlugins/Interface/PointList.h>
5 #include <cpPlugins/Interface/SimpleMPRWidget.h>
6 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
8 #include <vtkRenderWindowInteractor.h>
10 // -------------------------------------------------------------------------
11 cpPlugins::Widgets::SeedWidget::
16 this->_AddInput( "ReferenceImage" );
17 this->_AddOutput< cpPlugins::Interface::PointList >( "Output" );
19 this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" );
20 this->m_Parameters->SetBool( "SeedsAreInRealSpace", true );
23 // -------------------------------------------------------------------------
24 cpPlugins::Widgets::SeedWidget::
29 // -------------------------------------------------------------------------
30 std::string cpPlugins::Widgets::SeedWidget::
33 typedef itk::ImageBase< 2 > _2DImage;
34 typedef itk::ImageBase< 3 > _3DImage;
37 this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" );
38 itk::DataObject* itk_image = image->GetITK< _2DImage >( );
39 if( itk_image != NULL )
40 return( this->_GD0< _2DImage >( itk_image ) );
43 itk_image = image->GetITK< _3DImage >( );
44 if( itk_image != NULL )
45 return( this->_GD0< _3DImage >( itk_image ) );
48 return( "SeedWidget: Input image dimension not supported." );
51 // -------------------------------------------------------------------------
53 std::string cpPlugins::Widgets::SeedWidget::
54 _GD0( itk::DataObject* image )
56 typedef cpExtensions::Interaction::ImageInteractorStyle _S;
58 I* base_image = dynamic_cast< I* >( image );
60 this->GetOutputData< cpPlugins::Interface::PointList >( "Output" );
62 unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
67 if( this->m_MPRViewer != NULL )
69 for( unsigned int i = 0; i < 4; ++i )
73 this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
77 if( this->m_Configured )
79 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
81 s->GetSeedAsPoint( i, aux_pnt );
82 typename I::PointType seed;
83 for( unsigned int d = 0; d < dim; ++d )
84 seed[ d ] = aux_pnt[ d ];
85 out->AddPoint( seed );
99 _S* s = dynamic_cast< _S* >( this->m_SingleInteractor );
102 if( this->m_Configured )
104 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
106 s->GetSeedAsPoint( i, aux_pnt );
107 typename I::PointType seed;
108 for( unsigned int d = 0; d < dim; ++d )
109 seed[ d ] = aux_pnt[ d ];
110 out->AddPoint( seed );
118 this->m_Configured = true;