]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/BaseObjects/Object.cxx
89d7fe6a59c4c5a4a60d7ceb44a08c398dc56c8f
[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 a
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   const itk::Object* i = this->GetITK< itk::Object >( );
46   vtkObject* v = const_cast< vtkObject* >( this->GetVTK< vtkObject >( ) );
47   if( i != NULL && v == NULL )
48     return( i->GetMTime( ) );
49   else if( i == NULL && v != NULL )
50     return( v->GetMTime( ) );
51   else if( i != NULL && v != NULL )
52   {
53     auto iTime = i->GetMTime( );
54     auto vTime = i->GetMTime( );
55     return( itk::ModifiedTimeType( ( iTime > vTime )? iTime: vTime ) );
56   }
57   else
58     return( this->Superclass::GetMTime( ) );
59 }
60
61 // -------------------------------------------------------------------------
62 void cpPlugins::BaseObjects::Object::
63 SetITK( itk::LightObject* o )
64 {
65   if( this->m_ITK.GetPointer( ) != o )
66   {
67     this->m_ITK = o;
68     this->Modified( );
69
70   } // fi
71 }
72
73 // -------------------------------------------------------------------------
74 void cpPlugins::BaseObjects::Object::
75 SetVTK( vtkObjectBase* o )
76 {
77   if( this->m_VTK.GetPointer( ) != o )
78   {
79     this->m_VTK = o;
80     this->Modified( );
81
82   } // fi
83 }
84
85 // -------------------------------------------------------------------------
86 cpPlugins::BaseObjects::Object::
87 Object( )
88   : m_ITK( NULL ),
89     m_VTK( NULL ),
90     m_ViewX( float( 0 ) ),
91     m_ViewY( float( 0 ) )
92 {
93 }
94
95 // -------------------------------------------------------------------------
96 cpPlugins::BaseObjects::Object::
97 ~Object( )
98 {
99 }
100
101 // eof - $RCSfile$