From ce9810156c9d86d3cb15e4121536ded19f500991 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 13 Sep 2019 11:54:18 +0300 Subject: [PATCH] Do not delete infinity construction objects out of a history --- src/PartSet/PartSet_MenuMgr.cpp | 16 ---------------- src/XGUI/XGUI_ContextMenuMgr.cpp | 31 ++++++++----------------------- src/XGUI/XGUI_Workshop.cpp | 13 +++++++++++++ 3 files changed, 21 insertions(+), 39 deletions(-) diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index bb84381bf..06ebaefa6 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include @@ -235,21 +234,6 @@ 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 d2ae91572..f26973668 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -293,7 +293,6 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() bool hasCompositeOwner = false; bool hasResultInHistory = false; bool hasFolder = false; - bool canBeDeleted = true; ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner, hasResultInHistory, hasFolder); //Process Feature @@ -333,14 +332,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() if( aMgr->activeDocument() == aObject->document() ) { 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()) && aConstr->isInfinite()); - action("DELETE_CMD")->setEnabled(canBeDeleted); - } - else - action("DELETE_CMD")->setEnabled(!hasCompositeOwner); + action("DELETE_CMD")->setEnabled(!hasCompositeOwner); action("CLEAN_HISTORY_CMD")->setEnabled(!hasCompositeOwner && (hasFeature || hasParameter)); } @@ -354,15 +346,6 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("SHOW_ONLY_CMD")->setEnabled(true); action("SHADING_CMD")->setEnabled(true); action("WIREFRAME_CMD")->setEnabled(true); - - foreach(ObjectPtr aObj, aObjects) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); - if (!aFeature->isInHistory()) { - canBeDeleted = false; - break; - } - } - action("DELETE_CMD")->setEnabled(canBeDeleted); } } // end multi-selection @@ -463,8 +446,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() break; } if (!hasCompositeOwner && allActive ) { - if (hasResult || hasFeature || hasParameter) // #2924 results can be erased - action("DELETE_CMD")->setEnabled(canBeDeleted); + if (hasResult || hasFeature || hasParameter) // #2924 results can be erased + action("DELETE_CMD")->setEnabled(true); } if (!hasCompositeOwner && allActive && (hasFeature|| hasParameter)) action("CLEAN_HISTORY_CMD")->setEnabled(true); @@ -597,6 +580,10 @@ void XGUI_ContextMenuMgr::updateViewerMenu() } } + ModuleBase_IModule* aModule = myWorkshop->module(); + if (aModule) + aModule->updateViewerMenu(myActions); + if (myWorkshop->canChangeProperty("COLOR_CMD")) action("COLOR_CMD")->setEnabled(true); @@ -606,9 +593,7 @@ void XGUI_ContextMenuMgr::updateViewerMenu() if (myWorkshop->canChangeProperty("TRANSPARENCY_CMD")) action("TRANSPARENCY_CMD")->setEnabled(true); - ModuleBase_IModule* aModule = myWorkshop->module(); - if (aModule) - aModule->updateViewerMenu(myActions); + action("DELETE_CMD")->setEnabled(true); } void XGUI_ContextMenuMgr::connectObjectBrowser() diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 3fadef034..507d13e62 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1806,6 +1806,19 @@ void XGUI_Workshop::deleteObjects() if (!(hasResult || hasFeature || hasParameter || hasFolder)) return; + // Remove from the list non-deletable objects: infinite constuctions which are not in history + bool notDelete = true; + QObjectPtrList::iterator aIt; + for (aIt = anObjects.begin(); aIt != anObjects.end(); aIt++) { + ObjectPtr aObj = (*aIt); + ResultConstructionPtr aConstr = std::dynamic_pointer_cast(aObj); + FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); + notDelete = (!aFeature->isInHistory()) && aConstr->isInfinite(); + if (notDelete) { + anObjects.removeAll(aObj); + aIt--; + } + } // delete objects std::map > aReferences; std::set aFeatures; -- 2.39.2