1 #include <cpPlugins/Interface/ProcessObject.h>
3 #ifdef cpPlugins_Interface_QT4
4 #include <QApplication>
5 #include <cpPlugins/Interface/ParametersQtDialog.h>
6 #endif // cpPlugins_Interface_QT4
8 #include <vtkRenderWindowInteractor.h>
10 // -------------------------------------------------------------------------
11 void cpPlugins::Interface::ProcessObject::
14 if( this->m_ITKObject.IsNotNull( ) )
15 this->m_ITKObject->Modified( );
16 if( this->m_VTKObject.GetPointer( ) != NULL )
17 this->m_VTKObject->Modified( );
18 this->Superclass::Modified( );
21 // -------------------------------------------------------------------------
22 void cpPlugins::Interface::ProcessObject::
23 GetInputsNames( std::set< std::string >& names ) const
26 auto dIt = this->m_Inputs.begin( );
27 for( ; dIt != this->m_Inputs.end( ); ++dIt )
28 names.insert( dIt->first );
31 // -------------------------------------------------------------------------
32 void cpPlugins::Interface::ProcessObject::
33 GetOutputsNames( std::set< std::string >& names ) const
36 auto dIt = this->m_Outputs.begin( );
37 for( ; dIt != this->m_Outputs.end( ); ++dIt )
38 names.insert( dIt->first );
41 // -------------------------------------------------------------------------
42 unsigned int cpPlugins::Interface::ProcessObject::
43 GetNumberOfInputs( ) const
45 return( this->m_Inputs.size( ) );
48 // -------------------------------------------------------------------------
49 unsigned int cpPlugins::Interface::ProcessObject::
50 GetNumberOfOutputs( ) const
52 return( this->m_Outputs.size( ) );
55 // -------------------------------------------------------------------------
56 bool cpPlugins::Interface::ProcessObject::
58 const std::string& new_object_name, const std::string& output_name
61 auto oIt = this->m_Outputs.find( output_name );
62 if( oIt != this->m_Outputs.end( ) )
64 this->m_OutputObjectsNames[ output_name ] = new_object_name;
72 // -------------------------------------------------------------------------
73 void cpPlugins::Interface::ProcessObject::
74 SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
76 _TDataContainer::iterator i = this->m_Inputs.find( id );
77 if( i != this->m_Inputs.end( ) )
85 // -------------------------------------------------------------------------
86 std::string cpPlugins::Interface::ProcessObject::
91 // Force upstream updates
92 _TDataContainer::iterator i = this->m_Inputs.begin( );
93 for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
95 if( i->second.IsNotNull( ) )
97 Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
102 r = "cpPlugins::Interface::ProcessObject: No input connected.";
108 r = this->_GenerateData( );
110 // Configure output names
111 auto oIt = this->m_Outputs.begin( );
112 for( ; oIt != this->m_Outputs.end( ); ++oIt )
114 auto nIt = this->m_OutputObjectsNames.find( oIt->first );
115 if( nIt != this->m_OutputObjectsNames.end( ) )
116 oIt->second->SetName( nIt->second );
120 // Return error description, if any
124 // -------------------------------------------------------------------------
125 void cpPlugins::Interface::ProcessObject::
128 _TDataContainer::iterator i = this->m_Outputs.begin( );
129 for( ; i != this->m_Outputs.end( ); ++i )
130 if( i->second.IsNotNull( ) )
131 i->second->DisconnectPipeline( );
134 // -------------------------------------------------------------------------
135 const cpPlugins::Interface::ProcessObject::
136 TInteractors& cpPlugins::Interface::ProcessObject::
137 GetInteractors( ) const
139 return( this->m_Interactors );
142 // -------------------------------------------------------------------------
143 void cpPlugins::Interface::ProcessObject::
144 AddInteractor( vtkRenderWindowInteractor* interactor )
146 #ifdef cpPlugins_Interface_QT4
147 if( this->m_ParametersDialog == NULL )
148 this->m_ParametersDialog = new ParametersQtDialog( );
149 this->m_ParametersDialog->addInteractor( interactor );
150 #endif // cpPlugins_Interface_QT4
151 this->m_Interactors.insert( interactor );
154 // -------------------------------------------------------------------------
155 bool cpPlugins::Interface::ProcessObject::
156 ExecConfigurationDialog( QWidget* parent )
160 #ifdef cpPlugins_Interface_QT4
162 if( QApplication::instance( ) != NULL )
164 if( this->m_ParametersDialog == NULL )
165 this->m_ParametersDialog = new ParametersQtDialog( );
167 this->m_ParametersDialog->setTitle(
168 this->GetClassName( ) + std::string( " basic configuration" )
172 this->m_ParametersDialog->setParent( NULL );
173 this->m_ParametersDialog->setParameters( this->m_Parameters );
175 r = ( this->m_ParametersDialog->exec( ) == 1 );
180 #endif // cpPlugins_Interface_QT4
185 // -------------------------------------------------------------------------
186 cpPlugins::Interface::ProcessObject::
191 m_ParametersDialog( NULL ),
194 this->m_Parameters = TParameters::New( );
195 this->m_Parameters->SetProcessObject( this );
198 // -------------------------------------------------------------------------
199 cpPlugins::Interface::ProcessObject::
202 if( this->m_ParametersDialog != NULL )
203 delete this->m_ParametersDialog;
206 // -------------------------------------------------------------------------
207 void cpPlugins::Interface::ProcessObject::
208 _AddInput( const std::string& name )
210 this->m_Inputs[ name ] = NULL;
214 // -------------------------------------------------------------------------
215 CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );