0030863: Visualization, SelectMgr_ViewerSelector - disabling of View clipping planes...
authorkgv <kgv@opencascade.com>
Fri, 9 Aug 2019 10:00:30 +0000 (13:00 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 9 Aug 2019 14:36:47 +0000 (17:36 +0300)
SelectMgr_ViewerSelector::computeFrustum() - fixed lost clipping planes when creating a new frustum.

src/SelectMgr/SelectMgr_RectangularFrustum.hxx
src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx
src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx
src/SelectMgr/SelectMgr_ViewerSelector.cxx
src/SelectMgr/SelectMgr_ViewerSelector.hxx

index 41f340c61381a89bab223f761e38e85c08f30b32..3d8ad31e89058cf2daf9fa7cf4ca000a666ddc9b 100644 (file)
@@ -109,6 +109,12 @@ public:
   Standard_EXPORT virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
                                                 const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes) Standard_OVERRIDE;
 
+  //! Return clipping range.
+  const SelectMgr_ViewClipRange& ViewClipRanges() const { return myViewClipRange; }
+
+  //! Set clipping range.
+  void SetViewClipRanges (const SelectMgr_ViewClipRange& theRange) { myViewClipRange = theRange; }
+
   //! A set of helper functions that return rectangular selecting frustum data
   inline const gp_Pnt* GetVertices() const { return myVertices; }
 
index a3a43fda9a48d7f9d3f59509bf88b6dfb60cc173..b98a255dc2ebfeca44048cd7988e02571be2d1c8 100644 (file)
@@ -465,3 +465,18 @@ void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_S
 
   mySelectingVolumes[Frustum]->SetViewClipping (theViewPlanes, theObjPlanes);
 }
+
+//=======================================================================
+// function : SetViewClipping
+// purpose  :
+//=======================================================================
+void SelectMgr_SelectingVolumeManager::SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther)
+{
+  myViewClipPlanes   = theOther.ViewClipping();
+  myObjectClipPlanes = theOther.ObjectClipping();
+  if (myActiveSelectionType != Point)
+    return;
+
+  const SelectMgr_RectangularFrustum* aFrOther = reinterpret_cast<const SelectMgr_RectangularFrustum*>(theOther.mySelectingVolumes[Frustum].get());
+  reinterpret_cast<SelectMgr_RectangularFrustum*>(mySelectingVolumes[Frustum].get())->SetViewClipRanges (aFrOther->ViewClipRanges());
+}
index 87a9206cbd9d4d53d3f819b8bc1bcef4453901ef..1c8bda348568f7e610169f19a651c8de462314c0 100644 (file)
@@ -178,6 +178,9 @@ public:
   Standard_EXPORT void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
                                         const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes);
 
+  //! Copy clipping planes from another volume manager.
+  Standard_EXPORT void SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther);
+
   //! A set of helper functions that return rectangular selecting frustum data
   Standard_EXPORT const gp_Pnt* GetVertices() const;
 
