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::
49 SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
51 _TDataContainer::iterator i = this->m_Inputs.find( id );
52 if( i != this->m_Inputs.end( ) )
62 // -------------------------------------------------------------------------
63 std::string cpPlugins::Interface::ProcessObject::
68 // Force upstream updates
69 _TDataContainer::iterator i = this->m_Inputs.begin( );
70 for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
72 if( i->second.IsNotNull( ) )
74 Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
79 r = "cpPlugins::Interface::ProcessObject: No input connected.";
85 r = this->_GenerateData( );
87 // Return error description, if any
91 // -------------------------------------------------------------------------
92 void cpPlugins::Interface::ProcessObject::
95 _TDataContainer::iterator i = this->m_Outputs.begin( );
96 for( ; i != this->m_Outputs.end( ); ++i )
97 if( i->second.IsNotNull( ) )
98 i->second->DisconnectPipeline( );
101 // -------------------------------------------------------------------------
102 vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
103 GetSingleInteractor( )
105 return( this->m_SingleInteractor );
108 // -------------------------------------------------------------------------
109 const vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
110 GetSingleInteractor( ) const
112 return( this->m_SingleInteractor );
115 // -------------------------------------------------------------------------
116 void cpPlugins::Interface::ProcessObject::
117 SetSingleInteractor( vtkRenderWindowInteractor* interactor )
119 this->m_SingleInteractor = interactor;
122 // -------------------------------------------------------------------------
123 cpPlugins::Interface::
124 SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
127 return( this->m_MPRViewer );
130 // -------------------------------------------------------------------------
131 const cpPlugins::Interface::
132 SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
133 GetMPRViewer( ) const
135 return( this->m_MPRViewer );
138 // -------------------------------------------------------------------------
139 void cpPlugins::Interface::ProcessObject::
140 SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg )
142 this->m_MPRViewer = wdg;
145 // -------------------------------------------------------------------------
146 bool cpPlugins::Interface::ProcessObject::
147 ExecConfigurationDialog( QWidget* parent )
150 #ifdef cpPlugins_Interface_QT4
151 if( this->m_ParametersDialog != NULL )
153 this->m_ParametersDialog->setParent( NULL );
154 this->m_ParametersDialog->setParameters( this->m_Parameters );
155 r = ( this->m_ParametersDialog->exec( ) == 1 );
159 #endif // cpPlugins_Interface_QT4
163 // -------------------------------------------------------------------------
164 cpPlugins::Interface::ProcessObject::
167 m_ParametersDialog( NULL ),
170 this->m_Parameters = TParameters::New( );
171 this->m_Parameters->SetProcessObject( this );
173 #ifdef cpPlugins_Interface_QT4
174 if( QApplication::instance( ) != NULL )
175 this->m_ParametersDialog = new ParametersQtDialog( );
176 #endif // cpPlugins_Interface_QT4
179 // -------------------------------------------------------------------------
180 cpPlugins::Interface::ProcessObject::
183 #ifdef cpPlugins_Interface_QT4
184 if( this->m_ParametersDialog != NULL )
185 delete this->m_ParametersDialog;
186 #endif // cpPlugins_Interface_QT4
189 // -------------------------------------------------------------------------
190 void cpPlugins::Interface::ProcessObject::
191 _AddInput( const std::string& name )
193 this->m_Inputs[ name ] = NULL;