]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageSliceActors.h
8889b2f08d5986decaea77dbeef024e03c3cdc8b
[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     public:
37       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
38
39     public:
40       // Creation
41       static ImageSliceActors* New( );
42
43       void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 0 );
44       void AddInputData( vtkImageData* data, int axis = 0 );
45       void Clear( );
46
47       unsigned int GetNumberOfImageActors( ) const;
48       vtkImageActor* GetImageActor( unsigned int id );
49       const vtkImageActor* GetImageActor( unsigned int id ) const;
50       vtkTextActor* GetTextActor( );
51       const vtkTextActor* GetTextActor( ) const;
52       vtkActor* GetPlaneActor( );
53       const vtkActor* GetPlaneActor( ) const;
54       vtkPlane* GetPlaneFunction( );
55       const vtkPlane* GetPlaneFunction( ) const;
56
57       void AddActor( vtkAlgorithm* algorithm, vtkActor* actor );
58       void AddActor( vtkActor* actor );
59
60       void SetInterpolate( bool v );
61       void InterpolateOn( );
62       void InterpolateOff( );
63
64       double* GetDisplayBounds( ) const;
65       void GetDisplayBounds( double bounds[ 6 ] ) const;
66
67       int GetAxis( ) const;
68       int GetSliceNumber( ) const;
69       int GetSliceNumberMinValue( ) const;
70       int GetSliceNumberMaxValue( ) const;
71       void SetSliceNumber( const int& slice );
72       void UpdateText( );
73       void UpdateText( const double& w, const double& l );
74
75     protected:
76       ImageSliceActors( );
77       virtual ~ImageSliceActors( );
78
79       void _ConfigureNewInput( int axis );
80
81     private:
82       // Purposely not implemented
83       ImageSliceActors( const Self& );
84       Self& operator=( const Self& );
85
86     protected:
87       // Multiple actors
88       std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
89       std::vector< vtkSmartPointer< vtkImageActor > >       ImageActors;
90
91       typedef
92       std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > >
93       TActorPair;
94       std::vector< TActorPair > OtherActors;
95       bool Interpolate;
96
97       // Unique objects
98       vtkSmartPointer< vtkPlane >          PlaneFunction;
99       vtkSmartPointer< vtkPolyData >       PlaneSource;
100       vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
101       char                                 TextBuffer[ 1024 ];
102       vtkSmartPointer< vtkTextActor >      TextActor;
103       vtkSmartPointer< vtkActor >          PlaneActor;
104     };
105
106   } // ecapseman
107
108 } // ecapseman
109
110 #endif //  __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
111
112 // eof - $RCSfile$