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 void AddMesh( vtkPolyData* mesh );
90 void AssociateSlice( Self* slice );
91 void CleanAssociatedSlices( );
94 void SetStyle( vtkInteractorStyle* st );
96 void PushInto( vtkRenderer* ren );
97 void PopFrom( vtkRenderer* ren );
99 long GetSliceNumber( ) const;
100 void SetSliceNumber( long slice );
102 void ShowPixelText( double* pos );
104 void GetScalarRange( double r[ 2 ] ) const;
105 void SetScalarRange( const double& a, const double& b );
106 void UnsetScalarRange( );
107 void SetWindowLevel( const double& w, const double& l );
108 double GetWindow( ) const;
109 double GetLevel( ) const;
115 virtual ~ImageSliceActors( );
117 void _ConfigureInput( int orientation );
118 void _ConfigureCursor( );
121 static void _MouseMoveCommand(
123 const TStyle::ButtonID& btn,
124 int* idx, double* pos,
125 bool alt, bool ctr, bool sft
127 static void _MouseClickCommand(
129 const TStyle::ButtonID& btn,
130 int* idx, double* pos,
131 bool alt, bool ctr, bool sft
133 static void _MouseWheelCommand(
135 const int& dir, bool alt, bool ctr, bool sft
137 static void _KeyCommand(
141 static void _EnterCommand( void* data );
142 static void _LeaveCommand( void* data );
145 // Purposely not implemented
146 ImageSliceActors( const Self& );
147 Self& operator=( const Self& );
151 vtkSmartPointer< vtkImageSliceMapper > m_Mapper;
152 vtkSmartPointer< vtkImageActor > m_Actor;
155 std::vector< vtkSmartPointer< Self > > m_AssociatedSlices;
158 std::map< vtkPolyData*, SourceActor< vtkCutter > > m_Meshes;
161 SourceActor< vtkCursor3D > m_Cursor;
164 char m_TextBuffer[ MAX_TEXT_BUFFER ];
165 vtkSmartPointer< vtkTextActor > m_TextActor;
168 double m_ScalarRange[ 2 ];
169 bool m_ManualScalarRange;
172 vtkSmartPointer< vtkInteractorStyle > m_Style;
174 // Events-related data
175 double m_StartMouseEvent[ 3 ];
176 double m_StartWindow;
184 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__