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 itk::ModifiedTimeType cpPlugins::Widgets::SeedWidget::
14 // std::cout << "Seed GetMTime" << std::endl;
15 return( 0 /*this->Superclass::GetMTime( )*/ );
18 // -------------------------------------------------------------------------
19 cpPlugins::Widgets::SeedWidget::
24 this->_AddInput( "ReferenceImage" );
25 this->_AddOutput< cpPlugins::Interface::PointList >( "Output" );
27 this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" );
28 this->m_Parameters->SetBool( "SeedsAreInRealSpace", false );
31 // -------------------------------------------------------------------------
32 cpPlugins::Widgets::SeedWidget::
37 // -------------------------------------------------------------------------
38 std::string cpPlugins::Widgets::SeedWidget::
41 typedef itk::ImageBase< 2 > _2DImage;
42 typedef itk::ImageBase< 3 > _3DImage;
45 this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" );
46 itk::DataObject* itk_image = image->GetITK< _2DImage >( );
47 if( itk_image != NULL )
48 return( this->_GD0< _2DImage >( itk_image ) );
51 itk_image = image->GetITK< _3DImage >( );
52 if( itk_image != NULL )
53 return( this->_GD0< _3DImage >( itk_image ) );
56 return( "SeedWidget: Input image dimension not supported." );
59 // -------------------------------------------------------------------------
61 std::string cpPlugins::Widgets::SeedWidget::
62 _GD0( itk::DataObject* image )
64 typedef cpExtensions::Interaction::ImageInteractorStyle _S;
66 I* base_image = dynamic_cast< I* >( image );
68 this->GetOutputData< cpPlugins::Interface::PointList >( "Output" );
70 unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
71 bool real_space = this->m_Parameters->GetBool( "SeedsAreInRealSpace" );
75 out->SetHaveEuclideanPoints( real_space );
78 if( this->m_MPRViewer != NULL )
80 for( unsigned int i = 0; i < 4; ++i )
84 this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
88 if( this->m_Configured )
90 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
92 s->GetSeedAsPoint( i, aux_pnt );
93 typename I::PointType seed;
94 for( unsigned int d = 0; d < dim; ++d )
95 seed[ d ] = aux_pnt[ d ];
99 typename I::IndexType index;
100 if( base_image->TransformPhysicalPointToIndex( seed, index ) )
101 out->AddPoint( index );
104 out->AddPoint( seed );
118 _S* s = dynamic_cast< _S* >( this->m_SingleInteractor );
121 if( this->m_Configured )
123 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
125 s->GetSeedAsPoint( i, aux_pnt );
126 typename I::PointType seed;
127 for( unsigned int d = 0; d < dim; ++d )
128 seed[ d ] = aux_pnt[ d ];
131 typename I::IndexType index;
132 if( base_image->TransformPhysicalPointToIndex( seed, index ) )
133 out->AddPoint( index );
136 out->AddPoint( seed );
144 this->m_Configured = true;