From 05117d23f31d3809a09b687d91ade989a1dd4592 Mon Sep 17 00:00:00 2001 From: ribes Date: Thu, 7 Oct 2010 12:18:49 +0000 Subject: [PATCH] Better management of viewers (patch from branch V6) --- src/salomegui/BL_SalomeGui.cxx | 16 ++++++++++++++++ src/salomegui/BL_SalomeGui.hxx | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/salomegui/BL_SalomeGui.cxx b/src/salomegui/BL_SalomeGui.cxx index 4d23041..ba62dcd 100644 --- a/src/salomegui/BL_SalomeGui.cxx +++ b/src/salomegui/BL_SalomeGui.cxx @@ -41,6 +41,9 @@ BL::SalomeGui::initialize(CAM_Application* app) DEBTRACE("Entering in initialize"); SalomeApp_Module::initialize(app); // MANDATORY -> Otherwise SISEGV... connect( getApp(), SIGNAL(studyClosed()), this, SLOT(studyClosed())); + if ( app && app->desktop() ) + connect( app->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), + this, SLOT(onWindowActivated( SUIT_ViewWindow* )) ); } void @@ -51,6 +54,7 @@ BL::SalomeGui::studyClosed() _gengui->deleteDockWidget(); delete _gengui; _gengui = NULL; + _viewWin = NULL; } } @@ -107,6 +111,18 @@ BL::SalomeGui::deactivateModule(SUIT_Study* 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().compare("JobManager") != 0) // JobManager already activated ? + getApp()->activateModule("JobManager"); +} + // --- Export the module extern "C" { diff --git a/src/salomegui/BL_SalomeGui.hxx b/src/salomegui/BL_SalomeGui.hxx index 5ca85de..f6069a9 100644 --- a/src/salomegui/BL_SalomeGui.hxx +++ b/src/salomegui/BL_SalomeGui.hxx @@ -46,6 +46,9 @@ namespace BL bool activateModule( SUIT_Study* theStudy); void studyClosed(); + protected slots: + void onWindowActivated( SUIT_ViewWindow* svw); + protected: BL::GenericGui * _gengui; }; -- 2.39.2