]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Workspace.cxx
..
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.cxx
index bdc67e000d0c351e8a7e68ad39276fdc9e50ea4f..8eca62080671d2108b9bb02ec3c3faf6335bd201 100644 (file)
@@ -1,6 +1,35 @@
 #include <cpPlugins/Interface/Workspace.h>
 #include <cpPlugins/BaseObjects/Widget.h>
 
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Workspace::
+Pointer cpPlugins::Interface::Workspace::
+New( )
+{
+  Pointer smartPtr = new Self;
+  smartPtr->UnRegister( );
+  return( smartPtr );
+}
+
+// -------------------------------------------------------------------------
+itk::LightObject::Pointer cpPlugins::Interface::Workspace::
+CreateAnother( ) const
+{
+  itk::LightObject::Pointer smartPtr;
+  smartPtr = Self::New( ).GetPointer( );
+  return( smartPtr );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Workspace::
+Pointer cpPlugins::Interface::Workspace::
+Clone( ) const
+{
+  Pointer rval =
+    dynamic_cast< Self* >( this->InternalClone( ).GetPointer( ) );
+  return( rval );
+}
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
 Clear( )
@@ -232,6 +261,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(