Salome HOME
Update SketchBuilder to work on faces with holes (issue #1320)
[modules/shaper.git] / src / XGUI / XGUI_Tools.cpp
index 0b77c6c75cfb48c9a65acac5b5e8b0e93eb55905..9bb1dfa84d357c5c5c3cde1cbdad0019ebbab8ea 100644 (file)
@@ -2,6 +2,11 @@
 
 #include "XGUI_Tools.h"
 
+#include "XGUI_ModuleConnector.h"
+#include "XGUI_Workshop.h"
+
+#include "ModuleBase_IWorkshop.h"
+
 #include <TopoDS_Shape.hxx>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Result.h>
@@ -235,15 +240,29 @@ void refsDirectToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const O
     return;
   theAlreadyProcessed.insert(aFeature);
 
-  // 1. find references in the current document
+  //convert ignore object list to containt sub-features if the composite feature is in the list
+  QObjectPtrList aFullIgnoreList;
+  QObjectPtrList::const_iterator anIIt = theIgnoreList.begin(), anILast = theIgnoreList.end();
+  for (; anIIt != anILast; anIIt++) {
+    aFullIgnoreList.append(*anIIt);
+    CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*anIIt);
+    // if the current feature is aborted, the composite is removed and has invalid data
+    if (aComposite.get() && aComposite->data()->isValid()) {
+      int aNbSubs = aComposite->numberOfSubs();
+      for (int aSub = 0; aSub < aNbSubs; aSub++) {
+        aFullIgnoreList.append(aComposite->subFeature(aSub));
+      }
+    }
+  }
 
+  // 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) && !theIgnoreList.contains(*anIt))
+    if (!isSubOfComposite(theSourceObject, *anIt) && !aFullIgnoreList.contains(*anIt))
       theDirectRefFeatures.insert(*anIt);
   }
 
@@ -306,4 +325,10 @@ void refsDirectToFeatureInAllDocuments(const ObjectPtr& theSourceObject, const O
   }
 }
 
+XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop)
+{
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
+  return aConnector->workshop();
+}
+
 }