]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.cxx
ae4a1d3e4b2cf793c8eeab4ac1255691dbb589fd
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
1 #include <cpPlugins/Interface/ProcessObject.h>
2
3 #ifdef cpPlugins_Interface_QT4
4 #include <cpPlugins/Interface/ParametersQtDialog.h>
5 #endif // cpPlugins_Interface_QT4
6
7 // -------------------------------------------------------------------------
8 void cpPlugins::Interface::ProcessObject::
9 Modified( ) const
10 {
11   if( this->m_ITKObject.IsNotNull( ) )
12     this->m_ITKObject->Modified( );
13   if( this->m_VTKObject.GetPointer( ) != NULL )
14     this->m_VTKObject->Modified( );
15   this->Superclass::Modified( );
16 }
17
18 // -------------------------------------------------------------------------
19 cpPlugins::Interface::ProcessObject::
20 TParameters* cpPlugins::Interface::ProcessObject::
21 GetParameters( )
22 {
23   return( this->m_Parameters.GetPointer( ) );
24 }
25
26 // -------------------------------------------------------------------------
27 const cpPlugins::Interface::ProcessObject::
28 TParameters* cpPlugins::Interface::ProcessObject::
29 GetParameters( ) const
30 {
31   return( this->m_Parameters.GetPointer( ) );
32 }
33
34 // -------------------------------------------------------------------------
35 unsigned int cpPlugins::Interface::ProcessObject::
36 GetNumberOfInputs( ) const
37 {
38   return( this->m_Inputs.size( ) );
39 }
40
41 // -------------------------------------------------------------------------
42 unsigned int cpPlugins::Interface::ProcessObject::
43 GetNumberOfOutputs( ) const
44 {
45   return( this->m_Outputs.size( ) );
46 }
47
48 // -------------------------------------------------------------------------
49 void cpPlugins::Interface::ProcessObject::
50 SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
51 {
52   _TDataContainer::iterator i = this->m_Inputs.find( id );
53   if( i != this->m_Inputs.end( ) )
54   {
55     i->second = dobj;
56     this->Modified( );
57
58   } // fi
59 }
60
61 // -------------------------------------------------------------------------
62 std::string cpPlugins::Interface::ProcessObject::
63 Update( )
64 {
65   std::string r = "";
66
67   // Force upstream updates
68   _TDataContainer::iterator i = this->m_Inputs.begin( );
69   for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
70   {
71     Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
72     if( src != NULL )
73       r = src->Update( );
74
75   } // rof
76
77   // Current update
78   if( r == "" )
79     r = this->_GenerateData( );
80
81   // Return error description, if any
82   return( r );
83 }
84
85 // -------------------------------------------------------------------------
86 void cpPlugins::Interface::ProcessObject::
87 DisconnectOutputs( )
88 {
89   _TDataContainer::iterator i = this->m_Outputs.begin( );
90   for( ; i != this->m_Outputs.end( ); ++i )
91     if( i->second.IsNotNull( ) )
92       i->second->DisconnectPipeline( );
93 }
94
95 // -------------------------------------------------------------------------
96 bool cpPlugins::Interface::ProcessObject::
97 ExecConfigurationDialog( QWidget* parent )
98 {
99   bool r = false;
100
101 #ifdef cpPlugins_Interface_QT4
102
103   r = cpPlugins::Interface::ParametersQtDialog(
104     this->m_Parameters,
105     this->GetClassName( ) + std::string( " basic configuration" ),
106     parent
107     );
108   /*
109     if( r )
110     // TODO: !!! this->m_Parameters = parameters;
111     */
112
113 #endif // cpPlugins_Interface_QT4
114
115   return( r );
116 }
117
118 // -------------------------------------------------------------------------
119 cpPlugins::Interface::ProcessObject::
120 ProcessObject( )
121   : Superclass( ),
122     m_ITKObject( NULL ),
123     m_VTKObject( NULL )
124 {
125   this->m_Parameters = TParameters::New( );
126 }
127
128 // -------------------------------------------------------------------------
129 cpPlugins::Interface::ProcessObject::
130 ~ProcessObject( )
131 {
132 }
133
134 // -------------------------------------------------------------------------
135 void cpPlugins::Interface::ProcessObject::
136 _AddInput( const std::string& name )
137 {
138   this->m_Inputs[ name ] = NULL;
139   this->Modified( );
140 }
141
142 // eof - $RCSfile$