]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageSliceActors.h
1a5bf49c998b9383fb74f0506b86148192e579c5
[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 <vtkActor.h>
10 #include <vtkImageActor.h>
11 #include <vtkImageSliceMapper.h>
12 #include <vtkPlane.h>
13 #include <vtkPolyData.h>
14 #include <vtkPolyDataMapper.h>
15 #include <vtkPropCollection.h>
16 #include <vtkSmartPointer.h>
17 #include <vtkTextActor.h>
18
19 // -------------------------------------------------------------------------
20 class vtkAlgorithmOutput;
21 class vtkImageData;
22
23 // -------------------------------------------------------------------------
24 namespace cpExtensions
25 {
26   namespace Visualization
27   {
28     /**
29      */
30     class cpExtensions_EXPORT ImageSliceActors
31       : public vtkPropCollection
32     {
33     public:
34       typedef ImageSliceActors Self;
35
36       typedef void ( *TUpdateCommand )( void* );
37
38     public:
39       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
40
41     public:
42       // Creation
43       static ImageSliceActors* New( );
44
45       void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 0 );
46       void AddInputData( vtkImageData* data, int axis = 0 );
47       void Clear( );
48
49       unsigned int GetNumberOfImageActors( ) const;
50       vtkImageActor* GetImageActor( unsigned int id );
51       const vtkImageActor* GetImageActor( unsigned int id ) const;
52       vtkTextActor* GetTextActor( );
53       const vtkTextActor* GetTextActor( ) const;
54       vtkActor* GetPlaneActor( );
55       const vtkActor* GetPlaneActor( ) const;
56       vtkPlane* GetPlaneFunction( );
57       const vtkPlane* GetPlaneFunction( ) const;
58
59       void AddActor( vtkAlgorithm* algorithm, vtkActor* actor );
60       void AddActor( vtkActor* actor );
61
62       void SetInterpolate( bool v );
63       void InterpolateOn( );
64       void InterpolateOff( );
65
66       double* GetDisplayBounds( ) const;
67       void GetDisplayBounds( double bounds[ 6 ] ) const;
68
69       int GetAxis( ) const;
70       int GetSliceNumber( ) const;
71       int GetSliceNumberMinValue( ) const;
72       int GetSliceNumberMaxValue( ) const;
73       void SetSliceNumber( const int& slice );
74       void UpdateText( );
75       void UpdateText( const double& w, const double& l );
76
77       void SetUpdateCommand( TUpdateCommand cmd, void* data )
78         {
79           this->m_UpdateCommand = cmd;
80           this->m_UpdateData = data;
81         }
82
83     protected:
84       ImageSliceActors( );
85       virtual ~ImageSliceActors( );
86
87       void _ConfigureNewInput( int axis );
88
89     private:
90       // Purposely not implemented
91       ImageSliceActors( const Self& );
92       Self& operator=( const Self& );
93
94     protected:
95       // Multiple actors
96       std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
97       std::vector< vtkSmartPointer< vtkImageActor > >       ImageActors;
98
99       typedef
100       std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > >
101       TActorPair;
102       std::vector< TActorPair > OtherActors;
103       bool Interpolate;
104
105       // Unique objects
106       vtkSmartPointer< vtkPlane >          PlaneFunction;
107       vtkSmartPointer< vtkPolyData >       PlaneSource;
108       vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
109       char                                 TextBuffer[ 1024 ];
110       vtkSmartPointer< vtkTextActor >      TextActor;
111       vtkSmartPointer< vtkActor >          PlaneActor;
112
113
114       TUpdateCommand m_UpdateCommand;
115       void* m_UpdateData;
116     };
117
118   } // ecapseman
119
120 } // ecapseman
121
122 #endif //  __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
123
124 // eof - $RCSfile$