1 #include <cpPlugins/Interface/ProcessObject.h>
3 #ifdef cpPlugins_Interface_QT4
4 #include <QApplication>
5 #include <cpPlugins/Interface/ParametersQtDialog.h>
6 #include <cpPlugins/Interface/SimpleMPRWidget.h>
7 #endif // cpPlugins_Interface_QT4
9 #include <vtkRenderWindowInteractor.h>
11 // -------------------------------------------------------------------------
12 std::set< std::string > cpPlugins::Interface::ProcessObject::
13 GetInputsNames( ) const
15 std::set< std::string > names;
16 auto dIt = this->m_Inputs.begin( );
17 for( ; dIt != this->m_Inputs.end( ); ++dIt )
18 names.insert( dIt->first );
22 // -------------------------------------------------------------------------
23 std::set< std::string > cpPlugins::Interface::ProcessObject::
24 GetOutputsNames( ) const
26 std::set< std::string > names;
27 auto dIt = this->m_Outputs.begin( );
28 for( ; dIt != this->m_Outputs.end( ); ++dIt )
29 names.insert( dIt->first );
33 // -------------------------------------------------------------------------
34 unsigned int cpPlugins::Interface::ProcessObject::
35 GetNumberOfInputs( ) const
37 return( this->m_Inputs.size( ) );
40 // -------------------------------------------------------------------------
41 unsigned int cpPlugins::Interface::ProcessObject::
42 GetNumberOfOutputs( ) const
44 return( this->m_Outputs.size( ) );
47 // -------------------------------------------------------------------------
48 bool cpPlugins::Interface::ProcessObject::
50 const std::string& id, cpPlugins::Interface::DataObject::Pointer* dobj
53 _TDataContainer::iterator i = this->m_Inputs.find( id );
54 if( i != this->m_Inputs.end( ) )
64 // -------------------------------------------------------------------------
65 std::string cpPlugins::Interface::ProcessObject::
70 // Force upstream updates
71 _TDataContainer::iterator i = this->m_Inputs.begin( );
72 for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
74 if( i->second->IsNotNull( ) )
76 Self* src = dynamic_cast< Self* >( ( *( i->second ) )->GetSource( ) );
81 r = "cpPlugins::Interface::ProcessObject: No input connected.";
87 r = this->_GenerateData( );
89 // Return error description, if any
93 // -------------------------------------------------------------------------
94 void cpPlugins::Interface::ProcessObject::
97 _TDataContainer::iterator i = this->m_Outputs.begin( );
98 for( ; i != this->m_Outputs.end( ); ++i )
99 if( i->second->IsNotNull( ) )
100 ( *( i->second ) )->DisconnectPipeline( );
103 // -------------------------------------------------------------------------
104 vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
105 GetSingleInteractor( )
107 return( this->m_SingleInteractor );
110 // -------------------------------------------------------------------------
111 const vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
112 GetSingleInteractor( ) const
114 return( this->m_SingleInteractor );
117 // -------------------------------------------------------------------------
118 void cpPlugins::Interface::ProcessObject::
119 SetSingleInteractor( vtkRenderWindowInteractor* interactor )
121 this->m_SingleInteractor = interactor;
124 // -------------------------------------------------------------------------
125 cpPlugins::Interface::
126 SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
129 return( this->m_MPRViewer );
132 // -------------------------------------------------------------------------
133 const cpPlugins::Interface::
134 SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
135 GetMPRViewer( ) const
137 return( this->m_MPRViewer );
140 // -------------------------------------------------------------------------
141 void cpPlugins::Interface::ProcessObject::
142 SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg )
144 this->m_MPRViewer = wdg;
147 // -------------------------------------------------------------------------
148 bool cpPlugins::Interface::ProcessObject::
149 ExecConfigurationDialog( QWidget* parent )
152 #ifdef cpPlugins_Interface_QT4
153 if( this->m_ParametersDialog != NULL )
155 this->m_ParametersDialog->setParent( NULL );
156 this->m_ParametersDialog->setParameters( this->m_Parameters );
157 r = ( this->m_ParametersDialog->exec( ) == 1 );
161 #endif // cpPlugins_Interface_QT4
165 // -------------------------------------------------------------------------
166 cpPlugins::Interface::ProcessObject::
169 m_ParametersDialog( NULL ),
172 this->m_Parameters = TParameters::New( );
173 this->m_Parameters->SetProcessObject( this );
175 #ifdef cpPlugins_Interface_QT4
176 if( QApplication::instance( ) != NULL )
177 this->m_ParametersDialog = new ParametersQtDialog( );
178 #endif // cpPlugins_Interface_QT4
181 // -------------------------------------------------------------------------
182 cpPlugins::Interface::ProcessObject::
185 #ifdef cpPlugins_Interface_QT4
186 if( this->m_ParametersDialog != NULL )
187 delete this->m_ParametersDialog;
188 #endif // cpPlugins_Interface_QT4
191 auto iIt = this->m_Inputs.begin( );
192 for( ; iIt != this->m_Inputs.end( ); ++iIt )
194 this->m_Inputs.clear( );
197 auto oIt = this->m_Outputs.begin( );
198 for( ; oIt != this->m_Outputs.end( ); ++oIt )
200 this->m_Outputs.clear( );
203 // -------------------------------------------------------------------------
204 void cpPlugins::Interface::ProcessObject::
205 _AddInput( const std::string& name )
207 auto i = this->m_Inputs.find( name );
208 if( i == this->m_Inputs.end( ) )
210 this->m_Inputs[ name ] = NULL;