X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FProcessObject.cxx;h=f639d7f59e3ea2b5686950a48151e98b0d05ef73;hb=8e5fd31fd4d280781d8bc27a799361bf9c30b1d4;hp=3630e491022a4813778201346aa45d65d2b3b0fd;hpb=62d056ccb528d63392d197552830460e980a5aba;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 3630e49..f639d7f 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -1,19 +1,34 @@ #include +#ifdef cpPlugins_Interface_QT4 +#include +#endif // cpPlugins_Interface_QT4 + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ProcessObject:: +Modified( ) const +{ + if( this->m_ITKObject.IsNotNull( ) ) + this->m_ITKObject->Modified( ); + if( this->m_VTKObject.GetPointer( ) != NULL ) + this->m_VTKObject->Modified( ); + this->Superclass::Modified( ); +} + // ------------------------------------------------------------------------- -const cpPlugins::Interface::Parameters& cpPlugins::Interface::ProcessObject:: -GetDefaultParameters( ) const +TParameters* cpPlugins::Interface::ProcessObject:: +GetParameters( ) { - return( this->m_DefaultParameters ); + return( this->m_Parameters.GetPointer( ) ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -SetParameters( const cpPlugins::Interface::Parameters& params ) +const cpPlugins::Interface::ProcessObject:: +TParameters* cpPlugins::Interface::ProcessObject:: +GetParameters( ) const { - this->m_Parameters = params; - this->Modified( ); + return( this->m_Parameters.GetPointer( ) ); } // ------------------------------------------------------------------------- @@ -31,30 +46,35 @@ GetNumberOfOutputs( ) const } // ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -SetNumberOfInputs( unsigned int n ) +std::vector< std::string > cpPlugins::Interface::ProcessObject:: +GetInputsNames( ) const { - this->m_Inputs.clear( ); - this->m_Inputs.resize( n ); - this->Modified( ); + std::vector< std::string > r; + auto dIt = this->m_Inputs.begin( ); + for( ; dIt != this->m_Inputs.end( ); ++dIt ) + r.push_back( dIt->first ); + return( r ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -SetNumberOfOutputs( unsigned int n ) +std::vector< std::string > cpPlugins::Interface::ProcessObject:: +GetOutputsNames( ) const { - this->m_Outputs.clear( ); - this->m_Outputs.resize( n ); - this->Modified( ); + std::vector< std::string > r; + auto dIt = this->m_Outputs.begin( ); + for( ; dIt != this->m_Outputs.end( ); ++dIt ) + r.push_back( dIt->first ); + return( r ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: -SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj ) +SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj ) { - if( idx < this->m_Inputs.size( ) ) + _TDataContainer::iterator i = this->m_Inputs.find( id ); + if( i != this->m_Inputs.end( ) ) { - this->m_Inputs[ idx ] = dobj; + i->second = dobj; this->Modified( ); } // fi @@ -67,9 +87,10 @@ Update( ) std::string r = ""; // Force upstream updates - for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i ) + _TDataContainer::iterator i = this->m_Inputs.begin( ); + for( ; i != this->m_Inputs.end( ) && r == ""; ++i ) { - Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) ); + Self* src = dynamic_cast< Self* >( i->second->GetSource( ) ); if( src != NULL ) r = src->Update( ); @@ -87,24 +108,77 @@ Update( ) void cpPlugins::Interface::ProcessObject:: DisconnectOutputs( ) { - for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx ) - if( this->m_Outputs[ idx ].IsNotNull( ) ) - this->m_Outputs[ idx ]->DisconnectPipeline( ); + _TDataContainer::iterator i = this->m_Outputs.begin( ); + for( ; i != this->m_Outputs.end( ); ++i ) + if( i->second.IsNotNull( ) ) + i->second->DisconnectPipeline( ); +} + +// ------------------------------------------------------------------------- +bool cpPlugins::Interface::ProcessObject:: +ExecConfigurationDialog( QWidget* parent ) +{ + bool r = false; + +#ifdef cpPlugins_Interface_QT4 + + if( this->m_ParametersDialog == NULL ) + { + this->m_ParametersDialog = new ParametersQtDialog( parent ); + this->m_ParametersDialog->setTitle( + this->GetClassName( ) + std::string( " basic configuration" ) + ); + this->m_ParametersDialog->setParameters( this->m_Parameters ); + + } // fi + + if( !( this->m_ParametersDialog->IsModal( ) ) ) + { + this->m_ParametersDialog->show( ); + r = true; + } + else + r = ( this->m_ParametersDialog->exec( ) == 1 ); + + /* + r = cpPlugins::Interface::ParametersQtDialog( + this->m_Parameters, + this->GetClassName( ) + std::string( " basic configuration" ), + parent + ); + if( r ) + */ + +#endif // cpPlugins_Interface_QT4 + + return( r ); } // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: ProcessObject( ) - : Superclass( ) + : Superclass( ), + m_ITKObject( NULL ), + m_VTKObject( NULL ), + m_ParametersDialog( NULL ) { - this->m_ClassName = "cpPlugins::Interface::ProcessObject"; - this->m_ClassCategory = "BasicObject"; + this->m_Parameters = TParameters::New( ); } // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: ~ProcessObject( ) { + if( this->m_ParametersDialog == NULL ) + delete this->m_ParametersDialog; +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ProcessObject:: +_AddInput( const std::string& name ) +{ + this->m_Inputs[ name ] = NULL; + this->Modified( ); } // eof - $RCSfile$