index e80ff644dfe5d6c6b4c716354a672e8a7aaab3d0..262f704f5efc733e3f42075a4f261f9a4dbf94dc 100644 (file)
@@ -250,15 +250,14 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(Select3D_SensitiveEnti
 
 //=======================================================================
 // function: computeFrustum
-// purpose : Internal function that checks if a current selecting frustum
-//           needs to be scaled and transformed for the entity and performs
-//           necessary calculations
+// purpose :
 //=======================================================================
 void SelectMgr_ViewerSelector::computeFrustum (const Handle(Select3D_SensitiveEntity)& theEnt,
-                                               const SelectMgr_SelectingVolumeManager&     theMgr,
-                                               const gp_GTrsf&                             theInvTrsf,
-                                               SelectMgr_FrustumCache&                     theCachedMgrs,
-                                               SelectMgr_SelectingVolumeManager&           theResMgr)
+                                               const SelectMgr_SelectingVolumeManager& theMgrGlobal,
+                                               const SelectMgr_SelectingVolumeManager& theMgrObject,
+                                               const gp_GTrsf& theInvTrsf,
+                                               SelectMgr_FrustumCache& theCachedMgrs,
+                                               SelectMgr_SelectingVolumeManager& theResMgr)
 {
   Standard_Integer aScale = isToScaleFrustum (theEnt) ? sensitivity (theEnt) : 1;
   const gp_GTrsf aTrsfMtr = theEnt->HasInitLocation() ? theEnt->InvInitLocation() * theInvTrsf : theInvTrsf;
@@ -266,19 +265,26 @@ void SelectMgr_ViewerSelector::computeFrustum (const Handle(Select3D_SensitiveEn
   const Standard_Boolean toTransform = aTrsfMtr.Form() != gp_Identity;
   if (toScale && toTransform)
   {
-    theResMgr = theMgr.ScaleAndTransform (aScale, aTrsfMtr, NULL);
+    theResMgr = theMgrGlobal.ScaleAndTransform (aScale, aTrsfMtr, NULL);
+    theResMgr.SetViewClipping (theMgrObject);
   }
   else if (toScale)
   {
-    if (!theCachedMgrs.IsBound (aScale))
+    if (!theCachedMgrs.Find (aScale, theResMgr))
     {
-      theCachedMgrs.Bind (aScale, theMgr.ScaleAndTransform (aScale, gp_Trsf(), NULL));
+      theResMgr = theMgrGlobal.ScaleAndTransform (aScale, gp_Trsf(), NULL);
+      theCachedMgrs.Bind (aScale, theResMgr);
     }
-    theResMgr = theCachedMgrs.Find (aScale);
+    theResMgr.SetViewClipping (theMgrObject);
   }
   else if (toTransform)
   {
-    theResMgr = theMgr.ScaleAndTransform (1, aTrsfMtr, NULL);
+    theResMgr = theMgrGlobal.ScaleAndTransform (1, aTrsfMtr, NULL);
+    theResMgr.SetViewClipping (theMgrObject);
+  }
+  else
+  {
+    theResMgr = theMgrObject;
   }
 }
 
@@ -408,6 +414,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
   Standard_Integer aHead = -1;
   Standard_Integer aNode = 0; // a root node
   SelectMgr_FrustumCache aScaledTrnsfFrustums;
+  SelectMgr_SelectingVolumeManager aTmpMgr;
   for (;;)
   {
     if (!aSensitivesTree->IsOuter (aNode))
@@ -484,8 +491,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
           if (aSensitive->IsActiveForSelection())
           {
             const Handle(Select3D_SensitiveEntity)& anEnt = aSensitive->BaseSensitive();
-            SelectMgr_SelectingVolumeManager aTmpMgr = aMgr;
-            computeFrustum (anEnt, theMgr, aInversedTrsf, aScaledTrnsfFrustums, aTmpMgr);
+            computeFrustum (anEnt, theMgr, aMgr, aInversedTrsf, aScaledTrnsfFrustums, aTmpMgr);
             checkOverlap (anEnt, aInversedTrsf, aTmpMgr);
           }
         }
index c776afbc2e170725857664a4b3eb6d77e3c1896e..70b032cd1c3b077ff5198975c946d5b72b1f26f9 100644 (file)
@@ -290,14 +290,13 @@ private:
   //! removes a Selection from the Selector
   void Remove (const Handle(SelectMgr_Selection)& aSelection);
 
-  //! Internal function that checks if a current selecting frustum
-  //! needs to be scaled and transformed for the entity and performs
-  //! necessary calculations
+  //! Internal function that checks if a current selecting frustum needs to be scaled and transformed for the entity and performs necessary calculations.
   void computeFrustum (const Handle(Select3D_SensitiveEntity)& theEnt,
-                       const SelectMgr_SelectingVolumeManager&     theMgr,
-                       const gp_GTrsf&                             theInvTrsf,
-                       SelectMgr_FrustumCache&                     theCachedMgrs,
-                       SelectMgr_SelectingVolumeManager&           theResMgr);
+                       const SelectMgr_SelectingVolumeManager& theMgrGlobal,
+                       const SelectMgr_SelectingVolumeManager& theMgrObject,
+                       const gp_GTrsf& theInvTrsf,
+                       SelectMgr_FrustumCache& theCachedMgrs,
+                       SelectMgr_SelectingVolumeManager& theResMgr);
 
 
 private: // implementation of deprecated methods