From 88201b5418170634d740fdfe9fa1d5f5775ae97b Mon Sep 17 00:00:00 2001 From: mzernova Date: Wed, 10 Jun 2020 12:18:47 +0300 Subject: [PATCH] 0027919: Visualization - support multiple transformation persistence groups within single presentation added AnchorPoint transformation in accordance with local transformation (cherry picked from commit de18833ce2e8e83d84bdc25e441a4f55f50f3b7f) --- src/OpenGl/OpenGl_Structure.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 2fc4f91b41..72df9594ad 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -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(); } } -- 2.39.5