X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fsalomegui%2FBL_SalomeGui.cxx;h=0c90fa3c5df7bfc2c4ebb98cb3f24372472f1b0e;hb=fafdcee64180ce59122b48b01f869eb35f681b34;hp=5895d94a242a99e113ccd68e2e17e79d751adf26;hpb=97482df035ee6e97dde980312a5b02d356b03702;p=modules%2Fjobmanager.git diff --git a/src/salomegui/BL_SalomeGui.cxx b/src/salomegui/BL_SalomeGui.cxx index 5895d94..0c90fa3 100644 --- a/src/salomegui/BL_SalomeGui.cxx +++ b/src/salomegui/BL_SalomeGui.cxx @@ -1,26 +1,26 @@ -// Copyright (C) 2009 CEA/DEN, EDF R&D +// Copyright (C) 2009-2014 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com #include "BL_SalomeGui.hxx" +#include "JOBMANAGER_version.h" -BL::SalomeGui::SalomeGui() : MainWindows_SALOME("JobManager"), - SalomeApp_Module("JobManager"), - LightApp_Module("JobManager") +BL::SalomeGui::SalomeGui() : MainWindows_SALOME("JobManager") { DEBTRACE("Creating BL::SalomeGui"); _gengui = NULL; @@ -29,6 +29,10 @@ BL::SalomeGui::SalomeGui() : MainWindows_SALOME("JobManager"), BL::SalomeGui::~SalomeGui() { DEBTRACE("Destroying BL::SalomeGui"); + if (getApp()) + disconnect(getApp(), SIGNAL(studyClosed()), this, SLOT(studyClosed())); + if (_gengui) + delete _gengui; } void @@ -36,12 +40,22 @@ BL::SalomeGui::initialize(CAM_Application* app) { DEBTRACE("Entering in initialize"); SalomeApp_Module::initialize(app); // MANDATORY -> Otherwise SISEGV... - BL::MainWindows_SALOME::initialize(getApp()); + connect( getApp(), SIGNAL(studyClosed()), this, SLOT(studyClosed())); + if ( app && app->desktop() ) + connect( app->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), + this, SLOT(onWindowActivated( SUIT_ViewWindow* )) ); +} - _gengui = new BL::GenericGui(this); - _gengui->createActions(); - _gengui->createMenus(); - _gengui->updateButtonsStates(); +void +BL::SalomeGui::studyClosed() +{ + if (_gengui) + { + _gengui->deleteDockWidget(); + delete _gengui; + _gengui = NULL; + _viewWin = NULL; + } } bool @@ -49,10 +63,32 @@ BL::SalomeGui::activateModule(SUIT_Study* theStudy) { DEBTRACE("Entering in BL::SalomeGui::activateModule"); - bool bOk = SalomeApp_Module::activateModule(theStudy); - setMenuShown(true); + 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(); + } + } + + setMenuShown(true); _gengui->showDockWidgets(true); + bool bOk = SalomeApp_Module::activateModule(theStudy); return bOk; } @@ -68,18 +104,35 @@ bool BL::SalomeGui::deactivateModule(SUIT_Study* theStudy) { DEBTRACE("Entering in BL::SalomeGui::deactivateModule"); - setMenuShown(false); - _gengui->showDockWidgets(false); + if (_gengui) + _gengui->showDockWidgets(false); bool bOk = SalomeApp_Module::deactivateModule(theStudy); return bOk; } +void +BL::SalomeGui::onWindowActivated( SUIT_ViewWindow* svw) +{ + DEBTRACE("BL::SalomeGui::onWindowActivated"); + DEBTRACE("activeModule()->moduleName() " << (getApp()->activeModule() ? getApp()->activeModule()->moduleName().toStdString() : "") ); + + if (_viewWin) // Be sure to have a _viewWindow + if (svw->getId() == _viewWin->getId()) // Same Id ? + if (!getApp()->activeModule() || getApp()->activeModule()->moduleName() != "JobManager") // JobManager already activated ? + if ( !getApp()->activateModule("JobManager") ) return; +} + // --- Export the module extern "C" { - CAM_Module* createModule() + JOBMANAGER_EXPORT CAM_Module* createModule() { return new BL::SalomeGui(); } + + char* getModuleVersion() + { + return (char*)JOBMANAGER_VERSION_STR; + } }