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