]> SALOME platform Git repositories - modules/jobmanager.git/commitdiff
Salome HOME
Merge from V5_1_main 10/06/2010 V6_1_BR TRIPOLI_302 V6_1_0 V6_1_0a1 V6_1_0a2 V6_1_0rc1 V6_1_0rc2 V6_1_0rc3
authorvsr <vsr@opencascade.com>
Thu, 10 Jun 2010 11:05:39 +0000 (11:05 +0000)
committervsr <vsr@opencascade.com>
Thu, 10 Jun 2010 11:05:39 +0000 (11:05 +0000)
src/genericgui/BL_CreateJobWizard.cxx
src/genericgui/BL_GenericGui.cxx
src/genericgui/BL_GenericGui.hxx
src/salomegui/BL_SalomeGui.cxx
src/wrappers/BL_MainWindows_SALOME.cxx
src/wrappers/BL_MainWindows_SALOME.hxx

index 97da5a6f3ad78779d18aa2d21358a8f0a5bace06..a5a5b3479dda0e201f69fa3619077e96f5ab74ec 100644 (file)
 
 #include "BL_CreateJobWizard.hxx"
 #include "BL_JobsManager_QT.hxx"
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <stdlib.h>
 
 BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services)
 {
@@ -676,6 +680,17 @@ BL::FilesPage::FilesPage(BL::CreateJobWizard * parent)
   QPushButton * button_result = new QPushButton("Local Result directory");
   connect(button_result, SIGNAL(clicked()), this, SLOT(choose_local_directory()));
   _result_directory = new QLineEdit(this);
+
+  // Default result directory is home directory (if we found it)
+  // First try -> HOME
+  if (getenv("HOME"))
+    _result_directory->setText(getenv("HOME"));
+  else {
+    // Second try -> getpwuid
+    struct passwd * pass_struct = getpwuid(getuid());
+    if (pass_struct)
+      _result_directory->setText(pass_struct->pw_dir);
+  }
   registerField("result_directory", _result_directory);
 
   QGridLayout * output_box = new QGridLayout;
index fde75e34d95fc31d8fa637045c843c484d2af4e8..7050d71f4953fc983032df6fd9c8a0badebf90d6 100644 (file)
@@ -28,21 +28,70 @@ BL::GenericGui::GenericGui(BL::MainWindows_Wrap * wrapper) : QObject(wrapper->ge
   _job_name_selected = "";
 
   _dock_parent = _wrapper->getDockParent();
-  _tab_parent  = _wrapper->getTabParent();
 
   _salome_services = new BL::SALOMEServices();
   if (_salome_services->initNS() == false)
     DEBMSG("WARNING !!!!! SALOME IS NOT REACHABLE !!!!");
+}
+
+BL::GenericGui::~GenericGui()
+{
+  DEBTRACE("Destroying BL::GenericGui");
+  delete _salome_services;
+}
+
+void 
+BL::GenericGui::createDockWidgets()
+{
+  DEBTRACE("createDockWidgets BL::GenericGui");
   _jobs_manager = new BL::JobsManager_QT(_dock_parent, this, _salome_services);
   _model_manager = new BL::QModelManager(this, _jobs_manager);
-
   _model = _model_manager->getModel();
 
-  // ---- Adding different GUI parts
+  /* Summary */
+  _dw_summary = new QDockWidget(_dock_parent);
+  _dw_summary->setWindowTitle("Summary");
+  _summary = new BL::Summary(_dw_summary, _jobs_manager);
+  _summary->setModel(_model);
+  QScrollArea * scroll_widget_summary = new QScrollArea(_dw_summary);
+  scroll_widget_summary->setWidget(_summary);
+  scroll_widget_summary->setWidgetResizable(true);
+  _dw_summary->setWidget(scroll_widget_summary);
 
+  /* ResourceCatalog */
+  _dw_resource_catalog = new QDockWidget(_dock_parent);
+  _dw_resource_catalog->setWindowTitle("Resource Catalog");
+  _resource_catalog = new JM::ResourceCatalog(_dw_resource_catalog, _salome_services);
+  QScrollArea * scroll_widget_resource = new QScrollArea(_dw_resource_catalog);
+  scroll_widget_resource->setWidget(_resource_catalog);
+  scroll_widget_resource->setWidgetResizable(true);
+  _dw_resource_catalog->setWidget(scroll_widget_resource);
 
-  /* Tab Central Widget */
+  /* Main Dock Window */
+  _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _jobs_manager);
+  _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _dw_summary);
+  _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _dw_resource_catalog);
+  _dock_parent->splitDockWidget(_jobs_manager, _dw_summary, Qt::Vertical);
+  _dock_parent->tabifyDockWidget(_dw_summary, _dw_resource_catalog);
+
+  /* Signals and Slots */
+  // JobsManager -> Model
+  connect(_jobs_manager, SIGNAL(new_job_added(QString)), _model_manager, SLOT(new_job_added(QString)));
+  connect(_jobs_manager, SIGNAL(job_state_changed(QString)), _model_manager, SLOT(job_state_changed(QString)));
+  connect(_jobs_manager, SIGNAL(job_state_changed(QString)), this, SLOT(job_state_changed(QString)));
+  // Model -> summary
+  connect(_model, SIGNAL(rowsInserted(QModelIndex, int, int)), _summary, SLOT(rowsInserted(QModelIndex, int, int)));
+  connect(_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), _summary, SLOT(rowsRemoved(QModelIndex, int, int)));
+  connect(_model, SIGNAL(itemChanged(QStandardItem*)), _summary, SLOT(itemChanged(QStandardItem*)));
+}
+
+void 
+BL::GenericGui::createCentralWidget()
+{
+  DEBTRACE("createCentralWidget BL::GenericGui");
 
+  _tab_parent  = _wrapper->getTabParent();
+  /* Tab Central Widget */
   /* Buttons */
   _buttons = new BL::Buttons(_tab_parent);
   _buttons->setCreateButtonSlot(this, SLOT(create_job()));
@@ -78,60 +127,17 @@ BL::GenericGui::GenericGui(BL::MainWindows_Wrap * wrapper) : QObject(wrapper->ge
   scroll_central_widget->setWidgetResizable(true);
   _tab_parent->setCentralWidget(scroll_central_widget);
 
-  /* Summary */
-  _dw_summary = new QDockWidget(_dock_parent);
-  _dw_summary->setWindowTitle("Summary");
-  _summary = new BL::Summary(_dw_summary, _jobs_manager);
-  _summary->setModel(_model);
-  QScrollArea * scroll_widget_summary = new QScrollArea(_dw_summary);
-  scroll_widget_summary->setWidget(_summary);
-  scroll_widget_summary->setWidgetResizable(true);
-  _dw_summary->setWidget(scroll_widget_summary);
-
-  /* ResourceCatalog */
-  _dw_resource_catalog = new QDockWidget(_dock_parent);
-  _dw_resource_catalog->setWindowTitle("Resource Catalog");
-  _resource_catalog = new JM::ResourceCatalog(_dw_resource_catalog, _salome_services);
-  QScrollArea * scroll_widget_resource = new QScrollArea(_dw_resource_catalog);
-  scroll_widget_resource->setWidget(_resource_catalog);
-  scroll_widget_resource->setWidgetResizable(true);
-  _dw_resource_catalog->setWidget(scroll_widget_resource);
-
-  /* Main Dock Window */
-  _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _jobs_manager);
-  _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _dw_summary);
-  _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _dw_resource_catalog);
-  _dock_parent->splitDockWidget(_jobs_manager, _dw_summary, Qt::Vertical);
-  _dock_parent->tabifyDockWidget(_dw_summary, _dw_resource_catalog);
-
   /* Signals and Slots */
