Salome HOME
Bos #24043: EDF 23094 - problem with dump. Fix for nested compounds.
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetSelectionFilter.cpp
index 024e2d01936b317e4bbd90eaf4b979d3b9a57b85..741298f5a530da15a11a7bdb076995bbd8479e49 100644 (file)
@@ -476,7 +476,25 @@ void ModuleBase_WidgetSelectionFilter::onSelect()
       bool isValid = aSession->filters()->isValid(myFeature, aBody, aSubShape);
       if (isValid) {
         aBuilder.Add(aComp, aTShape);
-        ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aObj, aSubShape));
+        // bos #24043: Naming on a compsolid works wrong.
+        // Find a simple sub-result for the ViewerPrs context:
+        ResultBodyPtr aContext = aBody;
+        bool isComposite = aContext->numberOfSubs() > 0;
+        while (isComposite) {
+          isComposite = false;
+          int nbSubs = aContext->numberOfSubs();
+          for (int aSubIndex = 0; aSubIndex < nbSubs; aSubIndex++) {
+            ResultBodyPtr aSubResult = aContext->subResult(aSubIndex);
+            GeomShapePtr aSubResultShape = aSubResult->shape();
+            if (aSubResultShape->isSubShape(aSubShape)) {
+              aContext = aSubResult;
+              isComposite = aContext->numberOfSubs() > 0;
+              break;
+            }
+          }
+        }
+        ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aContext, aSubShape));
+        //ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aObj, aSubShape));
         myValues.append(aValue);
       }
     }