]> Creatis software - cpPlugins.git/blob - plugins/cpPluginsWidgets/SeedWidget.cxx
...
[cpPlugins.git] / plugins / cpPluginsWidgets / SeedWidget.cxx
1 #include "SeedWidget.h"
2
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>
10
11 // -------------------------------------------------------------------------
12 itk::ModifiedTimeType cpPluginsWidgets::SeedWidget::
13 GetMTime( ) const
14 {
15   // std::cout << "Seed GetMTime" << std::endl;
16   return( 0 /*this->Superclass::GetMTime( )*/ );
17 }
18
19 // -------------------------------------------------------------------------
20 cpPluginsWidgets::SeedWidget::
21 SeedWidget( )
22   : Superclass( ),
23     m_Configured( false )
24 {
25   this->_AddInput( "ReferenceImage" );
26   this->_AddOutput< cpPlugins::DataObject >( "Output" );
27 }
28
29 // -------------------------------------------------------------------------
30 cpPluginsWidgets::SeedWidget::
31 ~SeedWidget( )
32 {
33 }
34
35 // -------------------------------------------------------------------------
36 void cpPluginsWidgets::SeedWidget::
37 _GenerateData( )
38 {
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." );
43 }
44
45 // -------------------------------------------------------------------------
46 template< class _TImage >
47 void cpPluginsWidgets::SeedWidget::
48 _GD0( _TImage* image )
49 {
50
51   /*
52     typedef
53     cpExtensions::DataStructures::ImageIndexesContainer< _TImage::ImageDimension >
54     _TContainer;
55     typedef cpExtensions::Interaction::ImageInteractorStyle _S;
56
57     if( image != NULL )
58     {
59     auto container = this->_CreateITK< _TContainer >( );
60     double aux_pnt[ 3 ];
61     unsigned int dim = ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
62     container->Get( ).clear( );
63
64     // MPR
65     if( this->m_MPRViewer != NULL )
66     {
67     for( unsigned int i = 0; i < 4; ++i )
68     {
69     _S* s =
70     dynamic_cast< _S* >(
71     this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
72     );
73     if( s != NULL )
74     {
75     if( this->m_Configured )
76     {
77     for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
78     {
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 );
86
87     } // rof
88     }
89     else
90     s->SeedWidgetOn( );
91
92     } // fi
93
94     } // rof
95
96     } // fi
97
98     // Single interactor
99     _S* s = dynamic_cast< _S* >( this->m_SingleInteractor );
100     if( s != NULL )
101     {
102     if( this->m_Configured )
103     {
104     for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
105     {
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 );
113
114     } // rof
115     }
116     else
117     s->SeedWidgetOn( );
118
119     } // fi
120     this->m_Configured = true;
121     container->SetReferenceImage( image );
122     this->GetOutputData( "Output" )->SetITK( container );
123     }
124     else
125     this->_Error( "Input image dimension not supported." );
126   */
127 }
128
129 // eof - $RCSfile$