]> OCCT Git - occt-copy.git/commitdiff
0030922: Visualization - OpenGl_Text wrong local transformation if text has not own...
authornds <nds@opencascade.com>
Tue, 27 Aug 2019 05:26:23 +0000 (08:26 +0300)
committernds <nds@opencascade.com>
Thu, 10 Oct 2019 05:49:23 +0000 (08:49 +0300)
(cherry picked from commit d149bbcbaf7d237425b574a1977acb07db299bea)
(cherry picked from commit 95a4927b5b2b9310de6ebe36f0fe6523cebe52c6)
(cherry picked from commit f414985732fb8084363d543e65fc4d7232e22488)

src/AIS/AIS_TextLabel.cxx
src/AIS/AIS_TextLabel.hxx
src/OpenGl/OpenGl_Text.cxx
src/ViewerTest/ViewerTest_ObjectCommands.cxx

index 07bb69bf0c6676b6de291a04760f84c0a38347fd..ce9cc7459d53a2ff2cf24b9fd8de809ae75dda86 100644 (file)
@@ -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());
index 2641044959e870059d60578c9f9056b4355564f3..75f4c18d89120ff1efeaa5c5d9d9b0a08378e30f 100644 (file)
@@ -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:
index 2f88a720dab0e18671acb9427c340f73cd2a0a15..cefa63ec63d17581cf8045544c42a7e8cdb1a672 100644 (file)
@@ -426,6 +426,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<Standard_Real> (aCurrentWorldViewMat * aModViewMat);
   }
   else
index 12c90ad24ee35a1c9b857d5c8d628070a0534e7b..a5825f644f81f96b74c6f39b1548ff5a2115a66b 100644 (file)
@@ -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);