]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/MainWindow.cxx
...
[cpPlugins.git] / lib / cpBaseQtApplication / MainWindow.cxx
index d70d4c014bca5b19988f95a417bfb165ab5b38b1..46312b14d025fbe67c58282a4707c84c953b4ea9 100644 (file)
@@ -3,6 +3,7 @@
 #include <cpExtensions/QT/SimpleMPRWidget.h>
 #include <cpBaseQtApplication/ActorPropertiesQDialog.h>
 #include <cpBaseQtApplication/Editor.h>
+#include <cpBaseQtApplication/PathsDialog.h>
 #include <vtkRenderer.h>
 #include <QApplication>
 #include <QColorDialog>
@@ -51,15 +52,16 @@ MainWindow(
   if( i.exists( ) )
   {
     this->m_ExecutionPath = i.canonicalPath( ).toStdString( );
-    try
-    {
-      this->m_Interface.OpenEnvironments( this->m_ExecutionPath );
-      this->m_Interface.UpdateEnvironments( this->m_ExecutionPath );
-    }
+    try { this->m_Interface.AddEnvironments( this->m_ExecutionPath ); }
+    catch( ... ) { }
+    try { this->m_Interface.OpenEnvironments( this->m_ExecutionPath ); }
+    catch( ... ) { }
+    try { this->m_Interface.SaveEnvironments( this->m_ExecutionPath ); }
     catch( ... ) { }
   }
   else
     this->m_ExecutionPath = "";
+  this->UpdateEnvironment( );
   this->m_Workspace.SetInterface( &( this->m_Interface ) );
 }
 
@@ -75,7 +77,7 @@ UpdateEnvironment( )
 {
   try
   {
-    this->m_Interface.LoadEnvironment( );
+    this->m_Interface.LoadEnvironments( );
     this->m_Interface.GuessPlugins( );
   }
   catch( std::exception& err )
@@ -147,6 +149,17 @@ _ClearWorkspace( )
   this->m_Workspace.Clear( );
 }
 
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_AddEnvironments( const std::string& environments )
+{
+  try { this->m_Interface.AddEnvironments( environments ); }
+  catch( ... ) { }
+  try { this->m_Interface.SaveEnvironments( this->m_ExecutionPath ); }
+  catch( ... ) { }
+  this->UpdateEnvironment( );
+}
+
 // -------------------------------------------------------------------------
 void cpBaseQtApplication::MainWindow::
 _LoadPlugins( const std::string& filename )
@@ -249,26 +262,6 @@ _UpdateLoadedPlugins( )
       );
 }
 
-// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_ShowPlugins( )
-{
-  auto paths = this->m_Interface.GetPaths( );
-  auto plugins = this->m_Interface.GetPlugins( );
-  std::stringstream info;
-  info << "-----   PATHS   -----" << std::endl;
-  for( auto i = paths.begin( ); i != paths.end( ); ++i )
-    info << "   " << *i << std::endl;
-  info << std::endl << "-----  PLUGINS  -----" << std::endl;
-  for( auto i = plugins.begin( ); i != plugins.end( ); ++i )
-    info << "   " << *i << std::endl;
-  QMessageBox::information(
-    this,
-    "Loaded libraries and plugins information",
-    info.str( ).c_str( )
-    );
-}
-
 // -------------------------------------------------------------------------
 void cpBaseQtApplication::MainWindow::
 _Block( )
@@ -485,6 +478,26 @@ _InteractiveLoadPluginsFromPath( )
   this->_LoadPluginsFromPath( d.selectedFiles( ).begin( )->toStdString( ) );
 }
 
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_ShowPlugins( )
+{
+  auto paths = this->m_Interface.GetPaths( );
+  auto plugins = this->m_Interface.GetPlugins( );
+  std::stringstream info;
+  info << "-----   PATHS   -----" << std::endl;
+  for( auto i = paths.begin( ); i != paths.end( ); ++i )
+    info << "   " << *i << std::endl;
+  info << std::endl << "-----  PLUGINS  -----" << std::endl;
+  for( auto i = plugins.begin( ); i != plugins.end( ); ++i )
+    info << "   " << *i << std::endl;
+  QMessageBox::information(
+    this,
+    "Loaded libraries and plugins information",
+    info.str( ).c_str( )
+    );
+}
+
 // -------------------------------------------------------------------------
 void cpBaseQtApplication::MainWindow::
 _InteractiveLoadWorkspace( )
@@ -518,6 +531,26 @@ _InteractiveSaveWorkspace( )
   this->_SaveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
 }
 
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_InteractiveAddEnviromentPaths( )
+{
+  PathsDialog dlg( this );
+  dlg.addPaths( this->m_Interface.GetPaths( ) );
+  if( dlg.exec( ) )
+  {
+    auto paths = dlg.getPaths( );
+    for( auto p = paths.begin( ); p != paths.end( ); ++p )
+    {
+      try { this->m_Interface.AddEnvironments( *p ); }
+      catch( ... ) { }
+
+    } // rof
+    this->UpdateEnvironment( );
+
+  } // fi
+}
+
 // -------------------------------------------------------------------------
 void cpBaseQtApplication::MainWindow::
 _ExecFilter( const std::string& filter_name )