X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcpPlugins%2FInterface%2FProcessObject.cxx;h=db873e9d4f854724c7606a79af4e4f00a705c5b6;hb=de874ea850042e77a99a456188f423c8df2e374f;hp=93d36d57b9a5f7bbc72908de9d2ab94dcd1b699b;hpb=55743f4ff8867c0075518dcc6b76745722ce60ed;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 93d36d5..db873e9 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -1,6 +1,7 @@ #include #ifdef cpPlugins_Interface_QT4 +#include #include #endif // cpPlugins_Interface_QT4 @@ -18,25 +19,54 @@ Modified( ) const } // ------------------------------------------------------------------------- -std::vector< std::string > cpPlugins::Interface::ProcessObject:: -GetInputsNames( ) const +void cpPlugins::Interface::ProcessObject:: +GetInputsNames( std::set< std::string >& names ) const { - std::vector< std::string > r; + names.clear( ); auto dIt = this->m_Inputs.begin( ); for( ; dIt != this->m_Inputs.end( ); ++dIt ) - r.push_back( dIt->first ); - return( r ); + names.insert( dIt->first ); } // ------------------------------------------------------------------------- -std::vector< std::string > cpPlugins::Interface::ProcessObject:: -GetOutputsNames( ) const +void cpPlugins::Interface::ProcessObject:: +GetOutputsNames( std::set< std::string >& names ) const { - std::vector< std::string > r; + names.clear( ); auto dIt = this->m_Outputs.begin( ); for( ; dIt != this->m_Outputs.end( ); ++dIt ) - r.push_back( dIt->first ); - return( r ); + names.insert( dIt->first ); +} + +// ------------------------------------------------------------------------- +unsigned int cpPlugins::Interface::ProcessObject:: +GetNumberOfInputs( ) const +{ + return( this->m_Inputs.size( ) ); +} + +// ------------------------------------------------------------------------- +unsigned int cpPlugins::Interface::ProcessObject:: +GetNumberOfOutputs( ) const +{ + return( this->m_Outputs.size( ) ); +} + +// ------------------------------------------------------------------------- +bool cpPlugins::Interface::ProcessObject:: +SetOutputObjectName( + const std::string& new_object_name, const std::string& output_name + ) +{ + auto oIt = this->m_Outputs.find( output_name ); + if( oIt != this->m_Outputs.end( ) ) + { + this->m_OutputObjectsNames[ output_name ] = new_object_name; + this->Modified( ); + return( true ); + } + else + return( false ); } // ------------------------------------------------------------------------- @@ -62,16 +92,31 @@ Update( ) _TDataContainer::iterator i = this->m_Inputs.begin( ); for( ; i != this->m_Inputs.end( ) && r == ""; ++i ) { - Self* src = dynamic_cast< Self* >( i->second->GetSource( ) ); - if( src != NULL ) - r = src->Update( ); - + if( i->second.IsNotNull( ) ) + { + Self* src = dynamic_cast< Self* >( i->second->GetSource( ) ); + if( src != NULL ) + r = src->Update( ); + } + else + r = "cpPlugins::Interface::ProcessObject: No input connected."; + } // rof // Current update if( r == "" ) r = this->_GenerateData( ); + // Configure output names + auto oIt = this->m_Outputs.begin( ); + for( ; oIt != this->m_Outputs.end( ); ++oIt ) + { + auto nIt = this->m_OutputObjectsNames.find( oIt->first ); + if( nIt != this->m_OutputObjectsNames.end( ) ) + oIt->second->SetName( nIt->second ); + + } // rof + // Return error description, if any return( r ); } @@ -91,8 +136,11 @@ void cpPlugins::Interface::ProcessObject:: AddInteractor( vtkRenderWindowInteractor* interactor ) { #ifdef cpPlugins_Interface_QT4 + if( this->m_ParametersDialog == NULL ) + this->m_ParametersDialog = new ParametersQtDialog( ); this->m_ParametersDialog->addInteractor( interactor ); #endif // cpPlugins_Interface_QT4 + this->m_Interactors.insert( interactor ); } // ------------------------------------------------------------------------- @@ -104,22 +152,26 @@ ExecConfigurationDialog( QWidget* parent ) #ifdef cpPlugins_Interface_QT4 - this->m_ParametersDialog->setParent( NULL ); - this->m_ParametersDialog->setParameters( this->m_Parameters ); - - if( !( this->m_ParametersDialog->IsModal( ) ) ) - { - this->m_ParametersDialog->show( ); - r = Self::DialogResult_Modal; - } - else + if( QApplication::instance( ) != NULL ) { + if( this->m_ParametersDialog == NULL ) + this->m_ParametersDialog = new ParametersQtDialog( ); + /* TODO + this->m_ParametersDialog->setTitle( + this->GetClassName( ) + std::string( " basic configuration" ) + ); + */ + + this->m_ParametersDialog->setParent( NULL ); + this->m_ParametersDialog->setParameters( this->m_Parameters ); + if( this->m_ParametersDialog->exec( ) == 1 ) r = Self::DialogResult_NoModal; else r = Self::DialogResult_Cancel; - - } // fi + } + else + r = Self::DialogResult_Cancel; #endif // cpPlugins_Interface_QT4 @@ -132,22 +184,19 @@ ProcessObject( ) : Superclass( ), m_ITKObject( NULL ), m_VTKObject( NULL ), + m_ParametersDialog( NULL ), m_Plugins( NULL ) { this->m_Parameters = TParameters::New( ); this->m_Parameters->SetProcessObject( this ); - - this->m_ParametersDialog = new ParametersQtDialog( ); - this->m_ParametersDialog->setTitle( - this->GetClassName( ) + std::string( " basic configuration" ) - ); } // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: ~ProcessObject( ) { - delete this->m_ParametersDialog; + if( this->m_ParametersDialog != NULL ) + delete this->m_ParametersDialog; } // -------------------------------------------------------------------------