]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Method to check whether the object is a sub object of a composite. Should be called...
authornds <nds@opencascade.com>
Wed, 11 Nov 2015 07:53:22 +0000 (10:53 +0300)
committernds <nds@opencascade.com>
Wed, 11 Nov 2015 07:54:08 +0000 (10:54 +0300)
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Tools.h

index b0bc951061820d8ebcc7f9463e1a024bb1c605b1..cd7248f45e878c93cba110f38930608f7afe4b00 100644 (file)
@@ -155,6 +155,20 @@ void refsToFeatureInFeatureDocument(const ObjectPtr& theObject, std::set<Feature
   }
 }
 
+//**************************************************************
+bool XGUI_Tools::isSubOfComposite(const ObjectPtr& theObject)
+{
+  bool isSub = false;
+  std::set<FeaturePtr> aRefFeatures;
+  refsToFeatureInFeatureDocument(theObject, aRefFeatures);
+  std::set<FeaturePtr>::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<FeaturePtr> aRefFeatures;
   refsToFeatureInFeatureDocument(theObject, aRefFeatures);
   std::set<FeaturePtr>::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);
   }
index 21ca7356d04f531cd42ab29e7fc8b921ecb5440e..48ab0d57b892676cb315d481eacb94cd627efb9c 100644 (file)
@@ -128,6 +128,13 @@ void XGUI_EXPORT refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject,
                                              std::set<FeaturePtr>& theDirectRefFeatures,
                                              std::set<FeaturePtr>& theIndirectRefFeatures,
                                              std::set<FeaturePtr>& 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