mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030857: Visualization - using one implementation of Text in graphic group
Graphic3d_Group::Text(...) are obsolete, AddText() should be used instead of these methods. Graphic3d_Text is a new class for parameters necessary to fill OpenGl_Text. All parameters of Graphic3d_Group::Text() are moved into this class. OpenGl_TextParam is removed, these fields were moved into Graphic3d_Text. OpenGl_Text constructors/Init with OpenGl_TextParam parameter were removed. Constructor with Graphic3d_Text should be used instead of it. Using OpenGl_Text Init() with OpenGl_TextParam should be now replaced on two cases. The first case is setting values into Graphic3d_Text and the second case is calling Reset() after. As example, look at modification in OpenGl_FrameStatsPrs.
This commit is contained in:
@@ -136,6 +136,8 @@ Graphic3d_StructureDefinitionError.hxx
|
||||
Graphic3d_StructureManager.cxx
|
||||
Graphic3d_StructureManager.hxx
|
||||
Graphic3d_TextPath.hxx
|
||||
Graphic3d_Text.cxx
|
||||
Graphic3d_Text.hxx
|
||||
Graphic3d_Texture1D.cxx
|
||||
Graphic3d_Texture1D.hxx
|
||||
Graphic3d_Texture1Dmanual.cxx
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include <Graphic3d_Structure.hxx>
|
||||
#include "Graphic3d_Structure.pxx"
|
||||
#include <Graphic3d_StructureManager.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Graphic3d_TransModeFlags.hxx>
|
||||
#include <Message.hxx>
|
||||
@@ -310,31 +311,21 @@ void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
|
||||
// function : Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
|
||||
void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const Graphic3d_Vertex& thePoint,
|
||||
const Standard_Real /*theHeight*/,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment /*theHta*/,
|
||||
const Graphic3d_VerticalTextAlignment /*theVta*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
Standard_ShortReal x, y, z;
|
||||
thePoint.Coord (x, y, z);
|
||||
myStructure->CStructure()->Is2dText = Standard_True;
|
||||
myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (x),
|
||||
static_cast<Standard_ShortReal> (y),
|
||||
static_cast<Standard_ShortReal> (z),
|
||||
1.0f));
|
||||
}
|
||||
Update();
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -346,8 +337,10 @@ void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
Text (theText, thePoint, theHeight, 0.0,
|
||||
Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -357,15 +350,18 @@ void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const Graphic3d_Vertex& thePoint,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(), thePoint, theHeight, theAngle,
|
||||
theTp, theHta, theVta, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -375,53 +371,43 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTP,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTP*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax,
|
||||
const Standard_Boolean theHasOwnAnchor)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(),
|
||||
theOrientation,
|
||||
theHeight,
|
||||
theAngle,
|
||||
theTP,
|
||||
theHTA,
|
||||
theVTA,
|
||||
theToEvalMinMax,
|
||||
theHasOwnAnchor);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetOrientation (theOrientation);
|
||||
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
|
||||
void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real /*theHeight*/,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment /*theHta*/,
|
||||
const Graphic3d_VerticalTextAlignment /*theVta*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax,
|
||||
const Standard_Boolean /*theHasOwnAnchor*/)
|
||||
const Standard_Boolean theHasOwnAnchor)
|
||||
{
|
||||
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();
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetOrientation (theOrientation);
|
||||
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -433,7 +419,31 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(), thePoint, theHeight, 0.0,
|
||||
Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddText
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
myStructure->CStructure()->Is2dText = !theTextParams->HasPlane();
|
||||
|
||||
gp_Pnt aPosition = theTextParams->Position();
|
||||
myBounds.Add (Graphic3d_Vec4 ((Standard_ShortReal)aPosition.X(), (Standard_ShortReal)aPosition.Y(), (Standard_ShortReal)aPosition.Z(), 1.0f));
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
@@ -37,6 +37,7 @@
|
||||
|
||||
class Graphic3d_Structure;
|
||||
class Graphic3d_ArrayOfPrimitives;
|
||||
class Graphic3d_Text;
|
||||
|
||||
//! This class allows the definition of groups
|
||||
//! of primitives inside of graphic objects (presentations).
|
||||
@@ -110,87 +111,16 @@ public:
|
||||
//! Replace aspects specified in the replacement map.
|
||||
virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
|
||||
|
||||
public:
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_EXPORT virtual void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Real AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_EXPORT void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Real AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_EXPORT virtual void Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Adds a text for display
|
||||
Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
|
||||
//! Adds an array of primitives for display
|
||||
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType, const Handle(Graphic3d_IndexBuffer)& theIndices, const Handle(Graphic3d_Buffer)& theAttribs, const Handle(Graphic3d_BoundBuffer)& theBounds, const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
|
||||
//! Adds an array of primitives for display
|
||||
Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
@@ -240,6 +170,112 @@ public:
|
||||
//! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
|
||||
bool IsClosed() const { return myIsClosed; }
|
||||
|
||||
//! @name obsolete methods
|
||||
public:
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const Standard_CString AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Real AAngle,
|
||||
const Graphic3d_TextPath ATp,
|
||||
const Graphic3d_HorizontalTextAlignment AHta,
|
||||
const Graphic3d_VerticalTextAlignment AVta,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const Standard_CString AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Real AAngle,
|
||||
const Graphic3d_TextPath ATp,
|
||||
const Graphic3d_HorizontalTextAlignment AHta,
|
||||
const Graphic3d_VerticalTextAlignment AVta,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates a group in the structure <AStructure>.
|
||||
|
49
src/Graphic3d/Graphic3d_Text.cxx
Normal file
49
src/Graphic3d/Graphic3d_Text.cxx
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_Text.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Text::Graphic3d_Text (const Standard_ShortReal theHeight)
|
||||
: myHeight (theHeight),
|
||||
myHAlign (Graphic3d_HTA_LEFT),
|
||||
myVAlign (Graphic3d_VTA_BOTTOM),
|
||||
myHasPlane (Standard_False),
|
||||
myHasOwnAnchor (Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetOrientation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Text::SetOrientation (const gp_Ax2& theOrientation)
|
||||
{
|
||||
myOrientation = theOrientation;
|
||||
myHasPlane = Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ResetOrientation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Text::ResetOrientation()
|
||||
{
|
||||
myOrientation = gp_Ax2();
|
||||
myHasPlane = Standard_False;
|
||||
}
|
115
src/Graphic3d/Graphic3d_Text.hxx
Normal file
115
src/Graphic3d/Graphic3d_Text.hxx
Normal file
@@ -0,0 +1,115 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_Text_HeaderFile
|
||||
#define _Graphic3d_Text_HeaderFile
|
||||
|
||||
#include <gp_Ax2.hxx>
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
#include <NCollection_String.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
//! This class allows the definition of a text object for display.
|
||||
//! The text might be defined in one of ways, using:
|
||||
//! - text value and position,
|
||||
//! - text value, orientation and the state whether the text uses position as point of attach.
|
||||
//! - text formatter. Formatter contains text, height and alignment parameter.
|
||||
//!
|
||||
//! This class also has parameters of the text height and H/V alignments.
|
||||
class Graphic3d_Text : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
public:
|
||||
|
||||
//! Creates default text parameters.
|
||||
Standard_EXPORT Graphic3d_Text (const Standard_ShortReal theHeight);
|
||||
|
||||
//! Destructor.
|
||||
virtual ~Graphic3d_Text() {}
|
||||
|
||||
//! Returns text value.
|
||||
const NCollection_String& Text() const { return myText; }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (const NCollection_String& theText) { myText = theText; }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (const TCollection_AsciiString& theText) { myText = theText.ToCString(); }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (Standard_CString theText) { myText = theText; }
|
||||
|
||||
//! The 3D point of attachment is projected.
|
||||
//! If the orientation is defined, the text is written in the plane of projection.
|
||||
const gp_Pnt& Position() const { return myOrientation.Location(); }
|
||||
|
||||
//! Sets text point.
|
||||
void SetPosition (const gp_Pnt& thePoint) { myOrientation.SetLocation (thePoint); }
|
||||
|
||||
//! Returns text orientation in 3D space.
|
||||
const gp_Ax2& Orientation() const { return myOrientation; }
|
||||
|
||||
//! Returns true if the text is filled by a point
|
||||
Standard_Boolean HasPlane() const { return myHasPlane; }
|
||||
|
||||
//! Sets text orientation in 3D space.
|
||||
Standard_EXPORT void SetOrientation (const gp_Ax2& theOrientation);
|
||||
|
||||
//! Reset text orientation in 3D space.
|
||||
Standard_EXPORT void ResetOrientation();
|
||||
|
||||
//! Returns true if the text has an anchor point
|
||||
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchor; }
|
||||
|
||||
//! Returns true if the text has an anchor point
|
||||
void SetOwnAnchorPoint (const Standard_Boolean theHasOwnAnchor) { myHasOwnAnchor = theHasOwnAnchor; }
|
||||
|
||||
//! Sets height of text. (Relative to the Normalized Projection Coordinates (NPC) Space).
|
||||
Standard_ShortReal Height() const { return myHeight; }
|
||||
|
||||
//! Returns height of text
|
||||
void SetHeight (const Standard_ShortReal theHeight) { myHeight = theHeight; }
|
||||
|
||||
//! Returns horizontal alignment of text.
|
||||
Graphic3d_HorizontalTextAlignment HorizontalAlignment() const { return myHAlign; }
|
||||
|
||||
//! Sets horizontal alignment of text.
|
||||
void SetHorizontalAlignment (const Graphic3d_HorizontalTextAlignment theJustification) { myHAlign = theJustification; }
|
||||
|
||||
//! Returns vertical alignment of text.
|
||||
Graphic3d_VerticalTextAlignment VerticalAlignment() const { return myVAlign; }
|
||||
|
||||
//! Sets vertical alignment of text.
|
||||
void SetVerticalAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
|
||||
|
||||
protected:
|
||||
NCollection_String myText; //!< text value
|
||||
gp_Ax2 myOrientation; //!< Text orientation in 3D space.
|
||||
|
||||
Standard_ShortReal myHeight; //!< height of text
|
||||
Graphic3d_HorizontalTextAlignment myHAlign; //!< horizontal alignment
|
||||
Graphic3d_VerticalTextAlignment myVAlign; //!< vertical alignment
|
||||
|
||||
Standard_Boolean myHasPlane; //!< Check if text have orientation in 3D space.
|
||||
Standard_Boolean myHasOwnAnchor; //!< flag if text uses position as point of attach
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
#endif // _Graphic3d_Text_HeaderFile
|
Reference in New Issue
Block a user