1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
4 #include <cpExtensions/Config.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 void SetInputActor( vtkProp* actor, int orientation );
87 vtkImageData* GetInputData( );
89 vtkImageActor* GetImageActor( );
90 const vtkImageActor* GetImageActor( ) const;
92 void AddMesh( vtkPolyData* mesh );
94 void AssociateSlice( Self* slice );
95 void CleanAssociatedSlices( );
98 void SetStyle( vtkInteractorStyle* st );
100 void PushInto( vtkRenderer* ren );
101 void PopFrom( vtkRenderer* ren );
103 long GetSliceNumber( ) const;
104 void SetSliceNumber( long slice );
106 void ShowPixelText( double* pos );
108 void GetScalarRange( double r[ 2 ] ) const;
109 void SetScalarRange( const double& a, const double& b );
110 void UnsetScalarRange( );
111 void SetWindowLevel( const double& w, const double& l );
112 double GetWindow( ) const;
113 double GetLevel( ) const;
119 virtual ~ImageSliceActors( );
121 void _ConfigureInput( int orientation );
122 void _ConfigureCursor( );
125 static void _MouseMoveCommand(
127 const TStyle::ButtonID& btn,
128 int* idx, double* pos,
129 bool alt, bool ctr, bool sft
131 static void _MouseClickCommand(
133 const TStyle::ButtonID& btn,
134 int* idx, 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(
145 static void _EnterCommand( void* data );
146 static void _LeaveCommand( void* data );
149 // Purposely not implemented
150 ImageSliceActors( const Self& );
151 Self& operator=( const Self& );
155 vtkSmartPointer< vtkImageSliceMapper > m_Mapper;
156 vtkSmartPointer< vtkImageActor > m_Actor;
159 std::vector< vtkSmartPointer< Self > > m_AssociatedSlices;
162 std::map< vtkPolyData*, SourceActor< vtkCutter > > m_Meshes;
165 SourceActor< vtkCursor3D > m_Cursor;
168 char m_TextBuffer[ MAX_TEXT_BUFFER ];
169 vtkSmartPointer< vtkTextActor > m_TextActor;
172 double m_ScalarRange[ 2 ];
173 bool m_ManualScalarRange;
176 vtkSmartPointer< vtkInteractorStyle > m_Style;
178 // Events-related data
179 double m_StartMouseEvent[ 3 ];
180 double m_StartWindow;
188 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__