]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Extensions/Visualization/ImageInteractorStyle.h
Image interaction updated.
[cpPlugins.git] / lib / cpPlugins / Extensions / Visualization / ImageInteractorStyle.h
1 #ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
2 #define __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
3
4 #include <vector>
5
6 #include <vtkInteractorStyleImage.h>
7 #include <vtkOrientationMarkerWidget.h>
8 #include <vtkPropPicker.h>
9 #include <vtkSmartPointer.h>
10
11 /* TODO
12    #include <vtkInteractorStyleImage.h>
13    #include <vtkLineWidget2.h>
14    #include <vtkLineRepresentation.h>
15    #include <vtkPlane.h>
16    class vtkImageData;
17 */
18
19 namespace cpPlugins
20 {
21   namespace Extensions
22   {
23     namespace Visualization
24     {
25       class ImageSliceActors;
26       class MPRActors;
27
28       /**
29        */
30       class ImageInteractorStyle
31         : public vtkInteractorStyleImage
32       {
33       public:
34         typedef ImageInteractorStyle Self;
35
36         enum InteractionMode
37         {
38           NavigationMode = 0,
39           DeformationMode
40         };
41
42       public:
43         vtkTypeMacro( ImageInteractorStyle, vtkInteractorStyleImage );
44
45       public:
46         static Self* New( );
47
48         void Configure(
49           ImageSliceActors* slice_actors,
50           MPRActors* mpr_actors = NULL
51           );
52         void AssociateInteractor( vtkRenderWindowInteractor* interactor );
53
54         void SetModeToNavigation( );
55         void SetModeToDeformation( );
56         virtual void SetInteractor(
57           vtkRenderWindowInteractor* interactor, const int& axis
58           );
59
60         unsigned long AddDoubleClickObserver( vtkCommand* observer );
61         void RemoveDoubleClickObserver( unsigned long tag );
62         void RemoveDoubleClickObserver( vtkCommand* observer );
63         void RemoveDoubleClickObservers( );
64
65         // Description:
66         // Event bindings controlling the effects of pressing mouse buttons
67         // or moving the mouse.
68         virtual void OnMouseMove( );
69         virtual void OnLeftButtonDown( );
70         virtual void OnLeftButtonUp( );
71         virtual void OnMiddleButtonDown( );
72         virtual void OnMiddleButtonUp( );
73         virtual void OnRightButtonDown( );
74         virtual void OnRightButtonUp( );
75         virtual void OnMouseWheelForward( );
76         virtual void OnMouseWheelBackward( );
77
78         // Description:
79         // Override the "fly-to" (f keypress) for images.
80         virtual void OnChar( );
81
82         // These methods for the different interactions in different modes
83         // are overridden in subclasses to perform the correct motion. Since
84         // they might be called from OnTimer, they do not have mouse coord
85         // parameters (use interactor's GetEventPosition and
86         // GetLastEventPosition)
87
88         virtual void Rotate( ) { }
89         virtual void Spin( )   { }
90         virtual void Zoom( )   { }
91         virtual void Pick( )   { }
92         virtual void Slice( )  { }
93         virtual void WindowLevel( );
94
95         // Interaction mode entry points used internally.
96         virtual void StartPick( )  { }
97         virtual void EndPick( )    { }
98         virtual void StartSlice( ) { }
99         virtual void EndSlice( )   { }
100         virtual void StartWindowLevel( );
101         virtual void EndWindowLevel( );
102
103         // New events
104         virtual void StartCursorMoving( );
105         virtual void EndCursorMoving( );
106
107       protected:
108         ImageInteractorStyle( );
109         virtual ~ImageInteractorStyle( );
110
111         void _RenderAssociateInteractors( );
112         bool _PickPosition( double pos[ 3 ] );
113         void _UpdateCursor( );
114
115       private:
116         // Purposely not implemented
117         ImageInteractorStyle( const Self& );
118         Self& operator=( const Self& );
119
120       protected:
121         Self::InteractionMode Mode;
122
123         ImageSliceActors* m_SliceActors;
124         MPRActors*        m_MPRActors;
125
126         vtkSmartPointer< vtkOrientationMarkerWidget > OrientationWidget;
127         vtkSmartPointer< vtkPropPicker > PropPicker;
128
129         std::vector< vtkRenderWindowInteractor* > AssociatedInteractors;
130
131         bool CursorMoving;
132
133       public:
134         static const int DoubleClickEvent;
135       };
136
137     } // ecapseman
138
139   } // ecapseman
140
141 } // ecapseman
142
143 #endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
144
145 // eof - $RCSfile$