1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
4 #include <cpExtensions/cpExtensions_Export.h>
9 #include <vtkSmartPointer.h>
11 #include <vtkImageActor.h>
12 #include <vtkImageMapToColors.h>
13 #include <vtkImageSliceMapper.h>
15 #include <vtkPolyData.h>
16 #include <vtkPolyDataMapper.h>
17 #include <vtkPropCollection.h>
18 #include <vtkTextActor.h>
20 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
22 // -------------------------------------------------------------------------
23 class vtkAlgorithmOutput;
27 // -------------------------------------------------------------------------
28 namespace cpExtensions
30 namespace Visualization
34 class cpExtensions_EXPORT ImageSliceActors
35 : public vtkPropCollection
38 typedef ImageSliceActors Self;
40 typedef cpExtensions::Interaction::BaseInteractorStyle TBaseStyle;
41 typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
42 typedef void ( *TSlicesCommand )( double*, int, void* );
43 typedef void ( *TWindowLevelCommand )( double, double, void* );
44 typedef TBaseStyle::TMouseCommand TMouseCommand;
45 typedef TBaseStyle::TMouseWheelCommand TMouseWheelCommand;
46 typedef TBaseStyle::TKeyCommand TKeyCommand;
47 typedef TBaseStyle::TVoidCommand TVoidCommand;
50 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
54 static ImageSliceActors* New( );
56 void AddSlicesCommand( TSlicesCommand command, void* data );
57 void AddWindowLevelCommand( TWindowLevelCommand command, void* data );
58 void AddRenderCommand( TVoidCommand command, void* data );
60 void RemoveSlicesCommand( TSlicesCommand command );
61 void RemoveWindowLevelCommand( TWindowLevelCommand command );
62 void RemoveRenderCommand( TVoidCommand command );
64 void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
65 void AddInputData( vtkImageData* data, int axis = 2 );
68 vtkInteractorStyle* GetStyle( );
69 const vtkInteractorStyle* GetStyle( ) const;
71 void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
72 void PopActorsFrom( vtkRenderWindow* window );
73 unsigned int GetNumberOfImageActors( ) const;
74 vtkImageActor* GetImageActor( unsigned int id );
75 const vtkImageActor* GetImageActor( unsigned int id ) const;
76 vtkTextActor* GetTextActor( );
77 const vtkTextActor* GetTextActor( ) const;
78 vtkActor* GetPlaneActor( );
79 const vtkActor* GetPlaneActor( ) const;
80 vtkPlane* GetPlaneFunction( );
81 const vtkPlane* GetPlaneFunction( ) const;
83 void SetInterpolate( bool v );
84 void InterpolateOn( );
85 void InterpolateOff( );
87 double* GetDisplayBounds( ) const;
88 void GetDisplayBounds( double bounds[ 6 ] ) const;
91 void SetCursor( double pos[ 3 ] );
93 vtkImageMapToColors* GetImageMap( unsigned int id );
94 const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
96 double GetMinWindow( ) const;
97 double GetMaxWindow( ) const;
98 double GetMinLevel( ) const;
99 double GetMaxLevel( ) const;
100 double GetWindow( ) const;
101 double GetLevel( ) const;
102 void SetWindow( double w );
103 void SetLevel( double l );
104 void SetWindowLevel( double w, double l );
105 void ResetWindowLevel( );
107 void SetLookupTable( unsigned int id, vtkLookupTable* lut );
108 void SetLookupTableAsColor(
109 unsigned int id, double r, double g, double b
112 int GetAxis( ) const;
113 int GetSliceNumber( ) const;
114 int GetSliceNumberMinValue( ) const;
115 int GetSliceNumberMaxValue( ) const;
116 void SetSliceNumber( const int& slice );
117 void SetSlice( double* pos );
119 void UpdateText( double pos[ 3 ] );
120 void UpdateText( const double& w, const double& l );
127 virtual ~ImageSliceActors( );
129 void _ConfigureStyle( );
130 void _ConfigureNewLUT( vtkImageData* data );
131 void _ConfigureNewInput( int axis );
134 static void _MouseMoveCommand(
136 const TBaseStyle::ButtonID& btn,
137 int* idx, double* pos,
138 bool alt, bool ctr, bool sft
140 static void _MouseClickCommand(
142 const TBaseStyle::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(
156 // Purposely not implemented
157 ImageSliceActors( const Self& );
158 Self& operator=( const Self& );
161 vtkSmartPointer< TStyle > m_Style;
164 std::vector< vtkSmartPointer< vtkImageMapToColors > > m_ImageMaps;
165 std::vector< vtkSmartPointer< vtkImageSliceMapper > > m_SliceMappers;
166 std::vector< vtkSmartPointer< vtkImageActor > > m_ImageActors;
169 // Window-Level values
170 double m_MinWindow, m_MaxWindow;
171 double m_MinLevel, m_MaxLevel;
173 // Associated commands
174 std::map< TSlicesCommand, void* > m_SlicesCommands;
175 std::map< TWindowLevelCommand, void* > m_WindowLevelCommands;
176 std::map< TVoidCommand, void* > m_RenderCommands;
179 vtkSmartPointer< vtkPolyData > m_Cursor;
180 vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper;
181 vtkSmartPointer< vtkActor > m_CursorActor;
182 vtkSmartPointer< vtkPlane > m_PlaneFunction;
183 vtkSmartPointer< vtkPolyData > m_Plane;
184 vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
185 char m_TextBuffer[ 1024 ];
186 vtkSmartPointer< vtkTextActor > m_TextActor;
187 vtkSmartPointer< vtkActor > m_PlaneActor;
189 double m_StartWindowLevelPos[ 3 ];
190 double m_StartWindowLevel[ 2 ];
197 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__