From: nds Date: Wed, 11 Nov 2015 07:53:22 +0000 (+0300) Subject: Method to check whether the object is a sub object of a composite. Should be called... X-Git-Tag: V_2.0.0_alfa2~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d0445c11df5bce33d464c9c0ef97186519cc069d;p=modules%2Fshaper.git Method to check whether the object is a sub object of a composite. Should be called to correct enable state of the Delete aciton. --- 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