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::ImageInteractorStyle TStyle;
42 typedef TStyle::TMouseCommand TMouseCommand;
43 typedef TStyle::TMouseWheelCommand TMouseWheelCommand;
44 typedef TStyle::TKeyCommand TKeyCommand;
45 typedef TStyle::TVoidCommand TVoidCommand;
46 typedef TStyle::TMouseMoveCommand TMouseMoveCommand;
47 typedef TStyle::TMouseClickCommand TMouseClickCommand;
48 typedef TStyle::TMouseDoubleClickCommand TMouseDoubleClickCommand;
49 typedef TStyle::TExposeCommand TExposeCommand;
50 typedef TStyle::TConfigureCommand TConfigureCommand;
51 typedef TStyle::TEnterCommand TEnterCommand;
52 typedef TStyle::TLeaveCommand TLeaveCommand;
53 typedef void ( *TSlicesCommand )( double*, int, void* );
54 typedef void ( *TWindowLevelCommand )( double, double, void* );
55 typedef TVoidCommand TRenderCommand;
58 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
60 cpExtensions_BaseInteractorStyle_Commands( Slices );
61 cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
62 cpExtensions_BaseInteractorStyle_Commands( Render );
66 static ImageSliceActors* New( );
68 void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
69 void AddInputData( vtkImageData* data, int axis = 2 );
72 void AssociateSlice( Self* slice );
74 vtkImageData* GetInputImage( unsigned int id );
75 const vtkImageData* GetInputImage( unsigned int id ) const;
77 vtkInteractorStyle* GetStyle( );
78 const vtkInteractorStyle* GetStyle( ) const;
80 void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
81 void PopActorsFrom( vtkRenderWindow* window );
82 unsigned int GetNumberOfImageActors( ) const;
83 vtkImageActor* GetImageActor( unsigned int id );
84 const vtkImageActor* GetImageActor( unsigned int id ) const;
85 vtkTextActor* GetTextActor( );
86 const vtkTextActor* GetTextActor( ) const;
87 vtkActor* GetPlaneActor( );
88 const vtkActor* GetPlaneActor( ) const;
89 vtkPlane* GetPlaneFunction( );
90 const vtkPlane* GetPlaneFunction( ) const;
92 void SetInterpolate( bool v );
93 void InterpolateOn( );
94 void InterpolateOff( );
96 double* GetDisplayBounds( ) const;
97 void GetDisplayBounds( double bounds[ 6 ] ) const;
100 void SetCursor( double pos[ 3 ] );
102 vtkImageMapToColors* GetImageMap( unsigned int id );
103 const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
105 double GetMinWindow( ) const;
106 double GetMaxWindow( ) const;
107 double GetMinLevel( ) const;
108 double GetMaxLevel( ) const;
109 double GetWindow( ) const;
110 double GetLevel( ) const;
111 void SetWindow( double w );
112 void SetLevel( double l );
113 void SetWindowLevel( double w, double l );
114 void ResetWindowLevel( );
116 void SetLookupTable( unsigned int id, vtkLookupTable* lut );
117 void SetLookupTableAsColor(
118 unsigned int id, double r, double g, double b
121 int GetAxis( ) const;
122 int GetSliceNumber( ) const;
123 int GetSliceNumberMinValue( ) const;
124 int GetSliceNumberMaxValue( ) const;
125 void SetSliceNumber( const int& slice );
126 void SetSlice( double* pos );
128 void UpdateText( double pos[ 3 ] );
129 void UpdateText( const double& w, const double& l );
131 void Render( const double& t );
136 virtual ~ImageSliceActors( );
138 void _ConfigureStyle( );
139 void _ConfigureNewLUT( vtkImageData* data );
140 void _ConfigureNewInput( int axis );
143 static void _MouseMoveCommand(
145 const TStyle::ButtonID& btn,
146 int* idx, double* pos,
147 bool alt, bool ctr, bool sft
149 static void _MouseClickCommand(
151 const TStyle::ButtonID& btn,
152 int* idx, double* pos,
153 bool alt, bool ctr, bool sft
155 static void _MouseWheelCommand(
157 const int& dir, bool alt, bool ctr, bool sft
159 static void _KeyCommand(
163 static void _EnterCommand( void* data );
164 static void _LeaveCommand( void* data );
167 // Purposely not implemented
168 ImageSliceActors( const Self& );
169 Self& operator=( const Self& );
172 vtkSmartPointer< TStyle > m_Style;
173 vtkRenderWindow* m_Window;
176 std::vector< vtkSmartPointer< vtkImageMapToColors > > m_ImageMaps;
177 std::vector< vtkSmartPointer< vtkImageSliceMapper > > m_SliceMappers;
178 std::vector< vtkSmartPointer< vtkImageActor > > m_ImageActors;
182 std::vector< Self* > m_AssociatedSlices;
184 // Window-Level values
185 double m_MinWindow, m_MaxWindow;
186 double m_MinLevel, m_MaxLevel;
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__