-
-  // JobsManager -> Model
-  connect(_jobs_manager, SIGNAL(new_job_added(QString)), _model_manager, SLOT(new_job_added(QString)));
-  connect(_jobs_manager, SIGNAL(job_state_changed(QString)), _model_manager, SLOT(job_state_changed(QString)));
-  connect(_jobs_manager, SIGNAL(job_state_changed(QString)), this, SLOT(job_state_changed(QString)));
-
-  // Model -> X
-  connect(_model, SIGNAL(rowsInserted(QModelIndex, int, int)), _summary, SLOT(rowsInserted(QModelIndex, int, int)));
-  connect(_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), _summary, SLOT(rowsRemoved(QModelIndex, int, int)));
-  connect(_model, SIGNAL(itemChanged(QStandardItem*)), _summary, SLOT(itemChanged(QStandardItem*)));
+  // Model -> JobTab
   connect(_model, SIGNAL(itemChanged(QStandardItem*)), _job_tab, SLOT(itemChanged(QStandardItem*)));
-
   // TableView -> X
   connect(_jobs_table, SIGNAL(clicked(QModelIndex)), _job_tab, SLOT(job_selected(QModelIndex)));
   connect(_jobs_table, SIGNAL(clicked(QModelIndex)), this, SLOT(job_selected(QModelIndex)));
   connect(_jobs_table, SIGNAL(clicked(QModelIndex)), _model_manager, SLOT(job_selected(QModelIndex)));
-
   // Delete Job -> X
   connect(this, SIGNAL(job_deleted(QString)), _job_tab, SLOT(reset(QString)));
 }
 
