]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/MPRObjects.h
c800fc1ce626b11602c066f54a10b7ed363341f3
[cpPlugins.git] / lib / cpExtensions / Visualization / MPRObjects.h
1 #ifndef __CPEXTENSIONS__VISUALIZATION__MPROBJECTS__H__
2 #define __CPEXTENSIONS__VISUALIZATION__MPROBJECTS__H__
3
4 #include <cpExtensions/cpExtensions_Export.h>
5 #include <cpExtensions/Visualization/MPRActors.h>
6
7 #include <vtkObject.h>
8 #include <vtkRenderer.h>
9 #include <vtkRenderWindow.h>
10
11 // -------------------------------------------------------------------------
12 #define cpExtensions_MPRObjects_Renderer( DIR )                         \
13   inline vtkRenderer* Get##DIR##Renderer( )                             \
14   { return( this->m_Renderers[ Self::MPRDirections_##DIR ] ); }         \
15   inline const vtkRenderer* Get##DIR##Renderer( ) const                 \
16   { return( this->m_Renderers[ Self::MPRDirections_##DIR ] ); }
17
18 namespace cpExtensions
19 {
20   namespace Visualization
21   {
22     /**
23      */
24     class cpExtensions_EXPORT MPRObjects
25       : public vtkObject
26     {
27     public:
28       typedef MPRObjects Self;
29
30       typedef MPRActors::TStyle                   TStyle;
31       typedef MPRActors::TMouseCommand            TMouseCommand;
32       typedef MPRActors::TMouseWheelCommand       TMouseWheelCommand;
33       typedef MPRActors::TKeyCommand              TKeyCommand;
34       typedef MPRActors::TVoidCommand             TVoidCommand;
35       typedef MPRActors::TMouseMoveCommand        TMouseMoveCommand;
36       typedef MPRActors::TMouseClickCommand       TMouseClickCommand;
37       typedef MPRActors::TMouseDoubleClickCommand TMouseDoubleClickCommand;
38       typedef MPRActors::TExposeCommand           TExposeCommand;
39       typedef MPRActors::TConfigureCommand        TConfigureCommand;
40       typedef MPRActors::TEnterCommand            TEnterCommand;
41       typedef MPRActors::TLeaveCommand            TLeaveCommand;
42
43       enum MPRDirections
44       {
45         MPRDirections_X = 0,
46         MPRDirections_Y = 1,
47         MPRDirections_Z = 2,
48         MPRDirections_W = 3
49       };
50
51     public:
52       vtkTypeMacro( MPRObjects, vtkObject );
53
54       cpExtensions_MPRObjects_Renderer( X );
55       cpExtensions_MPRObjects_Renderer( Y );
56       cpExtensions_MPRObjects_Renderer( Z );
57       cpExtensions_MPRObjects_Renderer( W );
58
59     public:
60       // Creation
61       static MPRObjects* New( );
62
63       // Association
64       void SetRenderWindows(
65         vtkRenderWindow* x, vtkRenderWindow* y,
66         vtkRenderWindow* z, vtkRenderWindow* w
67         );
68
69       void SetInputConnection( vtkAlgorithmOutput* aout );
70       void SetInputImage( vtkImageData* data );
71       int AddBinaryConnection(
72         vtkAlgorithmOutput* aout,
73         const double& r, const double& g, const double& b
74         );
75       int AddBinaryImage(
76         vtkImageData* data,
77         const double& r, const double& g, const double& b
78         );
79       void Show( );
80       void Hide( );
81       void Clear( );
82
83       vtkImageData* GetInputImage( );
84       const vtkImageData* GetInputImage( ) const;
85       unsigned int GetNumberOfImages( ) const;
86
87       void SetInterpolate( bool v );
88       void InterpolateOn( );
89       void InterpolateOff( );
90
91       double GetMinWindow( ) const;
92       double GetMaxWindow( ) const;
93       double GetMinLevel( ) const;
94       double GetMaxLevel( ) const;
95       double GetWindow( ) const;
96       double GetLevel( ) const;
97       void SetWindow( double w );
98       void SetLevel( double l );
99       void SetWindowLevel( double w, double l );
100       void ResetWindowLevel( );
101
102       int GetSliceNumber( const int& axis ) const;
103       int GetSliceNumberMinValue( const int& axis ) const;
104       int GetSliceNumberMaxValue( const int& axis ) const;
105       void SetSliceNumber( const int& axis, const int& slice );
106       void SetSlice( const int& axis, double* pos );
107
108       void Render( const double& t );
109       void Render( const int& axis, const double& t );
110       void ResetCamera( const int& axis );
111       void ResetCameras( );
112
113     protected:
114       MPRObjects( );
115       virtual ~MPRObjects( );
116
117     private:
118       // Purposely not implemented
119       MPRObjects( const Self& );
120       Self& operator=( const Self& );
121
122     protected:
123       // Inputs
124       vtkSmartPointer< vtkRenderWindow > m_Windows[ 4 ];
125
126       // Internal pipelines
127       vtkSmartPointer< MPRActors >   m_MPRActors;
128       vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ];
129     };
130
131   } // ecapseman
132
133 } // ecapseman
134
135 #endif //  __CPEXTENSIONS__VISUALIZATION__MPROBJECTS__H__
136
137 // eof - $RCSfile$