]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageInteractorStyle.cxx
Minor refactoring and errors solved
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageInteractorStyle.cxx
1 #include <cpExtensions/Visualization/ImageInteractorStyle.h>
2
3 #include <vtkImageActor.h>
4 #include <vtkRenderWindowInteractor.h>
5
6 // -------------------------------------------------------------------------
7 cpExtensions::Visualization::ImageInteractorStyle::
8 Self* cpExtensions::Visualization::ImageInteractorStyle::
9 New( )
10 {
11   return( new Self );
12 }
13
14 // -------------------------------------------------------------------------
15 void cpExtensions::Visualization::ImageInteractorStyle::
16 AssociateImageActor( vtkImageActor* actor )
17 {
18   if( actor != NULL )
19   {
20     this->m_PropPicker->AddPickList( actor );
21     this->Modified( );
22
23   } // fi
24 }
25
26 // -------------------------------------------------------------------------
27 cpExtensions::Visualization::ImageInteractorStyle::
28 ImageInteractorStyle( )
29   : Superclass( )
30 {
31   this->m_PropPicker = vtkSmartPointer< vtkPropPicker >::New( );
32   this->m_PropPicker->PickFromListOn( );
33 }
34
35 // -------------------------------------------------------------------------
36 cpExtensions::Visualization::ImageInteractorStyle::
37 ~ImageInteractorStyle( )
38 {
39 }
40
41 // -------------------------------------------------------------------------
42 bool cpExtensions::Visualization::ImageInteractorStyle::
43 _PickPosition( double pos[ 3 ] )
44 {
45   static const double _0 = double( 0 );
46   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
47   if( rwi == NULL )
48     return( false );
49
50   // Find the renderer where the event has been raised
51   double x = double( rwi->GetEventPosition( )[ 0 ] );
52   double y = double( rwi->GetEventPosition( )[ 1 ] );
53   this->FindPokedRenderer( x, y );
54
55   // Pick a 3D position
56   int r = this->m_PropPicker->Pick( x, y, _0, this->CurrentRenderer );
57   if( r == 0 )
58     return( false );
59   this->m_PropPicker->GetPickPosition( pos );
60   return( true );
61 }
62
63 // eof - $RCSfile$