-// Copyright (C) 2009 CEA/DEN, EDF R&D
+// Copyright (C) 2009-2012 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.
//
-// 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;
BL::SalomeGui::~SalomeGui()
{
DEBTRACE("Destroying BL::SalomeGui");
+ if (getApp())
+ disconnect(getApp(), SIGNAL(studyClosed()), this, SLOT(studyClosed()));
+ if (_gengui)
+ delete _gengui;
}
void
{
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
{
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;
}
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;
+ }
}