]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/BaseObjects/Object.cxx
...
[cpPlugins.git] / lib / cpPlugins / BaseObjects / Object.cxx
1 #include <cpPlugins/BaseObjects/Object.h>
2
3 #include <itkObject.h>
4 #include <vtkObject.h>
5
6 // -------------------------------------------------------------------------
7 const float& cpPlugins::BaseObjects::Object::
8 GetViewX( ) const
9 {
10   return( this->m_ViewX );
11 }
12
13 // -------------------------------------------------------------------------
14 const float& cpPlugins::BaseObjects::Object::
15 GetViewY( ) const
16 {
17   return( this->m_ViewY );
18 }
19
20 // -------------------------------------------------------------------------
21 void cpPlugins::BaseObjects::Object::
22 SetViewCoords( float x, float y )
23 {
24   this->m_ViewX = x;
25   this->m_ViewY = y;
26   // WARNING: do not call "this->Modified( )" -> It could lead to
27   //          re-execution of all pipeline
28 }
29
30 // -------------------------------------------------------------------------
31 void cpPlugins::BaseObjects::Object::
32 Modified( ) const
33 {
34   const itk::Object* i = this->GetITK< itk::Object >( );
35   vtkObject* v = const_cast< vtkObject* >( this->GetVTK< vtkObject >( ) );
36   if( i != NULL ) i->Modified( );
37   if( v != NULL ) v->Modified( );
38   this->Superclass::Modified( );
39 }
40
41 // -------------------------------------------------------------------------
42 itk::ModifiedTimeType cpPlugins::BaseObjects::Object::
43 GetMTime( ) const
44 {
45   itk::ModifiedTimeType lt = this->Superclass::GetMTime( );
46   const itk::Object* i = this->GetITK< itk::Object >( );
47   vtkObject* v = const_cast< vtkObject* >( this->GetVTK< vtkObject >( ) );
48
49   itk::ModifiedTimeType rt;
50   if( i != NULL && v == NULL )
51     rt = i->GetMTime( );
52   else if( i == NULL && v != NULL )
53     rt = v->GetMTime( );
54   else if( i != NULL && v != NULL )
55   {
56     auto iTime = i->GetMTime( );
57     auto vTime = v->GetMTime( );
58     rt = ( iTime < vTime )? vTime: iTime;
59
60   } // fi
61   return( ( lt < rt )? rt: lt );
62 }
63
64 // -------------------------------------------------------------------------
65 void cpPlugins::BaseObjects::Object::
66 SetITK( itk::LightObject* o )
67 {
68   if( this->m_ITK.GetPointer( ) != o )
69   {
70     this->m_ITK = o;
71     this->Modified( );
72
73   } // fi
74 }
75
76 // -------------------------------------------------------------------------
77 void cpPlugins::BaseObjects::Object::
78 SetVTK( vtkObjectBase* o )
79 {
80   if( this->m_VTK.GetPointer( ) != o )
81   {
82     this->m_VTK = o;
83     this->Modified( );
84
85   } // fi
86 }
87
88 // -------------------------------------------------------------------------
89 cpPlugins::BaseObjects::Object::
90 Object( )
91   : m_ITK( NULL ),
92     m_VTK( NULL ),
93     m_ViewX( float( 0 ) ),
94     m_ViewY( float( 0 ) )
95 {
96 }
97
98 // -------------------------------------------------------------------------
99 cpPlugins::BaseObjects::Object::
100 ~Object( )
101 {
102 }
103
104 // eof - $RCSfile$