]> OCCT Git - occt-copy.git/commitdiff
0027919: Visualization - support multiple transformation persistence groups within...
authormzernova <mzernova@opencascade.com>
Wed, 10 Jun 2020 09:18:47 +0000 (12:18 +0300)
committernds <nds@opencascade.com>
Thu, 14 Jan 2021 06:50:09 +0000 (09:50 +0300)
added AnchorPoint transformation in accordance with local transformation

(cherry picked from commit de18833ce2e8e83d84bdc25e441a4f55f50f3b7f)
(cherry picked from commit 88201b5418170634d740fdfe9fa1d5f5775ae97b)
(cherry picked from commit e0d6884df321c7d5750ee2c45f96d5e0b4166e01)
(cherry picked from commit acd78717b153e7f1e913a411d9278bfdabf2017a)

src/OpenGl/OpenGl_Structure.cxx

index 2fc4f91b412e81e148338ecc418f4dcfd918bd46..72df9594ad51856aed224b6263416caf21aa0bda 100644 (file)
@@ -392,10 +392,22 @@ void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorksp
   const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
   for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
   {
-    Handle(Graphic3d_TransformPers) aTrsfPersistence = aGroupIter.Value()->TransformPersistence();
+    const Handle(Graphic3d_TransformPers)& aTrsfPersistence = aGroupIter.Value()->TransformPersistence();
+    gp_Pnt aStartPnt;
+
     if (!aTrsfPersistence.IsNull())
     {
+      if (aTrsfPersistence->IsZoomOrRotate())
+      {
+        aCtx->ModelWorldState.Push();
+        OpenGl_Mat4& aModelWorld = aCtx->ModelWorldState.ChangeCurrent();
+        aStartPnt = aTrsfPersistence->AnchorPoint();
+        Graphic3d_Vec4 anAnchorPoint = aModelWorld * Graphic3d_Vec4 (aStartPnt.X(), aStartPnt.Y(), aStartPnt.Z(), 1.0);
+        aModelWorld.InitIdentity();
+        aTrsfPersistence->SetAnchorPoint (gp_Pnt (anAnchorPoint.x(), anAnchorPoint.y(), anAnchorPoint.z()));
+      }
       applyPersistence (aCtx, aTrsfPersistence, Standard_True);
+      aCtx->ApplyModelViewMatrix();
     }
 
     theHasClosed = theHasClosed || aGroupIter.Value()->IsClosed();
@@ -403,7 +415,13 @@ void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorksp
 
     if (!aTrsfPersistence.IsNull())
     {
+      if (aTrsfPersistence->IsZoomOrRotate())
+      {
+        aTrsfPersistence->SetAnchorPoint (aStartPnt);
+        aCtx->ModelWorldState.Pop();
+      }
       applyPersistence (aCtx, aTrsfPersistence, Standard_False);
+      aCtx->ApplyModelViewMatrix();
     }
   }
 }
@@ -668,6 +686,7 @@ void OpenGl_Structure::applyPersistence (const Handle(OpenGl_Context)& theContex
   else
   {
     theContext->WorldViewState.Pop();
+    theContext->ApplyModelViewMatrix();
   }
 }