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
126 // -------------------------------------------------------------------------
127 cpPlugins::Interface::ProcessObject::
128 DialogResult cpPlugins::Interface::ProcessObject::
129 ExecConfigurationDialog( QWidget* parent )
131 DialogResult r = Self::DialogResult_Cancel;
133 #ifdef cpPlugins_Interface_QT4
135 if( QApplication::instance( ) != NULL )
137 if( this->m_ParametersDialog == NULL )
138 this->m_ParametersDialog = new ParametersQtDialog( );
139 this->m_ParametersDialog->setTitle(
140 this->GetClassName( ) + std::string( " basic configuration" )
143 this->m_ParametersDialog->setParent( NULL );
144 this->m_ParametersDialog->setParameters( this->m_Parameters );
146 if( !( this->m_ParametersDialog->IsModal( ) ) )
148 this->m_ParametersDialog->show( );
149 r = Self::DialogResult_Modal;
153 if( this->m_ParametersDialog->exec( ) == 1 )
154 r = Self::DialogResult_NoModal;
156 r = Self::DialogResult_Cancel;
161 r = Self::DialogResult_Cancel;
163 #endif // cpPlugins_Interface_QT4
168 // -------------------------------------------------------------------------
169 cpPlugins::Interface::ProcessObject::
174 m_ParametersDialog( NULL ),
177 this->m_Parameters = TParameters::New( );
178 this->m_Parameters->SetProcessObject( this );
181 // -------------------------------------------------------------------------
182 cpPlugins::Interface::ProcessObject::
185 if( this->m_ParametersDialog != NULL )
186 delete this->m_ParametersDialog;
189 // -------------------------------------------------------------------------
190 void cpPlugins::Interface::ProcessObject::
191 _AddInput( const std::string& name )
193 this->m_Inputs[ name ] = NULL;
197 // -------------------------------------------------------------------------
198 CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );