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", true );
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 std::cout << "update seeds" << std::endl;
66 typedef cpExtensions::Interaction::ImageInteractorStyle _S;
68 I* base_image = dynamic_cast< I* >( image );
70 this->GetOutputData< cpPlugins::Interface::PointList >( "Output" );
72 unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
77 if( this->m_MPRViewer != NULL )
79 for( unsigned int i = 0; i < 4; ++i )
83 this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
87 if( this->m_Configured )
89 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
91 s->GetSeedAsPoint( i, aux_pnt );
92 typename I::PointType seed;
93 for( unsigned int d = 0; d < dim; ++d )
94 seed[ d ] = aux_pnt[ d ];
95 out->AddPoint( seed );
109 _S* s = dynamic_cast< _S* >( this->m_SingleInteractor );
112 if( this->m_Configured )
114 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
116 s->GetSeedAsPoint( i, aux_pnt );
117 typename I::PointType seed;
118 for( unsigned int d = 0; d < dim; ++d )
119 seed[ d ] = aux_pnt[ d ];
120 out->AddPoint( seed );
128 this->m_Configured = true;