]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide deletion of sketch objects
authorvsv <vsv@opencascade.com>
Thu, 12 Sep 2019 12:31:38 +0000 (15:31 +0300)
committerazv <azv@opencascade.com>
Mon, 23 Sep 2019 09:37:53 +0000 (12:37 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp

index 06ebaefa6e65416f6446c1cf7f57f9cc7b581cd6..bb84381bff854b31b2b569f040c32b15f24d80a0 100644 (file)
@@ -51,6 +51,7 @@
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultParameter.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <QMainWindow>
 #include <QAction>
@@ -234,6 +235,21 @@ void PartSet_MenuMgr::updateViewerMenu(const QMap<QString, QAction*>& theStdActi
     theStdActions["SHOW_CMD"]->setEnabled(false);
     theStdActions["HIDE_CMD"]->setEnabled(false);
     theStdActions["HIDEALL_CMD"]->setEnabled(false);
+
+    ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
+    QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
+    ResultConstructionPtr aResult;
+    bool canBeDeleted = true;
+    foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
+      aResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aPrs->object());
+      if (aResult.get() != NULL) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs->object());
+        canBeDeleted = !(!(aFeature->isInHistory()) && aResult->isInfinite());
+        if (!canBeDeleted)
+          break;
+      }
+    }
+    theStdActions["DELETE_CMD"]->setEnabled(canBeDeleted);
   }
 }
 
index 226aa30dda252dfedcba4bca6b533df7f10a1a5d..d2ae91572d3057735f3c238ed11a55214fa0a623 100644 (file)
@@ -334,8 +334,9 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
         {
           action("RENAME_CMD")->setEnabled(true);
           if (aObject->groupName() == ModelAPI_ResultConstruction::group()) {
+            ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObject);
             FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
-            canBeDeleted = aFeature->isInHistory();
+            canBeDeleted = !(!(aFeature->isInHistory()) && aConstr->isInfinite());
             action("DELETE_CMD")->setEnabled(canBeDeleted);
           }
           else
@@ -596,10 +597,6 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
     }
   }
 
-  ModuleBase_IModule* aModule = myWorkshop->module();
-  if (aModule)
-    aModule->updateViewerMenu(myActions);
-
   if (myWorkshop->canChangeProperty("COLOR_CMD"))
     action("COLOR_CMD")->setEnabled(true);
 
@@ -609,8 +606,9 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
   if (myWorkshop->canChangeProperty("TRANSPARENCY_CMD"))
     action("TRANSPARENCY_CMD")->setEnabled(true);
 
-  // Delete command is not used in viewer pop-up menu
-  action("DELETE_CMD")->setEnabled(false);
+  ModuleBase_IModule* aModule = myWorkshop->module();
+  if (aModule)
+    aModule->updateViewerMenu(myActions);
 }
 
 void XGUI_ContextMenuMgr::connectObjectBrowser()