From: vsv Date: Fri, 13 Sep 2019 08:54:18 +0000 (+0300) Subject: Do not delete infinity construction objects out of a history X-Git-Tag: V9_4_0a2~4^2~103 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5ec39dc5644f2eafbc746fb36c6978aa348c322b;p=modules%2Fshaper.git Do not delete infinity construction objects out of a history --- 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 ae217d58f..00cf24153 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); } if (hasFeature && myWorkshop->canMoveFeature()) action("MOVE_CMD")->setEnabled(true); @@ -465,8 +448,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); @@ -599,6 +582,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); @@ -608,9 +595,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 18c034672..2ab27551e 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1813,6 +1813,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;