-BL::GenericGui::~GenericGui()
-{
-  DEBTRACE("Destroying BL::GenericGui");
-  delete _salome_services;
-}
-
 void
 BL::GenericGui::deleteDockWidget()
 {
index 822538da156f4a19566a2545ff76a2b013f9ca16..f6492bbc336d7f82ffc812e85419c09ab5c7d739 100644 (file)
@@ -46,6 +46,9 @@ namespace BL
       GenericGui(BL::MainWindows_Wrap * wrapper);
       virtual ~GenericGui();
 
+      void createDockWidgets();
+      void createCentralWidget();
+
       void showDockWidgets(bool isVisible);
       void createActions();
       void createMenus();
index 7528758353e700af93c64c9f55fcb5c6e1cf6c8a..4d2304113fb4ab653d2e2324966389b88f4c7570 100644 (file)
@@ -62,15 +62,29 @@ BL::SalomeGui::activateModule(SUIT_Study* theStudy)
   if (!_gengui)
   {
    BL::MainWindows_SALOME::initialize(getApp());
+   BL::MainWindows_SALOME::createView();
    _gengui = new BL::GenericGui(this);
+
+   _gengui->createDockWidgets();
+   _gengui->createCentralWidget();
    _gengui->createActions();
    _gengui->createMenus();
    _gengui->updateButtonsStates();
   }
+  else
+   {
+    // Test main view
+    if (!BL::MainWindows_SALOME::restoreViewFocus())
+     {
+      // We need to recreate QT objects and the view
+      BL::MainWindows_SALOME::createView();
+      _gengui->createCentralWidget();
+     }
+   }
 
-  bool bOk = SalomeApp_Module::activateModule(theStudy);
   setMenuShown(true);
   _gengui->showDockWidgets(true);
+  bool bOk = SalomeApp_Module::activateModule(theStudy);
   return bOk;
 }
 
index 29c73cbca7e452d7fb85725a22bcacba64d1e15d..ccedfe5ec1c325fa9793699e275072f7967f65dd 100644 (file)
@@ -24,6 +24,7 @@ BL::MainWindows_SALOME::MainWindows_SALOME(const QString & module_name) :
 {
   DEBTRACE("Creating BL::MainWindows_SALOME");
   _actionId = 190;
+  _currentViewId = -1;
 }
 
 void 
@@ -31,14 +32,45 @@ BL::MainWindows_SALOME::initialize(SalomeApp_Application * appli)
 {
   DEBTRACE("Initialize BL::MainWindows_SALOME");
   BL_ASSERT(appli);
-
   _appli = appli;
+}
+
+
+void
+BL::MainWindows_SALOME::createView()
+{
+  DEBTRACE("BL::MainWindows_SALOME CreateView");
   _svm = new SUIT_ViewManager(_appli->activeStudy(), _appli->desktop(), new SUIT_ViewModel());
   _appli->addViewManager(_svm);
   _viewWin = _svm->createViewWindow();
-
+  _currentViewId = _viewWin->getId();
   if (_viewWin && _appli->desktop())
     _viewWin->resize((int)(_appli->desktop()->width() * 0.6), (int)(_appli->desktop()->height() * 0.6 ));
+  DEBTRACE("End of BL::MainWindows_SALOME CreateView");
+}
+
+bool
+BL::MainWindows_SALOME::restoreViewFocus()
+{
+  bool result = false;
+  SUIT_ViewWindow* resWnd = 0;
+
+  // Search window
+  QList<SUIT_ViewWindow*> wndlist = _appli->desktop()->windows();
+  SUIT_ViewWindow* wnd;
+  for (int i = 0; i < wndlist.size(); ++i) 
+   {
+    wnd = wndlist.at(i);
+    if (_currentViewId == wnd->getId()) {resWnd = wnd;}
+    if (resWnd) {break;}
+   }
+
+  if (resWnd)
+   {
+    wnd->setFocus();
+    result = true;
+   }
+  return result;
 }
 
 QString  
index 3be325f475d2029b244f0f12606397a74602635d..627c20d22d5e9dd324b7164a78da2ad58ee3af9d 100644 (file)
@@ -64,12 +64,15 @@ namespace BL
 
       // Usefull methods
       virtual void initialize(SalomeApp_Application * appli);
+      bool restoreViewFocus();
+      void createView();
 
     protected:
       SalomeApp_Application * _appli;
       SalomeApp_Module * _module;
       SUIT_ViewManager * _svm;
       SUIT_ViewWindow  * _viewWin;
+      int _currentViewId;
 
       int _actionId;
       int getActionId() { return _actionId++; }