]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Extensions/Visualization/ImageInteractorStyle.h
2eb6f12390013b2bb3bb2bc5fb6026bf4b12c722
[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         // Description:
61         // Event bindings controlling the effects of pressing mouse buttons
62         // or moving the mouse.
63         virtual void OnMouseMove( );
64         virtual void OnLeftButtonDown( );
65         virtual void OnLeftButtonUp( );
66         virtual void OnMiddleButtonDown( );
67         virtual void OnMiddleButtonUp( );
68         virtual void OnRightButtonDown( );
69         virtual void OnRightButtonUp( );
70         virtual void OnMouseWheelForward( );
71         virtual void OnMouseWheelBackward( );
72
73         // Description:
74         // Override the "fly-to" (f keypress) for images.
75         virtual void OnChar( );
76
77         // These methods for the different interactions in different modes
78         // are overridden in subclasses to perform the correct motion. Since
79         // they might be called from OnTimer, they do not have mouse coord
80         // parameters (use interactor's GetEventPosition and
81         // GetLastEventPosition)
82         virtual void Rotate( );
83         virtual void Pan( );
84         virtual void Spin( );
85         virtual void Zoom( );
86         virtual void WindowLevel( );
87         virtual void Pick( );
88         virtual void Slice( );
89
90         // Interaction mode entry points used internally.
91         virtual void StartWindowLevel( );
92         virtual void EndWindowLevel( );
93         virtual void StartPick( );
94         virtual void EndPick( );
95         virtual void StartSlice( );
96         virtual void EndSlice( );
97
98         // New events
99         virtual void StartCursorMoving( );
100         virtual void EndCursorMoving( );
101
102       protected:
103         ImageInteractorStyle( );
104         virtual ~ImageInteractorStyle( );
105
106         void _RenderAssociateInteractors( );
107         bool _PickPosition( double pos[ 3 ] );
108         void _UpdateCursor( );
109
110       private:
111         // Purposely not implemented
112         ImageInteractorStyle( const Self& );
113         Self& operator=( const Self& );
114
115       protected:
116         Self::InteractionMode Mode;
117
118         ImageSliceActors* m_SliceActors;
119         MPRActors*        m_MPRActors;
120
121         vtkSmartPointer< vtkOrientationMarkerWidget > OrientationWidget;
122         vtkSmartPointer< vtkPropPicker > PropPicker;
123
124         std::vector< vtkRenderWindowInteractor* > AssociatedInteractors;
125
126         bool CursorMoving;
127
128       public:
129         static const int SliceEvent;
130       };
131
132     } // ecapseman
133
134   } // ecapseman
135
136 } // ecapseman
137
138 #endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
139
140 // eof - $RCSfile$