From: isk Date: Tue, 23 Jun 2015 12:11:07 +0000 (+0300) Subject: 0026343: Visualization - Zoom persistent text with 3D orientation X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=aae09937f151a2cbaead7f0b158914747fc81c6d;p=occt-copy.git 0026343: Visualization - Zoom persistent text with 3D orientation --- diff --git a/src/AIS/AIS_TextLabel.cxx b/src/AIS/AIS_TextLabel.cxx index 511f66103e..833c28025b 100644 --- a/src/AIS/AIS_TextLabel.cxx +++ b/src/AIS/AIS_TextLabel.cxx @@ -31,10 +31,10 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject) //purpose : //======================================================================= AIS_TextLabel::AIS_TextLabel() -: myText ("?"), - myPosition (0.0, 0.0, 0.0), - myFont ("Courier"), - myFontAspect (Font_FA_Regular) +: myText ("?"), + myFont ("Courier"), + myFontAspect (Font_FA_Regular), + myHasOrientation3D (Standard_False) { myDrawer->SetTextAspect (new Prs3d_TextAspect()); @@ -76,7 +76,7 @@ void AIS_TextLabel::SetText (const TCollection_ExtendedString& theText) //======================================================================= void AIS_TextLabel::SetPosition (const gp_Pnt& thePosition) { - myPosition = thePosition; + myOrientation3D.SetLocation (thePosition); } //======================================================================= @@ -143,6 +143,43 @@ void AIS_TextLabel::SetFont (Standard_CString theFont) myDrawer->TextAspect()->SetFont (myFont.ToCString()); } +//======================================================================= +//function : Set3dOrientation +//purpose : +//======================================================================= +void AIS_TextLabel::SetOrientation3D (const gp_Ax2& theOrientation) +{ + myHasOrientation3D = Standard_True; + myOrientation3D = theOrientation; +} + +//======================================================================= +//function : Position +//purpose : +//======================================================================= +const gp_Pnt& AIS_TextLabel::Position() const +{ + return myOrientation3D.Location(); +} + +//======================================================================= +//function : Orientation3D +//purpose : +//======================================================================= +const gp_Ax2& AIS_TextLabel::Orientation3D() const +{ + return myOrientation3D; +} + +//======================================================================= +//function : HasOrientation3D() +//purpose : +//======================================================================= +Standard_Boolean AIS_TextLabel::HasOrientation3D() const +{ + return myHasOrientation3D; +} + //======================================================================= //function : Compute //purpose : @@ -156,7 +193,16 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr case 0: { Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect(); - Prs3d_Text::Draw (thePrs, anAsp, myText, myPosition); + + if (myHasOrientation3D) + { + Prs3d_Text::Draw (thePrs, anAsp, myText, myOrientation3D); + } + else + { + Prs3d_Text::Draw (thePrs, anAsp, myText, Position()); + } + break; } } @@ -174,7 +220,7 @@ void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSele case 0: { Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this, 10); - Handle(Select3D_SensitivePoint) aSensitivePoint = new Select3D_SensitivePoint (anEntityOwner, myPosition); + Handle(Select3D_SensitivePoint) aSensitivePoint = new Select3D_SensitivePoint (anEntityOwner, Position()); theSelection->Add (aSensitivePoint); break; } diff --git a/src/AIS/AIS_TextLabel.hxx b/src/AIS/AIS_TextLabel.hxx index 813bf01ee1..10db6f1891 100644 --- a/src/AIS/AIS_TextLabel.hxx +++ b/src/AIS/AIS_TextLabel.hxx @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -64,6 +65,18 @@ public: //! Setup font. Standard_EXPORT void SetFont (Standard_CString theFont); + //! Setup orientation 3D. + Standard_EXPORT void SetOrientation3D (const gp_Ax2& theOrientation); + + //! Returns position. + Standard_EXPORT const gp_Pnt& Position() const; + + //! Returns orientation 3D. + Standard_EXPORT const gp_Ax2& Orientation3D() const; + + //! Returns true if current text placement in 3D. + Standard_EXPORT Standard_Boolean HasOrientation3D() const; + private: //! Compute @@ -78,9 +91,10 @@ private: protected: TCollection_ExtendedString myText; - gp_Pnt myPosition; TCollection_AsciiString myFont; Font_FontAspect myFontAspect; + gp_Ax2 myOrientation3D; + Standard_Boolean myHasOrientation3D; public: diff --git a/src/Graphic3d/Graphic3d_Group.cdl b/src/Graphic3d/Graphic3d_Group.cdl index e22cd5fa6e..bc3e673c95 100644 --- a/src/Graphic3d/Graphic3d_Group.cdl +++ b/src/Graphic3d/Graphic3d_Group.cdl @@ -46,6 +46,9 @@ deferred class Group from Graphic3d inherits TShared -- -- Developers are strongly recommended to take all the above into account when filling Graphic3d_Group -- with aspects and primitives and choose the group usage model beforehand out of application needs. + -- + -- Note that some Graphic3d_Group class virtual methods contain only base implementation + -- that is extended by the descendant class in OpenGl package. ---Warning: ---References: @@ -331,7 +334,7 @@ deferred class Group from Graphic3d inherits TShared -- AAngle : Orientation of the text -- (with respect to the horizontal). ---Category: Methods to create Text - + Text ( me : mutable; AText : ExtendedString from TCollection; APoint : Vertex from Graphic3d; @@ -353,7 +356,33 @@ deferred class Group from Graphic3d inherits TShared -- AHta : HTA_LEFT -- AVta : VTA_BOTTOM ---Category: Methods to create Text - + + Text (me : mutable; + theTextUtf : CString from Standard; + theOrientation : Ax2 from gp; + theHeight : Real from Standard; + theAngle : PlaneAngle from Quantity; + theTp : TextPath from Graphic3d; + theHTA : HorizontalTextAlignment from Graphic3d; + theVTA : VerticalTextAlignment from Graphic3d; + theToEvalMinMax : Boolean from Standard = Standard_True) is virtual; + ---Level: Public + ---Purpose: Creates the string at orientation in 3D space. + ---Category: Methods to create Text + + Text (me : mutable; + theText : ExtendedString from TCollection; + theOrientation : Ax2 from gp; + theHeight : Real from Standard; + theAngle : PlaneAngle from Quantity; + theTp : TextPath from Graphic3d; + theHTA : HorizontalTextAlignment from Graphic3d; + theVTA : VerticalTextAlignment from Graphic3d; + theToEvalMinMax : Boolean from Standard = Standard_True) is static; + ---Level: Internal + ---Purpose: Creates the string at orientation in 3D space. + ---Category: Methods to create Text + --------------------------------------- ---Category: Methods to create Triangle --------------------------------------- diff --git a/src/Graphic3d/Graphic3d_Group.cxx b/src/Graphic3d/Graphic3d_Group.cxx index 62a4dedc7a..e3e67b646a 100644 --- a/src/Graphic3d/Graphic3d_Group.cxx +++ b/src/Graphic3d/Graphic3d_Group.cxx @@ -1138,6 +1138,59 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText, theTp, theHta, theVta, theToEvalMinMax); } +// ======================================================================= +// function : Text +// purpose : +// ======================================================================= +void Graphic3d_Group::Text (const TCollection_ExtendedString& theText, + const gp_Ax2& theOrientation, + const Standard_Real theHeight, + const Quantity_PlaneAngle theAngle, + const Graphic3d_TextPath theTP, + const Graphic3d_HorizontalTextAlignment theHTA, + const Graphic3d_VerticalTextAlignment theVTA, + const Standard_Boolean theToEvalMinMax) +{ + const NCollection_String aText ((Standard_Utf16Char*)(theText.ToExtString())); + Text (aText.ToCString(), + theOrientation, + theHeight, + theAngle, + theTP, + theHTA, + theVTA, + theToEvalMinMax); +} + +// ======================================================================= +// function : Text +// purpose : +// ======================================================================= +void Graphic3d_Group::Text (const Standard_CString /*theText*/, + const gp_Ax2& theOrientation, + const Standard_Real /*theHeight*/, + const Quantity_PlaneAngle /*theAngle*/, + const Graphic3d_TextPath /*theTp*/, + const Graphic3d_HorizontalTextAlignment /*theHta*/, + const Graphic3d_VerticalTextAlignment /*theVta*/, + const Standard_Boolean theToEvalMinMax) +{ + if (IsDeleted()) + { + return; + } + + if (theToEvalMinMax) + { + myStructure->CStructure()->Is2dText = Standard_False; + myBounds.Add (Graphic3d_Vec4 (static_cast (theOrientation.Location().X()), + static_cast (theOrientation.Location().Y()), + static_cast (theOrientation.Location().Z()), + 1.0f)); + } + Update(); +} + // ======================================================================= // function : Text // purpose : diff --git a/src/OpenGl/OpenGl_Group.cxx b/src/OpenGl/OpenGl_Group.cxx index 8eda7341bb..600b703392 100644 --- a/src/OpenGl/OpenGl_Group.cxx +++ b/src/OpenGl/OpenGl_Group.cxx @@ -232,6 +232,46 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf, theTp, theHta, theVta, theToEvalMinMax); } +// ======================================================================= +// function : Text +// purpose : +// ======================================================================= +void OpenGl_Group::Text (const Standard_CString theTextUtf, + const gp_Ax2& theOrientation, + const Standard_Real theHeight, + const Quantity_PlaneAngle theAngle, + const Graphic3d_TextPath theTp, + const Graphic3d_HorizontalTextAlignment theHTA, + const Graphic3d_VerticalTextAlignment theVTA, + const Standard_Boolean theToEvalMinMax) +{ + if (IsDeleted()) + { + return; + } + + OpenGl_TextParam aParams; + OpenGl_Structure* aStruct = GlStruct(); + + aParams.Height = int ((theHeight < 2.0) ? aStruct->GlDriver()->DefaultTextHeight() : theHeight); + aParams.HAlign = theHTA; + aParams.VAlign = theVTA; + + OpenGl_Text* aText = new OpenGl_Text (theTextUtf, theOrientation, aParams); + + AddElement (aText); + + Graphic3d_Group::Text (theTextUtf, + theOrientation, + theHeight, + theAngle, + theTp, + theHTA, + theVTA, + theToEvalMinMax); + +} + // ======================================================================= // function : UserDraw // purpose : diff --git a/src/OpenGl/OpenGl_Group.hxx b/src/OpenGl/OpenGl_Group.hxx index 6406bd245e..5d1c1df04b 100644 --- a/src/OpenGl/OpenGl_Group.hxx +++ b/src/OpenGl/OpenGl_Group.hxx @@ -77,6 +77,16 @@ public: const Graphic3d_VerticalTextAlignment theVta, const Standard_Boolean theToEvalMinMax); + //! Add text element in 3D space. + Standard_EXPORT virtual void Text (const Standard_CString theTextUtf, + const gp_Ax2& theOrientation, + const Standard_Real theHeight, + const Quantity_PlaneAngle theAngle, + const Graphic3d_TextPath theTp, + const Graphic3d_HorizontalTextAlignment theHTA, + const Graphic3d_VerticalTextAlignment theVTA, + const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE; + //! Add UserDraw element using obsolete API Standard_EXPORT virtual void UserDraw (const Standard_Address theObject, const Standard_Boolean theToEvalMinMax, diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index d98a62da76..93ceede87e 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -146,8 +147,8 @@ OpenGl_Text::OpenGl_Text() myWinZ (0.0f), myScaleHeight (1.0f), myPoint (0.0f, 0.0f, 0.0f), - - myIs2d (false) + myIs2d (false), + myHasPlane (false) { myParams.Height = 10; myParams.HAlign = Graphic3d_HTA_LEFT; @@ -169,13 +170,37 @@ OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText, myParams (theParams), myString (theText), myPoint (thePoint), - myIs2d (false) + myIs2d (false), + myHasPlane (false) { // } // ======================================================================= +// function : OpenGl_Text +// purpose : +// ======================================================================= +OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText, + const gp_Ax2& theOrientation, + const OpenGl_TextParam& theParams) +: myWinX (0.0), + myWinY (0.0), + myWinZ (0.0), + myScaleHeight (1.0), + myExportHeight (1.0), + myParams (theParams), + myString (theText), + myOrientation (theOrientation), + myIs2d (false), + myHasPlane (true) +{ + const gp_Pnt& aPoint = theOrientation.Location(); + myPoint = OpenGl_Vec3 (static_cast (aPoint.X()), + static_cast (aPoint.Y()), + static_cast (aPoint.Z())); +} +// ======================================================================= // function : SetPosition // purpose : // ======================================================================= @@ -391,6 +416,9 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const aTextAspect, aTextAspect->ShaderProgramRes (aCtx)); } + myOrientationMatrix = theWorkspace->ActiveView()->Camera()->OrientationMatrix(); + myProjMatrix.Convert (aCtx->ProjectionState.Current()); + // use highlight color or colors from aspect if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) { @@ -443,6 +471,16 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, const OpenGl_Vec3 theDVec) const { OpenGl_Mat4d aModViewMat; + OpenGl_Mat4d aProjectMat; + + if (myHasPlane) + { + aProjectMat = myProjMatrix * myOrientationMatrix; + } + else + { + aProjectMat = myProjMatrix; + } if (myIs2d) { @@ -459,14 +497,29 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, std::floor (myWinY + theDVec.y()), myWinZ + theDVec.z(), OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX), - OpenGl_Mat4d::Map (myProjMatrix), + OpenGl_Mat4d::Map (aProjectMat), myViewport, anObjX, anObjY, anObjZ); - OpenGl_Utils::Translate (aModViewMat, anObjX, anObjY, anObjZ); - OpenGl_Utils::Rotate (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0); + if (myHasPlane) + { + const gp_Dir& aVectorDir = myOrientation.XDirection(); + const gp_Dir& aVectorUp = myOrientation.Direction(); + const gp_Dir& aVectorRight = myOrientation.YDirection(); + + aModViewMat.SetColumn (3, OpenGl_Vec3d (anObjX, anObjY, anObjZ)); + aModViewMat.SetColumn (2, OpenGl_Vec3d (aVectorUp.X(), aVectorUp.Y(), aVectorUp.Z())); + aModViewMat.SetColumn (1, OpenGl_Vec3d (aVectorRight.X(), aVectorRight.Y(), aVectorRight.Z())); + aModViewMat.SetColumn (0, OpenGl_Vec3d (aVectorDir.X(), aVectorDir.Y(), aVectorDir.Z())); + } + else + { + OpenGl_Utils::Translate (aModViewMat, anObjX, anObjY, anObjZ); + OpenGl_Utils::Rotate (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0); + } + if (!theTextAspect.IsZoomable()) { #ifdef _WIN32 @@ -490,6 +543,9 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, theCtx->WorldViewState.SetCurrent (aModViewMat); theCtx->ApplyWorldViewMatrix(); + theCtx->ProjectionState.SetCurrent (aProjectMat); + theCtx->ApplyProjectionMatrix(); + if (!theCtx->ActiveProgram().IsNull()) { // Upload updated state to shader program @@ -582,7 +638,9 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, { aFontFt = new Font_FTFont (NULL); - if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight)) + // 96 is default resolution (dpi) for display devices like the screen. + // Support of adaptive calculation of the resolution is necessary. + if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight, 96)) { aFont = new OpenGl_Font (aFontFt, theKey); if (!aFont->Init (theCtx)) @@ -692,7 +750,6 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, if (!myIs2d) { glGetIntegerv (GL_VIEWPORT, myViewport); - myProjMatrix.Convert (theCtx->ProjectionState.Current()); OpenGl_Utils::Project (myPoint.x(), myPoint.y(), @@ -836,6 +893,9 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f)); drawText (thePrintCtx, theCtx, theTextAspect); + theCtx->ProjectionState.SetCurrent (myProjMatrix); + theCtx->ApplyProjectionMatrix(); + #if !defined(GL_ES_VERSION_2_0) if (theCtx->core11 != NULL) { diff --git a/src/OpenGl/OpenGl_Text.hxx b/src/OpenGl/OpenGl_Text.hxx index 71200ee30a..b4cfeaaaa2 100755 --- a/src/OpenGl/OpenGl_Text.hxx +++ b/src/OpenGl/OpenGl_Text.hxx @@ -27,6 +27,8 @@ #include #include +#include + class Handle(OpenGl_PrinterContext); //! Text rendering @@ -40,6 +42,11 @@ public: const OpenGl_Vec3& thePoint, const OpenGl_TextParam& theParams); + //! Creates new text in 3D space. + Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText, + const gp_Ax2& theOrientation, + const OpenGl_TextParam& theParams); + //! Setup new string and position Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx, const Standard_Utf8Char* theText, @@ -139,6 +146,7 @@ protected: mutable OpenGl_Mat4d myProjMatrix; mutable OpenGl_Mat4d myModelMatrix; + mutable OpenGl_Mat4d myOrientationMatrix; mutable GLint myViewport[4]; mutable GLdouble myWinX; mutable GLdouble myWinY; @@ -152,6 +160,8 @@ protected: NCollection_String myString; OpenGl_Vec3 myPoint; bool myIs2d; + gp_Ax2 myOrientation; //!< Text orientation in 3D space. + bool myHasPlane; //!< Check if text have orientation in 3D space. public: diff --git a/src/Prs3d/Prs3d_Text.cdl b/src/Prs3d/Prs3d_Text.cdl index 62c160ceee..8b7992b66a 100644 --- a/src/Prs3d/Prs3d_Text.cdl +++ b/src/Prs3d/Prs3d_Text.cdl @@ -22,7 +22,8 @@ uses Pnt from gp, Drawer from Prs3d, TextAspect from Prs3d, - ExtendedString from TCollection + ExtendedString from TCollection, + Ax2 from gp is Draw(myclass; aPresentation: Presentation from Prs3d; @@ -36,7 +37,14 @@ is -- static void Draw (const Handle(Prs3d_Presentation)& -- aPresentation, const Handle(Prs3d_TextAspect)& -- anAspect, const TCollection_ExtendedString& aText, - -- const gp_Pnt& AttachmentPoint); + -- const gp_Pnt& AttachmentPoint); + + Draw(myclass; + thePresentation : Presentation from Prs3d; + theAspect : TextAspect from Prs3d; + theText : ExtendedString from TCollection; + theOrientation : Ax2 from gp); + ---Purpose: Defines the display of the text theText at the orientation 3d space. Draw(myclass; aPresentation: Presentation from Prs3d; anAspect: TextAspect from Prs3d; diff --git a/src/Prs3d/Prs3d_Text.cxx b/src/Prs3d/Prs3d_Text.cxx index ea726f96d7..6de1d62231 100644 --- a/src/Prs3d/Prs3d_Text.cxx +++ b/src/Prs3d/Prs3d_Text.cxx @@ -31,12 +31,9 @@ void Prs3d_Text::Draw ( Standard_Real x,y,z; AttachmentPoint.Coord(x,y,z); - -// POP Graphic3d_Grup accepte de l'extended Prs3d_Root::CurrentGroup(aPresentation)->Text( -// TCollection_AsciiString(aText).ToCString(), - aText, - Graphic3d_Vertex(x,y,z), + aText, + Graphic3d_Vertex(x,y,z), anAspect->Height(), anAspect->Angle(), anAspect->Orientation(), @@ -54,3 +51,22 @@ void Prs3d_Text::Draw ( Prs3d_Text::Draw(aPresentation,aDrawer->TextAspect(),aText,AttachmentPoint); } + +// ======================================================================= +// function : Draw +// purpose : +// ======================================================================= +void Prs3d_Text::Draw (const Handle(Prs3d_Presentation)& thePresentation, + const Handle(Prs3d_TextAspect)& theAspect, + const TCollection_ExtendedString& theText, + const gp_Ax2& theOrientation) +{ + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect(theAspect->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->Text(theText, + theOrientation, + theAspect->Height(), + theAspect->Angle(), + theAspect->Orientation(), + theAspect->HorizontalJustification(), + theAspect->VerticalJustification()); +} diff --git a/src/Prs3d/Prs3d_TextAspect.cdl b/src/Prs3d/Prs3d_TextAspect.cdl index ba7dbecdc2..6d169366a7 100644 --- a/src/Prs3d/Prs3d_TextAspect.cdl +++ b/src/Prs3d/Prs3d_TextAspect.cdl @@ -66,10 +66,10 @@ is SetVerticalJustification(me: mutable; aJustification: VerticalTextAlignment from Graphic3d); --- Purpose: Sets the vertical alignment of text. - + SetOrientation(me: mutable; anOrientation: TextPath from Graphic3d); - ---Purpose: Sets the orientation of text. - + ---Purpose: Sets the orientation of text. + HorizontalJustification(me) returns HorizontalTextAlignment from Graphic3d; --- Purpose: Returns the horizontal alignment of the text. -- The range of values includes: @@ -87,15 +87,15 @@ is -- - half -- - base -- - bottom - + Orientation(me) returns TextPath from Graphic3d; --- Purpose: Returns the orientation of the text. -- Text can be displayed in the following directions: -- - up -- - down -- - left, or - -- - right - + -- - right + Aspect(me) returns AspectText3d from Graphic3d; ---Purpose: Returns the purely textual attributes used in the display of text. -- These include: @@ -112,7 +112,7 @@ fields myHeight: Real from Standard; myHorizontalJustification: HorizontalTextAlignment from Graphic3d; myVerticalJustification: VerticalTextAlignment from Graphic3d; - myOrientation: TextPath from Graphic3d; + myOrientation: TextPath from Graphic3d; end TextAspect from Prs3d; diff --git a/src/Prs3d/Prs3d_TextAspect.cxx b/src/Prs3d/Prs3d_TextAspect.cxx index c0527bae54..07fec50b9e 100644 --- a/src/Prs3d/Prs3d_TextAspect.cxx +++ b/src/Prs3d/Prs3d_TextAspect.cxx @@ -23,7 +23,8 @@ Prs3d_TextAspect::Prs3d_TextAspect () myHeight(16.), myHorizontalJustification(Graphic3d_HTA_LEFT), myVerticalJustification(Graphic3d_VTA_BOTTOM), - myOrientation(Graphic3d_TP_RIGHT) { + myOrientation(Graphic3d_TP_RIGHT) +{ myTextAspect = new Graphic3d_AspectText3d ( Quantity_Color(Quantity_NOC_YELLOW), diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 0c59eeec6b..d482be6afe 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -2430,6 +2430,12 @@ static int VDrawText (Draw_Interpretor& theDI, aTextPrs->SetText (aText); + + Standard_Boolean aHasPlane = Standard_False; + gp_Dir aNormal; + gp_Dir aDirection; + gp_Pnt aPos; + for (; anArgIt < theArgsNb; ++anArgIt) { TCollection_AsciiString aParam (theArgVec[anArgIt]); @@ -2448,7 +2454,6 @@ static int VDrawText (Draw_Interpretor& theDI, return 1; } - gp_Pnt aPos; aPos.SetX (Draw::Atof (theArgVec[++anArgIt])); aPos.SetY (Draw::Atof (theArgVec[++anArgIt])); aPos.SetZ (Draw::Atof (theArgVec[++anArgIt])); @@ -2616,6 +2621,26 @@ static int VDrawText (Draw_Interpretor& theDI, aTextPrs->SetFont (theArgVec[anArgIt]); } + else if (aParam == "-plane") + { + if (anArgIt + 6 >= theArgsNb) + { + std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n"; + return 1; + } + + Standard_Real aX = Draw::Atof (theArgVec[++anArgIt]); + Standard_Real aY = Draw::Atof (theArgVec[++anArgIt]); + Standard_Real aZ = Draw::Atof (theArgVec[++anArgIt]); + aNormal.SetCoord (aX, aY, aZ); + + aX = Draw::Atof (theArgVec[++anArgIt]); + aY = Draw::Atof (theArgVec[++anArgIt]); + aZ = Draw::Atof (theArgVec[++anArgIt]); + aDirection.SetCoord (aX, aY, aZ); + + aHasPlane = Standard_True; + } else { std::cout << "Error: unknown argument '" << aParam << "'\n"; @@ -2623,6 +2648,11 @@ static int VDrawText (Draw_Interpretor& theDI, } } + if (aHasPlane) + { + aTextPrs->SetOrientation3D (gp_Ax2 (aPos, aNormal, aDirection)); + } + ViewerTest::Display (aName, aTextPrs, Standard_False); return 0; } @@ -6005,6 +6035,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands) "\n\t\t: [-aspect {regular|bold|italic|bolditalic}=regular]" "\n\t\t: [-font font=Times]" "\n\t\t: [-noupdate]" + "\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]" "\n\t\t: Display text label at specified position.", __FILE__, VDrawText, group); diff --git a/tests/3rdparty/grids.list b/tests/3rdparty/grids.list index 3cd0a0bf93..358d577b50 100644 --- a/tests/3rdparty/grids.list +++ b/tests/3rdparty/grids.list @@ -1,2 +1,3 @@ 001 export 002 fonts +003 text3d \ No newline at end of file diff --git a/tests/3rdparty/text3d/A1 b/tests/3rdparty/text3d/A1 new file mode 100644 index 0000000000..ab7f34f5b2 --- /dev/null +++ b/tests/3rdparty/text3d/A1 @@ -0,0 +1,28 @@ +puts "===========" +puts "0026149: " +puts "" +puts "===========" + +pload ALL +vinit View1 +vclear +vaxo + +set x 10 +set y 50 +set z 30 + +box b $x $y $z +vdisplay b +vtrihedron tri0 + +vdrawtext t0 "Top text in plane yOz" -pos $x 0 $z -color green -height 20 -plane 1 0 0 0 1 0 -valign top +vdrawtext t1 "Bottom text in plane yOz" -pos 0 $y 0 -color green -height 20 -plane -1 0 0 0 -1 0 -valign bottom + +vdrawtext t2 "Some text on the top face" -pos $x/2 $y/2 $z -color red -height 20 -plane 0 0 1 0 1 0 -valign center -halign center + +vdrawtext t3 "First line\nSecond line" -pos $x/2 0 $z/2 -color 0.0 0.0 1.0 -height 20 -plane 0 -1 0 0 0 1 -valign center -halign center + +vfit + +vdump ${imagedir}/${casename}.png