From f12c60b3b0b5a407f558d894c0aa66ff19ccfe2e 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 226aa30dd..d2ae91572 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 @@ -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() -- 2.39.2