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* );
43 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
45 vtkGetMacro( MinWindow, double );
46 vtkGetMacro( MaxWindow, double );
47 vtkGetMacro( MinLevel, double );
48 vtkGetMacro( MaxLevel, double );
52 static ImageSliceActors* New( );
54 void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
55 void AddInputData( vtkImageData* data, int axis = 2 );
58 void AssociateSlice( Self* other );
59 void SetSlicesCommand( TCursorCommand cmd, void* data );
61 vtkInteractorStyle* GetStyle( );
62 const vtkInteractorStyle* GetStyle( ) const;
64 void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
65 void PopActorsFrom( vtkRenderWindow* window );
66 unsigned int GetNumberOfImageActors( ) const;
67 vtkImageActor* GetImageActor( unsigned int id );
68 const vtkImageActor* GetImageActor( unsigned int id ) const;
69 vtkTextActor* GetTextActor( );
70 const vtkTextActor* GetTextActor( ) const;
71 vtkActor* GetPlaneActor( );
72 const vtkActor* GetPlaneActor( ) const;
73 vtkPlane* GetPlaneFunction( );
74 const vtkPlane* GetPlaneFunction( ) const;
76 void AddActor( vtkAlgorithm* algorithm, vtkActor* actor );
77 void AddActor( vtkActor* actor );
79 void SetInterpolate( bool v );
80 void InterpolateOn( );
81 void InterpolateOff( );
83 double* GetDisplayBounds( ) const;
84 void GetDisplayBounds( double bounds[ 6 ] ) const;
87 void SetCursor( double pos[ 3 ] );
89 vtkImageMapToColors* GetImageMap( unsigned int id );
90 const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
92 double GetWindow( ) const;
93 double GetLevel( ) const;
94 void SetWindow( double w );
95 void SetLevel( double l );
96 void SetWindowLevel( double w, double l );
97 void ResetWindowLevel( );
99 void SetLookupTable( unsigned int id, vtkLookupTable* lut );
100 void SetLookupTableAsColor(
101 unsigned int id, double r, double g, double b
104 int GetAxis( ) const;
105 int GetSliceNumber( ) const;
106 int GetSliceNumberMinValue( ) const;
107 int GetSliceNumberMaxValue( ) const;
108 void SetSliceNumber( const int& slice );
109 void SetSlice( double* pos );
111 void UpdateText( double pos[ 3 ] );
112 void UpdateText( const double& w, const double& l );
116 virtual ~ImageSliceActors( );
118 void _ConfigureNewLUT( vtkImageData* data );
119 void _ConfigureNewInput( int axis );
122 static void _MouseMoveCommand(
124 const ImageInteractorStyle::ButtonID& btn, double* pos,
125 bool alt, bool ctr, bool sft
127 static void _MouseClickCommand(
129 const ImageInteractorStyle::ButtonID& btn, double* pos,
130 bool alt, bool ctr, bool sft
132 static void _MouseDoubleClickCommand(
134 const ImageInteractorStyle::ButtonID& btn, double* pos,
135 bool alt, bool ctr, bool sft
137 static void _MouseWheelCommand(
139 const int& dir, bool alt, bool ctr, bool sft
141 static void _KeyCommand(
147 // Purposely not implemented
148 ImageSliceActors( const Self& );
149 Self& operator=( const Self& );
152 vtkSmartPointer< ImageInteractorStyle > Style;
155 std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
156 std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
157 std::vector< vtkSmartPointer< vtkImageActor > > ImageActors;
160 // Window-Level values
161 double MinWindow, MaxWindow;
162 double MinLevel, MaxLevel;
164 // Other associated slices
165 std::vector< vtkSmartPointer< Self > > AssociatedSlices;
166 TCursorCommand SlicesCommand;
169 // Other associated actors
170 typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor;
171 typedef std::vector< TAssociatedActor > TAssociatedActors;
172 TAssociatedActors AssociatedActors;
175 vtkSmartPointer< vtkPolyData > Cursor;
176 vtkSmartPointer< vtkPolyDataMapper > CursorMapper;
177 vtkSmartPointer< vtkActor > CursorActor;
178 vtkSmartPointer< vtkPlane > PlaneFunction;
179 vtkSmartPointer< vtkPolyData > Plane;
180 vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
181 char TextBuffer[ 1024 ];
182 vtkSmartPointer< vtkTextActor > TextActor;
183 vtkSmartPointer< vtkActor > PlaneActor;
185 double StartWindowLevelPos[ 3 ];
186 double StartWindowLevel[ 2 ];
193 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__