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;
26 // -------------------------------------------------------------------------
27 namespace cpExtensions
29 namespace Visualization
33 class cpExtensions_EXPORT ImageSliceActors
34 : public vtkPropCollection
37 typedef ImageSliceActors Self;
39 typedef void ( *TCursorCommand )( double*, int, void* );
42 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
53 static ImageSliceActors* New( );
55 void AddInputConnection(
56 vtkAlgorithmOutput* aout,
58 LUTType lut = Self::LUTType_None
63 LUTType lut = Self::LUTType_None );
66 void AssociateSlice( Self* other );
67 void SetSlicesCommand( TCursorCommand cmd, void* data );
69 vtkInteractorStyle* GetStyle( );
70 const vtkInteractorStyle* GetStyle( ) const;
72 void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
73 void PopActorsFrom( vtkRenderWindow* window );
74 unsigned int GetNumberOfImageActors( ) const;
75 vtkImageActor* GetImageActor( unsigned int id );
76 const vtkImageActor* GetImageActor( unsigned int id ) const;
77 vtkTextActor* GetTextActor( );
78 const vtkTextActor* GetTextActor( ) const;
79 vtkActor* GetPlaneActor( );
80 const vtkActor* GetPlaneActor( ) const;
81 vtkPlane* GetPlaneFunction( );
82 const vtkPlane* GetPlaneFunction( ) const;
84 void AddActor( vtkAlgorithm* algorithm, vtkActor* actor );
85 void AddActor( vtkActor* actor );
87 void SetInterpolate( bool v );
88 void InterpolateOn( );
89 void InterpolateOff( );
91 double* GetDisplayBounds( ) const;
92 void GetDisplayBounds( double bounds[ 6 ] ) const;
95 void SetCursor( double pos[ 3 ] );
97 vtkImageMapToColors* GetImageMap( unsigned int id );
98 const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
100 double GetWindow( unsigned int id ) const;
101 double GetLevel( unsigned int id ) const;
102 void SetWindow( unsigned int id, double w );
103 void SetLevel( unsigned int id, double l );
104 void SetWindowLevel( unsigned int id, double w, double l );
105 void ResetWindowLevel( unsigned int id );
107 int GetAxis( ) const;
108 int GetSliceNumber( ) const;
109 int GetSliceNumberMinValue( ) const;
110 int GetSliceNumberMaxValue( ) const;
111 void SetSliceNumber( const int& slice );
112 void SetSlice( double* pos );
114 void UpdateText( double pos[ 3 ] );
115 void UpdateText( const double& w, const double& l );
119 virtual ~ImageSliceActors( );
121 void _ConfigureNewLUT( vtkImageData* data, LUTType lut_t );
122 void _ConfigureNewInput( int axis );
125 static void _MouseMoveCommand(
127 const ImageInteractorStyle::ButtonID& btn, double* pos,
128 bool alt, bool ctr, bool sft
130 static void _MouseClickCommand(
132 const ImageInteractorStyle::ButtonID& btn, double* pos,
133 bool alt, bool ctr, bool sft
135 static void _MouseDoubleClickCommand(
137 const ImageInteractorStyle::ButtonID& btn, double* pos,
138 bool alt, bool ctr, bool sft
140 static void _MouseWheelCommand(
142 const int& dir, bool alt, bool ctr, bool sft
144 static void _KeyCommand(
150 // Purposely not implemented
151 ImageSliceActors( const Self& );
152 Self& operator=( const Self& );
155 vtkSmartPointer< ImageInteractorStyle > Style;
158 std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
159 std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
160 std::vector< vtkSmartPointer< vtkImageActor > > ImageActors;
163 // Other associated slices
164 std::vector< vtkSmartPointer< Self > > AssociatedSlices;
165 TCursorCommand SlicesCommand;
168 // Other associated actors
169 typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor;
170 typedef std::vector< TAssociatedActor > TAssociatedActors;
171 TAssociatedActors AssociatedActors;
174 vtkSmartPointer< vtkPolyData > Cursor;
175 vtkSmartPointer< vtkPolyDataMapper > CursorMapper;
176 vtkSmartPointer< vtkActor > CursorActor;
177 vtkSmartPointer< vtkPlane > PlaneFunction;
178 vtkSmartPointer< vtkPolyData > PlaneSource;
179 vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
180 char TextBuffer[ 1024 ];
181 vtkSmartPointer< vtkTextActor > TextActor;
182 vtkSmartPointer< vtkActor > PlaneActor;
184 double StartWindowLevelPos[ 3 ];
185 double StartWindowLevel[ 2 ];
192 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__