1 #include <cpPlugins/Interface/ProcessObject.h>
3 #ifdef cpPlugins_Interface_QT4
4 #include <cpPlugins/Interface/ParametersQtDialog.h>
5 #endif // cpPlugins_Interface_QT4
7 #include <vtkRenderWindowInteractor.h>
9 // -------------------------------------------------------------------------
10 void cpPlugins::Interface::ProcessObject::
13 if( this->m_ITKObject.IsNotNull( ) )
14 this->m_ITKObject->Modified( );
15 if( this->m_VTKObject.GetPointer( ) != NULL )
16 this->m_VTKObject->Modified( );
17 this->Superclass::Modified( );
20 // -------------------------------------------------------------------------
21 bool cpPlugins::Interface::ProcessObject::
22 IsInteractive( ) const
24 std::vector< std::string > names;
25 this->m_Parameters->GetNames( names );
27 auto i = names.begin( );
28 for( ; i != names.end( ); ++i )
30 TParameters::Type t = this->m_Parameters->GetType( *i );
31 res |= ( t == TParameters::Point );
32 res |= ( t == TParameters::Index );
33 res |= ( t == TParameters::PointList );
34 res |= ( t == TParameters::IndexList );
40 // -------------------------------------------------------------------------
41 cpPlugins::Interface::ProcessObject::
42 TParameters* cpPlugins::Interface::ProcessObject::
45 return( this->m_Parameters.GetPointer( ) );
48 // -------------------------------------------------------------------------
49 const cpPlugins::Interface::ProcessObject::
50 TParameters* cpPlugins::Interface::ProcessObject::
51 GetParameters( ) const
53 return( this->m_Parameters.GetPointer( ) );
56 // -------------------------------------------------------------------------
57 cpPlugins::Interface::
58 Plugins* cpPlugins::Interface::ProcessObject::
61 return( this->m_Plugins );
64 // -------------------------------------------------------------------------
65 const cpPlugins::Interface::
66 Plugins* cpPlugins::Interface::ProcessObject::
69 return( this->m_Plugins );
72 // -------------------------------------------------------------------------
73 void cpPlugins::Interface::ProcessObject::
74 SetPlugins( Plugins* p )
79 // -------------------------------------------------------------------------
80 unsigned int cpPlugins::Interface::ProcessObject::
81 GetNumberOfInputs( ) const
83 return( this->m_Inputs.size( ) );
86 // -------------------------------------------------------------------------
87 unsigned int cpPlugins::Interface::ProcessObject::
88 GetNumberOfOutputs( ) const
90 return( this->m_Outputs.size( ) );
93 // -------------------------------------------------------------------------
94 std::vector< std::string > cpPlugins::Interface::ProcessObject::
95 GetInputsNames( ) const
97 std::vector< std::string > r;
98 auto dIt = this->m_Inputs.begin( );
99 for( ; dIt != this->m_Inputs.end( ); ++dIt )
100 r.push_back( dIt->first );
104 // -------------------------------------------------------------------------
105 std::vector< std::string > cpPlugins::Interface::ProcessObject::
106 GetOutputsNames( ) const
108 std::vector< std::string > r;
109 auto dIt = this->m_Outputs.begin( );
110 for( ; dIt != this->m_Outputs.end( ); ++dIt )
111 r.push_back( dIt->first );
115 // -------------------------------------------------------------------------
116 void cpPlugins::Interface::ProcessObject::
117 SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
119 _TDataContainer::iterator i = this->m_Inputs.find( id );
120 if( i != this->m_Inputs.end( ) )
128 // -------------------------------------------------------------------------
129 std::string cpPlugins::Interface::ProcessObject::
134 // Force upstream updates
135 _TDataContainer::iterator i = this->m_Inputs.begin( );
136 for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
138 Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
146 r = this->_GenerateData( );
148 // Return error description, if any
152 // -------------------------------------------------------------------------
153 void cpPlugins::Interface::ProcessObject::
156 _TDataContainer::iterator i = this->m_Outputs.begin( );
157 for( ; i != this->m_Outputs.end( ); ++i )
158 if( i->second.IsNotNull( ) )
159 i->second->DisconnectPipeline( );
162 // -------------------------------------------------------------------------
163 void cpPlugins::Interface::ProcessObject::
164 AddInteractor( vtkRenderWindowInteractor* interactor )
166 #ifdef cpPlugins_Interface_QT4
167 this->m_ParametersDialog->addInteractor( interactor );
168 #endif // cpPlugins_Interface_QT4
171 // -------------------------------------------------------------------------
172 cpPlugins::Interface::ProcessObject::
173 DialogResult cpPlugins::Interface::ProcessObject::
174 ExecConfigurationDialog( QWidget* parent )
176 DialogResult r = Self::DialogResult_Cancel;
178 #ifdef cpPlugins_Interface_QT4
180 this->m_ParametersDialog->setParent( NULL );
181 this->m_ParametersDialog->setParameters( this->m_Parameters );
183 if( !( this->m_ParametersDialog->IsModal( ) ) )
185 this->m_ParametersDialog->show( );
186 r = Self::DialogResult_Modal;
190 if( this->m_ParametersDialog->exec( ) == 1 )
191 r = Self::DialogResult_NoModal;
193 r = Self::DialogResult_Cancel;
197 #endif // cpPlugins_Interface_QT4
202 // -------------------------------------------------------------------------
203 cpPlugins::Interface::ProcessObject::
210 this->m_Parameters = TParameters::New( );
211 this->m_Parameters->SetProcessObject( this );
213 this->m_ParametersDialog = new ParametersQtDialog( );
214 this->m_ParametersDialog->setTitle(
215 this->GetClassName( ) + std::string( " basic configuration" )
219 // -------------------------------------------------------------------------
220 cpPlugins::Interface::ProcessObject::
223 delete this->m_ParametersDialog;
226 // -------------------------------------------------------------------------
227 void cpPlugins::Interface::ProcessObject::
228 _AddInput( const std::string& name )
230 this->m_Inputs[ name ] = NULL;