]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageSliceActors.h
37aeac402cef79579d23b0bbab961fbb209b162c
[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 <vtkActor.h>
7 #include <vtkImageActor.h>
8 #include <vtkImageSliceMapper.h>
9 #include <vtkPolyData.h>
10 #include <vtkPolyDataMapper.h>
11 #include <vtkPropCollection.h>
12 #include <vtkSmartPointer.h>
13 #include <vtkTextActor.h>
14
15 // -------------------------------------------------------------------------
16 #define cpPlugins_ImageSliceActors( name, type )        \
17   inline type* Get##name##Actor( ) const                \
18   {                                                     \
19     return(                                             \
20       dynamic_cast< type* >(                            \
21         const_cast< Self* >( this )->                   \
22         GetItemAsObject( this->name##ActorIndex )       \
23         )                                               \
24       );                                                \
25   }
26
27 // -------------------------------------------------------------------------
28 class vtkAlgorithmOutput;
29 class vtkImageData;
30
31 // -------------------------------------------------------------------------
32 namespace cpExtensions
33 {
34   namespace Visualization
35   {
36     /**
37      */
38     class cpExtensions_EXPORT ImageSliceActors
39       : public vtkPropCollection
40     {
41     public:
42       typedef ImageSliceActors Self;
43
44     public:
45       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
46
47       cpPlugins_ImageSliceActors( Image, vtkImageActor );
48       cpPlugins_ImageSliceActors( Text, vtkTextActor );
49       cpPlugins_ImageSliceActors( Plane, vtkActor );
50
51     public:
52       // Creation
53       static ImageSliceActors* New( );
54
55       void SetInputConnection( vtkAlgorithmOutput* aout, int axis );
56       void SetInputData( vtkImageData* data, int axis );
57
58       double* GetDisplayBounds( ) const;
59       void GetDisplayBounds( double bounds[ 6 ] ) const;
60
61       int GetAxis( ) const;
62       int GetSliceNumber( ) const;
63       int GetSliceNumberMinValue( ) const;
64       int GetSliceNumberMaxValue( ) const;
65       void SetSliceNumber( const int& slice );
66       void UpdateText( );
67
68     protected:
69       ImageSliceActors( );
70       virtual ~ImageSliceActors( );
71
72     private:
73       // Purposely not implemented
74       ImageSliceActors( const Self& );
75       Self& operator=( const Self& );
76
77     protected:
78       vtkSmartPointer< vtkImageSliceMapper > SliceMapper;
79       vtkSmartPointer< vtkPolyData >         PlaneSource;
80       vtkSmartPointer< vtkPolyDataMapper >   PlaneMapper;
81       char                                   TextBuffer[ 1024 ];
82
83       vtkSmartPointer< vtkImageActor > ImageActor;
84       vtkSmartPointer< vtkTextActor >  TextActor;
85       vtkSmartPointer< vtkActor >      PlaneActor;
86
87       unsigned int ImageActorIndex;
88       unsigned int TextActorIndex;
89       unsigned int PlaneActorIndex;
90     };
91
92   } // ecapseman
93
94 } // ecapseman
95
96 #endif //  __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__
97
98 // eof - $RCSfile$