]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Workspace.cxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.cxx
index 67eaf0a677b3937809c3f5431fc9023a68aea909..c56897e2b1cbc317f67b6397d2736d35fb42505e 100644 (file)
@@ -1,9 +1,12 @@
 #include <cpPlugins/Interface/Workspace.h>
+#include <cpPlugins/Interface/SimpleMPRWidget.h>
+#include <vtkRenderWindowInteractor.h>
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Workspace::
 Workspace( )
-  : m_Plugins( NULL )
+  : m_Plugins( NULL ),
+    m_MPRViewer( NULL )
 {
   this->m_Graph = TGraph::New( );
 }
@@ -103,11 +106,12 @@ HasFilter( const std::string& name ) const
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Workspace::
+cpPlugins::Interface::Workspace::
+TFilter* cpPlugins::Interface::Workspace::
 CreateFilter( const std::string& filter, const std::string& name )
 {
   if( this->m_Plugins == NULL )
-    return( false );
+    return( NULL );
 
   // Get or create new filter from name
   if( !( this->m_Graph->HasVertexIndex( name ) ) )
@@ -116,15 +120,17 @@ CreateFilter( const std::string& filter, const std::string& name )
     if( f.IsNotNull( ) )
     {
       f->SetName( name );
+      f->SetSingleInteractor( this->m_SingleInteractor );
+      f->SetMPRViewer( this->m_MPRViewer );
+      
       TObject::Pointer o = f.GetPointer( );
       this->m_Graph->SetVertex( name, o );
-      return( true );
-    }
-    else
-      return( false );
+
+    } // fi
+    return( f.GetPointer( ) );
   }
   else
-    return( true );
+    return( this->GetFilter( name ) );
 }
 
 // -------------------------------------------------------------------------
@@ -147,6 +153,50 @@ RemoveFilter( const std::string& name )
 {
 }
 
+// -------------------------------------------------------------------------
+vtkRenderWindowInteractor* cpPlugins::Interface::Workspace::
+GetSingleInteractor( )
+{
+  return( this->m_SingleInteractor );
+}
+
+// -------------------------------------------------------------------------
+const vtkRenderWindowInteractor* cpPlugins::Interface::Workspace::
+GetSingleInteractor( ) const
+{
+  return( this->m_SingleInteractor );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+SetSingleInteractor( vtkRenderWindowInteractor* interactor )
+{
+  this->m_SingleInteractor = interactor;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::
+SimpleMPRWidget* cpPlugins::Interface::Workspace::
+GetMPRViewer( )
+{
+  return( this->m_MPRViewer );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::
+SimpleMPRWidget* cpPlugins::Interface::Workspace::
+GetMPRViewer( ) const
+{
+  return( this->m_MPRViewer );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg )
+{
+  this->m_MPRViewer = wdg;
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
 Connect(
@@ -161,27 +211,30 @@ Connect(
     return( false );
 
   // Real connection
-  dest->SetInput( input_name, orig->GetOutput< TData >( 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* 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 );
   }
@@ -294,7 +347,7 @@ GetExposedOutputPorts( ) const
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::Workspace::
-Execute( QWidget* p )
+Execute( )
 {
   // Find sinks
   std::set< std::string > sinks = this->m_Graph->GetSinks( );
@@ -303,7 +356,7 @@ Execute( QWidget* p )
   std::string err = "";
   for( auto sIt = sinks.begin( ); sIt != sinks.end( ); ++sIt )
   {
-    std::string lerr = this->Execute( *sIt, p );
+    std::string lerr = this->Execute( *sIt );
     if( lerr != "" )
       err += lerr + std::string( "\n" );
 
@@ -313,7 +366,7 @@ Execute( QWidget* p )
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::Workspace::
-Execute( const std::string& name, QWidget* p )
+Execute( const std::string& name )
 {
   // Get filter
   TFilter* f = this->GetFilter( name );
@@ -324,16 +377,7 @@ Execute( const std::string& name, QWidget* p )
       );
 
   // Execute and return
-  if( p != NULL )
-  {
-    auto diag_res = f->ExecConfigurationDialog( p );
-    if( diag_res == TFilter::DialogResult_NoModal )
-      return( f->Update( ) );
-    else
-      return( "" );
-  }
-  else
-    return( f->Update( ) );
+  return( f->Update( ) );
 }
 
 // eof - $RCSfile$