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 if( i->second.IsNotNull( ) )
83 Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
88 r = "cpPlugins::Interface::ProcessObject: No input connected.";
94 r = this->_GenerateData( );
96 // Configure output names
97 auto oIt = this->m_Outputs.begin( );
98 for( ; oIt != this->m_Outputs.end( ); ++oIt )
100 auto nIt = this->m_OutputObjectsNames.find( oIt->first );
101 if( nIt != this->m_OutputObjectsNames.end( ) )
102 oIt->second->SetName( nIt->second );
106 // Return error description, if any
110 // -------------------------------------------------------------------------
111 void cpPlugins::Interface::ProcessObject::
114 _TDataContainer::iterator i = this->m_Outputs.begin( );
115 for( ; i != this->m_Outputs.end( ); ++i )
116 if( i->second.IsNotNull( ) )
117 i->second->DisconnectPipeline( );
120 // -------------------------------------------------------------------------
121 void cpPlugins::Interface::ProcessObject::
122 AddInteractor( vtkRenderWindowInteractor* interactor )
124 #ifdef cpPlugins_Interface_QT4
125 if( this->m_ParametersDialog == NULL )
126 this->m_ParametersDialog = new ParametersQtDialog( );
127 this->m_ParametersDialog->addInteractor( interactor );
128 #endif // cpPlugins_Interface_QT4
129 this->m_Interactors.insert( interactor );
132 // -------------------------------------------------------------------------
133 cpPlugins::Interface::ProcessObject::
134 DialogResult cpPlugins::Interface::ProcessObject::
135 ExecConfigurationDialog( QWidget* parent )
137 DialogResult r = Self::DialogResult_Cancel;
139 #ifdef cpPlugins_Interface_QT4
141 if( QApplication::instance( ) != NULL )
143 if( this->m_ParametersDialog == NULL )
144 this->m_ParametersDialog = new ParametersQtDialog( );
145 this->m_ParametersDialog->setTitle(
146 this->GetClassName( ) + std::string( " basic configuration" )
149 this->m_ParametersDialog->setParent( NULL );
150 this->m_ParametersDialog->setParameters( this->m_Parameters );
152 if( !( this->m_ParametersDialog->IsModal( ) ) )
154 this->m_ParametersDialog->show( );
155 r = Self::DialogResult_Modal;
159 if( this->m_ParametersDialog->exec( ) == 1 )
160 r = Self::DialogResult_NoModal;
162 r = Self::DialogResult_Cancel;
167 r = Self::DialogResult_Cancel;
169 #endif // cpPlugins_Interface_QT4
174 // -------------------------------------------------------------------------
175 cpPlugins::Interface::ProcessObject::
180 m_ParametersDialog( NULL ),
183 this->m_Parameters = TParameters::New( );
184 this->m_Parameters->SetProcessObject( this );
187 // -------------------------------------------------------------------------
188 cpPlugins::Interface::ProcessObject::
191 if( this->m_ParametersDialog != NULL )
192 delete this->m_ParametersDialog;
195 // -------------------------------------------------------------------------
196 void cpPlugins::Interface::ProcessObject::
197 _AddInput( const std::string& name )
199 this->m_Inputs[ name ] = NULL;
203 // -------------------------------------------------------------------------
204 CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );