]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Interaction/ImageInteractorStyle.cxx
More widgets added
[cpPlugins.git] / lib / cpExtensions / Interaction / ImageInteractorStyle.cxx
1 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
2
3 #include <vtkImageActor.h>
4 #include <vtkRenderWindowInteractor.h>
5
6 // -------------------------------------------------------------------------
7 cpExtensions::Interaction::ImageInteractorStyle::
8 Self* cpExtensions::Interaction::ImageInteractorStyle::
9 New( )
10 {
11   return( new Self );
12 }
13
14 // -------------------------------------------------------------------------
15 void cpExtensions::Interaction::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::Interaction::ImageInteractorStyle::
28 ImageInteractorStyle( )
29   : Superclass( )
30 {
31   this->m_PropPicker = vtkSmartPointer< vtkPropPicker >::New( );
32   this->m_PropPicker->PickFromListOn( );
33 }
34
35 // -------------------------------------------------------------------------
36 cpExtensions::Interaction::ImageInteractorStyle::
37 ~ImageInteractorStyle( )
38 {
39 }
40
41 // -------------------------------------------------------------------------
42 bool cpExtensions::Interaction::ImageInteractorStyle::
43 _PickPosition( int idx[ 2 ], double pos[ 3 ] )
44 {
45   vtkRenderWindowInteractor* rwi = this->GetInteractor( );
46   if( rwi == NULL )
47     return( false );
48
49   // Find the renderer where the event has been raised
50   idx[ 0 ] = rwi->GetEventPosition( )[ 0 ];
51   idx[ 1 ] = rwi->GetEventPosition( )[ 1 ];
52   this->FindPokedRenderer( double( idx[ 0 ] ), double( idx[ 1 ] ) );
53
54   // Pick a 3D position
55   int r = this->m_PropPicker->Pick(
56     double( idx[ 0 ] ), double( idx[ 1 ] ), double( 0 ),
57     this->CurrentRenderer
58     );
59   if( r == 0 )
60     return( false );
61   this->m_PropPicker->GetPickPosition( pos );
62   return( true );
63 }
64
65 // eof - $RCSfile$