From d0445c11df5bce33d464c9c0ef97186519cc069d Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 11 Nov 2015 10:53:22 +0300 Subject: [PATCH] Method to check whether the object is a sub object of a composite. Should be called to correct enable state of the Delete aciton. --- src/XGUI/XGUI_Tools.cpp | 16 ++++++++++++++++ src/XGUI/XGUI_Tools.h | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index b0bc95106..cd7248f45 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -155,6 +155,20 @@ void refsToFeatureInFeatureDocument(const ObjectPtr& theObject, std::set aRefFeatures; + refsToFeatureInFeatureDocument(theObject, aRefFeatures); + std::set::const_iterator anIt = aRefFeatures.begin(), + aLast = aRefFeatures.end(); + for (; anIt != aLast && !isSub; anIt++) { + isSub = isSubOfComposite(theObject, *anIt); + } + return isSub; +} + //************************************************************** bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature) { @@ -188,11 +202,13 @@ void refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const ObjectP theAlreadyProcessed.insert(aFeature); // 1. find references in the current document + std::set aRefFeatures; refsToFeatureInFeatureDocument(theObject, aRefFeatures); std::set::const_iterator anIt = aRefFeatures.begin(), aLast = aRefFeatures.end(); for (; anIt != aLast; anIt++) { + // composite feature should not be deleted when the sub feature is to be deleted if (!isSubOfComposite(theSourceObject, *anIt)) theDirectRefFeatures.insert(*anIt); } diff --git a/src/XGUI/XGUI_Tools.h b/src/XGUI/XGUI_Tools.h index 21ca7356d..48ab0d57b 100644 --- a/src/XGUI/XGUI_Tools.h +++ b/src/XGUI/XGUI_Tools.h @@ -128,6 +128,13 @@ void XGUI_EXPORT refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject, std::set& theDirectRefFeatures, std::set& theIndirectRefFeatures, std::set& theAlreadyProcessed); + +/*! +* Returns true if the result is a sub object of some composite object +* \param theObject a result object +* \returns boolean value +*/ +bool XGUI_EXPORT isSubOfComposite(const ObjectPtr& theObject); }; #endif -- 2.39.2