1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
4 #include <cpExtensions/Visualization/BaseInteractorStyle.h>
8 #include <vtkSmartPointer.h>
9 #include <vtkPropPicker.h>
12 #include <vtkInteractorStyleImage.h>
13 #include <vtkOrientationMarkerWidget.h>
15 #include <cpExtensions/cpExtensions_Export.h>
17 // -------------------------------------------------------------------------
18 #define cpPlugins_ImageInteractorStyle_ObserverMacro( e ) \
19 inline unsigned long Add##e##Observer( vtkCommand* observer ) \
20 { return( this->AddObserver( Self::e##Event, observer ) ); } \
21 inline void Remove##e##Observer( unsigned long tag ) \
22 { this->RemoveObserver( tag ); } \
23 inline void Remove##e##Observer( vtkCommand* observer ) \
24 { this->RemoveObserver( observer ); } \
25 inline void Remove##e##Observers( ) \
26 { this->RemoveObservers( Self::e##Event ); }
29 // Forward definitions
32 namespace cpExtensions
34 namespace Visualization
38 class cpExtensions_EXPORT ImageInteractorStyle
39 : public BaseInteractorStyle
42 typedef ImageInteractorStyle Self;
43 vtkTypeMacro( ImageInteractorStyle, BaseInteractorStyle );
46 typedef void ( *TMouseCommand )( void*, const ButtonID&, double*, bool, bool, bool );
47 typedef void ( *TMouseWheelCommand )( void*, const int&, bool, bool, bool );
48 typedef void ( *TKeyCommand )( void*, const char& );
50 vtkGetMacro( MouseMoveCommand, TMouseCommand );
51 vtkGetMacro( MouseClickCommand, TMouseCommand );
52 vtkGetMacro( MouseDoubleClickCommand, TMouseCommand );
53 vtkGetMacro( MouseWheelCommand, TMouseWheelCommand );
54 vtkGetMacro( KeyCommand, TKeyCommand );
56 vtkSetMacro( MouseMoveCommand, TMouseCommand );
57 vtkSetMacro( MouseClickCommand, TMouseCommand );
58 vtkSetMacro( MouseDoubleClickCommand, TMouseCommand );
59 vtkSetMacro( MouseWheelCommand, TMouseWheelCommand );
60 vtkSetMacro( KeyCommand, TKeyCommand );
65 virtual void AssociateView( void* data );
66 virtual void AssociateImageActor( vtkImageActor* actor );
67 virtual void AssociateInteractor( vtkRenderWindowInteractor* rwi );
69 // Possible mouse motion events
70 virtual void OnMouseMove( );
71 virtual void OnMouseWheelForward( );
72 virtual void OnMouseWheelBackward( );
74 // Possible mouse click-related events
75 virtual void OnLeftClick( );
76 virtual void OnLeftDoubleClick( );
77 virtual void OnMiddleClick( );
78 virtual void OnMiddleDoubleClick( );
79 virtual void OnRightClick( );
80 virtual void OnRightDoubleClick( );
82 // Keyboard-related events
83 virtual void OnChar( );
86 virtual void OnExpose( );
87 virtual void OnConfigure( );
88 virtual void OnEnter( );
89 virtual void OnLeave( );
92 ImageInteractorStyle( );
93 virtual ~ImageInteractorStyle( );
95 bool _PickPosition( double pos[ 3 ] );
96 void _RenderAssociatedInteractors( );
99 // Purposely not implemented
100 ImageInteractorStyle( const Self& );
101 Self& operator=( const Self& );
104 vtkSmartPointer< vtkPropPicker > PropPicker;
106 std::vector< vtkSmartPointer< vtkRenderWindowInteractor > >
107 AssociatedInteractors;
111 TMouseCommand MouseMoveCommand;
112 TMouseCommand MouseClickCommand;
113 TMouseCommand MouseDoubleClickCommand;
114 TMouseWheelCommand MouseWheelCommand;
115 TKeyCommand KeyCommand;
119 class ImageSliceActors;
126 class cpExtensions_EXPORT ImageInteractorStyle
127 : public vtkInteractorStyleImage
130 typedef ImageInteractorStyle Self;
139 vtkTypeMacro( ImageInteractorStyle, vtkInteractorStyleImage );
141 cpPlugins_ImageInteractorStyle_ObserverMacro( DoubleClick );
142 cpPlugins_ImageInteractorStyle_ObserverMacro( Cursor );
143 cpPlugins_ImageInteractorStyle_ObserverMacro( Radius );
149 ImageSliceActors* slice_actors,
150 MPRActors* mpr_actors = NULL
152 void AssociateInteractor( vtkRenderWindowInteractor* interactor );
154 void SetModeToNavigation( );
155 void SetModeToDeformation( );
156 virtual void SetInteractor(
157 vtkRenderWindowInteractor* interactor, const int& axis
161 // Event bindings controlling the effects of pressing mouse buttons
162 // or moving the mouse.
163 virtual void OnMouseMove( );
164 virtual void OnLeftButtonDown( );
165 virtual void OnLeftButtonUp( );
166 virtual void OnMiddleButtonDown( );
167 virtual void OnMiddleButtonUp( );
168 virtual void OnRightButtonDown( );
169 virtual void OnRightButtonUp( );
170 virtual void OnMouseWheelForward( );
171 virtual void OnMouseWheelBackward( );
174 // Override the "fly-to" (f keypress) for images.
175 virtual void OnChar( );
177 // These methods for the different interactions in different modes
178 // are overridden in subclasses to perform the correct motion. Since
179 // they might be called from OnTimer, they do not have mouse coord
180 // parameters (use interactor's GetEventPosition and
181 // GetLastEventPosition)
183 virtual void Rotate( ) { }
184 virtual void Spin( ) { }
185 virtual void Zoom( ) { }
186 virtual void Pick( ) { }
187 virtual void Slice( ) { }
188 virtual void WindowLevel( );
190 // Interaction mode entry points used internally.
191 virtual void StartPick( ) { }
192 virtual void EndPick( ) { }
193 virtual void StartSlice( ) { }
194 virtual void EndSlice( ) { }
195 virtual void StartWindowLevel( );
196 virtual void EndWindowLevel( );
199 virtual void StartCursorMoving( );
200 virtual void EndCursorMoving( );
201 virtual void StartRadiusMoving( );
202 virtual void EndRadiusMoving( );
205 ImageInteractorStyle( );
206 virtual ~ImageInteractorStyle( );
208 void _RenderAssociateInteractors( );
209 void _UpdateCursor( );
210 void _UpdateRadius( );
213 // Purposely not implemented
214 ImageInteractorStyle( const Self& );
215 Self& operator=( const Self& );
218 Self::InteractionMode Mode;
220 ImageSliceActors* m_SliceActors;
221 MPRActors* m_MPRActors;
223 vtkSmartPointer< vtkOrientationMarkerWidget > OrientationWidget;
225 std::vector< vtkRenderWindowInteractor* > AssociatedInteractors;
232 vtkSmartPointer< vtkPolyData > Circle;
233 vtkSmartPointer< vtkPolyDataMapper > CircleMapper;
234 vtkSmartPointer< vtkActor > CircleActor;
237 static const int CursorEvent;
238 static const int RadiusEvent;
239 static const int DoubleClickEvent;
247 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__