]> OCCT Git - occt-copy.git/commitdiff
0030695: Visualization - selection by box should use clipping planes set for viewer
authornds <nds@opencascade.com>
Mon, 6 May 2019 21:01:56 +0000 (00:01 +0300)
committernds <nds@opencascade.com>
Mon, 6 May 2019 21:01:56 +0000 (00:01 +0300)
src/SelectMgr/SelectMgr_ViewerSelector.cxx

index 20933e9777456694817242b345bacb74a9ec0b52..c30df2405a412135b26965555db7eb83dcfa45cb 100644 (file)
@@ -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)