X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcpPlugins%2FInterface%2FWorkspace.cxx;h=5b80a36bb9a19f392bf941be9a7c9fd4f7cd3d90;hb=b41426f0faaee22357b16793efc0f741b039bc41;hp=bdc67e000d0c351e8a7e68ad39276fdc9e50ea4f;hpb=2fed0327528e671e32cc7151cb65ebd769c053e6;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index bdc67e0..5b80a36 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -232,6 +232,48 @@ Connect( return( ok ); } +// ------------------------------------------------------------------------- +bool cpPlugins::Interface::Workspace:: +Connect( + TDataObject* input, + const std::string& destination_filter, + const std::string& destination_input + ) +{ + // Get filters and check pertinence + if( input == NULL ) + return( false ); + TFilter* destination = this->GetFilter( destination_filter ); + if( destination == NULL ) + return( false ); + if( !( destination->HasInput( destination_input ) ) ) + return( false ); + + // Check if there is room for a new connection + bool ok = true; + if( destination->IsInputMultiple( destination_input ) ) + { + for( + unsigned int i = 0; + i < destination->GetInputSize( destination_input ); + ++i + ) + if( + destination->GetInput( destination_input, i )->GetSource( ) == + input->GetSource( ) + ) + ok = false; + } + else + ok = ( destination->GetInput( destination_input ) == NULL ); + if( ok ) + destination->AddInput( + destination_input, + input + ); + return( ok ); +} + // ------------------------------------------------------------------------- bool cpPlugins::Interface::Workspace:: Disconnect(