From 20890f89a3cb6b296257b87078265e4cf40afe80 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 6 May 2019 16:34:02 +0300 Subject: [PATCH] 0030695: Visualization - selection by box should use clipping planes set for viewer --- src/SelectMgr/SelectMgr_ViewerSelector.cxx | 29 ++++++++++++++++++++ src/StdSelect/StdSelect_ViewerSelector3d.cxx | 4 +++ 2 files changed, 33 insertions(+) diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 0476e7fd6b..20933e9777 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -420,7 +420,36 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable { return; } + // in case of Box/Polyline selection - keep only Owners having all Entities detected + if (!theMgr.ViewClipping().IsNull() && + theMgr.GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Box) + //&& theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Polyline)) + { + Graphic3d_BndBox3d aBBox (aSensitivesTree->MinPoint (0), aSensitivesTree->MaxPoint (0)); + // If box selection is active, and the whole sensitive tree is out of the clip planes + // selection is empty for this object + const Handle(Graphic3d_SequenceOfHClipPlane)& aViewPlanes = theMgr.ViewClipping(); + + for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aViewPlanes); aPlaneIt.More(); aPlaneIt.Next()) + { + const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value(); + if (!aPlane->IsOn()) + { + continue; + } + Graphic3d_ClipState aState = aPlane->ProbeBox (aBBox); + if (aState == Graphic3d_ClipState_Out) + { + return; + } + if (aState == Graphic3d_ClipState_On && !mySelectingVolumeMgr.IsOverlapAllowed()) // partially clipped + { + return; + } + } + } + const Standard_Integer aFirstStored = mystored.Extent() + 1; Standard_Integer aStack[BVH_Constants_MaxTreeDepth]; diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index 19fc15a01d..8ed26b7c6d 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -175,6 +175,8 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPMin, mySelectingVolumeMgr.BuildSelectingVolume (aMinMousePos, aMaxMousePos); + mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes()); + TraverseSensitives(); } @@ -193,6 +195,8 @@ void StdSelect_ViewerSelector3d::Pick (const TColgp_Array1OfPnt2d& thePolyline, mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight); mySelectingVolumeMgr.BuildSelectingVolume (thePolyline); + mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes()); + TraverseSensitives(); } -- 2.39.5