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 std::set< std::string > cpPlugins::Interface::ProcessObject::
12 GetInputsNames( ) const
14 std::set< std::string > names;
15 auto dIt = this->m_Inputs.begin( );
16 for( ; dIt != this->m_Inputs.end( ); ++dIt )
17 names.insert( dIt->first );
21 // -------------------------------------------------------------------------
22 std::set< std::string > cpPlugins::Interface::ProcessObject::
23 GetOutputsNames( ) const
25 std::set< std::string > names;
26 auto dIt = this->m_Outputs.begin( );
27 for( ; dIt != this->m_Outputs.end( ); ++dIt )
28 names.insert( dIt->first );
32 // -------------------------------------------------------------------------
33 unsigned int cpPlugins::Interface::ProcessObject::
34 GetNumberOfInputs( ) const
36 return( this->m_Inputs.size( ) );
39 // -------------------------------------------------------------------------
40 unsigned int cpPlugins::Interface::ProcessObject::
41 GetNumberOfOutputs( ) const
43 return( this->m_Outputs.size( ) );
46 // -------------------------------------------------------------------------
47 bool cpPlugins::Interface::ProcessObject::
48 SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
50 _TDataContainer::iterator i = this->m_Inputs.find( id );
51 if( i != this->m_Inputs.end( ) )
61 // -------------------------------------------------------------------------
62 std::string cpPlugins::Interface::ProcessObject::
67 // Force upstream updates
68 _TDataContainer::iterator i = this->m_Inputs.begin( );
69 for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
71 if( i->second.IsNotNull( ) )
73 Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
78 r = "cpPlugins::Interface::ProcessObject: No input connected.";
84 r = this->_GenerateData( );
86 // Return error description, if any
90 // -------------------------------------------------------------------------
91 void cpPlugins::Interface::ProcessObject::
94 _TDataContainer::iterator i = this->m_Outputs.begin( );
95 for( ; i != this->m_Outputs.end( ); ++i )
96 if( i->second.IsNotNull( ) )
97 i->second->DisconnectPipeline( );
100 // -------------------------------------------------------------------------
101 const cpPlugins::Interface::ProcessObject::
102 TInteractors& cpPlugins::Interface::ProcessObject::
103 GetInteractors( ) const
105 return( this->m_Interactors );
108 // -------------------------------------------------------------------------
109 void cpPlugins::Interface::ProcessObject::
110 AddInteractor( vtkRenderWindowInteractor* interactor )
112 this->m_Interactors.insert( interactor );
113 #ifdef cpPlugins_Interface_QT4
114 this->m_ParametersDialog->addInteractor( interactor );
115 #endif // cpPlugins_Interface_QT4
118 // -------------------------------------------------------------------------
119 bool cpPlugins::Interface::ProcessObject::
120 ExecConfigurationDialog( QWidget* parent )
123 #ifdef cpPlugins_Interface_QT4
124 if( this->m_ParametersDialog != NULL )
126 this->m_ParametersDialog->setParent( NULL );
127 this->m_ParametersDialog->setParameters( this->m_Parameters );
128 r = ( this->m_ParametersDialog->exec( ) == 1 );
132 #endif // cpPlugins_Interface_QT4
136 // -------------------------------------------------------------------------
137 cpPlugins::Interface::ProcessObject::
140 m_ParametersDialog( NULL )
142 this->m_Parameters = TParameters::New( );
143 this->m_Parameters->SetProcessObject( this );
145 #ifdef cpPlugins_Interface_QT4
146 if( QApplication::instance( ) != NULL )
147 this->m_ParametersDialog = new ParametersQtDialog( );
148 #endif // cpPlugins_Interface_QT4
151 // -------------------------------------------------------------------------
152 cpPlugins::Interface::ProcessObject::
155 #ifdef cpPlugins_Interface_QT4
156 if( this->m_ParametersDialog != NULL )
157 delete this->m_ParametersDialog;
158 #endif // cpPlugins_Interface_QT4
161 // -------------------------------------------------------------------------
162 void cpPlugins::Interface::ProcessObject::
163 _AddInput( const std::string& name )
165 this->m_Inputs[ name ] = NULL;
169 // -------------------------------------------------------------------------
170 CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );