mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
0026343: Visualization - Zoom persistent text with 3D orientation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Font_FontAspect.hxx>
|
||||
@@ -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:
|
||||
|
||||
|
@@ -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 <theText> at orientation <theOrientation> 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 <theText> at orientation <theOrientation> in 3D space.
|
||||
---Category: Methods to create Text
|
||||
|
||||
---------------------------------------
|
||||
---Category: Methods to create Triangle
|
||||
---------------------------------------
|
||||
|
@@ -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<Standard_ShortReal> (theOrientation.Location().X()),
|
||||
static_cast<Standard_ShortReal> (theOrientation.Location().Y()),
|
||||
static_cast<Standard_ShortReal> (theOrientation.Location().Z()),
|
||||
1.0f));
|
||||
}
|
||||
Update();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Text
|
||||
// purpose :
|
||||
|
@@ -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 :
|
||||
|
@@ -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,
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <OpenGl_Text.hxx>
|
||||
#include <OpenGl_Utils.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <OpenGl_View.hxx>
|
||||
|
||||
#include <Font_FontMgr.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
@@ -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<Standard_ShortReal> (aPoint.X()),
|
||||
static_cast<Standard_ShortReal> (aPoint.Y()),
|
||||
static_cast<Standard_ShortReal> (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<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
|
||||
OpenGl_Utils::Rotate<GLdouble> (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<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
|
||||
OpenGl_Utils::Rotate<GLdouble> (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<Standard_Real> (aModViewMat);
|
||||
theCtx->ApplyWorldViewMatrix();
|
||||
|
||||
theCtx->ProjectionState.SetCurrent<Standard_Real> (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<Standard_Real> (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<Standard_Real> (myProjMatrix);
|
||||
theCtx->ApplyProjectionMatrix();
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (theCtx->core11 != NULL)
|
||||
{
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
|
||||
#include <gp_Ax2.hxx>
|
||||
|
||||
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:
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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),
|
||||
|
@@ -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);
|
||||
|
||||
|
1
tests/3rdparty/grids.list
vendored
1
tests/3rdparty/grids.list
vendored
@@ -1,2 +1,3 @@
|
||||
001 export
|
||||
002 fonts
|
||||
003 text3d
|
28
tests/3rdparty/text3d/A1
vendored
Normal file
28
tests/3rdparty/text3d/A1
vendored
Normal file
@@ -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
|
Reference in New Issue
Block a user