]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Pipeline/Object.h
yet another refactoring
[cpPlugins.git] / lib / cpPlugins / Pipeline / Object.h
1 #ifndef __cpPlugins__Pipeline__Object__h__
2 #define __cpPlugins__Pipeline__Object__h__
3
4 #include <cpPlugins/Config.h>
5
6 #include <itkLightObject.h>
7 #include <itkObject.h>
8 #include <itkObjectFactory.h>
9 #include <vtkSmartPointer.h>
10 #include <vtkObjectBase.h>
11
12 namespace cpPlugins
13 {
14   namespace Pipeline
15   {
16     /**
17      */
18     class cpPlugins_EXPORT Object
19       : public itk::Object
20     {
21     public:
22       typedef Object                          Self;
23       typedef itk::Object                     Superclass;
24       typedef itk::SmartPointer< Self >       Pointer;
25       typedef itk::SmartPointer< const Self > ConstPointer;
26
27     public:
28       itkTypeMacro( Object, itk::Object );
29
30     public:
31       virtual const char* GetClassName( ) const = 0;
32       virtual const char* GetClassCategory( ) const = 0;
33
34       const float& GetViewX( ) const;
35       const float& GetViewY( ) const;
36       void SetViewCoords( float x, float y );
37
38       virtual void Modified( ) const cpPlugins_OVERRIDE;
39
40       virtual void SetITK( itk::LightObject* o );
41       virtual void SetVTK( vtkObjectBase* o );
42
43       template< class _TType = itk::LightObject >
44       inline _TType* GetITK( )
45         {
46           if( this->m_ITK.GetPointer( ) == NULL )
47             this->_UpdateITK( );
48           return( dynamic_cast< _TType* >( this->m_ITK.GetPointer( ) ) );
49         }
50
51       template< class _TType = itk::LightObject >
52       inline const _TType* GetITK( ) const
53         {
54           if( this->m_ITK.GetPointer( ) == NULL )
55             this->_UpdateITK( );
56           return(
57             dynamic_cast< const _TType* >( this->m_ITK.GetPointer( ) )
58             );
59         }
60
61       template< class _TType = vtkObjectBase >
62       inline _TType* GetVTK( )
63         {
64           if( this->m_VTK.GetPointer( ) == NULL )
65             this->_UpdateVTK( );
66           return( dynamic_cast< _TType* >( this->m_VTK.GetPointer( ) ) );
67         }
68
69       template< class _TType = vtkObjectBase >
70       inline const _TType* GetVTK( ) const
71         {
72           if( this->m_VTK.GetPointer( ) == NULL )
73             this->_UpdateVTK( );
74           return(
75             dynamic_cast< const _TType* >( this->m_VTK.GetPointer( ) )
76             );
77         }
78
79     protected:
80       Object( );
81       virtual ~Object( );
82
83       virtual void _UpdateITK( ) const;
84       virtual void _UpdateVTK( ) const;
85
86     private:
87       // Purposely not implemented
88       Object( const Self& );
89       Self& operator=( const Self& );
90
91     protected:
92       itk::LightObject::Pointer        m_ITK;
93       vtkSmartPointer< vtkObjectBase > m_VTK;
94
95       float m_ViewX;
96       float m_ViewY;
97     };
98
99   } // ecapseman
100
101 } // ecapseman
102
103 #endif // __cpPlugins__Pipeline__Object__h__
104
105 // eof - $RCSfile$