]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageSliceActors.h
Merge ssh://git.creatis.insa-lyon.fr/cpPlugins
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageSliceActors.h
1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
3
4 #include <cpExtensions/cpExtensions_Export.h>
5
6 #include <utility>
7 #include <vector>
8
9 #include <vtkSmartPointer.h>
10 #include <vtkActor.h>
11 #include <vtkImageActor.h>
12 #include <vtkImageSliceMapper.h>
13 #include <vtkPlane.h>
14 #include <vtkPolyData.h>
15 #include <vtkPolyDataMapper.h>
16 #include <vtkPropCollection.h>
17 #include <vtkTextActor.h>
18
19 #include <cpExtensions/Visualization/ImageInteractorStyle.h>
20
21 // -------------------------------------------------------------------------
22 class vtkAlgorithmOutput;
23 class vtkImageData;
24
25 // -------------------------------------------------------------------------
26 namespace cpExtensions
27 {
28   namespace Visualization
29   {
30     /**
31      */
32     class cpExtensions_EXPORT ImageSliceActors
33       : public vtkPropCollection
34     {
35     public:
36       typedef ImageSliceActors Self;
37
38     public:
39       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
40
41     public:
42       // Creation
43       static ImageSliceActors* New( );
44
45       void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
46       void AddInputData( vtkImageData* data, int axis = 2 );
47       void Clear( );
48
49       vtkInteractorStyle* GetStyle( );
50       const vtkInteractorStyle* GetStyle( ) const;
51
52       void PushActorsInto( vtkRenderWindow* window );
53       void PopActorsFrom( vtkRenderWindow* window );
54       unsigned int GetNumberOfImageActors( ) const;
55       vtkImageActor* GetImageActor( unsigned int id );
56       const vtkImageActor* GetImageActor( unsigned int id ) const;
57       vtkTextActor* GetTextActor( );
58       const vtkTextActor* GetTextActor( ) const;
59       vtkActor* GetPlaneActor( );
60       const vtkActor* GetPlaneActor( ) const;
61       vtkPlane* GetPlaneFunction( );
62       const vtkPlane* GetPlaneFunction( ) const;
63
64       void AddActor( vtkAlgorithm* algorithm, vtkActor* actor );
65       void AddActor( vtkActor* actor );
66
67       void SetInterpolate( bool v );
68       void InterpolateOn( );
69       void InterpolateOff( );
70
71       double* GetDisplayBounds( ) const;
72       void GetDisplayBounds( double bounds[ 6 ] ) const;
73
74       void ResetCursor( );
75       void SetCursor( double pos[ 3 ] );
76
77       int GetAxis( ) const;
78       int GetSliceNumber( ) const;
79       int GetSliceNumberMinValue( ) const;
80       int GetSliceNumberMaxValue( ) const;
81       void SetSliceNumber( const int& slice );
82       void UpdateText( );
83       void UpdateText( double pos[ 3 ] );
84       void UpdateText( const double& w, const double& l );
85
86     protected:
87       ImageSliceActors( );
88       virtual ~ImageSliceActors( );
89
90       void _ConfigureNewInput( int axis );
91
92       // Events
93       static void _MouseMoveCommand(
94         void* data,
95         const ImageInteractorStyle::ButtonID& btn, double* pos,
96         bool alt, bool ctr, bool sft
97         );
98       static void _MouseClickCommand(
99         void* data,
100         const ImageInteractorStyle::ButtonID& btn, double* pos,
101         bool alt, bool ctr, bool sft
102         );
103       static void _MouseDoubleClickCommand(
104         void* data,
105         const ImageInteractorStyle::ButtonID& btn, double* pos,
106         bool alt, bool ctr, bool sft
107         );
108       static void _MouseWheelCommand(
109         void* data,
110         const int& dir, bool alt, bool ctr, bool sft
111         );
112       static void _KeyCommand(
113         void* data,
114         const char& key
115         );
116
117     private:
118       // Purposely not implemented
119       ImageSliceActors( const Self& );
120       Self& operator=( const Self& );
121
122     protected:
123       vtkSmartPointer< ImageInteractorStyle > Style;
124
125       // Multiple actors
126       std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
127       std::vector< vtkSmartPointer< vtkImageActor > >       ImageActors;
128       bool Interpolate;
129
130       // Other associated actors
131       typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor;
132       typedef std::vector< TAssociatedActor >       TAssociatedActors;
133       TAssociatedActors AssociatedActors;
134
135       // Unique objects
136       vtkSmartPointer< vtkPolyData >       Cursor;
137       vtkSmartPointer< vtkPolyDataMapper > CursorMapper;
138       vtkSmartPointer< vtkActor >          CursorActor;
139       vtkSmartPointer< vtkPlane >          PlaneFunction;
140       vtkSmartPointer< vtkPolyData >       PlaneSource;
141       vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
142       char                                 TextBuffer[ 1024 ];
143       vtkSmartPointer< vtkTextActor >      TextActor;
144       vtkSmartPointer< vtkActor >          PlaneActor;
145     };
146
147   } // ecapseman
148
149 } // ecapseman
150
151 #endif //  __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
152
153 // eof - $RCSfile$