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/Visualization/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 void ( *TCursorCommand )( double*, int, void* );
41 typedef BaseInteractorStyle::TMouseCommand TMouseCommand;
42 typedef BaseInteractorStyle::TMouseWheelCommand TMouseWheelCommand;
43 typedef BaseInteractorStyle::TKeyCommand TKeyCommand;
44 typedef BaseInteractorStyle::TVoidCommand TVoidCommand;
47 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
51 static ImageSliceActors* New( );
53 void AddSlicesCommand( TCursorCommand command, void* data );
54 void AddSeedCommand( TCursorCommand command, void* data );
56 void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
57 void AddInputData( vtkImageData* data, int axis = 2 );
60 void AssociateSlice( Self* other );
62 vtkInteractorStyle* GetStyle( );
63 const vtkInteractorStyle* GetStyle( ) const;
65 void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
66 void PopActorsFrom( vtkRenderWindow* window );
67 unsigned int GetNumberOfImageActors( ) const;
68 vtkImageActor* GetImageActor( unsigned int id );
69 const vtkImageActor* GetImageActor( unsigned int id ) const;
70 vtkTextActor* GetTextActor( );
71 const vtkTextActor* GetTextActor( ) const;
72 vtkActor* GetPlaneActor( );
73 const vtkActor* GetPlaneActor( ) const;
74 vtkPlane* GetPlaneFunction( );
75 const vtkPlane* GetPlaneFunction( ) const;
77 void AddActor( vtkAlgorithm* algorithm, vtkActor* actor );
78 void AddActor( vtkActor* actor );
80 void SetInterpolate( bool v );
81 void InterpolateOn( );
82 void InterpolateOff( );
84 double* GetDisplayBounds( ) const;
85 void GetDisplayBounds( double bounds[ 6 ] ) const;
88 void SetCursor( double pos[ 3 ] );
90 vtkImageMapToColors* GetImageMap( unsigned int id );
91 const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
93 double GetMinWindow( ) const;
94 double GetMaxWindow( ) const;
95 double GetMinLevel( ) const;
96 double GetMaxLevel( ) const;
97 double GetWindow( ) const;
98 double GetLevel( ) const;
99 void SetWindow( double w );
100 void SetLevel( double l );
101 void SetWindowLevel( double w, double l );
102 void ResetWindowLevel( );
104 void SetLookupTable( unsigned int id, vtkLookupTable* lut );
105 void SetLookupTableAsColor(
106 unsigned int id, double r, double g, double b
109 int GetAxis( ) const;
110 int GetSliceNumber( ) const;
111 int GetSliceNumberMinValue( ) const;
112 int GetSliceNumberMaxValue( ) const;
113 void SetSliceNumber( const int& slice );
114 void SetSlice( double* pos );
116 void UpdateText( double pos[ 3 ] );
117 void UpdateText( const double& w, const double& l );
121 virtual ~ImageSliceActors( );
123 void _ConfigureStyle( );
124 void _ConfigureNewLUT( vtkImageData* data );
125 void _ConfigureNewInput( int axis );
128 static void _MouseMoveCommand(
130 const BaseInteractorStyle::ButtonID& btn, double* pos,
131 bool alt, bool ctr, bool sft
133 static void _MouseClickCommand(
135 const BaseInteractorStyle::ButtonID& btn, double* pos,
136 bool alt, bool ctr, bool sft
138 static void _MouseDoubleClickCommand(
140 const BaseInteractorStyle::ButtonID& btn, double* pos,
141 bool alt, bool ctr, bool sft
143 static void _MouseWheelCommand(
145 const int& dir, bool alt, bool ctr, bool sft
147 static void _KeyCommand(
153 // Purposely not implemented
154 ImageSliceActors( const Self& );
155 Self& operator=( const Self& );
158 vtkSmartPointer< ImageInteractorStyle > m_Style;
161 std::vector< vtkSmartPointer< vtkImageMapToColors > > m_ImageMaps;
162 std::vector< vtkSmartPointer< vtkImageSliceMapper > > m_SliceMappers;
163 std::vector< vtkSmartPointer< vtkImageActor > > m_ImageActors;
166 // Window-Level values
167 double m_MinWindow, m_MaxWindow;
168 double m_MinLevel, m_MaxLevel;
170 // Other associated slices
171 std::vector< vtkSmartPointer< Self > > m_AssociatedSlices;
173 // Associated commands
174 std::vector< std::pair< TCursorCommand, void* > > m_SlicesCommands;
175 std::vector< std::pair< TCursorCommand, void* > > m_SeedCommands;
177 // Other associated actors
178 typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor;
179 typedef std::vector< TAssociatedActor > TAssociatedActors;
180 TAssociatedActors m_AssociatedActors;
183 vtkSmartPointer< vtkPolyData > m_Cursor;
184 vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper;
185 vtkSmartPointer< vtkActor > m_CursorActor;
186 vtkSmartPointer< vtkPlane > m_PlaneFunction;
187 vtkSmartPointer< vtkPolyData > m_Plane;
188 vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
189 char m_TextBuffer[ 1024 ];
190 vtkSmartPointer< vtkTextActor > m_TextActor;
191 vtkSmartPointer< vtkActor > m_PlaneActor;
193 double m_StartWindowLevelPos[ 3 ];
194 double m_StartWindowLevel[ 2 ];
201 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__