From 9e1e1cbb0c2f94054244133ddc8fa9bc5991acf4 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 20 Jul 2017 13:23:31 +0300 Subject: [PATCH] Issue #2219 Remove sub-shapes removes solids of compsolid. --- src/XGUI/XGUI_Displayer.cpp | 51 +++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b68f63dd6..6c4865bf8 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -1541,6 +1541,9 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th const NCollection_DataMap>& theShapesToBeSelected) { + NCollection_Map aCompsolidPresentations; + NCollection_Map aSelectedPresentations; + NCollection_List anActiveOwners; theContext->MainSelector()->ActiveOwners(anActiveOwners); NCollection_List::Iterator anOwnersIt (anActiveOwners); @@ -1564,26 +1567,46 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th if (aShape.IsNull()) continue; + Handle(ModuleBase_BRepOwner) aCustomOwner = Handle(ModuleBase_BRepOwner)::DownCast(anOwner); + NCollection_DataMap > ::Iterator aShapeIt(theShapesToBeSelected); for (; aShapeIt.More(); aShapeIt.Next()) { - if (aShapeIt.Key().IsSame(aShape)) { - const TopoDS_Shape& aParameterShape = aShapeIt.Key(); - // isSame should be used here as it does not check orientation of shapes - // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is - // different for Edges shapes in model shape and owner even if this is the same shape - if (aParameterShape.IsSame(aShape)) { - Handle(AIS_InteractiveObject) anOwnerPresentation = - Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); - NCollection_Map aPresentations = - theShapesToBeSelected.Find(aParameterShape); - if (aPresentations.Contains(anOwnerPresentation)) { - theContext->AddOrRemoveSelected(anOwner); - anOwner->SetSelected (Standard_True); - } + const TopoDS_Shape& aParameterShape = aShapeIt.Key(); + // isSame should be used here as it does not check orientation of shapes + // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is + // different for Edges shapes in model shape and owner even if this is the same shape + if (aParameterShape.IsSame(aShape)) { + Handle(AIS_InteractiveObject) anOwnerPresentation = + Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); + NCollection_Map aPresentations = + theShapesToBeSelected.Find(aParameterShape); + if (aPresentations.Contains(anOwnerPresentation)) { + theContext->AddOrRemoveSelected(anOwner); + anOwner->SetSelected (Standard_True); + // collect selected presentations to do not select them if compsolid is selected + if (!aSelectedPresentations.Contains(anOwnerPresentation)) + aSelectedPresentations.Add(anOwnerPresentation); } } + else if (!aCustomOwner.IsNull()) { // CompSolid processing #2219 + // shape of owner is compound, but shape to be selected is compsolid, so + // we need to compare shape to AIS presentation of owner(rule of the owner creation) + Handle(AIS_Shape) anOwnerPresentation = + Handle(AIS_Shape)::DownCast(anOwner->Selectable()); + const TopoDS_Shape& aPresentationShape = anOwnerPresentation->Shape(); + if (aParameterShape.IsSame(anOwnerPresentation->Shape()) && + !aCompsolidPresentations.Contains(anOwnerPresentation)) + aCompsolidPresentations.Add(anOwnerPresentation); + } } } } + // select CompSolid presentations if their owners was not selected yet + NCollection_Map::Iterator anIt (aCompsolidPresentations); + for (; anIt.More(); anIt.Next()) { + if (aSelectedPresentations.Contains(anIt.Value())) + continue; + theContext->AddOrRemoveSelected(anIt.Value()); + } } -- 2.39.2