]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Object.cxx
First dump for version 0.1.0
[cpPlugins.git] / lib / cpPlugins / Object.cxx
1 #include <cpPlugins/Object.h>
2
3 #include <itkObject.h>
4 #include <vtkObject.h>
5
6 // -------------------------------------------------------------------------
7 const float& cpPlugins::Object::
8 GetViewX( ) const
9 {
10   return( this->m_ViewX );
11 }
12
13 // -------------------------------------------------------------------------
14 const float& cpPlugins::Object::
15 GetViewY( ) const
16 {
17   return( this->m_ViewY );
18 }
19
20 // -------------------------------------------------------------------------
21 void cpPlugins::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 #ifdef cpPlugins_QT4
31 // -------------------------------------------------------------------------
32 void cpPlugins::Object::
33 SetViewCoords( const QPointF& coords )
34 {
35   this->SetViewCoords( coords.x( ), coords.y( ) );
36 }
37
38 // -------------------------------------------------------------------------
39 QPointF cpPlugins::Object::
40 GetViewCoords( ) const
41 {
42   return( QPointF( this->m_ViewX, this->m_ViewY ) );
43 }
44 #endif // cpPlugins_QT4
45
46 // -------------------------------------------------------------------------
47 void cpPlugins::Object::
48 Modified( ) const
49 {
50   const itk::Object* i = this->GetITK< itk::Object >( );
51   vtkObject* v = const_cast< vtkObject* >( this->GetVTK< vtkObject >( ) );
52   if( i != NULL ) i->Modified( );
53   if( v != NULL ) v->Modified( );
54 }
55
56 // -------------------------------------------------------------------------
57 itk::ModifiedTimeType cpPlugins::Object::
58 GetMTime( ) const
59 {
60   const itk::Object* i = this->GetITK< itk::Object >( );
61   vtkObject* v = const_cast< vtkObject* >( this->GetVTK< vtkObject >( ) );
62   if( i != NULL && v == NULL )
63     return( i->GetMTime( ) );
64   else if( i == NULL && v != NULL )
65     return( v->GetMTime( ) );
66   else if( i != NULL && v != NULL )
67   {
68     auto iTime = i->GetMTime( );
69     auto vTime = i->GetMTime( );
70     return( itk::ModifiedTimeType( ( iTime < vTime )? iTime: vTime ) );
71   }
72   else
73     return( this->Superclass::GetMTime( ) );
74 }
75
76 // -------------------------------------------------------------------------
77 void cpPlugins::Object::
78 SetITK( itk::LightObject* o )
79 {
80   if( this->m_ITKObject.GetPointer( ) != o )
81   {
82     this->m_ITKObject = o;
83     this->Modified( );
84
85   } // fi
86 }
87
88 // -------------------------------------------------------------------------
89 void cpPlugins::Object::
90 SetVTK( vtkObjectBase* o )
91 {
92   if( this->m_VTKObject.GetPointer( ) != o )
93   {
94     this->m_VTKObject = o;
95     this->Modified( );
96
97   } // fi
98 }
99
100 // -------------------------------------------------------------------------
101 cpPlugins::Object::
102 Object( )
103   : m_ITKObject( NULL ),
104     m_VTKObject( NULL ),
105     m_ViewX( float( 0 ) ),
106     m_ViewY( float( 0 ) )
107 {
108 }
109
110 // -------------------------------------------------------------------------
111 cpPlugins::Object::
112 ~Object( )
113 {
114 }
115
116 // eof - $RCSfile$