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;
28 // -------------------------------------------------------------------------
29 namespace cpExtensions
31 namespace Visualization
35 class cpExtensions_EXPORT ImageSliceActors
36 : public vtkPropCollection
39 typedef ImageSliceActors Self;
41 typedef cpExtensions::Interaction::BaseInteractorStyle TBaseStyle;
42 typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
43 typedef void ( *TSlicesCommand )( double*, int, void* );
44 typedef void ( *TWindowLevelCommand )( double, double, void* );
45 typedef TBaseStyle::TMouseCommand TMouseCommand;
46 typedef TBaseStyle::TMouseWheelCommand TMouseWheelCommand;
47 typedef TBaseStyle::TKeyCommand TKeyCommand;
48 typedef TBaseStyle::TVoidCommand TVoidCommand;
51 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
55 static ImageSliceActors* New( );
57 void AddSlicesCommand( TSlicesCommand command, void* data );
58 void AddWindowLevelCommand( TWindowLevelCommand command, void* data );
59 void AddRenderCommand( TVoidCommand command, void* data );
61 void RemoveSlicesCommand( TSlicesCommand command );
62 void RemoveWindowLevelCommand( TWindowLevelCommand command );
63 void RemoveRenderCommand( TVoidCommand command );
65 void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
66 void AddInputData( vtkImageData* data, int axis = 2 );
69 void AssociateSlice( Self* slice );
71 vtkImageData* GetInputImage( unsigned int id );
72 const vtkImageData* GetInputImage( unsigned int id ) 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 GetNumberOfImageActors( ) const;
80 vtkImageActor* GetImageActor( unsigned int id );
81 const vtkImageActor* GetImageActor( unsigned int id ) 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 vtkImageMapToColors* GetImageMap( unsigned int id );
100 const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
102 double GetMinWindow( ) const;
103 double GetMaxWindow( ) const;
104 double GetMinLevel( ) const;
105 double GetMaxLevel( ) const;
106 double GetWindow( ) const;
107 double GetLevel( ) const;
108 void SetWindow( double w );
109 void SetLevel( double l );
110 void SetWindowLevel( double w, double l );
111 void ResetWindowLevel( );
113 void SetLookupTable( unsigned int id, vtkLookupTable* lut );
114 void SetLookupTableAsColor(
115 unsigned int id, double r, double g, double b
118 int GetAxis( ) const;
119 int GetSliceNumber( ) const;
120 int GetSliceNumberMinValue( ) const;
121 int GetSliceNumberMaxValue( ) const;
122 void SetSliceNumber( const int& slice );
123 void SetSlice( double* pos );
125 void UpdateText( double pos[ 3 ] );
126 void UpdateText( const double& w, const double& l );
133 virtual ~ImageSliceActors( );
135 void _ConfigureStyle( );
136 void _ConfigureNewLUT( vtkImageData* data );
137 void _ConfigureNewInput( int axis );
140 static void _MouseMoveCommand(
142 const TBaseStyle::ButtonID& btn,
143 int* idx, double* pos,
144 bool alt, bool ctr, bool sft
146 static void _MouseClickCommand(
148 const TBaseStyle::ButtonID& btn,
149 int* idx, double* pos,
150 bool alt, bool ctr, bool sft
152 static void _MouseWheelCommand(
154 const int& dir, bool alt, bool ctr, bool sft
156 static void _KeyCommand(
162 // Purposely not implemented
163 ImageSliceActors( const Self& );
164 Self& operator=( const Self& );
167 vtkSmartPointer< TStyle > m_Style;
168 vtkRenderWindow* m_Window;
171 std::vector< vtkSmartPointer< vtkImageMapToColors > > m_ImageMaps;
172 std::vector< vtkSmartPointer< vtkImageSliceMapper > > m_SliceMappers;
173 std::vector< vtkSmartPointer< vtkImageActor > > m_ImageActors;
177 std::vector< Self* > m_AssociatedSlices;
179 // Window-Level values
180 double m_MinWindow, m_MaxWindow;
181 double m_MinLevel, m_MaxLevel;
183 // Associated commands
184 std::map< TSlicesCommand, void* > m_SlicesCommands;
185 std::map< TWindowLevelCommand, void* > m_WindowLevelCommands;
186 std::map< TVoidCommand, void* > m_RenderCommands;
189 vtkSmartPointer< vtkPolyData > m_Cursor;
190 vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper;
191 vtkSmartPointer< vtkActor > m_CursorActor;
192 vtkSmartPointer< vtkPolyData > m_Plane;
193 vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
194 char m_TextBuffer[ 1024 ];
195 vtkSmartPointer< vtkTextActor > m_TextActor;
196 vtkSmartPointer< vtkActor > m_PlaneActor;
198 double m_StartWindowLevelPos[ 3 ];
199 double m_StartWindowLevel[ 2 ];
206 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__