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>
17 #include <cpExtensions/Visualization/ImageBlender.h>
19 // -------------------------------------------------------------------------
20 class vtkAlgorithmOutput;
25 // -------------------------------------------------------------------------
26 namespace cpExtensions
28 namespace Visualization
32 class cpExtensions_EXPORT ImageSliceActors
33 : public vtkPropCollection
36 typedef ImageSliceActors Self;
38 typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
39 typedef TStyle::TMouseCommand TMouseCommand;
40 typedef TStyle::TMouseWheelCommand TMouseWheelCommand;
41 typedef TStyle::TKeyCommand TKeyCommand;
42 typedef TStyle::TVoidCommand TVoidCommand;
43 typedef TStyle::TMouseMoveCommand TMouseMoveCommand;
44 typedef TStyle::TMouseClickCommand TMouseClickCommand;
45 typedef TStyle::TMouseDoubleClickCommand TMouseDoubleClickCommand;
46 typedef TStyle::TExposeCommand TExposeCommand;
47 typedef TStyle::TConfigureCommand TConfigureCommand;
48 typedef TStyle::TEnterCommand TEnterCommand;
49 typedef TStyle::TLeaveCommand TLeaveCommand;
50 typedef void ( *TSlicesCommand )( double*, int, void* );
51 typedef void ( *TWindowLevelCommand )( double, double, void* );
52 typedef TVoidCommand TRenderCommand;
55 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
57 cpExtensions_BaseInteractorStyle_Commands( Slices );
58 cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
59 cpExtensions_BaseInteractorStyle_Commands( Render );
63 static ImageSliceActors* New( );
65 ImageBlender* GetBlender( );
66 const ImageBlender* GetBlender( ) const;
67 void SetBlender( ImageBlender* blender );
68 void SetAxis( int axis );
69 void AddInputConnection( vtkAlgorithmOutput* aout );
70 void AddInputData( vtkImageData* data );
73 void AssociateSlice( Self* slice );
75 vtkImageData* GetInputImage( unsigned int id );
76 const vtkImageData* GetInputImage( unsigned int id ) const;
78 vtkInteractorStyle* GetStyle( );
79 const vtkInteractorStyle* GetStyle( ) const;
81 void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
82 void PopActorsFrom( vtkRenderWindow* window );
83 unsigned int GetNumberOfImages( ) const;
84 vtkImageActor* GetImageActor( );
85 const vtkImageActor* GetImageActor( ) const;
86 vtkTextActor* GetTextActor( );
87 const vtkTextActor* GetTextActor( ) const;
88 vtkActor* GetPlaneActor( );
89 const vtkActor* GetPlaneActor( ) const;
90 vtkPlane* GetPlaneFunction( );
91 const vtkPlane* GetPlaneFunction( ) const;
93 void SetInterpolate( bool v );
94 void InterpolateOn( );
95 void InterpolateOff( );
97 double* GetDisplayBounds( ) const;
98 void GetDisplayBounds( double bounds[ 6 ] ) const;
101 void SetCursor( double pos[ 3 ] );
103 double GetMinWindow( ) const;
104 double GetMaxWindow( ) const;
105 double GetMinLevel( ) const;
106 double GetMaxLevel( ) const;
107 double GetWindow( ) const;
108 double GetLevel( ) const;
109 void SetWindow( double w );
110 void SetLevel( double l );
111 void SetWindowLevel( double w, double l );
112 void ResetWindowLevel( );
114 int GetAxis( ) const;
115 int GetSliceNumber( ) const;
116 int GetSliceNumberMinValue( ) const;
117 int GetSliceNumberMaxValue( ) const;
118 void SetSliceNumber( const int& slice );
119 void SetSlice( double* pos );
121 void UpdateText( double pos[ 3 ] );
122 void UpdateText( const double& w, const double& l );
124 void Render( const double& t );
129 virtual ~ImageSliceActors( );
131 void _ConfigureStyle( );
134 static void _MouseMoveCommand(
136 const TStyle::ButtonID& btn,
137 int* idx, double* pos,
138 bool alt, bool ctr, bool sft
140 static void _MouseClickCommand(
142 const TStyle::ButtonID& btn,
143 int* idx, double* pos,
144 bool alt, bool ctr, bool sft
146 static void _MouseWheelCommand(
148 const int& dir, bool alt, bool ctr, bool sft
150 static void _KeyCommand(
154 static void _EnterCommand( void* data );
155 static void _LeaveCommand( void* data );
158 // Purposely not implemented
159 ImageSliceActors( const Self& );
160 Self& operator=( const Self& );
163 vtkSmartPointer< TStyle > m_Style;
164 vtkRenderWindow* m_Window;
167 vtkSmartPointer< ImageBlender > m_ImageBlender;
168 vtkSmartPointer< vtkImageSliceMapper > m_ImageMapper;
169 vtkSmartPointer< vtkImageActor > m_ImageActor;
172 int m_VisibleExtent[ 6 ];
173 double m_VisibleBounds[ 6 ];
176 std::vector< Self* > m_AssociatedSlices;
179 vtkSmartPointer< vtkPolyData > m_Cursor;
180 vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper;
181 vtkSmartPointer< vtkActor > m_CursorActor;
183 vtkSmartPointer< vtkPolyData > m_HorizontalLine;
184 vtkSmartPointer< vtkPolyDataMapper > m_HorizontalLineMapper;
185 vtkSmartPointer< vtkActor > m_HorizontalLineActor;
187 vtkSmartPointer< vtkPolyData > m_VerticalLine;
188 vtkSmartPointer< vtkPolyDataMapper > m_VerticalLineMapper;
189 vtkSmartPointer< vtkActor > m_VerticalLineActor;
191 vtkSmartPointer< vtkPolyData > m_Plane;
192 vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
193 vtkSmartPointer< vtkActor > m_PlaneActor;
195 char m_TextBuffer[ 1024 ];
196 vtkSmartPointer< vtkTextActor > m_TextActor;
198 double m_StartWindowLevelPos[ 3 ];
199 double m_StartWindowLevel[ 2 ];
206 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__