]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Workspace.cxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.cxx
index be724acf5f186989cb7ccbbf7a3e518375a4f309..b37c2caa8b5c92d2418c6450515389847350f3a3 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,7 +211,7 @@ Connect(
     return( false );
 
   // Real connection
-  dest->SetInput( input_name, orig->GetOutput< TData >( output_name ) );
+  dest->SetInput( input_name, orig->GetOutputPort( output_name ) );
   this->m_Graph->AddEdge(
     orig_filter, dest_filter,
     TConnection( output_name, input_name )
@@ -171,7 +221,7 @@ Connect(
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
-Connect( TData* input_object, const std::string& input_name )
+Connect( TData::Pointer* input_object, const std::string& input_name )
 {
   auto port = this->m_ExposedInputPorts.find( input_name );
   if( port != this->m_ExposedInputPorts.end( ) )
@@ -276,61 +326,25 @@ RenameExposedOutputPort(
     return( false );
 }
 
-// -------------------------------------------------------------------------
-/* TODO
-cpPlugins::Interface::Workspace::
-TData* cpPlugins::Interface::Workspace::
-GetOutput( const std::string& name )
-{
-  auto port = this->m_ExposedOutputPorts.find( name );
-  if( port != this->m_ExposedOutputPorts.end( ) )
-  {
-    TFilter* f = this->GetFilter( port->second.first );
-    if( f != NULL )
-      return( f->GetOutput< TData >( port->second.second ) );
-    else
-      return( NULL );
-  }
-  else
-    return( NULL );
-}
-
 // -------------------------------------------------------------------------
 const cpPlugins::Interface::Workspace::
-TData* cpPlugins::Interface::Workspace::
-GetOutput( const std::string& name ) const
+TExposedPorts& cpPlugins::Interface::Workspace::
+GetExposedInputPorts( ) const
 {
-  auto port = this->m_ExposedOutputPorts.find( name );
-  if( port != this->m_ExposedOutputPorts.end( ) )
-  {
-    const TFilter* f = this->GetFilter( port->second.first );
-    if( f != NULL )
-      return( f->GetOutput< TData >( port->second.second ) );
-    else
-      return( NULL );
-  }
-  else
-    return( NULL );
+  return( this->m_ExposedInputPorts );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-ClearInputPorts( )
-{
-  this->m_ExposedInputPorts.clear( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-ClearOutputPorts( )
+const cpPlugins::Interface::Workspace::
+TExposedPorts& cpPlugins::Interface::Workspace::
+GetExposedOutputPorts( ) const
 {
-  this->m_ExposedOutputPorts.clear( );
+  return( this->m_ExposedOutputPorts );
 }
-*/
 
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::Workspace::
-Execute( QWidget* p )
+Execute( )
 {
   // Find sinks
   std::set< std::string > sinks = this->m_Graph->GetSinks( );
@@ -339,7 +353,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" );
 
@@ -349,7 +363,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 );
@@ -360,16 +374,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$