From f283acabdaea72a0abca46aa296ae1b933ca1970 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 7 May 2019 00:01:56 +0300 Subject: [PATCH] 0030695: Visualization - selection by box should use clipping planes set for viewer --- src/SelectMgr/SelectMgr_ViewerSelector.cxx | 57 ++++++++++++++++++---- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 20933e9777..c30df2405a 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -439,14 +439,14 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable } Graphic3d_ClipState aState = aPlane->ProbeBox (aBBox); - if (aState == Graphic3d_ClipState_Out) - { - return; - } - if (aState == Graphic3d_ClipState_On && !mySelectingVolumeMgr.IsOverlapAllowed()) // partially clipped + if (aState == Graphic3d_ClipState_Out) // do not process only whole trees, next check on the tree node { return; } + //if (aState == Graphic3d_ClipState_On && !mySelectingVolumeMgr.IsOverlapAllowed()) // partially clipped + //{ + // return; + //} } } @@ -493,17 +493,54 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable } else { - Standard_Integer aStartIdx = aSensitivesTree->BegPrimitive (aNode); - Standard_Integer anEndIdx = aSensitivesTree->EndPrimitive (aNode); - for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx) + bool aClipped = false; + if (!theMgr.ViewClipping().IsNull() && + theMgr.GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Box) + //&& theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Polyline)) { - const Handle(SelectMgr_SensitiveEntity)& aSensitive = anEntitySet->GetSensitiveById (anIdx); - if (aSensitive->IsActiveForSelection()) + Graphic3d_BndBox3d aBBox (aSensitivesTree->MinPoint (aNode), aSensitivesTree->MaxPoint (aNode)); + // 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(SelectBasics_SensitiveEntity)& anEnt = aSensitive->BaseSensitive(); SelectMgr_SelectingVolumeManager aTmpMgr = aMgr; computeFrustum (anEnt, theMgr, aInversedTrsf, aScaledTrnsfFrustums, aTmpMgr); checkOverlap (anEnt, aInversedTrsf, aTmpMgr); + const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value(); + if (!aPlane->IsOn()) + { + continue; + } + Graphic3d_ClipState aState = aPlane->ProbeBox (aBBox); + if (aState == Graphic3d_ClipState_Out) + { + aClipped = true; + break; + } + if (aState == Graphic3d_ClipState_On && !mySelectingVolumeMgr.IsOverlapAllowed()) // partially clipped + { + aClipped = true; + break; + } + } + } + if (!aClipped) + { + Standard_Integer aStartIdx = aSensitivesTree->BegPrimitive (aNode); + Standard_Integer anEndIdx = aSensitivesTree->EndPrimitive (aNode); + for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx) + { + const Handle(SelectMgr_SensitiveEntity)& aSensitive = anEntitySet->GetSensitiveById (anIdx); + if (aSensitive->IsActiveForSelection()) + { + const Handle(SelectBasics_SensitiveEntity)& anEnt = aSensitive->BaseSensitive(); + SelectMgr_SelectingVolumeManager aTmpMgr = aMgr; + computeFrustum (anEnt, theMgr, aInversedTrsf, aScaledTrnsfFrustums, aTmpMgr); + checkOverlap (anEnt, aInversedTrsf, aTmpMgr); + } } } if (aHead < 0) -- 2.39.5