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>
10 #include <vtkLookupTable.h>
12 #include <vtkPolyData.h>
13 #include <vtkPolyDataMapper.h>
14 #include <vtkPropCollection.h>
15 #include <vtkTextActor.h>
17 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
18 #include <cpExtensions/Visualization/ImageBlender.h>
20 // -------------------------------------------------------------------------
21 class vtkAlgorithmOutput;
26 // -------------------------------------------------------------------------
27 namespace cpExtensions
29 namespace Visualization
33 class cpExtensions_EXPORT ImageSliceActors
34 : public vtkPropCollection
37 typedef ImageSliceActors Self;
39 typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
40 typedef TStyle::TMouseCommand TMouseCommand;
41 typedef TStyle::TMouseWheelCommand TMouseWheelCommand;
42 typedef TStyle::TKeyCommand TKeyCommand;
43 typedef TStyle::TVoidCommand TVoidCommand;
44 typedef TStyle::TMouseMoveCommand TMouseMoveCommand;
45 typedef TStyle::TMouseClickCommand TMouseClickCommand;
46 typedef TStyle::TMouseDoubleClickCommand TMouseDoubleClickCommand;
47 typedef TStyle::TExposeCommand TExposeCommand;
48 typedef TStyle::TConfigureCommand TConfigureCommand;
49 typedef TStyle::TEnterCommand TEnterCommand;
50 typedef TStyle::TLeaveCommand TLeaveCommand;
51 typedef void ( *TSlicesCommand )( double*, int, void* );
52 typedef void ( *TWindowLevelCommand )( double, double, void* );
53 typedef TVoidCommand TRenderCommand;
54 typedef TSlicesCommand TCursorAxesCommand;
56 typedef cpExtensions::Visualization::ImageBlender TBlender;
59 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
61 cpExtensions_BaseInteractorStyle_Commands( Slices );
62 cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
63 cpExtensions_BaseInteractorStyle_Commands( Render );
64 cpExtensions_BaseInteractorStyle_Commands( CursorAxes );
68 static ImageSliceActors* New( );
70 void SetAxis( int axis );
71 void SetInputConnection( vtkAlgorithmOutput* aout );
72 void SetInputImage( vtkImageData* data );
73 int AddBinaryConnection(
74 vtkAlgorithmOutput* aout,
75 const double& r, const double& g, const double& b
79 const double& r, const double& g, const double& b
83 void AssociateSlice( Self* slice );
85 vtkImageData* GetInputImage( );
86 const vtkImageData* GetInputImage( ) const;
88 vtkInteractorStyle* GetStyle( );
89 const vtkInteractorStyle* GetStyle( ) const;
91 void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
92 void PopActorsFrom( vtkRenderWindow* window );
93 unsigned int GetNumberOfImages( ) const;
95 vtkImageActor* GetImageActor( );
96 const vtkImageActor* GetImageActor( ) const;
97 vtkImageActor* GetBinaryActor( );
98 const vtkImageActor* GetBinaryActor( ) const;
99 vtkTextActor* GetTextActor( );
100 const vtkTextActor* GetTextActor( ) const;
101 vtkActor* GetPlaneActor( );
102 const vtkActor* GetPlaneActor( ) const;
103 vtkPlane* GetPlaneFunction( );
104 const vtkPlane* GetPlaneFunction( ) const;
106 void SetInterpolate( bool v );
107 void InterpolateOn( );
108 void InterpolateOff( );
110 double* GetDisplayBounds( ) const;
111 void GetDisplayBounds( double bounds[ 6 ] ) const;
114 void SetCursor( double pos[ 3 ] );
116 void ResetAxesCursor( );
117 void SetAxesCursor( double pos[ 3 ] );
119 double GetMinWindow( ) const;
120 double GetMaxWindow( ) const;
121 double GetMinLevel( ) const;
122 double GetMaxLevel( ) const;
123 double GetWindow( ) const;
124 double GetLevel( ) const;
125 void SetWindow( double w );
126 void SetLevel( double l );
127 void SetWindowLevel( double w, double l );
128 void ResetWindowLevel( );
130 int GetAxis( ) const;
131 int GetSliceNumber( ) const;
132 int GetSliceNumberMinValue( ) const;
133 int GetSliceNumberMaxValue( ) const;
134 void SetSliceNumber( const int& slice );
135 void SetSlice( double* pos );
137 void UpdateText( double pos[ 3 ] );
138 void UpdateText( const double& w, const double& l );
145 virtual ~ImageSliceActors( );
147 void _ConfigureStyle( );
148 void _ConfigureInputImage( );
149 void _ConfigureBinaryImage(
150 const double& r, const double& g, const double& b
154 static void _MouseMoveCommand(
156 const TStyle::ButtonID& btn,
157 int* idx, double* pos,
158 bool alt, bool ctr, bool sft
160 static void _MouseClickCommand(
162 const TStyle::ButtonID& btn,
163 int* idx, double* pos,
164 bool alt, bool ctr, bool sft
166 static void _MouseWheelCommand(
168 const int& dir, bool alt, bool ctr, bool sft
170 static void _KeyCommand(
174 static void _EnterCommand( void* data );
175 static void _LeaveCommand( void* data );
178 // Purposely not implemented
179 ImageSliceActors( const Self& );
180 Self& operator=( const Self& );
183 static double m_PlaneColors[ 3 ][ 3 ];
185 vtkSmartPointer< TStyle > m_Style;
186 vtkRenderWindow* m_Window;
189 vtkSmartPointer< vtkImageSliceMapper > m_ImageMapper;
190 vtkSmartPointer< vtkImageActor > m_ImageActor;
192 vtkSmartPointer< vtkImageData > m_BlenderBase;
193 vtkSmartPointer< TBlender > m_Blender;
194 vtkSmartPointer< vtkImageSliceMapper > m_BlenderMapper;
195 vtkSmartPointer< vtkLookupTable > m_BlenderLUT;
196 vtkSmartPointer< vtkImageActor > m_BlenderActor;
200 double m_WLRange[ 4 ];
202 int m_VisibleExtent[ 6 ];
203 double m_VisibleBounds[ 6 ];
206 std::vector< Self* > m_AssociatedSlices;
209 vtkSmartPointer< vtkPolyData > m_Cursor;
210 vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper;
211 vtkSmartPointer< vtkActor > m_CursorActor;
213 vtkSmartPointer< vtkPolyData > m_Axis1;
214 vtkSmartPointer< vtkPolyDataMapper > m_Axis1Mapper;
215 vtkSmartPointer< vtkActor > m_Axis1Actor;
217 vtkSmartPointer< vtkPolyData > m_Axis2;
218 vtkSmartPointer< vtkPolyDataMapper > m_Axis2Mapper;
219 vtkSmartPointer< vtkActor > m_Axis2Actor;
221 vtkSmartPointer< vtkPolyData > m_Plane;
222 vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
223 vtkSmartPointer< vtkActor > m_PlaneActor;
225 char m_TextBuffer[ 1024 ];
226 vtkSmartPointer< vtkTextActor > m_TextActor;
228 double m_StartWindowLevelPos[ 3 ];
229 double m_StartWindowLevel[ 2 ];
236 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__