From: vsv Date: Mon, 13 Mar 2017 10:42:03 +0000 (+0300) Subject: Issue #1539: Add edit menu if list of selection contains a feature. X-Git-Tag: V_2.7.0~234 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7e98da81e21fa2f2ff5810c02fc78c6e846a1467;p=modules%2Fshaper.git Issue #1539: Add edit menu if list of selection contains a feature. --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 24953f5a6..b249f2311 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -510,13 +510,21 @@ void PartSet_MenuMgr::grantedOperationIds(ModuleBase_Operation* theOperation, void PartSet_MenuMgr::onEdit(bool) { QObjectPtrList aObjects = myModule->workshop()->selection()->selectedObjects(); - FeaturePtr aFeature = std::dynamic_pointer_cast(aObjects.first()); - if (aFeature == NULL) { - ResultParameterPtr aParam = - std::dynamic_pointer_cast(aObjects.first()); - if (aParam.get() != NULL) { - aFeature = ModelAPI_Feature::feature(aParam); + FeaturePtr aFeature; + foreach(ObjectPtr aObj, aObjects) { + aFeature = std::dynamic_pointer_cast(aObj); + if (aFeature.get()) + break; + } + if (aFeature.get() == NULL) { + ResultParameterPtr aParam; + foreach(ObjectPtr aObj, aObjects) { + aParam = std::dynamic_pointer_cast(aObj); + if (aParam.get()) + break; } + if (aParam.get() != NULL) + aFeature = ModelAPI_Feature::feature(aParam); } if (aFeature.get() != NULL) myModule->editFeature(aFeature); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 18679ad14..f4480e827 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1159,14 +1159,15 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const SessionPtr aMgr = ModelAPI_Session::get(); QAction* aActivatePartAction = myMenuMgr->action("ACTIVATE_PART_CMD"); + bool hasResult = false; + bool hasFeature = false; + bool hasParameter = false; + bool hasCompositeOwner = false; + ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, + hasCompositeOwner); + ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation(); if (aSelected == 1) { - bool hasResult = false; - bool hasFeature = false; - bool hasParameter = false; - bool hasCompositeOwner = false; - ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, - hasCompositeOwner); ObjectPtr aObject = aObjects.first(); if (aObject) { ResultPartPtr aPart = std::dynamic_pointer_cast(aObject); @@ -1195,6 +1196,12 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const } } } + } else { + if (hasFeature) { + myMenuMgr->action("EDIT_CMD")->setEnabled(aCurrentOp == 0); + theMenu->addAction(myMenuMgr->action("EDIT_CMD")); + theMenu->addSeparator(); + } } bool aNotDeactivate = (aCurrentOp == 0); if (!aNotDeactivate) {