From: Leonardo Florez-Valencia Date: Fri, 29 Jan 2016 23:09:22 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~256 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f69098bd941d8753926760dead2792584eb95f53;p=cpPlugins.git ... --- diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index b6161de..ad1e23c 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -27,6 +27,7 @@ ENDFOREACH(prog) SET( EXAMPLES_PROGRAMS_WITH_PLUGINS + example_SphereSource #example_ReadWriteImage #example_MarchingCubes #example_MPR diff --git a/appli/examples/example_SphereSource.cxx b/appli/examples/example_SphereSource.cxx new file mode 100644 index 0000000..75e99a3 --- /dev/null +++ b/appli/examples/example_SphereSource.cxx @@ -0,0 +1,54 @@ +#include +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +typedef cpPlugins::Interface::Interface TInterface; +typedef cpPlugins::Interface::ProcessObject TFilter; + +// ------------------------------------------------------------------------- +int main( int argc, char* argv[] ) +{ + if( argc < 6 ) + { + std::cerr + << "Usage: " << argv[ 0 ] + << " plugins_dir" + << " radius phi_res theta_res output_mesh" << std::endl; + return( 1 ); + + } // fi + + // Create interface and load plugins + TInterface interface; + if( interface.LoadFromFolder( argv[ 1 ], true ) ) + { + TFilter::Pointer source = + interface.CreateObject( "cpPlugins::BasicFilters::SphereMeshSource" ); + TFilter::Pointer writer = + interface.CreateObject( "cpPlugins::IO::MeshWriter" ); + + // Configure source + source->GetParameters( )->SetString( "Radius", argv[ 2 ], true ); + source->GetParameters( )->SetString( "PhiResolution", argv[ 3 ], true ); + source->GetParameters( )->SetString( "ThetaResolution", argv[ 4 ], true ); + + // Configure writer + writer->GetParameters( )->SetString( "FileName", argv[ 5 ], true ); + + // Connect filters + writer->SetInput( "Input", source->GetOutput( "Output" ) ); + + // Execute pipeline + std::cout << "Error: \"" << writer->Update( ) << "\"" << std::endl; + } + else + std::cerr << "No plugins found." << std::endl; + + return( 0 ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPipelineEditor/Block.cxx b/lib/cpPipelineEditor/Block.cxx index 0cc3bd4..61938a7 100644 --- a/lib/cpPipelineEditor/Block.cxx +++ b/lib/cpPipelineEditor/Block.cxx @@ -9,6 +9,8 @@ #include #include +#include + #include "Port.h" #include "Connection.h" #include "Editor.h" @@ -285,7 +287,7 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt ) QAction* selectedAction = menu.exec( evt->screenPos( ) ); if( selectedAction == configureAction ) - auto res = this->m_Filter->ExecConfigurationDialog( NULL ); + this->m_Filter->GetParametersDialog( )->exec( ); else if( selectedAction == updateAction ) this->m_Editor->updateFilter( this->namePort( ).toStdString( ) ); } diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 5434319..1128fe1 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -1,4 +1,5 @@ #include +#include #ifdef cpPlugins_Interface_QT4 #include @@ -6,16 +7,13 @@ #include #endif // cpPlugins_Interface_QT4 -#include - // ------------------------------------------------------------------------- std::set< std::string > cpPlugins::Interface::ProcessObject:: GetInputsNames( ) const { std::set< std::string > names; - auto dIt = this->m_Inputs.begin( ); - for( ; dIt != this->m_Inputs.end( ); ++dIt ) - names.insert( dIt->first ); + for( auto i = this->m_Inputs.begin( ); i != this->m_Inputs.end( ); ++i ) + names.insert( i->first ); return( names ); } @@ -24,9 +22,8 @@ std::set< std::string > cpPlugins::Interface::ProcessObject:: GetOutputsNames( ) const { std::set< std::string > names; - auto dIt = this->m_Outputs.begin( ); - for( ; dIt != this->m_Outputs.end( ); ++dIt ) - names.insert( dIt->first ); + for( auto i = this->m_Outputs.begin( ); i != this->m_Outputs.end( ); ++i ) + names.insert( i->first ); return( names ); } @@ -44,16 +41,43 @@ GetNumberOfOutputs( ) const return( this->m_Outputs.size( ) ); } +// ------------------------------------------------------------------------- +cpPlugins::Interface:: +ProcessObjectPort& cpPlugins::Interface::ProcessObject:: +GetOutput( const std::string& id ) +{ + static ProcessObjectPort null_port; + auto i = this->m_Outputs.find( id ); + if( i == this->m_Outputs.end( ) ) + { + null_port = NULL; + return( null_port ); + } + else + return( i->second ); +} + +// ------------------------------------------------------------------------- +const cpPlugins::Interface:: +ProcessObjectPort& cpPlugins::Interface::ProcessObject:: +GetOutput( const std::string& id ) const +{ + static const ProcessObjectPort null_port; + auto i = this->m_Outputs.find( id ); + if( i == this->m_Outputs.end( ) ) + return( null_port ); + else + return( i->second ); +} + // ------------------------------------------------------------------------- bool cpPlugins::Interface::ProcessObject:: -SetInput( - const std::string& id, cpPlugins::Interface::DataObject::Pointer* dobj - ) +SetInput( const std::string& id, const ProcessObjectPort& port ) { - _TDataContainer::iterator i = this->m_Inputs.find( id ); + auto i = this->m_Inputs.find( id ); if( i != this->m_Inputs.end( ) ) { - i->second = dobj; + i->second = port; this->Modified( ); return( true ); } @@ -62,103 +86,92 @@ SetInput( } // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ProcessObject:: -Update( ) +void cpPlugins::Interface::ProcessObject:: +DisconnectInputs( ) { - std::string r = ""; - - // Force upstream updates - _TDataContainer::iterator i = this->m_Inputs.begin( ); - for( ; i != this->m_Inputs.end( ) && r == ""; ++i ) - { - 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( ); - - // Return error description, if any - return( r ); + auto i = this->m_Inputs.begin( ); + for( ; i != this->m_Inputs.end( ); ++i ) + i->second = NULL; + this->Modified( ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: DisconnectOutputs( ) { - _TDataContainer::iterator i = this->m_Outputs.begin( ); + auto i = this->m_Outputs.begin( ); for( ; i != this->m_Outputs.end( ); ++i ) - if( i->second->IsNotNull( ) ) - ( *( i->second ) )->DisconnectPipeline( ); + if( i->second.IsValid( ) ) + i->second->DisconnectPipeline( ); + this->Modified( ); } // ------------------------------------------------------------------------- -vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject:: -GetSingleInteractor( ) +void cpPlugins::Interface::ProcessObject:: +Disconnect( ) { - return( this->m_SingleInteractor ); + this->DisconnectInputs( ); + this->DisconnectOutputs( ); } // ------------------------------------------------------------------------- -const vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject:: -GetSingleInteractor( ) const +itk::ModifiedTimeType cpPlugins::Interface::ProcessObject:: +GetMTime( ) const { - return( this->m_SingleInteractor ); + auto params_time = this->m_Parameters->GetMTime( ); + auto filter_time = this->Superclass::GetMTime( ); + auto ipobj = this->GetITK< itk::ProcessObject >( ); + if( ipobj == NULL ) + { + auto vpobj = this->GetVTK< vtkAlgorithm >( ); + if( vpobj != NULL ) + filter_time = ( const_cast< vtkAlgorithm* >( vpobj ) )->GetMTime( ); + } + else + filter_time = ipobj->GetMTime( ); + return( ( params_time < filter_time )? filter_time: params_time ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -SetSingleInteractor( vtkRenderWindowInteractor* interactor ) +std::string cpPlugins::Interface::ProcessObject:: +Update( ) { - this->m_SingleInteractor = interactor; -} + static + std::string r = ""; -// ------------------------------------------------------------------------- -cpPlugins::Interface:: -SimpleMPRWidget* cpPlugins::Interface::ProcessObject:: -GetMPRViewer( ) -{ - return( this->m_MPRViewer ); -} + // Force upstream updates + _TDataContainer::iterator i = this->m_Inputs.begin( ); + bool need_to_update = false; + for( ; i != this->m_Inputs.end( ) && r == ""; ++i ) + { + if( i->second.IsValid( ) ) + { + Self* src = dynamic_cast< Self* >( i->second->GetSource( ) ); + if( src != NULL ) + { + need_to_update |= ( this->m_LastExecutionTime < src->GetMTime( ) ); + r = src->Update( ); -// ------------------------------------------------------------------------- -const cpPlugins::Interface:: -SimpleMPRWidget* cpPlugins::Interface::ProcessObject:: -GetMPRViewer( ) const -{ - return( this->m_MPRViewer ); -} + } // fi + } + else + r = "cpPlugins::Interface::ProcessObject: No input connected."; -// ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg ) -{ - this->m_MPRViewer = wdg; -} + } // rof -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::ProcessObject:: -ExecConfigurationDialog( QWidget* parent ) -{ - bool r = false; -#ifdef cpPlugins_Interface_QT4 - if( this->m_ParametersDialog != NULL ) + // Current update + if( r == "" ) { - this->m_ParametersDialog->setParent( NULL ); - this->m_ParametersDialog->setParameters( this->m_Parameters ); - r = ( this->m_ParametersDialog->exec( ) == 1 ); - } - else - r = false; -#endif // cpPlugins_Interface_QT4 + if( this->m_LastExecutionTime < this->GetMTime( ) || need_to_update ) + { + r = this->_GenerateData( ); + this->m_LastExecutionTime = this->GetMTime( ); + + } // fi + + } // fi + + // Return error description, if any return( r ); } @@ -166,6 +179,7 @@ ExecConfigurationDialog( QWidget* parent ) cpPlugins::Interface::ProcessObject:: ProcessObject( ) : Superclass( ), + m_LastExecutionTime( 0 ), m_ParametersDialog( NULL ), m_MPRViewer( NULL ) { @@ -174,7 +188,11 @@ ProcessObject( ) #ifdef cpPlugins_Interface_QT4 if( QApplication::instance( ) != NULL ) + { this->m_ParametersDialog = new ParametersQtDialog( ); + this->m_ParametersDialog->setParameters( this->m_Parameters ); + + } // fi #endif // cpPlugins_Interface_QT4 } @@ -182,35 +200,19 @@ ProcessObject( ) cpPlugins::Interface::ProcessObject:: ~ProcessObject( ) { -#ifdef cpPlugins_Interface_QT4 + this->Disconnect( ); 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 ) { + typedef typename _TDataContainer::value_type _TValue; auto i = this->m_Inputs.find( name ); if( i == this->m_Inputs.end( ) ) - { - this->m_Inputs[ name ] = NULL; - this->Modified( ); - - } // fi + i = this->m_Inputs.insert( _TValue( name, NULL ) ).first; } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index ec6cb2a..862da18 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -1,20 +1,15 @@ #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__ #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__ +#include #include #include - -#include +#include #include // Some forward declarations class vtkRenderWindowInteractor; -#ifdef cpPlugins_Interface_QT4 -class QWidget; -#else -typedef char QWidget; -#endif // cpPlugins_Interface_QT4 namespace cpPlugins { @@ -48,75 +43,55 @@ namespace cpPlugins itkTypeMacro( ProcessObject, Object ); cpPlugins_Id_Macro( ProcessObject, BaseObject ); - itkBooleanMacro( Interactive ); - itkGetConstMacro( Interactive, bool ); - itkSetMacro( Interactive, bool ); - itkGetConstObjectMacro( Parameters, TParameters ); + itkGetObjectMacro( Parameters, TParameters ); + itkGetMacro( ParametersDialog, ParametersQtDialog* ); + itkGetMacro( SingleInteractor, vtkRenderWindowInteractor* ); + itkGetMacro( MPRViewer, SimpleMPRWidget* ); + + itkSetObjectMacro( ParametersDialog, ParametersQtDialog ); + itkSetObjectMacro( SingleInteractor, vtkRenderWindowInteractor ); + itkSetObjectMacro( MPRViewer, SimpleMPRWidget ); public: - virtual std::set< std::string > GetInputsNames( ) const; - virtual std::set< std::string > GetOutputsNames( ) const; + // IO management + std::set< std::string > GetInputsNames( ) const; + std::set< std::string > GetOutputsNames( ) const; unsigned int GetNumberOfInputs( ) const; unsigned int GetNumberOfOutputs( ) const; - virtual bool SetInput( const std::string& id, DataObject::Pointer* dobj ); - - virtual std::string Update( ); - virtual void DisconnectOutputs( ); - - // Widgets management - vtkRenderWindowInteractor* GetSingleInteractor( ); - const vtkRenderWindowInteractor* GetSingleInteractor( ) const; - void SetSingleInteractor( vtkRenderWindowInteractor* interactor ); - SimpleMPRWidget* GetMPRViewer( ); - const SimpleMPRWidget* GetMPRViewer( ) const; - void SetMPRViewer( SimpleMPRWidget* wdg ); - virtual bool ExecConfigurationDialog( QWidget* parent ); + ProcessObjectPort& GetOutput( const std::string& id ); + const ProcessObjectPort& GetOutput( const std::string& id ) const; template< class T > inline T* GetInputData( const std::string& id ); - template< class T > inline const T* GetInputData( const std::string& id ) const; - template< class T > inline T* GetOutputData( const std::string& id ); - template< class T > inline const T* GetOutputData( const std::string& id ) const; - DataObject::Pointer* GetOutputPort( const std::string& id ) - { - auto i = this->m_Outputs.find( id ); - if( i != this->m_Outputs.end( ) ) - return( i->second ); - else - return( NULL ); - } - - const DataObject::Pointer* GetOutputPort( const std::string& id ) const - { - auto i = this->m_Outputs.find( id ); - if( i != this->m_Outputs.end( ) ) - return( i->second ); - else - return( NULL ); - } + bool SetInput( const std::string& id, const ProcessObjectPort& port ); + + void DisconnectInputs( ); + void DisconnectOutputs( ); + void Disconnect( ); + + // Pipeline execution + virtual itk::ModifiedTimeType GetMTime( ) const; + virtual std::string Update( ); protected: ProcessObject( ); virtual ~ProcessObject( ); - virtual void _AddInput( const std::string& name ); - + void _AddInput( const std::string& name ); template< class O > - inline void _AddOutput( const std::string& id ); - + inline void _AddOutput( const std::string& name ); template< class F > inline F* _CreateITK( ); - template< class F > inline F* _CreateVTK( ); @@ -128,16 +103,16 @@ namespace cpPlugins Self& operator=( const Self& ); protected: + typedef std::map< std::string, ProcessObjectPort > _TDataContainer; + _TDataContainer m_Inputs; + _TDataContainer m_Outputs; Parameters::Pointer m_Parameters; - ParametersQtDialog* m_ParametersDialog; - vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor; - SimpleMPRWidget* m_MPRViewer; - bool m_Interactive; + itk::ModifiedTimeType m_LastExecutionTime; - typedef std::map< std::string, DataObject::Pointer* > _TDataContainer; - _TDataContainer m_Inputs; - _TDataContainer m_Outputs; + ParametersQtDialog* m_ParametersDialog; + vtkRenderWindowInteractor* m_SingleInteractor; + SimpleMPRWidget* m_MPRViewer; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/ProcessObject.hxx b/lib/cpPlugins/Interface/ProcessObject.hxx index a3362fc..1b691ff 100644 --- a/lib/cpPlugins/Interface/ProcessObject.hxx +++ b/lib/cpPlugins/Interface/ProcessObject.hxx @@ -6,9 +6,9 @@ template< class T > T* cpPlugins::Interface::ProcessObject:: GetInputData( const std::string& id ) { - _TDataContainer::iterator i = this->m_Inputs.find( id ); + auto i = this->m_Inputs.find( id ); if( i != this->m_Inputs.end( ) ) - return( dynamic_cast< T* >( i->second->GetPointer( ) ) ); + return( dynamic_cast< T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -18,9 +18,9 @@ template< class T > const T* cpPlugins::Interface::ProcessObject:: GetInputData( const std::string& id ) const { - _TDataContainer::const_iterator i = this->m_Inputs.find( id ); + auto i = this->m_Inputs.find( id ); if( i != this->m_Inputs.end( ) ) - return( dynamic_cast< const T* >( i->second->GetPointer( ) ) ); + return( dynamic_cast< const T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -30,9 +30,9 @@ template< class T > T* cpPlugins::Interface::ProcessObject:: GetOutputData( const std::string& id ) { - _TDataContainer::iterator i = this->m_Outputs.find( id ); + auto i = this->m_Outputs.find( id ); if( i != this->m_Outputs.end( ) ) - return( dynamic_cast< T* >( i->second->GetPointer( ) ) ); + return( dynamic_cast< T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -42,9 +42,9 @@ template< class T > const T* cpPlugins::Interface::ProcessObject:: GetOutputData( const std::string& id ) const { - _TDataContainer::const_iterator i = this->m_Outputs.find( id ); + auto i = this->m_Outputs.find( id ); if( i != this->m_Outputs.end( ) ) - return( dynamic_cast< const T* >( i->second->GetPointer( ) ) ); + return( dynamic_cast< const T* >( i->second.GetPointer( ) ) ); else return( NULL ); } @@ -52,18 +52,17 @@ GetOutputData( const std::string& id ) const // ------------------------------------------------------------------------- template< class O > void cpPlugins::Interface::ProcessObject:: -_AddOutput( const std::string& id ) +_AddOutput( const std::string& name ) { - auto oIt = this->m_Outputs.find( id ); - if( oIt == this->m_Outputs.end( ) ) + typedef typename _TDataContainer::value_type _TValue; + auto i = this->m_Outputs.find( name ); + if( i == this->m_Outputs.end( ) ) { - this->m_Outputs[ id ] = new DataObject::Pointer( ); - oIt = this->m_Outputs.find( id ); + typename O::Pointer o = O::New( ); + o->SetSource( this ); + this->m_Outputs[ name ] = o; } // fi - *( oIt->second ) = O::New( ); - ( *( oIt->second ) )->SetSource( this ); - this->Modified( ); } // ------------------------------------------------------------------------- @@ -71,13 +70,13 @@ template< class F > F* cpPlugins::Interface::ProcessObject:: _CreateITK( ) { - F* filter = dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) ); + F* filter = this->GetITK< F >( ); if( filter == NULL ) { - typename F::Pointer ptr = F::New( ); - this->m_ITKObject = ptr; - filter = ptr.GetPointer( ); - this->m_VTKObject = NULL; + typename F::Pointer filter_ptr = F::New( ); + this->SetITK( filter_ptr.GetPointer( ) ); + this->SetVTK( NULL ); + filter = filter_ptr.GetPointer( ); } // fi return( filter ); @@ -88,12 +87,13 @@ template< class F > F* cpPlugins::Interface::ProcessObject:: _CreateVTK( ) { - F* filter = dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) ); + F* filter = this->GetVTK< F >( ); if( filter == NULL ) { - filter = F::New( ); - this->m_VTKObject = filter; - this->m_ITKObject = NULL; + vtkSmartPointer< F > filter_ptr = vtkSmartPointer< F >::New( ); + this->SetITK( NULL ); + this->SetVTK( filter_ptr ); + filter = filter_ptr.GetPointer( ); } // fi return( filter ); diff --git a/lib/cpPlugins/Interface/ProcessObjectPort.cxx b/lib/cpPlugins/Interface/ProcessObjectPort.cxx new file mode 100644 index 0000000..cec8fac --- /dev/null +++ b/lib/cpPlugins/Interface/ProcessObjectPort.cxx @@ -0,0 +1,55 @@ +#include + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObjectPort:: +ProcessObjectPort( ) +{ + this->m_Data = NULL; +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObjectPort:: +ProcessObjectPort( DataObject* obj ) +{ + this->m_Data = obj; +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObjectPort:: +ProcessObjectPort( const Self& other ) +{ + this->m_Data = other.m_Data.GetPointer( ); +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObjectPort:: +~ProcessObjectPort( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObjectPort:: +Self& cpPlugins::Interface::ProcessObjectPort:: +operator=( DataObject* obj ) +{ + this->m_Data = obj; + return( *this ); +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObjectPort:: +Self& cpPlugins::Interface::ProcessObjectPort:: +operator=( const Self& other ) +{ + this->m_Data = other.m_Data.GetPointer( ); + return( *this ); +} + +// ------------------------------------------------------------------------- +bool cpPlugins::Interface::ProcessObjectPort:: +IsValid( ) const +{ + return( this->m_Data.IsNotNull( ) ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ProcessObjectPort.h b/lib/cpPlugins/Interface/ProcessObjectPort.h new file mode 100644 index 0000000..393fd53 --- /dev/null +++ b/lib/cpPlugins/Interface/ProcessObjectPort.h @@ -0,0 +1,46 @@ +#ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECTPORT__H__ +#define __CPPLUGINS__INTERFACE__PROCESSOBJECTPORT__H__ + +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT ProcessObjectPort + { + public: + typedef ProcessObjectPort Self; + + public: + ProcessObjectPort( ); + ProcessObjectPort( DataObject* obj ); + ProcessObjectPort( const Self& other ); + virtual ~ProcessObjectPort( ); + Self& operator=( DataObject* obj ); + Self& operator=( const Self& other ); + + bool IsValid( ) const; + + // This could be seen as a pointer to DataObject's + DataObject* GetPointer( ) + { return( this->m_Data.GetPointer( ) ); } + const DataObject* GetPointer( ) const + { return( this->m_Data.GetPointer( ) ); } + DataObject* operator->( ) const + { return( this->m_Data.GetPointer( ) ); } + + protected: + cpPlugins::Interface::DataObject::Pointer m_Data; + + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__PROCESSOBJECTPORT__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index b37c2ca..c56897e 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -211,27 +211,30 @@ Connect( return( false ); // Real connection - dest->SetInput( input_name, orig->GetOutputPort( output_name ) ); - this->m_Graph->AddEdge( - orig_filter, dest_filter, - TConnection( output_name, input_name ) - ); - return( false ); + if( dest->SetInput( input_name, orig->GetOutput( output_name ) ) ) + { + this->m_Graph->AddEdge( + orig_filter, dest_filter, + TConnection( output_name, input_name ) + ); + return( true ); + } + else + return( false ); } // ------------------------------------------------------------------------- bool cpPlugins::Interface::Workspace:: -Connect( TData::Pointer* input_object, const std::string& input_name ) +Connect( + const ProcessObjectPort& input_port, const std::string& exposed_port + ) { - auto port = this->m_ExposedInputPorts.find( input_name ); + auto port = this->m_ExposedInputPorts.find( exposed_port ); if( port != this->m_ExposedInputPorts.end( ) ) { TFilter* filter = this->GetFilter( port->second.first ); if( filter != NULL ) - { - filter->SetInput( port->second.second, input_object ); - return( true ); - } + return( filter->SetInput( port->second.second, input_port ) ); else return( false ); } diff --git a/lib/cpPlugins/Interface/Workspace.h b/lib/cpPlugins/Interface/Workspace.h index b4c4641..be85418 100644 --- a/lib/cpPlugins/Interface/Workspace.h +++ b/lib/cpPlugins/Interface/Workspace.h @@ -93,7 +93,7 @@ namespace cpPlugins const std::string& output_name, const std::string& input_name ); bool Connect( - TData::Pointer* input_object, const std::string& exposed_port + const ProcessObjectPort& input_port, const std::string& exposed_port ); void RemoveConnection( const std::string& dest_filter, const std::string& input_name diff --git a/lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx b/lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx index 78d5da4..957136d 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx @@ -26,7 +26,7 @@ _GenerateData( ) return( "InputDataReproducer: No input/output ports." ); // Connect output - *( o->second ) = *( i->second ); + o->second = i->second; return( "" ); } diff --git a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx index f989635..53e39f0 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx @@ -10,7 +10,7 @@ cpPlugins::BasicFilters::SphereMeshSource:: SphereMeshSource( ) : Superclass( ) { - this->_AddInput( "Center" ); + // TODO: this->_AddInput( "Center" ); this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" ); this->m_Parameters->ConfigureAsReal( "Radius" ); diff --git a/lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx b/lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx index 4841bcf..ef7c581 100644 --- a/lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx +++ b/lib/cpPlugins/Plugins/IO/DicomSeriesReader.cxx @@ -20,6 +20,7 @@ #include // ------------------------------------------------------------------------- +/* bool cpPlugins::IO::DicomSeriesReader:: ExecConfigurationDialog( QWidget* parent ) { @@ -185,6 +186,7 @@ ExecConfigurationDialog( QWidget* parent ) return( r ); } +*/ // ------------------------------------------------------------------------- cpPlugins::IO::DicomSeriesReader:: diff --git a/lib/cpPlugins/Plugins/IO/DicomSeriesReader.h b/lib/cpPlugins/Plugins/IO/DicomSeriesReader.h index 1d619d0..968932f 100644 --- a/lib/cpPlugins/Plugins/IO/DicomSeriesReader.h +++ b/lib/cpPlugins/Plugins/IO/DicomSeriesReader.h @@ -34,8 +34,10 @@ namespace cpPlugins itkTypeMacro( DicomSeriesReader, ImageReader ); cpPlugins_Id_Macro( cpPlugins::IO::DicomSeriesReader, IO ); - public: - virtual bool ExecConfigurationDialog( QWidget* parent ); + /* TODO + public: + virtual bool ExecConfigurationDialog( QWidget* parent ); + */ protected: DicomSeriesReader( ); diff --git a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx index c5c8383..97e96fa 100644 --- a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx +++ b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx @@ -100,7 +100,7 @@ _GD0( itk::DataObject* image ) } // fi // Single interactor - _S* s = dynamic_cast< _S* >( this->m_SingleInteractor.GetPointer( ) ); + _S* s = dynamic_cast< _S* >( this->m_SingleInteractor ); if( s != NULL ) { if( this->m_Configured )