1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
4 #include <cpExtensions/cpExtensions_Export.h>
6 #include <vtkSmartPointer.h>
8 #include <vtkImageActor.h>
9 #include <vtkImageSliceMapper.h>
11 #include <vtkPolyData.h>
12 #include <vtkPolyDataMapper.h>
13 #include <vtkPropCollection.h>
14 #include <vtkTextActor.h>
16 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
18 // -------------------------------------------------------------------------
19 class vtkAlgorithmOutput;
24 // -------------------------------------------------------------------------
25 namespace cpExtensions
27 namespace Visualization
31 class cpExtensions_EXPORT ImageSliceActors
32 : public vtkPropCollection
35 typedef ImageSliceActors Self;
37 typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
38 typedef TStyle::TMouseCommand TMouseCommand;
39 typedef TStyle::TMouseWheelCommand TMouseWheelCommand;
40 typedef TStyle::TKeyCommand TKeyCommand;
41 typedef TStyle::TVoidCommand TVoidCommand;
42 typedef TStyle::TMouseMoveCommand TMouseMoveCommand;
43 typedef TStyle::TMouseClickCommand TMouseClickCommand;
44 typedef TStyle::TMouseDoubleClickCommand TMouseDoubleClickCommand;
45 typedef TStyle::TExposeCommand TExposeCommand;
46 typedef TStyle::TConfigureCommand TConfigureCommand;
47 typedef TStyle::TEnterCommand TEnterCommand;
48 typedef TStyle::TLeaveCommand TLeaveCommand;
49 typedef void ( *TSlicesCommand )( double*, int, void* );
50 typedef void ( *TWindowLevelCommand )( double, double, void* );
51 typedef TVoidCommand TRenderCommand;
54 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
56 cpExtensions_BaseInteractorStyle_Commands( Slices );
57 cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
58 cpExtensions_BaseInteractorStyle_Commands( Render );
62 static ImageSliceActors* New( );
64 void SetAxis( int axis );
65 void AddInputConnection( vtkAlgorithmOutput* aout );
66 void AddInputData( vtkImageData* data );
69 void AssociateSlice( Self* slice );
71 vtkImageData* GetInputImage( );
72 const vtkImageData* GetInputImage( ) const;
74 vtkInteractorStyle* GetStyle( );
75 const vtkInteractorStyle* GetStyle( ) const;
77 void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
78 void PopActorsFrom( vtkRenderWindow* window );
79 unsigned int GetNumberOfImages( ) const;
80 vtkImageActor* GetImageActor( );
81 const vtkImageActor* GetImageActor( ) const;
82 vtkTextActor* GetTextActor( );
83 const vtkTextActor* GetTextActor( ) const;
84 vtkActor* GetPlaneActor( );
85 const vtkActor* GetPlaneActor( ) const;
86 vtkPlane* GetPlaneFunction( );
87 const vtkPlane* GetPlaneFunction( ) const;
89 void SetInterpolate( bool v );
90 void InterpolateOn( );
91 void InterpolateOff( );
93 double* GetDisplayBounds( ) const;
94 void GetDisplayBounds( double bounds[ 6 ] ) const;
97 void SetCursor( double pos[ 3 ] );
99 double GetMinWindow( ) const;
100 double GetMaxWindow( ) const;
101 double GetMinLevel( ) const;
102 double GetMaxLevel( ) const;
103 double GetWindow( ) const;
104 double GetLevel( ) const;
105 void SetWindow( double w );
106 void SetLevel( double l );
107 void SetWindowLevel( double w, double l );
108 void ResetWindowLevel( );
110 int GetAxis( ) const;
111 int GetSliceNumber( ) const;
112 int GetSliceNumberMinValue( ) const;
113 int GetSliceNumberMaxValue( ) const;
114 void SetSliceNumber( const int& slice );
115 void SetSlice( double* pos );
117 void UpdateText( double pos[ 3 ] );
118 void UpdateText( const double& w, const double& l );
120 void Render( const double& t );
125 virtual ~ImageSliceActors( );
127 void _ConfigureStyle( );
130 static void _MouseMoveCommand(
132 const TStyle::ButtonID& btn,
133 int* idx, double* pos,
134 bool alt, bool ctr, bool sft
136 static void _MouseClickCommand(
138 const TStyle::ButtonID& btn,
139 int* idx, double* pos,
140 bool alt, bool ctr, bool sft
142 static void _MouseWheelCommand(
144 const int& dir, bool alt, bool ctr, bool sft
146 static void _KeyCommand(
150 static void _EnterCommand( void* data );
151 static void _LeaveCommand( void* data );
154 // Purposely not implemented
155 ImageSliceActors( const Self& );
156 Self& operator=( const Self& );
159 vtkSmartPointer< TStyle > m_Style;
160 vtkRenderWindow* m_Window;
163 vtkSmartPointer< vtkImageSliceMapper > m_ImageMapper;
164 vtkSmartPointer< vtkImageActor > m_ImageActor;
167 double m_WLRange[ 4 ];
169 int m_VisibleExtent[ 6 ];
170 double m_VisibleBounds[ 6 ];
173 std::vector< Self* > m_AssociatedSlices;
176 vtkSmartPointer< vtkPolyData > m_Cursor;
177 vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper;
178 vtkSmartPointer< vtkActor > m_CursorActor;
180 vtkSmartPointer< vtkPolyData > m_HorizontalLine;
181 vtkSmartPointer< vtkPolyDataMapper > m_HorizontalLineMapper;
182 vtkSmartPointer< vtkActor > m_HorizontalLineActor;
184 vtkSmartPointer< vtkPolyData > m_VerticalLine;
185 vtkSmartPointer< vtkPolyDataMapper > m_VerticalLineMapper;
186 vtkSmartPointer< vtkActor > m_VerticalLineActor;
188 vtkSmartPointer< vtkPolyData > m_Plane;
189 vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
190 vtkSmartPointer< vtkActor > m_PlaneActor;
192 char m_TextBuffer[ 1024 ];
193 vtkSmartPointer< vtkTextActor > m_TextActor;
195 double m_StartWindowLevelPos[ 3 ];
196 double m_StartWindowLevel[ 2 ];
203 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__