1 #include "SeedWidget.h"
3 #include <cpPlugins/Image.h>
4 #include <cpExtensions/DataStructures/ImageIndexesContainer.h>
5 #include <cpExtensions/QT/SimpleMPRWidget.h>
6 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
7 #include <vtkRenderWindowInteractor.h>
8 #include <itkSimpleDataObjectDecorator.h>
9 #include <itkSimpleDataObjectDecorator.hxx>
11 // -------------------------------------------------------------------------
12 itk::ModifiedTimeType cpPluginsWidgets::SeedWidget::
15 // std::cout << "Seed GetMTime" << std::endl;
16 return( 0 /*this->Superclass::GetMTime( )*/ );
19 // -------------------------------------------------------------------------
20 cpPluginsWidgets::SeedWidget::
25 this->_AddInput( "ReferenceImage" );
26 this->_AddOutput< cpPlugins::DataObject >( "Output" );
29 // -------------------------------------------------------------------------
30 cpPluginsWidgets::SeedWidget::
35 // -------------------------------------------------------------------------
36 void cpPluginsWidgets::SeedWidget::
39 auto image = this->GetInputData< itk::DataObject >( "ReferenceImage" );
40 cpPlugins_Image_Demangle_Dim ( _GD0, image, 2 );
41 else cpPlugins_Image_Demangle_Dim( _GD0, image, 3 );
42 else this->_Error( "No valid input image." );
45 // -------------------------------------------------------------------------
46 template< class _TImage >
47 void cpPluginsWidgets::SeedWidget::
48 _GD0( _TImage* image )
53 cpExtensions::DataStructures::ImageIndexesContainer< _TImage::ImageDimension >
55 typedef cpExtensions::Interaction::ImageInteractorStyle _S;
59 auto container = this->_CreateITK< _TContainer >( );
61 unsigned int dim = ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
62 container->Get( ).clear( );
65 if( this->m_MPRViewer != NULL )
67 for( unsigned int i = 0; i < 4; ++i )
71 this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
75 if( this->m_Configured )
77 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
79 s->GetSeedAsPoint( i, aux_pnt );
80 typename _TImage::PointType seed;
81 for( unsigned int d = 0; d < dim; ++d )
82 seed[ d ] = aux_pnt[ d ];
83 typename _TImage::IndexType idx;
84 if( image->TransformPhysicalPointToIndex( seed, idx ) )
85 container->Get( ).push_back( idx );
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 _TImage::PointType seed;
108 for( unsigned int d = 0; d < dim; ++d )
109 seed[ d ] = aux_pnt[ d ];
110 typename _TImage::IndexType idx;
111 if( image->TransformPhysicalPointToIndex( seed, idx ) )
112 container->Get( ).push_back( idx );
120 this->m_Configured = true;
121 container->SetReferenceImage( image );
122 this->GetOutputData( "Output" )->SetITK( container );
125 this->_Error( "Input image dimension not supported." );