X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FProcessObject.cxx;h=5434319fb09c1d9e7a8b47169e15185d83cda862;hb=1b600247da314fe62d007ca8a0ce24d0006931f4;hp=f639d7f59e3ea2b5686950a48151e98b0d05ef73;hpb=4a793c6b8f400b2303a3f69680aea22948d8ecc6;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index f639d7f..5434319 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -1,34 +1,33 @@ #include #ifdef cpPlugins_Interface_QT4 +#include #include +#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( ); -} +#include // ------------------------------------------------------------------------- -cpPlugins::Interface::ProcessObject:: -TParameters* cpPlugins::Interface::ProcessObject:: -GetParameters( ) +std::set< std::string > cpPlugins::Interface::ProcessObject:: +GetInputsNames( ) const { - return( this->m_Parameters.GetPointer( ) ); + std::set< std::string > names; + auto dIt = this->m_Inputs.begin( ); + for( ; dIt != this->m_Inputs.end( ); ++dIt ) + names.insert( dIt->first ); + return( names ); } // ------------------------------------------------------------------------- -const cpPlugins::Interface::ProcessObject:: -TParameters* cpPlugins::Interface::ProcessObject:: -GetParameters( ) const +std::set< std::string > cpPlugins::Interface::ProcessObject:: +GetOutputsNames( ) const { - return( this->m_Parameters.GetPointer( ) ); + std::set< std::string > names; + auto dIt = this->m_Outputs.begin( ); + for( ; dIt != this->m_Outputs.end( ); ++dIt ) + names.insert( dIt->first ); + return( names ); } // ------------------------------------------------------------------------- @@ -46,38 +45,20 @@ GetNumberOfOutputs( ) const } // ------------------------------------------------------------------------- -std::vector< std::string > cpPlugins::Interface::ProcessObject:: -GetInputsNames( ) const -{ - 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 ); -} - -// ------------------------------------------------------------------------- -std::vector< std::string > cpPlugins::Interface::ProcessObject:: -GetOutputsNames( ) const -{ - 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( const std::string& id, cpPlugins::Interface::DataObject* dobj ) +bool cpPlugins::Interface::ProcessObject:: +SetInput( + const std::string& id, cpPlugins::Interface::DataObject::Pointer* dobj + ) { _TDataContainer::iterator i = this->m_Inputs.find( id ); if( i != this->m_Inputs.end( ) ) { i->second = dobj; this->Modified( ); - - } // fi + return( true ); + } + else + return( false ); } // ------------------------------------------------------------------------- @@ -90,10 +71,15 @@ 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 @@ -110,8 +96,52 @@ DisconnectOutputs( ) { _TDataContainer::iterator i = this->m_Outputs.begin( ); for( ; i != this->m_Outputs.end( ); ++i ) - if( i->second.IsNotNull( ) ) - i->second->DisconnectPipeline( ); + if( i->second->IsNotNull( ) ) + ( *( i->second ) )->DisconnectPipeline( ); +} + +// ------------------------------------------------------------------------- +vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject:: +GetSingleInteractor( ) +{ + return( this->m_SingleInteractor ); +} + +// ------------------------------------------------------------------------- +const vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject:: +GetSingleInteractor( ) const +{ + return( this->m_SingleInteractor ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ProcessObject:: +SetSingleInteractor( vtkRenderWindowInteractor* interactor ) +{ + this->m_SingleInteractor = interactor; +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface:: +SimpleMPRWidget* cpPlugins::Interface::ProcessObject:: +GetMPRViewer( ) +{ + return( this->m_MPRViewer ); +} + +// ------------------------------------------------------------------------- +const cpPlugins::Interface:: +SimpleMPRWidget* cpPlugins::Interface::ProcessObject:: +GetMPRViewer( ) const +{ + return( this->m_MPRViewer ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ProcessObject:: +SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg ) +{ + this->m_MPRViewer = wdg; } // ------------------------------------------------------------------------- @@ -119,38 +149,16 @@ bool cpPlugins::Interface::ProcessObject:: ExecConfigurationDialog( QWidget* parent ) { bool r = false; - #ifdef cpPlugins_Interface_QT4 - - if( this->m_ParametersDialog == NULL ) + if( this->m_ParametersDialog != NULL ) { - this->m_ParametersDialog = new ParametersQtDialog( parent ); - this->m_ParametersDialog->setTitle( - this->GetClassName( ) + std::string( " basic configuration" ) - ); + this->m_ParametersDialog->setParent( NULL ); this->m_ParametersDialog->setParameters( this->m_Parameters ); - - } // fi - - if( !( this->m_ParametersDialog->IsModal( ) ) ) - { - this->m_ParametersDialog->show( ); - r = true; + r = ( this->m_ParametersDialog->exec( ) == 1 ); } else - r = ( this->m_ParametersDialog->exec( ) == 1 ); - - /* - r = cpPlugins::Interface::ParametersQtDialog( - this->m_Parameters, - this->GetClassName( ) + std::string( " basic configuration" ), - parent - ); - if( r ) - */ - + r = false; #endif // cpPlugins_Interface_QT4 - return( r ); } @@ -158,27 +166,51 @@ ExecConfigurationDialog( QWidget* parent ) cpPlugins::Interface::ProcessObject:: ProcessObject( ) : Superclass( ), - m_ITKObject( NULL ), - m_VTKObject( NULL ), - m_ParametersDialog( NULL ) + m_ParametersDialog( NULL ), + m_MPRViewer( NULL ) { this->m_Parameters = TParameters::New( ); + this->m_Parameters->SetProcessObject( this ); + +#ifdef cpPlugins_Interface_QT4 + if( QApplication::instance( ) != NULL ) + this->m_ParametersDialog = new ParametersQtDialog( ); +#endif // cpPlugins_Interface_QT4 } // ------------------------------------------------------------------------- cpPlugins::Interface::ProcessObject:: ~ProcessObject( ) { - if( this->m_ParametersDialog == NULL ) +#ifdef cpPlugins_Interface_QT4 + if( this->m_ParametersDialog != NULL ) delete this->m_ParametersDialog; +#endif // cpPlugins_Interface_QT4 + + /* + auto iIt = this->m_Inputs.begin( ); + for( ; iIt != this->m_Inputs.end( ); ++iIt ) + delete iIt->second; + this->m_Inputs.clear( ); + */ + + auto oIt = this->m_Outputs.begin( ); + for( ; oIt != this->m_Outputs.end( ); ++oIt ) + delete oIt->second; + this->m_Outputs.clear( ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: _AddInput( const std::string& name ) { - this->m_Inputs[ name ] = NULL; - this->Modified( ); + auto i = this->m_Inputs.find( name ); + if( i == this->m_Inputs.end( ) ) + { + this->m_Inputs[ name ] = NULL; + this->Modified( ); + + } // fi } // eof - $RCSfile$