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 41f340c..3d8ad31 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 a3a43fd..b98a255 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 87a9206..1c8bda3 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 e80ff64..262f704 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 c776afb..70b032c 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