From: vsv Date: Mon, 6 Apr 2015 13:31:15 +0000 (+0300) Subject: Activate all commands when there is no selection X-Git-Tag: V_1.1.0~57^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3bfeabb8c413d8d86694283d1331d84f75926db9;p=modules%2Fshaper.git Activate all commands when there is no selection --- diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 33f1826a7..9e7ce02ae 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -128,32 +128,39 @@ void XGUI_ActionsMgr::updateCheckState() void XGUI_ActionsMgr::updateOnViewSelection() { - XGUI_Selection* aSelection = myWorkshop->selector()->selection(); - if (aSelection->getSelected().size() == 0 || !myOperationMgr->hasOperation()) + if (!myOperationMgr->hasOperation()) return; + ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); FeaturePtr anActiveFeature = anOperation->feature(); if(!anActiveFeature.get()) return; - QString aFeatureId = QString::fromStdString(anActiveFeature->getKind()); - SessionPtr aMgr = ModelAPI_Session::get(); - ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - foreach(QString aId, nestedCommands(aFeatureId)) { - std::list aValidators; - std::list > anArguments; - aFactory->validators(aId.toStdString(), aValidators, anArguments); - std::list::iterator aValidator = aValidators.begin(); - std::list >::iterator aValidatorArgs = anArguments.begin(); - for (; aValidator != aValidators.end(); aValidator++, aValidatorArgs++) { - if (!(*aValidator)) - continue; - const ModuleBase_SelectionValidator* aSelValidator = - dynamic_cast(*aValidator); - if (!aSelValidator) - continue; - setActionEnabled(aId, aSelValidator->isValid(aSelection, *aValidatorArgs)); + QString aFeatureId = QString::fromStdString(anActiveFeature->getKind()); + XGUI_Selection* aSelection = myWorkshop->selector()->selection(); + if (aSelection->getSelected().size() == 0) { + foreach(QString aId, nestedCommands(aFeatureId)) { + setActionEnabled(aId, true); + } + } else { + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + foreach(QString aId, nestedCommands(aFeatureId)) { + std::list aValidators; + std::list > anArguments; + aFactory->validators(aId.toStdString(), aValidators, anArguments); + std::list::iterator aValidator = aValidators.begin(); + std::list >::iterator aValidatorArgs = anArguments.begin(); + for (; aValidator != aValidators.end(); aValidator++, aValidatorArgs++) { + if (!(*aValidator)) + continue; + const ModuleBase_SelectionValidator* aSelValidator = + dynamic_cast(*aValidator); + if (!aSelValidator) + continue; + setActionEnabled(aId, aSelValidator->isValid(aSelection, *aValidatorArgs)); + } } } }