mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
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)
This commit is contained in:
@@ -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());
|
||||
|
@@ -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:
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user