]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/BaseObjects/Object.h
...
[cpPlugins.git] / lib / cpPlugins / BaseObjects / Object.h
1 #ifndef __cpPlugins__BaseObjects__Object__h__
2 #define __cpPlugins__BaseObjects__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 BaseObjects
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       virtual itk::ModifiedTimeType GetMTime( ) const cpPlugins_OVERRIDE;
40
41       virtual void SetITK( itk::LightObject* o );
42       virtual void SetVTK( vtkObjectBase* o );
43
44       template< class _TType = itk::LightObject >
45       inline _TType* GetITK( )
46         { return( dynamic_cast< _TType* >( this->m_ITK.GetPointer( ) ) ); }
47
48       template< class _TType = itk::LightObject >
49       inline const _TType* GetITK( ) const
50         {
51           return(
52             dynamic_cast< const _TType* >( this->m_ITK.GetPointer( ) )
53             );
54         }
55
56       template< class _TType = vtkObjectBase >
57       inline _TType* GetVTK( )
58         { return( dynamic_cast< _TType* >( this->m_VTK.GetPointer( ) ) ); }
59
60       template< class _TType = vtkObjectBase >
61       inline const _TType* GetVTK( ) const
62         {
63           return(
64             dynamic_cast< const _TType* >( this->m_VTK.GetPointer( ) )
65             );
66         }
67
68     protected:
69       Object( );
70       virtual ~Object( );
71
72     private:
73       // Purposely not implemented
74       Object( const Self& );
75       Self& operator=( const Self& );
76
77     protected:
78       itk::LightObject::Pointer        m_ITK;
79       vtkSmartPointer< vtkObjectBase > m_VTK;
80
81       float m_ViewX;
82       float m_ViewY;
83     };
84
85   } // ecapseman
86
87 } // ecapseman
88
89 #endif // __cpPlugins__BaseObjects__Object__h__
90
91 // eof - $RCSfile$