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 bool cpPlugins::Interface::ProcessObject::
44 const std::string& new_object_name, const std::string& output_name
47 auto oIt = this->m_Outputs.find( output_name );
48 if( oIt != this->m_Outputs.end( ) )
50 this->m_OutputObjectsNames[ output_name ] = new_object_name;
58 // -------------------------------------------------------------------------
59 void cpPlugins::Interface::ProcessObject::
60 SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
62 _TDataContainer::iterator i = this->m_Inputs.find( id );
63 if( i != this->m_Inputs.end( ) )
71 // -------------------------------------------------------------------------
72 std::string cpPlugins::Interface::ProcessObject::
77 // Force upstream updates
78 _TDataContainer::iterator i = this->m_Inputs.begin( );
79 for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
81 Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
89 r = this->_GenerateData( );
91 // Configure output names
92 auto oIt = this->m_Outputs.begin( );
93 for( ; oIt != this->m_Outputs.end( ); ++oIt )
95 auto nIt = this->m_OutputObjectsNames.find( oIt->first );
96 if( nIt != this->m_OutputObjectsNames.end( ) )
97 oIt->second->SetName( nIt->second );
101 // Return error description, if any
105 // -------------------------------------------------------------------------
106 void cpPlugins::Interface::ProcessObject::
109 _TDataContainer::iterator i = this->m_Outputs.begin( );
110 for( ; i != this->m_Outputs.end( ); ++i )
111 if( i->second.IsNotNull( ) )
112 i->second->DisconnectPipeline( );
115 // -------------------------------------------------------------------------
116 void cpPlugins::Interface::ProcessObject::
117 AddInteractor( vtkRenderWindowInteractor* interactor )
119 #ifdef cpPlugins_Interface_QT4
120 if( this->m_ParametersDialog == NULL )
121 this->m_ParametersDialog = new ParametersQtDialog( );
122 this->m_ParametersDialog->addInteractor( interactor );
123 #endif // cpPlugins_Interface_QT4
124 this->m_Interactors.insert( interactor );
127 // -------------------------------------------------------------------------
128 cpPlugins::Interface::ProcessObject::
129 DialogResult cpPlugins::Interface::ProcessObject::
130 ExecConfigurationDialog( QWidget* parent )
132 DialogResult r = Self::DialogResult_Cancel;
134 #ifdef cpPlugins_Interface_QT4
136 if( QApplication::instance( ) != NULL )
138 if( this->m_ParametersDialog == NULL )
139 this->m_ParametersDialog = new ParametersQtDialog( );
140 this->m_ParametersDialog->setTitle(
141 this->GetClassName( ) + std::string( " basic configuration" )
144 this->m_ParametersDialog->setParent( NULL );
145 this->m_ParametersDialog->setParameters( this->m_Parameters );
147 if( !( this->m_ParametersDialog->IsModal( ) ) )
149 this->m_ParametersDialog->show( );
150 r = Self::DialogResult_Modal;
154 if( this->m_ParametersDialog->exec( ) == 1 )
155 r = Self::DialogResult_NoModal;
157 r = Self::DialogResult_Cancel;
162 r = Self::DialogResult_Cancel;
164 #endif // cpPlugins_Interface_QT4
169 // -------------------------------------------------------------------------
170 cpPlugins::Interface::ProcessObject::
175 m_ParametersDialog( NULL ),
178 this->m_Parameters = TParameters::New( );
179 this->m_Parameters->SetProcessObject( this );
182 // -------------------------------------------------------------------------
183 cpPlugins::Interface::ProcessObject::
186 if( this->m_ParametersDialog != NULL )
187 delete this->m_ParametersDialog;
190 // -------------------------------------------------------------------------
191 void cpPlugins::Interface::ProcessObject::
192 _AddInput( const std::string& name )
194 this->m_Inputs[ name ] = NULL;
198 // -------------------------------------------------------------------------
199 CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );