]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/BaseWidget.cxx
7bcca5266366eb932c777aaae49cbd42d2726034
[cpPlugins.git] / lib / cpPlugins / BaseWidget.cxx
1 #include <cpPlugins/BaseWidget.h>
2
3 #ifdef cpPlugins_QT4
4
5 // -------------------------------------------------------------------------
6 itk::ModifiedTimeType cpPlugins::BaseWidget::
7 GetMTime( ) const
8 {
9   // Let time only be managed by itk -> synch issues when data is
10   // represented by vtk
11   return( this->itk::Object::GetMTime( ) );
12 }
13
14 // -------------------------------------------------------------------------
15 const cpPlugins::BaseWidget::TMPRWidget* cpPlugins::BaseWidget::
16 GetMPRViewer( ) const
17 {
18   return( this->m_MPRViewer );
19 }
20
21 // -------------------------------------------------------------------------
22 const vtkRenderWindowInteractor* cpPlugins::BaseWidget::
23 GetSingleInteractor( ) const
24 {
25   return( this->m_SingleInteractor );
26 }
27
28 // -------------------------------------------------------------------------
29 void cpPlugins::BaseWidget::
30 SetMPRViewer( cpPlugins::BaseWidget::TMPRWidget* v )
31 {
32   if( this->m_MPRViewer != v )
33   {
34     this->m_MPRViewer = v;
35     this->Modified( );
36
37   } // fi
38 }
39
40 // -------------------------------------------------------------------------
41 void cpPlugins::BaseWidget::
42 SetSingleInteractor( vtkRenderWindowInteractor* i )
43 {
44   if( this->m_SingleInteractor != i )
45   {
46     this->m_SingleInteractor = i;
47     this->Modified( );
48
49   } // fi
50 }
51
52 // -------------------------------------------------------------------------
53 bool cpPlugins::BaseWidget::
54 IsInteractive( )
55 {
56   return( true );
57 }
58
59 // -------------------------------------------------------------------------
60 void cpPlugins::BaseWidget::
61 SetInteractionObjects( const std::vector< void* >& objs )
62 {
63   if( objs.size( ) > 0 )
64   {
65     vtkRenderWindowInteractor* rwi =
66       reinterpret_cast< vtkRenderWindowInteractor* >( objs[ 0 ] );
67     this->SetSingleInteractor( rwi );
68   }
69   if( objs.size( ) > 1 )
70   {
71     TMPRWidget* wdg = reinterpret_cast< TMPRWidget* >( objs[ 1 ] );
72     this->SetMPRViewer( wdg );
73
74   } // fi
75 }
76
77 // -------------------------------------------------------------------------
78 cpPlugins::BaseWidget::
79 BaseWidget( )
80   : Superclass( ),
81     m_MPRViewer( NULL ),
82     m_SingleInteractor( NULL )
83 {
84   this->m_Parameters.ConfigureAsString( "Text" );
85   this->m_Parameters.SetString( "Text", "" );
86 }
87
88 // -------------------------------------------------------------------------
89 cpPlugins::BaseWidget::
90 ~BaseWidget( )
91 {
92   // Warning: Qt's smartpointers require this to avoid segfaults
93   this->m_MPRViewer = NULL;
94   this->m_SingleInteractor = NULL;
95 }
96
97 #endif // cpPlugins_QT4
98
99 // eof - $RCSfile$