Salome HOME
#1145 synchronization between object browser and viewer is lost
[modules/shaper.git] / src / XGUI / XGUI_Tools.cpp
index b0bc951061820d8ebcc7f9463e1a024bb1c605b1..ab9ef819f618481662ef078c9f63979fd9326252 100644 (file)
@@ -174,6 +174,20 @@ bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
   return isSub;
 }
 
+//**************************************************************
+bool 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;
+}
+
 //**************************************************************
 void refsToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const ObjectPtr& theObject,
                                  std::set<FeaturePtr>& theDirectRefFeatures, 
@@ -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);
   }