]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/MainWindow.cxx
..
[cpPlugins.git] / lib / cpBaseQtApplication / MainWindow.cxx
index 0b67e49f5df7d297b19f8fd05e640b3613f321fd..9b16236acb94760f09af7f12bf3fb1f8d7e8c6ad 100644 (file)
@@ -1,5 +1,8 @@
 #include <cpBaseQtApplication/MainWindow.h>
 #include <cpBaseQtApplication/Plugins/Navigator.h>
+#include <cpBaseQtApplication/Pipeline/Canvas.h>
+#include <cpExtensions/QT/ConfigurationChooser.h>
+#include <cpExtensions/QT/ActorsWidgetInterface.h>
 
 #include <QDir>
 #include <QFileDialog>
@@ -13,6 +16,8 @@ MainWindow(
   )
   : Superclass( parent ),
     m_LastSaveFileName( "" ),
+    m_SingleWorkspace( false ),
+    m_BaseWindowTitle( "cpBaseQtApplication" ),
     m_Canvas( NULL ),
     m_Navigator( NULL ),
     m_Viewer( NULL )
@@ -128,6 +133,14 @@ void cpBaseQtApplication::MainWindow::
 setViewer( cpExtensions::QT::ActorsWidgetInterface* v )
 {
   this->m_Viewer = v;
+  if( this->m_Viewer != NULL )
+  {
+    auto interactors = this->m_Viewer->GetInteractors( );
+    for( auto wIt : this->m_Workspaces )
+      for( auto i : interactors )
+        wIt.second->AddInteractor( i );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -216,7 +229,23 @@ _addWorkspace( const std::string& name )
 {
   auto wIt = this->m_Workspaces.find( name );
   if( wIt == this->m_Workspaces.end( ) )
+  {
+    if( this->m_SingleWorkspace )
+      this->m_Workspaces.clear( );
     this->m_Workspaces[ name ] = TWorkspace::New( );
+    if( this->m_Canvas != NULL )
+      this->m_Canvas->setWorkspace( this->m_Workspaces[ name ] );
+    if( this->m_Viewer !=  NULL )
+    {
+      auto interactors = this->m_Viewer->GetInteractors( );
+      auto wIt = this->m_Workspaces.find( name );
+      for( auto i : interactors )
+        wIt->second->AddInteractor( i );
+
+    } // fi
+    this->setWindowTitle( ( this->m_BaseWindowTitle + name ).c_str( ) );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -349,6 +378,8 @@ _loadWorkspace( const std::string& fname )
   {
     this->_addWorkspace( fname );
     this->m_Workspaces[ fname ]->Load( fname );
+    if( this->m_Canvas != NULL )
+      this->m_Canvas->setWorkspace( this->m_Workspaces[ fname ] );
   }
   catch( std::exception& err )
   {
@@ -377,4 +408,21 @@ _loadWorkspace( )
   this->_loadWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
 }
 
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_actorsProperties( )
+{
+  auto data =
+    dynamic_cast< cpExtensions::QT::ActorsWidgetInterface* >(
+      this->m_Viewer
+      );
+  if( data != NULL )
+  {
+    auto dlg = new cpExtensions::QT::ConfigurationChooser( this );
+    dlg->setData( data );
+    dlg->exec( );
+
+  } // fi
+}
+
 // eof - $RCSfile$