From: nds Date: Tue, 27 Aug 2019 05:26:23 +0000 (+0300) Subject: 0030922: Visualization - OpenGl_Text wrong local transformation if text has not own... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=6ad25e3a28407f265580a6a5a056802dfe840b0d;p=occt-copy.git 0030922: Visualization - OpenGl_Text wrong local transformation if text has not own attach point (cherry picked from commit d149bbcbaf7d237425b574a1977acb07db299bea) (cherry picked from commit 95a4927b5b2b9310de6ebe36f0fe6523cebe52c6) (cherry picked from commit f414985732fb8084363d543e65fc4d7232e22488) (cherry picked from commit 976a69be5faf878072d4b93006493a5fd5ae422f) --- diff --git a/src/AIS/AIS_TextLabel.cxx b/src/AIS/AIS_TextLabel.cxx index 07bb69bf0c..ce9cc7459d 100644 --- a/src/AIS/AIS_TextLabel.cxx +++ b/src/AIS/AIS_TextLabel.cxx @@ -41,6 +41,7 @@ AIS_TextLabel::AIS_TextLabel() myFont ("Courier"), myFontAspect (Font_FA_Regular), myHasOrientation3D (Standard_False), + myHasOwnAnchorPoint (Standard_True), myHasFlipping (Standard_False) { myDrawer->SetTextAspect (new Prs3d_TextAspect()); @@ -308,7 +309,12 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr gp_Ax2 anOrientation = myOrientation3D; anOrientation.SetLocation (aPosition); - Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, !myHasFlipping); + + Standard_Boolean aHasOwnAnchor = HasOwnAnchorPoint(); + if (myHasFlipping) + aHasOwnAnchor = Standard_False; // always not using own anchor if flipping + + Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, aHasOwnAnchor); if (myHasFlipping && isInit) { Prs3d_Root::CurrentGroup (thePrs)->SetFlippingOptions (Standard_False, gp_Ax2()); diff --git a/src/AIS/AIS_TextLabel.hxx b/src/AIS/AIS_TextLabel.hxx index 2641044959..75f4c18d89 100644 --- a/src/AIS/AIS_TextLabel.hxx +++ b/src/AIS/AIS_TextLabel.hxx @@ -90,6 +90,12 @@ public: Standard_EXPORT Standard_Boolean HasFlipping() const; + //! Returns flag if text uses position as point of attach + Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; } + + //! Set flag if text uses position as point of attach + void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; } + //! Define the display type of the text. //! //! TODT_NORMAL Default display. Text only. @@ -121,6 +127,7 @@ protected: Font_FontAspect myFontAspect; gp_Ax2 myOrientation3D; Standard_Boolean myHasOrientation3D; + Standard_Boolean myHasOwnAnchorPoint; Standard_Boolean myHasFlipping; public: diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index c550ce4ecc..784cdc74d2 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -427,6 +427,12 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx, { OpenGl_Mat4d aCurrentWorldViewMat; aCurrentWorldViewMat.Convert (theCtx->WorldViewState.Current()); + + // apply local transformation + OpenGl_Mat4d aModelWorld; + aModelWorld.Convert (theCtx->ModelWorldState.Current()); + aCurrentWorldViewMat = aCurrentWorldViewMat * aModelWorld; + theCtx->WorldViewState.SetCurrent (aCurrentWorldViewMat * aModViewMat); } else diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 12c90ad24e..a5825f644f 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -2542,6 +2542,15 @@ static int VDrawText (Draw_Interpretor& theDI, { aTextPrs->SetFlipping (Standard_True); } + else if (aParam == "-ownanchor") + { + if (++anArgIt >= theArgsNb) + { + std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n"; + return 1; + } + aTextPrs->SetOwnAnchorPoint (Draw::Atoi (theArgVec[anArgIt]) == 1); + } else if (aParam == "-disptype" || aParam == "-displaytype") { @@ -6459,6 +6468,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands) "\n\t\t: [-noupdate]" "\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]" "\n\t\t: [-flipping]" + "\n\t\t: [-ownanchor {0|1}=1]" "\n\t\t: Display text label at specified position.", __FILE__, VDrawText, group);