1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
4 #include <cpExtensions/cpExtensions_Export.h>
6 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
9 #include <vtkCursor3D.h>
10 #include <vtkCutter.h>
11 #include <vtkImageActor.h>
12 #include <vtkImageSliceMapper.h>
13 #include <vtkPolyDataMapper.h>
14 #include <vtkPropCollection.h>
15 #include <vtkTextActor.h>
16 #include <vtkSmartPointer.h>
18 #define MAX_TEXT_BUFFER 1024
20 class vtkAlgorithmOutput;
24 namespace cpExtensions
26 namespace Visualization
30 class cpExtensions_EXPORT ImageSliceActors
31 : public vtkPropCollection
34 typedef ImageSliceActors Self;
35 typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
36 typedef TStyle::TMouseCommand TMouseCommand;
37 typedef TStyle::TMouseWheelCommand TMouseWheelCommand;
38 typedef TStyle::TKeyCommand TKeyCommand;
39 typedef TStyle::TVoidCommand TVoidCommand;
40 typedef TStyle::TMouseMoveCommand TMouseMoveCommand;
41 typedef TStyle::TMouseClickCommand TMouseClickCommand;
42 typedef TStyle::TMouseDoubleClickCommand TMouseDoubleClickCommand;
43 typedef TStyle::TExposeCommand TExposeCommand;
44 typedef TStyle::TConfigureCommand TConfigureCommand;
45 typedef TStyle::TEnterCommand TEnterCommand;
46 typedef TStyle::TLeaveCommand TLeaveCommand;
47 typedef void ( *TSlicesCommand )( double*, int, void* );
48 typedef void ( *TWindowLevelCommand )( double, double, void* );
49 typedef TVoidCommand TRenderCommand;
51 template< class _TSource >
54 vtkSmartPointer< _TSource > Source;
55 vtkSmartPointer< vtkPolyDataMapper > Mapper;
56 vtkSmartPointer< vtkActor > Actor;
59 this->Source = vtkSmartPointer< _TSource >::New( );
60 this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
61 this->Actor = vtkSmartPointer< vtkActor >::New( );
62 this->Mapper->SetInputConnection( this->Source->GetOutputPort( ) );
63 this->Actor->SetMapper( this->Mapper );
67 this->Source->Modified( );
68 this->Mapper->Modified( );
69 this->Actor->Modified( );
74 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
76 cpExtensions_BaseInteractorStyle_Commands( Slices );
77 cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
78 cpExtensions_BaseInteractorStyle_Commands( Render );
84 void SetInputConnection( vtkAlgorithmOutput* aout, int orientation );
85 void SetInputData( vtkImageData* data, int orientation );
86 vtkImageData* GetInputData( );
88 vtkImageActor* GetImageActor( );
89 const vtkImageActor* GetImageActor( ) const;
91 void AddMesh( vtkPolyData* mesh );
93 void AssociateSlice( Self* slice );
94 void CleanAssociatedSlices( );
97 void SetStyle( vtkInteractorStyle* st );
99 void PushInto( vtkRenderer* ren );
100 void PopFrom( vtkRenderer* ren );
102 long GetSliceNumber( ) const;
103 void SetSliceNumber( long slice );
105 void ShowPixelText( double* pos );
107 void GetScalarRange( double r[ 2 ] ) const;
108 void SetScalarRange( const double& a, const double& b );
109 void UnsetScalarRange( );
110 void SetWindowLevel( const double& w, const double& l );
111 double GetWindow( ) const;
112 double GetLevel( ) const;
118 virtual ~ImageSliceActors( );
120 void _ConfigureInput( int orientation );
121 void _ConfigureCursor( );
124 static void _MouseMoveCommand(
126 const TStyle::ButtonID& btn,
127 int* idx, double* pos,
128 bool alt, bool ctr, bool sft
130 static void _MouseClickCommand(
132 const TStyle::ButtonID& btn,
133 int* idx, double* pos,
134 bool alt, bool ctr, bool sft
136 static void _MouseWheelCommand(
138 const int& dir, bool alt, bool ctr, bool sft
140 static void _KeyCommand(
144 static void _EnterCommand( void* data );
145 static void _LeaveCommand( void* data );
148 // Purposely not implemented
149 ImageSliceActors( const Self& );
150 Self& operator=( const Self& );
154 vtkSmartPointer< vtkImageSliceMapper > m_Mapper;
155 vtkSmartPointer< vtkImageActor > m_Actor;
158 std::vector< vtkSmartPointer< Self > > m_AssociatedSlices;
161 std::map< vtkPolyData*, SourceActor< vtkCutter > > m_Meshes;
164 SourceActor< vtkCursor3D > m_Cursor;
167 char m_TextBuffer[ MAX_TEXT_BUFFER ];
168 vtkSmartPointer< vtkTextActor > m_TextActor;
171 double m_ScalarRange[ 2 ];
172 bool m_ManualScalarRange;
175 vtkSmartPointer< vtkInteractorStyle > m_Style;
177 // Events-related data
178 double m_StartMouseEvent[ 3 ];
179 double m_StartWindow;
187 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__