]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1539: Add edit menu if list of selection contains a feature.
authorvsv <vsv@opencascade.com>
Mon, 13 Mar 2017 10:42:03 +0000 (13:42 +0300)
committervsv <vsv@opencascade.com>
Mon, 13 Mar 2017 10:42:03 +0000 (13:42 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_Module.cpp

index 24953f5a600d23f01f8a94773b53016988133b67..b249f2311983ade7c75c110a9b176c1c74c641d9 100644 (file)
@@ -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<ModelAPI_Feature>(aObjects.first());
-  if (aFeature == NULL) {
-    ResultParameterPtr aParam =
-      std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObjects.first());
-    if (aParam.get() != NULL) {
-      aFeature = ModelAPI_Feature::feature(aParam);
+  FeaturePtr aFeature;
+  foreach(ObjectPtr aObj, aObjects) {
+    aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+    if (aFeature.get())
+      break;
+  }
+  if (aFeature.get() == NULL) {
+    ResultParameterPtr aParam;
+    foreach(ObjectPtr aObj, aObjects) {
+      aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObj);
+      if (aParam.get())
+        break;
     }
+    if (aParam.get() != NULL)
+      aFeature = ModelAPI_Feature::feature(aParam);
   }
   if (aFeature.get() != NULL)
     myModule->editFeature(aFeature);
index 18679ad143981f6b29d81489fcf69eaefe82499c..f4480e827d1cfd2f95a90fb58031fb16a599857e 100755 (executable)
@@ -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<ModelAPI_ResultPart>(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) {