X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ActiveControlMgr.cpp;h=b79971cf2b7bd08836b4d903939f9094567db700;hb=c6745a6b1ad00c0285fab5aeac2cb0d57afef5cc;hp=7c2fc833b817d76264125a64cb432bcbb4070bef;hpb=613e672654df0f1e6838fb55b384842ce534809a;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ActiveControlMgr.cpp b/src/XGUI/XGUI_ActiveControlMgr.cpp index 7c2fc833b..b79971cf2 100644 --- a/src/XGUI/XGUI_ActiveControlMgr.cpp +++ b/src/XGUI/XGUI_ActiveControlMgr.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 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 @@ -12,21 +12,34 @@ // // 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 +// 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 -#include +#include "XGUI_ActiveControlMgr.h" +#include "XGUI_ActiveControlSelector.h" +#include "XGUI_SelectionActivate.h" +#include "XGUI_SelectionMgr.h" +#include "XGUI_Tools.h" +#include "XGUI_Workshop.h" #include #include +//#define DEBUG_ACTIVE_SELECTOR + +#ifdef DEBUG_ACTIVE_SELECTOR +void debugInfo(const QString& theMessage, XGUI_ActiveControlSelector* theSelector) +{ + std::cout << theMessage.toStdString().c_str() << ", active: " + << (theSelector ? theSelector->getType().toStdString().c_str() : "NULL") << std::endl; +} +#endif + //******************************************************************** XGUI_ActiveControlMgr::XGUI_ActiveControlMgr(ModuleBase_IWorkshop* theWorkshop) -: myWorkshop(theWorkshop), myActiveSelector(0) +: myWorkshop(theWorkshop), myActiveSelector(0), myIsBlocked(false) { connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); } @@ -60,34 +73,58 @@ void XGUI_ActiveControlMgr::onSelectorActivated() if (!aSelector || aSelector == myActiveSelector) return; - if (myActiveSelector) + if (myIsBlocked) // we've come here from the same method + return; + myIsBlocked = true; + if (myActiveSelector) { myActiveSelector->setActive(false); - + } activateSelector(aSelector); + XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionModes(); + XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionFilters(); + +#ifdef DEBUG_ACTIVE_SELECTOR + debugInfo("onSelectorActivated", myActiveSelector); +#endif + myIsBlocked = false; } //******************************************************************** void XGUI_ActiveControlMgr::onSelectorDeactivated() { XGUI_ActiveControlSelector* aSelector = qobject_cast(sender()); - if (!aSelector) + deactivateSelector(aSelector); +} + +//******************************************************************** +void XGUI_ActiveControlMgr::deactivateSelector(XGUI_ActiveControlSelector* theSelector) +{ + if (!theSelector || theSelector != myActiveSelector || !myActiveSelector) return; - myActiveSelector = NULL; + if (myIsBlocked) // we've come here from the same method + return; + myIsBlocked = true; - aSelector->setActive(false); - myWorkshop->module()->updateActiveSelectionFilters(); + myActiveSelector->setActive(false); + activateSelector(NULL); XGUI_ActiveControlSelector* aSelectorToBeActivated = 0; - for (int i = 0, aCount = mySelectors.count(); i < aCount; i++) - { - if (!mySelectors[i]->needToBeActiated()) + for (int i = 0, aCount = mySelectors.count(); i < aCount; i++) { + if (!mySelectors[i]->needToBeActivated()) continue; aSelectorToBeActivated = mySelectors[i]; break; } if (aSelectorToBeActivated) activateSelector(aSelectorToBeActivated); + + XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionModes(); + XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionFilters(); +#ifdef DEBUG_ACTIVE_SELECTOR + debugInfo("onSelectorDeactivated", myActiveSelector); +#endif + myIsBlocked = false; } //******************************************************************** @@ -97,13 +134,15 @@ void XGUI_ActiveControlMgr::onSelectionChanged() return; myActiveSelector->processSelection(); +#ifdef DEBUG_ACTIVE_SELECTOR + debugInfo("onSelectionChanged", myActiveSelector); +#endif } //******************************************************************** void XGUI_ActiveControlMgr::activateSelector(XGUI_ActiveControlSelector* theSelector) { myActiveSelector = theSelector; - theSelector->setActive(true); - - myWorkshop->module()->updateActiveSelectionFilters(); + if (myActiveSelector) + myActiveSelector->setActive(true); }