]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.cxx
f639d7f59e3ea2b5686950a48151e98b0d05ef73
[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 std::vector< std::string > cpPlugins::Interface::ProcessObject::
50 GetInputsNames( ) const
51 {
52   std::vector< std::string > r;
53   auto dIt = this->m_Inputs.begin( );
54   for( ; dIt != this->m_Inputs.end( ); ++dIt )
55     r.push_back( dIt->first );
56   return( r );
57 }
58
59 // -------------------------------------------------------------------------
60 std::vector< std::string > cpPlugins::Interface::ProcessObject::
61 GetOutputsNames( ) const
62 {
63   std::vector< std::string > r;
64   auto dIt = this->m_Outputs.begin( );
65   for( ; dIt != this->m_Outputs.end( ); ++dIt )
66     r.push_back( dIt->first );
67   return( r );
68 }
69
70 // -------------------------------------------------------------------------
71 void cpPlugins::Interface::ProcessObject::
72 SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
73 {
74   _TDataContainer::iterator i = this->m_Inputs.find( id );
75   if( i != this->m_Inputs.end( ) )
76   {
77     i->second = dobj;
78     this->Modified( );
79
80   } // fi
81 }
82
83 // -------------------------------------------------------------------------
84 std::string cpPlugins::Interface::ProcessObject::
85 Update( )
86 {
87   std::string r = "";
88
89   // Force upstream updates
90   _TDataContainer::iterator i = this->m_Inputs.begin( );
91   for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
92   {
93     Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
94     if( src != NULL )
95       r = src->Update( );
96
97   } // rof
98
99   // Current update
100   if( r == "" )
101     r = this->_GenerateData( );
102
103   // Return error description, if any
104   return( r );
105 }
106
107 // -------------------------------------------------------------------------
108 void cpPlugins::Interface::ProcessObject::
109 DisconnectOutputs( )
110 {
111   _TDataContainer::iterator i = this->m_Outputs.begin( );
112   for( ; i != this->m_Outputs.end( ); ++i )
113     if( i->second.IsNotNull( ) )
114       i->second->DisconnectPipeline( );
115 }
116
117 // -------------------------------------------------------------------------
118 bool cpPlugins::Interface::ProcessObject::
119 ExecConfigurationDialog( QWidget* parent )
120 {
121   bool r = false;
122
123 #ifdef cpPlugins_Interface_QT4
124
125   if( this->m_ParametersDialog == NULL )
126   {
127     this->m_ParametersDialog = new ParametersQtDialog( parent );
128     this->m_ParametersDialog->setTitle(
129       this->GetClassName( ) + std::string( " basic configuration" )
130       );
131     this->m_ParametersDialog->setParameters( this->m_Parameters );
132
133   } // fi
134
135   if( !( this->m_ParametersDialog->IsModal( ) ) )
136   {
137     this->m_ParametersDialog->show( );
138     r = true;
139   }
140   else
141     r = ( this->m_ParametersDialog->exec( ) == 1 );
142
143   /*
144     r = cpPlugins::Interface::ParametersQtDialog(
145     this->m_Parameters,
146     this->GetClassName( ) + std::string( " basic configuration" ),
147     parent
148     );
149     if( r )
150   */
151
152 #endif // cpPlugins_Interface_QT4
153
154   return( r );
155 }
156
157 // -------------------------------------------------------------------------
158 cpPlugins::Interface::ProcessObject::
159 ProcessObject( )
160   : Superclass( ),
161     m_ITKObject( NULL ),
162     m_VTKObject( NULL ),
163     m_ParametersDialog( NULL )
164 {
165   this->m_Parameters = TParameters::New( );
166 }
167
168 // -------------------------------------------------------------------------
169 cpPlugins::Interface::ProcessObject::
170 ~ProcessObject( )
171 {
172   if( this->m_ParametersDialog == NULL )
173     delete this->m_ParametersDialog;
174 }
175
176 // -------------------------------------------------------------------------
177 void cpPlugins::Interface::ProcessObject::
178 _AddInput( const std::string& name )
179 {
180   this->m_Inputs[ name ] = NULL;
181   this->Modified( );
182 }
183
184 // eof - $RCSfile$