1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
4 #include <cpExtensions/cpExtensions_Export.h>
6 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
8 #include <vtkCursor3D.h>
9 #include <vtkImageActor.h>
10 #include <vtkImageSliceMapper.h>
11 #include <vtkPolyDataMapper.h>
12 #include <vtkPropCollection.h>
13 #include <vtkTextActor.h>
14 #include <vtkSmartPointer.h>
16 #define MAX_TEXT_BUFFER 1024
18 class vtkAlgorithmOutput;
22 namespace cpExtensions
24 namespace Visualization
28 class cpExtensions_EXPORT ImageSliceActors
29 : public vtkPropCollection
32 typedef ImageSliceActors Self;
33 typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
34 typedef TStyle::TMouseCommand TMouseCommand;
35 typedef TStyle::TMouseWheelCommand TMouseWheelCommand;
36 typedef TStyle::TKeyCommand TKeyCommand;
37 typedef TStyle::TVoidCommand TVoidCommand;
38 typedef TStyle::TMouseMoveCommand TMouseMoveCommand;
39 typedef TStyle::TMouseClickCommand TMouseClickCommand;
40 typedef TStyle::TMouseDoubleClickCommand TMouseDoubleClickCommand;
41 typedef TStyle::TExposeCommand TExposeCommand;
42 typedef TStyle::TConfigureCommand TConfigureCommand;
43 typedef TStyle::TEnterCommand TEnterCommand;
44 typedef TStyle::TLeaveCommand TLeaveCommand;
45 typedef void ( *TSlicesCommand )( double*, int, void* );
46 typedef void ( *TWindowLevelCommand )( double, double, void* );
47 typedef TVoidCommand TRenderCommand;
49 template< class _TSource >
52 vtkSmartPointer< _TSource > Source;
53 vtkSmartPointer< vtkPolyDataMapper > Mapper;
54 vtkSmartPointer< vtkActor > Actor;
57 this->Source = vtkSmartPointer< _TSource >::New( );
58 this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
59 this->Actor = vtkSmartPointer< vtkActor >::New( );
60 this->Mapper->SetInputConnection( this->Source->GetOutputPort( ) );
61 this->Actor->SetMapper( this->Mapper );
65 this->Source->Modified( );
66 this->Mapper->Modified( );
67 this->Actor->Modified( );
73 vtkTypeMacro( ImageSliceActors, vtkPropCollection );
75 cpExtensions_BaseInteractorStyle_Commands( Slices );
76 cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
77 cpExtensions_BaseInteractorStyle_Commands( Render );
83 void SetInputConnection( vtkAlgorithmOutput* aout, int orientation );
84 void SetInputData( vtkImageData* data, int orientation );
86 void AssociateSlice( Self* slice );
87 void CleanAssociatedSlices( );
90 void SetStyle( vtkInteractorStyle* st );
92 void PushInto( vtkRenderer* ren );
93 void PopFrom( vtkRenderer* ren );
95 long GetSliceNumber( ) const;
96 void SetSliceNumber( long slice );
98 void ShowPixelText( double* pos );
100 void GetScalarRange( double r[ 2 ] ) const;
101 void SetScalarRange( const double& a, const double& b );
102 void UnsetScalarRange( );
103 void SetWindowLevel( const double& w, const double& l );
104 double GetWindow( ) const;
105 double GetLevel( ) const;
111 virtual ~ImageSliceActors( );
113 void _ConfigureInput( int orientation );
114 void _ConfigureCursor( );
117 static void _MouseMoveCommand(
119 const TStyle::ButtonID& btn,
120 int* idx, double* pos,
121 bool alt, bool ctr, bool sft
123 static void _MouseClickCommand(
125 const TStyle::ButtonID& btn,
126 int* idx, double* pos,
127 bool alt, bool ctr, bool sft
129 static void _MouseWheelCommand(
131 const int& dir, bool alt, bool ctr, bool sft
133 static void _KeyCommand(
137 static void _EnterCommand( void* data );
138 static void _LeaveCommand( void* data );
141 // Purposely not implemented
142 ImageSliceActors( const Self& );
143 Self& operator=( const Self& );
147 vtkSmartPointer< vtkImageSliceMapper > m_Mapper;
148 vtkSmartPointer< vtkImageActor > m_Actor;
151 std::vector< vtkSmartPointer< Self > > m_AssociatedSlices;
154 SourceActor< vtkCursor3D > m_Cursor;
157 char m_TextBuffer[ MAX_TEXT_BUFFER ];
158 vtkSmartPointer< vtkTextActor > m_TextActor;
161 double m_ScalarRange[ 2 ];
162 bool m_ManualScalarRange;
165 vtkSmartPointer< vtkInteractorStyle > m_Style;
167 // Events-related data
168 double m_StartMouseEvent[ 3 ];
169 double m_StartWindow;
177 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__