From 9be65b4d45c40e24b7fcaf79663bd4897696fdfe Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 12 Sep 2019 15:31:38 +0300 Subject: [PATCH] Provide deletion of sketch objects --- src/PartSet/PartSet_MenuMgr.cpp | 16 ++++++++++++++++ src/XGUI/XGUI_ContextMenuMgr.cpp | 12 +++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 06ebaefa6..bb84381bf 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -234,6 +235,21 @@ void PartSet_MenuMgr::updateViewerMenu(const QMap& theStdActi theStdActions["SHOW_CMD"]->setEnabled(false); theStdActions["HIDE_CMD"]->setEnabled(false); theStdActions["HIDEALL_CMD"]->setEnabled(false); + + ModuleBase_ISelection* aSelection = myModule->workshop()->selection(); + QList aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer); + ResultConstructionPtr aResult; + bool canBeDeleted = true; + foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) { + aResult = std::dynamic_pointer_cast(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); } } diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 51f9fbec2..ae217d58f 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -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(aObject); FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); - canBeDeleted = aFeature->isInHistory(); + canBeDeleted = !(!(aFeature->isInHistory()) && aConstr->isInfinite()); action("DELETE_CMD")->setEnabled(canBeDeleted); } else @@ -598,10 +599,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); @@ -611,8 +608,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() -- 2.39.2