1 #ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
2 #define __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
6 #include <vtkInteractorStyleImage.h>
7 #include <vtkOrientationMarkerWidget.h>
8 #include <vtkPropPicker.h>
9 #include <vtkSmartPointer.h>
11 #include <cpPlugins/Extensions/cpPlugins_Extensions_Export.h>
13 // -------------------------------------------------------------------------
14 #define cpPlugins_ImageInteractorStyle_ObserverMacro( e ) \
15 inline unsigned long Add##e##Observer( vtkCommand* observer ) \
16 { return( this->AddObserver( Self::e##Event, observer ) ); } \
17 inline void Remove##e##Observer( unsigned long tag ) \
18 { this->RemoveObserver( tag ); } \
19 inline void Remove##e##Observer( vtkCommand* observer ) \
20 { this->RemoveObserver( observer ); } \
21 inline void Remove##e##Observers( ) \
22 { this->RemoveObservers( Self::e##Event ); }
28 namespace Visualization
30 class ImageSliceActors;
35 class cpPlugins_Extensions_EXPORT ImageInteractorStyle
36 : public vtkInteractorStyleImage
39 typedef ImageInteractorStyle Self;
48 vtkTypeMacro( ImageInteractorStyle, vtkInteractorStyleImage );
50 cpPlugins_ImageInteractorStyle_ObserverMacro( DoubleClick );
51 cpPlugins_ImageInteractorStyle_ObserverMacro( Cursor );
52 cpPlugins_ImageInteractorStyle_ObserverMacro( Radius );
58 ImageSliceActors* slice_actors,
59 MPRActors* mpr_actors = NULL
61 void AssociateInteractor( vtkRenderWindowInteractor* interactor );
63 void SetModeToNavigation( );
64 void SetModeToDeformation( );
65 virtual void SetInteractor(
66 vtkRenderWindowInteractor* interactor, const int& axis
70 // Event bindings controlling the effects of pressing mouse buttons
71 // or moving the mouse.
72 virtual void OnMouseMove( );
73 virtual void OnLeftButtonDown( );
74 virtual void OnLeftButtonUp( );
75 virtual void OnMiddleButtonDown( );
76 virtual void OnMiddleButtonUp( );
77 virtual void OnRightButtonDown( );
78 virtual void OnRightButtonUp( );
79 virtual void OnMouseWheelForward( );
80 virtual void OnMouseWheelBackward( );
83 // Override the "fly-to" (f keypress) for images.
84 virtual void OnChar( );
86 // These methods for the different interactions in different modes
87 // are overridden in subclasses to perform the correct motion. Since
88 // they might be called from OnTimer, they do not have mouse coord
89 // parameters (use interactor's GetEventPosition and
90 // GetLastEventPosition)
92 virtual void Rotate( ) { }
93 virtual void Spin( ) { }
94 virtual void Zoom( ) { }
95 virtual void Pick( ) { }
96 virtual void Slice( ) { }
97 virtual void WindowLevel( );
99 // Interaction mode entry points used internally.
100 virtual void StartPick( ) { }
101 virtual void EndPick( ) { }
102 virtual void StartSlice( ) { }
103 virtual void EndSlice( ) { }
104 virtual void StartWindowLevel( );
105 virtual void EndWindowLevel( );
108 virtual void StartCursorMoving( );
109 virtual void EndCursorMoving( );
110 virtual void StartRadiusMoving( );
111 virtual void EndRadiusMoving( );
114 ImageInteractorStyle( );
115 virtual ~ImageInteractorStyle( );
117 void _RenderAssociateInteractors( );
118 bool _PickPosition( double pos[ 3 ] );
119 void _UpdateCursor( );
120 void _UpdateRadius( );
123 // Purposely not implemented
124 ImageInteractorStyle( const Self& );
125 Self& operator=( const Self& );
128 Self::InteractionMode Mode;
130 ImageSliceActors* m_SliceActors;
131 MPRActors* m_MPRActors;
133 vtkSmartPointer< vtkOrientationMarkerWidget > OrientationWidget;
134 vtkSmartPointer< vtkPropPicker > PropPicker;
136 std::vector< vtkRenderWindowInteractor* > AssociatedInteractors;
143 vtkSmartPointer< vtkPolyData > Circle;
144 vtkSmartPointer< vtkPolyDataMapper > CircleMapper;
145 vtkSmartPointer< vtkActor > CircleActor;
148 static const int CursorEvent;
149 static const int RadiusEvent;
150 static const int DoubleClickEvent;
159 #endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__