#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Graphic3d_TextParams.hxx>
+#include <Graphic3d_Text.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
{
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (anAspect->Height());
- const NCollection_String aText (theText.ToExtString());
- aTextParams->Init (aText,
- gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
- Standard_False, // has own anchor
- Graphic3d_HTA_LEFT,
- theVertAlignment);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (anAspect->Height());
+ aTextParams->SetText (theText.ToExtString());
+ aTextParams->SetOrientation (gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()));
+ aTextParams->SetOwnAnchorPoint (Standard_False);
+ aTextParams->SetVAlignment (theVertAlignment);
+
theGroup->AddText (aTextParams);
}
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
-#include <Graphic3d_TextParams.hxx>
+#include <Graphic3d_Text.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
if (*aText != '\0')
{
- Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
-
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (1./81.);
- aTextParams->Init (aText, a2);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (1./81.);
+ aTextParams->SetText (aText);
+ aTextParams->SetPosition (gp_Pnt (aPlast.X(),aPlast.Y(),aPlast.Z()));
Prs3d_Root::CurrentGroup(aPresentation)->AddText (aTextParams);
}
}
if (*aText != '\0')
{
- Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (1./81.);
- aTextParams->Init (aText, a2);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (1./81.);
+ aTextParams->SetText (aText);
+ aTextParams->SetPosition (gp_Pnt (aPlast.X(),aPlast.Y(),aPlast.Z()));
Prs3d_Root::CurrentGroup(aPresentation)->AddText(aTextParams);
}
}
Graphic3d_StructureManager.cxx
Graphic3d_StructureManager.hxx
Graphic3d_TextPath.hxx
-Graphic3d_TextParams.cxx
-Graphic3d_TextParams.hxx
+Graphic3d_Text.cxx
+Graphic3d_Text.hxx
Graphic3d_Texture1D.cxx
Graphic3d_Texture1D.hxx
Graphic3d_Texture1Dmanual.cxx
#include <Graphic3d_Structure.hxx>
#include "Graphic3d_Structure.pxx"
#include <Graphic3d_StructureManager.hxx>
-#include <Graphic3d_TextParams.hxx>
+#include <Graphic3d_Text.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TransModeFlags.hxx>
#include <Message.hxx>
const Graphic3d_VerticalTextAlignment theVta,
const Standard_Boolean theToEvalMinMax)
{
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theHeight);
- aTextParams->Init (theText, thePoint, theHta, theVta);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
+ aTextParams->SetText (theText);
+ aTextParams->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
+ aTextParams->SetHAlignment (theHta);
+ aTextParams->SetVAlignment (theVta);
AddText (aTextParams, theToEvalMinMax);
}
const Standard_Real theHeight,
const Standard_Boolean theToEvalMinMax)
{
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theHeight);
- aTextParams->Init (theText, thePoint);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
+ aTextParams->SetText (theText);
+ aTextParams->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
AddText (aTextParams, theToEvalMinMax);
}
{
const NCollection_String aText (theText.ToExtString());
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theHeight);
- aTextParams->Init (aText, thePoint, theHta, theVta);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
+ aTextParams->SetText (aText);
+ aTextParams->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
+ aTextParams->SetHAlignment (theHta);
+ aTextParams->SetVAlignment (theVta);
AddText (aTextParams, theToEvalMinMax);
}
{
const NCollection_String aText (theText.ToExtString());
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theHeight);
- aTextParams->Init (aText, theOrientation, theHasOwnAnchor, theHta, theVta);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
+ aTextParams->SetText (aText);
+ aTextParams->SetOrientation (theOrientation);
+ aTextParams->SetOwnAnchorPoint (theHasOwnAnchor);
+ aTextParams->SetHAlignment (theHta);
+ aTextParams->SetVAlignment (theVta);
AddText (aTextParams, theToEvalMinMax);
}
const Standard_Boolean theToEvalMinMax,
const Standard_Boolean theHasOwnAnchor)
{
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theHeight);
- aTextParams->Init (theText, theOrientation, theHasOwnAnchor, theHta, theVta);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
+ aTextParams->SetText (theText);
+ aTextParams->SetOrientation (theOrientation);
+ aTextParams->SetOwnAnchorPoint (theHasOwnAnchor);
+ aTextParams->SetHAlignment (theHta);
+ aTextParams->SetVAlignment (theVta);
AddText (aTextParams, theToEvalMinMax);
}
const Standard_Boolean theToEvalMinMax,
const Standard_Boolean theHasOwnAnchor)
{
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theHeight);
- aTextParams->Init (theTextFormatter, theOrientation, theHasOwnAnchor);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
+ aTextParams->SetTextFormatter (theTextFormatter);
+ aTextParams->SetOrientation (theOrientation);
+ aTextParams->SetOwnAnchorPoint (theHasOwnAnchor);
AddText (aTextParams, theToEvalMinMax);
}
{
const NCollection_String aText (theText.ToExtString());
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theHeight);
- aTextParams->Init (aText, thePoint);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
+ aTextParams->SetText (aText);
+ aTextParams->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
AddText (aTextParams, theToEvalMinMax);
}
// function : AddText
// purpose :
// =======================================================================
-void Graphic3d_Group::AddText (const Handle(Graphic3d_TextParams)& theTextParams,
+void Graphic3d_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
const Standard_Boolean theToEvalMinMax)
{
if (IsDeleted())
if (theToEvalMinMax)
{
- if (theTextParams->HasPlane())
- {
- myStructure->CStructure()->Is2dText = Standard_False;
- const gp_Ax2& anOrientation = theTextParams->Orientation();
- myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (anOrientation.Location().X()),
- static_cast<Standard_ShortReal> (anOrientation.Location().Y()),
- static_cast<Standard_ShortReal> (anOrientation.Location().Z()),
- 1.0f));
- }
- else
- {
- Standard_ShortReal x, y, z;
- theTextParams->Position().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));
- }
+ myStructure->CStructure()->Is2dText = !theTextParams->HasPlane();
+
+ gp_Pnt aPosition = theTextParams->Position();
+ myBounds.Add (Graphic3d_Vec4 (aPosition.X(), aPosition.Y(), aPosition.Z(), 1.0f));
}
Update();
class Graphic3d_Structure;
class Graphic3d_ArrayOfPrimitives;
class Graphic3d_AspectFillCapping;
-class Graphic3d_TextParams;
+class Graphic3d_Text;
//! This class allows the definition of groups
//! of primitives inside of graphic objects (presentations).
//! Replace aspects specified in the replacement map.
virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
+ //! 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);
+
+ //! Adds an array of primitives for display
+ Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
+
+ //! Creates a primitive array with single marker using AddPrimitiveArray().
+ Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True);
+
+public:
+
+ //! sets the stencil test to theIsEnabled state;
+ Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0;
+
+ //! sets the flipping to theIsEnabled state.
+ Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane) = 0;
+
+ //! Returns true if the group contains Polygons, Triangles or Quadrangles.
+ bool ContainsFacet() const { return myContainsFacet; }
+
+ //! Returns Standard_True if the group <me> is deleted.
+ //! <me> is deleted after the call Remove (me) or the
+ //! associated structure is deleted.
+ Standard_EXPORT Standard_Boolean IsDeleted() const;
+
+ //! Returns Standard_True if the group <me> is empty.
+ Standard_EXPORT Standard_Boolean IsEmpty() const;
+
+ //! Returns the coordinates of the boundary box of the group.
+ Standard_EXPORT void MinMaxValues (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
+ Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const;
+
+ //! Sets the coordinates of the boundary box of the group.
+ Standard_EXPORT void SetMinMaxValues (const Standard_Real theXMin, const Standard_Real theYMin, const Standard_Real theZMin,
+ const Standard_Real theXMax, const Standard_Real theYMax, const Standard_Real theZMax);
+
+ //! Returns boundary box of the group <me> without transformation applied,
+ const Graphic3d_BndBox4f& BoundingBox() const { return myBounds; }
+
+ //! Returns non-const boundary box of the group <me> without transformation applied,
+ Graphic3d_BndBox4f& ChangeBoundingBox() { return myBounds; }
+
+ //! Returns the structure containing the group <me>.
+ Standard_EXPORT Handle(Graphic3d_Structure) Structure() const;
+
+ //! Changes property shown that primitive arrays within this group form closed volume (do no contain open shells).
+ void SetClosed (const bool theIsClosed) { myIsClosed = theIsClosed; }
+
+ //! 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>.
const Standard_Boolean theToEvalMinMax,
const Standard_Boolean theHasOwnAnchor = Standard_True);
- //! Adds a text for display
- Standard_EXPORT virtual void AddText (const Handle(Graphic3d_TextParams)& 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);
-
- //! Adds an array of primitives for display
- Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
-
- //! Creates a primitive array with single marker using AddPrimitiveArray().
- Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True);
-
-public:
-
- //! sets the stencil test to theIsEnabled state;
- Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0;
-
- //! sets the flipping to theIsEnabled state.
- Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane) = 0;
-
- //! Returns true if the group contains Polygons, Triangles or Quadrangles.
- bool ContainsFacet() const { return myContainsFacet; }
-
- //! Returns Standard_True if the group <me> is deleted.
- //! <me> is deleted after the call Remove (me) or the
- //! associated structure is deleted.
- Standard_EXPORT Standard_Boolean IsDeleted() const;
-
- //! Returns Standard_True if the group <me> is empty.
- Standard_EXPORT Standard_Boolean IsEmpty() const;
-
- //! Returns the coordinates of the boundary box of the group.
- Standard_EXPORT void MinMaxValues (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
- Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const;
-
- //! Sets the coordinates of the boundary box of the group.
- Standard_EXPORT void SetMinMaxValues (const Standard_Real theXMin, const Standard_Real theYMin, const Standard_Real theZMin,
- const Standard_Real theXMax, const Standard_Real theYMax, const Standard_Real theZMax);
-
- //! Returns boundary box of the group <me> without transformation applied,
- const Graphic3d_BndBox4f& BoundingBox() const { return myBounds; }
-
- //! Returns non-const boundary box of the group <me> without transformation applied,
- Graphic3d_BndBox4f& ChangeBoundingBox() { return myBounds; }
-
- //! Returns the structure containing the group <me>.
- Standard_EXPORT Handle(Graphic3d_Structure) Structure() const;
-
- //! Changes property shown that primitive arrays within this group form closed volume (do no contain open shells).
- void SetClosed (const bool theIsClosed) { myIsClosed = theIsClosed; }
-
- //! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
- bool IsClosed() const { return myIsClosed; }
-
protected:
//! Creates a group in the structure <AStructure>.
--- /dev/null
+// Copyright (c) 2013-2014 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_Real theHeight)
+: myHeight (theHeight),
+ myHasPlane (Standard_False),
+ myHasOwnAnchor (Standard_True),
+ myHAlign (Graphic3d_HTA_LEFT),
+ myVAlign (Graphic3d_VTA_BOTTOM)
+{
+}
--- /dev/null
+// 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_TextParams_HeaderFile
+#define _Graphic3d_TextParams_HeaderFile
+
+#include <gp_Ax2.hxx>
+
+#include <Graphic3d_Vertex.hxx>
+#include <Graphic3d_TextPath.hxx>
+#include <Graphic3d_HorizontalTextAlignment.hxx>
+#include <Graphic3d_VerticalTextAlignment.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+
+#include <Font_TextFormatter.hxx>
+
+//! This class with text parameters.
+//! The text might be defined in some plane and has own attached point.
+//! In case if text formatter is used, the text value is store in the formatter.
+class Graphic3d_Text : public Standard_Transient
+{
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
+
+public:
+
+ Standard_EXPORT Graphic3d_Text (const Standard_Real theHeight);
+
+ //! Destructor.
+ Standard_EXPORT virtual ~Graphic3d_Text() {}
+
+ //! Sets text value.
+ const NCollection_String& Text() const { return myText; }
+
+ //! Returns text value.
+ void SetText (const NCollection_String& 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.
+ void SetOrientation (const gp_Ax2& theOrientation) { myOrientation = theOrientation; myHasPlane = Standard_True; }
+
+ //! Reset text orientation in 3D space.
+ void ResetOrientation() { myOrientation = gp_Ax2(); myHasPlane = Standard_False; }
+
+ //! 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_Real Height() const { return myHeight; }
+
+ //! Returns height of text
+ void SetHeight (const Standard_Real theHeight) { myHeight = theHeight; }
+
+ //! Returns horizontal alignment of text.
+ Graphic3d_HorizontalTextAlignment HAlignment() const { return myHAlign; }
+
+ //! Sets horizontal alignment of text.
+ void SetHAlignment (const Graphic3d_HorizontalTextAlignment theJustification) { myHAlign = theJustification; }
+
+ //! Returns vertical alignment of text.
+ Graphic3d_VerticalTextAlignment VAlignment() const { return myVAlign; }
+
+ //! Sets vertical alignment of text.
+ void SetVAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
+
+ //! Returns text formatter
+ const Handle(Font_TextFormatter)& TextFormatter() const { return myTextFormatter; }
+
+ //! Sets text formatter
+ void SetTextFormatter (const Handle(Font_TextFormatter)& theTextFormatter) { myTextFormatter = theTextFormatter; }
+
+private:
+ NCollection_String myText; //!< text value
+ Handle(Font_TextFormatter) myTextFormatter; //!< text formatter collect information about text letter positions
+
+ bool myHasPlane; //!< Check if text have orientation in 3D space.
+ gp_Ax2 myOrientation; //!< Text orientation in 3D space.
+
+ Standard_Real myHeight; //!< height of text
+ Graphic3d_HorizontalTextAlignment myHAlign; //!< horizontal alignment
+ Graphic3d_VerticalTextAlignment myVAlign; //!< vertical alignment
+ Standard_Boolean myHasOwnAnchor; //!< flag if text uses position as point of attach
+};
+
+DEFINE_STANDARD_HANDLE(Graphic3d_Text, Standard_Transient)
+
+#endif // _Graphic3d_TextParams_HeaderFile
+++ /dev/null
-// Copyright (c) 2013-2014 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_TextParams.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_TextParams, Standard_Transient)
-
-// =======================================================================
-// function : Graphic3d_TextParams
-// purpose :
-// =======================================================================
-Graphic3d_TextParams::Graphic3d_TextParams (const Standard_Real theHeight)
-: myHeight (theHeight)
-{
- reset();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void Graphic3d_TextParams::Init (const NCollection_String theText,
- const Graphic3d_Vertex& thePoint,
- const Graphic3d_HorizontalTextAlignment theHta,
- const Graphic3d_VerticalTextAlignment theVta)
-{
- reset();
-
- myHasPlane = Standard_False;
- myHasOwnAnchor = Standard_True;
-
- myText = theText;
- myPoint = thePoint;
-
- myHAlign = theHta;
- myVAlign = theVta;
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void Graphic3d_TextParams::Init (const NCollection_String theText,
- const gp_Ax2& theOrientation,
- const Standard_Boolean theHasOwnAnchor,
- const Graphic3d_HorizontalTextAlignment theHta,
- const Graphic3d_VerticalTextAlignment theVta)
-{
- reset();
-
- myHasPlane = Standard_True;
- myHasOwnAnchor = theHasOwnAnchor;
-
- myText = theText;
- myOrientation = theOrientation;
- const gp_Pnt& aPoint = theOrientation.Location();
- myPoint = Graphic3d_Vertex (static_cast<Standard_ShortReal> (aPoint.X()),
- static_cast<Standard_ShortReal> (aPoint.Y()),
- static_cast<Standard_ShortReal> (aPoint.Z()));
-
- myHAlign = theHta;
- myVAlign = theVta;
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void Graphic3d_TextParams::Init (const Handle(Font_TextFormatter)& theTextFormatter,
- const gp_Ax2& theOrientation,
- const Standard_Boolean theHasOwnAnchor)
-{
- reset();
-
- myHasPlane = Standard_True;
- myHasOwnAnchor = theHasOwnAnchor;
-
- myText = "";
- myTextFormatter = theTextFormatter;
- myOrientation = theOrientation;
- const gp_Pnt& aPoint = theOrientation.Location();
- myPoint = Graphic3d_Vertex (static_cast<Standard_ShortReal> (aPoint.X()),
- static_cast<Standard_ShortReal> (aPoint.Y()),
- static_cast<Standard_ShortReal> (aPoint.Z()));
-}
-
-// =======================================================================
-// function : reset
-// purpose :
-// =======================================================================
-void Graphic3d_TextParams::reset()
-{
- myHasPlane = Standard_False;
- myHasOwnAnchor = Standard_True;
-
- myText = "";
- myTextFormatter = NULL;
- myPoint = Graphic3d_Vertex (0.0f, 0.0f, 0.0f);
- myOrientation = gp_Ax2();
-
- myHAlign = Graphic3d_HTA_LEFT;
- myVAlign = Graphic3d_VTA_BOTTOM;
-}
+++ /dev/null
-// Copyright (c) 2013-2014 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_TextParams_HeaderFile
-#define _Graphic3d_TextParams_HeaderFile
-
-#include <gp_Ax2.hxx>
-
-#include <Graphic3d_Vertex.hxx>
-#include <Graphic3d_TextPath.hxx>
-#include <Graphic3d_HorizontalTextAlignment.hxx>
-#include <Graphic3d_VerticalTextAlignment.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_Transient.hxx>
-
-#include <Font_TextFormatter.hxx>
-
-//! This class describes texture parameters.
-class Graphic3d_TextParams : public Standard_Transient
-{
- DEFINE_STANDARD_RTTIEXT(Graphic3d_TextParams, Standard_Transient)
-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 Graphic3d_TextParams (const Standard_Real theHeight);
-
- //! Destructor.
- Standard_EXPORT virtual ~Graphic3d_TextParams() {}
-
- //! Fill with text and point
- Standard_EXPORT void Init (const NCollection_String theText,
- const Graphic3d_Vertex& thePoint,
- const Graphic3d_HorizontalTextAlignment theHta = Graphic3d_HTA_LEFT,
- const Graphic3d_VerticalTextAlignment theVta = Graphic3d_VTA_BOTTOM);
-
- //! Fill with text and orientation
- Standard_EXPORT void Init (const NCollection_String theText,
- const gp_Ax2& theOrientation,
- const Standard_Boolean theHasOwnAnchor = Standard_True,
- const Graphic3d_HorizontalTextAlignment theHta = Graphic3d_HTA_LEFT,
- const Graphic3d_VerticalTextAlignment theVta = Graphic3d_VTA_BOTTOM);
-
- //! Fill by text formatter
- Standard_EXPORT void Init (const Handle(Font_TextFormatter)& theTextFormatter,
- const gp_Ax2& theOrientation,
- const Standard_Boolean theHasOwnAnchor = Standard_True);
-
- //! Returns true if the text is filled by a point
- Standard_Boolean HasPlane() const { return myHasPlane; }
-
- const NCollection_String& Text() const { return myText; }
-
- //! Returns text point.
- const Graphic3d_Vertex& Position() const { return myPoint; }
-
- //! Sets text point.
- void SetPosition (const Graphic3d_Vertex& thePoint) { myPoint.SetCoord (thePoint.X(), thePoint.Y(), thePoint.Z()); }
-
- //! Returns true if the text has an anchor point
- Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchor; }
-
- //! Returns text orientation in 3D space.
- const gp_Ax2& Orientation() const { return myOrientation; }
-
- Standard_Integer Height() const { return myHeight; }
- void SetHeight (const Standard_Integer theHeight) { myHeight = theHeight; }
-
- Graphic3d_HorizontalTextAlignment HAlignment() const { return myHAlign; }
- Graphic3d_VerticalTextAlignment VAlignment() const { return myVAlign; }
-
- //! Returns text formatter
- const Handle(Font_TextFormatter)& TextFormatter() const { return myTextFormatter; }
-
-protected:
- //! Resets parameters to default
- void reset();
-
-private:
- NCollection_String myText;
- Handle(Font_TextFormatter) myTextFormatter;
-
- bool myHasPlane; //!< Check if text have orientation in 3D space.
- Graphic3d_Vertex myPoint;
- gp_Ax2 myOrientation; //!< Text orientation in 3D space.
-
-private:
- // general properties
- Standard_Integer myHeight;
- Graphic3d_HorizontalTextAlignment myHAlign;
- Graphic3d_VerticalTextAlignment myVAlign;
- Standard_Boolean myHasOwnAnchor;
-};
-
-DEFINE_STANDARD_HANDLE(Graphic3d_TextParams, Standard_Transient)
-
-#endif // _Graphic3d_TextParams_HeaderFile
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
-#include <Graphic3d_TextParams.hxx>
+#include <Graphic3d_Text.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Vertex.hxx>
#include <MeshVS_Buffer.hxx>
}
aPnts.Append (Graphic3d_Vec3 ((float )X, (float )Y, (float )Z));
- Graphic3d_Vertex aPoint (X, Y, Z);
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (aHeight);
- aTextParams->Init (aStr.ToCString(), aPoint);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (aHeight);
+ aTextParams->SetText (aStr.ToCString());
+ aTextParams->SetPosition (gp_Pnt (X, Y, Z));
aTextGroup->AddText(aTextParams);
}
}
myTextAspect.SetAspect (aRendParams.StatsTextAspect);
// adjust text alignment depending on corner
- OpenGl_TextParam aParams;
- aParams.Height = aRendParams.StatsTextHeight;
- aParams.HAlign = Graphic3d_HTA_CENTER;
- aParams.VAlign = Graphic3d_VTA_CENTER;
+ Graphic3d_Text aParams (aRendParams.StatsTextHeight);
+ aParams.SetHAlignment (Graphic3d_HTA_CENTER);
+ aParams.SetVAlignment (Graphic3d_VTA_CENTER);
if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_LEFT) != 0)
{
- aParams.HAlign = Graphic3d_HTA_LEFT;
+ aParams.SetHAlignment (Graphic3d_HTA_LEFT);
}
else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
{
- aParams.HAlign = Graphic3d_HTA_RIGHT;
+ aParams.SetHAlignment (Graphic3d_HTA_RIGHT);
}
if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_TOP) != 0)
{
- aParams.VAlign = Graphic3d_VTA_TOP;
+ aParams.SetVAlignment (Graphic3d_VTA_TOP);
}
else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_BOTTOM) != 0)
{
- aParams.VAlign = Graphic3d_VTA_BOTTOM;
+ aParams.SetVAlignment (Graphic3d_VTA_BOTTOM);
}
- if (aParams.Height != myCountersText.FormatParams()->Height()
- || aParams.HAlign != myCountersText.FormatParams()->HAlignment()
- || aParams.VAlign != myCountersText.FormatParams()->VAlignment())
+ if (aParams.Height() != myCountersText.FormatParams()->Height()
+ || aParams.HAlignment() != myCountersText.FormatParams()->HAlignment()
+ || aParams.VAlignment() != myCountersText.FormatParams()->VAlignment())
{
myCountersText.Release (aCtx.operator->());
}
TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats);
myCountersText.Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f),
- Standard_False, aParams.Height, aParams.HAlign, aParams.VAlign);
+ Standard_False, aParams.Height(), aParams.HAlignment(), aParams.VAlignment());
updateChart (theWorkspace);
}
}
{
- OpenGl_TextParam aParams;
- aParams.Height = aRendParams.StatsTextHeight;
- aParams.HAlign = (!myChartTrsfPers.IsNull()
+ Graphic3d_Text aParams (aRendParams.StatsTextHeight);
+ aParams.SetHAlignment ((!myChartTrsfPers.IsNull()
&& myChartTrsfPers->IsTrihedronOr2d()
&& (myChartTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
? Graphic3d_HTA_RIGHT
- : Graphic3d_HTA_LEFT;
- aParams.VAlign = Graphic3d_VTA_CENTER;
+ : Graphic3d_HTA_LEFT);
+ aParams.SetVAlignment (Graphic3d_VTA_CENTER);
TCollection_AsciiString aLabels[3] =
{
TCollection_AsciiString() + 0 + " ms",
formatTimeMs(aMaxDuration)
};
- const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT
+ const float aLabX = aParams.HAlignment() == Graphic3d_HTA_RIGHT
? float(anOffset.x())
: float(anOffset.x() + aCharSize.x());
myChartLabels[0].Init (aCtx,
aLabels[isTopDown ? 0 : 2].ToCString(),
OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f),
- Standard_False, aParams.Height, aParams.HAlign, aParams.VAlign);
+ Standard_False, aParams.Height(), aParams.HAlignment(), aParams.VAlignment());
myChartLabels[1].Init (aCtx,
aLabels[isTopDown ? 1 : 1].ToCString(),
OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f),
- Standard_False, aParams.Height, aParams.HAlign, aParams.VAlign);
+ Standard_False, aParams.Height(), aParams.HAlignment(), aParams.VAlignment());
myChartLabels[2].Init (aCtx,
aLabels[isTopDown ? 2 : 0].ToCString(),
OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f),
- Standard_False, aParams.Height, aParams.HAlign, aParams.VAlign);
+ Standard_False, aParams.Height(), aParams.HAlignment(), aParams.VAlignment());
}
}
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_GraphicDriver.hxx>
-#include <Graphic3d_TextParams.hxx>
+#include <Graphic3d_Text.hxx>
#include <Graphic3d_TransformPers.hxx>
#include <Graphic3d_TransformUtils.hxx>
#include <gp_Ax3.hxx>
namespace
{
- static const OpenGl_TextParam THE_LABEL_PARAMS =
- {
- 16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
- };
+ static Standard_Real THE_LABEL_HEIGHT = 16;
+ static Graphic3d_HorizontalTextAlignment THE_LABEL_HALIGH = Graphic3d_HTA_LEFT;
+ static Graphic3d_VerticalTextAlignment THE_LABEL_VALIGH = Graphic3d_VTA_BOTTOM;
}
// =======================================================================
myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
theWorkspace->SetAspects (&myAspectLabels);
- anAxis.Label.FormatParams()->SetPosition (Graphic3d_Vertex(aMiddle.x(), aMiddle.y(), aMiddle.z()));
+ anAxis.Label.FormatParams()->SetPosition (gp_Pnt (aMiddle.x(), aMiddle.y(), aMiddle.z()));
anAxis.Label.Render (theWorkspace);
}
Line (NULL),
Arrow (NULL)
{
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (THE_LABEL_PARAMS.Height);
- aTextParams->Init (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()),
- Graphic3d_Vertex (theDirection.x(), theDirection.y(), theDirection.z()),
- THE_LABEL_PARAMS.HAlign, THE_LABEL_PARAMS.VAlign);
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (THE_LABEL_HEIGHT);
+ aTextParams->SetText (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()));
+ aTextParams->SetPosition (gp_Pnt (theDirection.x(), theDirection.y(), theDirection.z()));
+ aTextParams->SetHAlignment (THE_LABEL_HALIGH);
+ aTextParams->SetVAlignment (THE_LABEL_VALIGH);
Label = OpenGl_Text (aTextParams);
NameColor = theAspect.NameColor();
LineAspect.Aspect()->SetColor (theAspect.Color());
}
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
- OpenGl_TextParam aTextParam;
- aTextParam.Height = (int )aHeight;
OpenGl_Aspects aTextAspect;
TCollection_ExtendedString anExtText = theText;
NCollection_String aText (anExtText.ToExtString());
- OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
+ OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aHeight, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
}
//=======================================================================
// function : AddText
// purpose :
// =======================================================================
-void OpenGl_Group::AddText (const Handle(Graphic3d_TextParams)& theTextParams,
+void OpenGl_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
const Standard_Boolean theToEvalMinMax)
{
if (IsDeleted())
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
//! Adds a text for display
- Standard_EXPORT virtual void AddText (const Handle(Graphic3d_TextParams)& theTextParams,
+ Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
const Standard_Boolean theToEvalMinMax = Standard_True) Standard_OVERRIDE;
//! Add flipping element
myScaleHeight (1.0f),
myIs2d (false)
{
- myParams = new Graphic3d_TextParams (10.);
- myParams->Init ("", Graphic3d_Vertex (0.0f, 0.0f, 0.0f));
+ myParams = new Graphic3d_Text (10.);
+ myParams->SetText ("");
+ myParams->SetPosition (gp_Pnt (0.0f, 0.0f, 0.0f));
}
// =======================================================================
// =======================================================================
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
const OpenGl_Vec3& thePoint,
- const OpenGl_TextParam& theParams)
+ const Graphic3d_Text& theParams)
: myWinX (0.0f),
myWinY (0.0f),
myWinZ (0.0f),
myExportHeight (1.0f),
myIs2d (false)
{
- myParams = new Graphic3d_TextParams (theParams.Height);
- myParams->Init (theText, Graphic3d_Vertex (thePoint.x(), thePoint.y(), thePoint.z()), theParams.HAlign, theParams.VAlign);
+ myParams = new Graphic3d_Text (theParams.Height());
+ myParams->SetText (theText);
+ myParams->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
+ myParams->SetHAlignment (theParams.HAlignment());
+ myParams->SetVAlignment (theParams.VAlignment());
//
}
// =======================================================================
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
const gp_Ax2& theOrientation,
- const OpenGl_TextParam& theParams,
+ const Graphic3d_Text& theParams,
const bool theHasOwnAnchor)
: myWinX (0.0),
myWinY (0.0),
myExportHeight (1.0),
myIs2d (false)
{
- myParams = new Graphic3d_TextParams (theParams.Height);
- myParams->Init (theText, theOrientation, theHasOwnAnchor, theParams.HAlign, theParams.VAlign);
+ myParams = new Graphic3d_Text (theParams.Height());
+ myParams->SetText (theText);
+ myParams->SetOrientation (theOrientation);
+ myParams->SetOwnAnchorPoint (theHasOwnAnchor);
+ myParams->SetHAlignment (theParams.HAlignment());
+ myParams->SetVAlignment (theParams.VAlignment());
}
// =======================================================================
// function : OpenGl_Text
// purpose :
// =======================================================================
-OpenGl_Text::OpenGl_Text (const Handle(Graphic3d_TextParams)& theTextParams)
+OpenGl_Text::OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams)
: myWinX (0.0f),
myWinY (0.0f),
myWinZ (0.0f),
// =======================================================================
void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
{
- myParams->SetPosition (Graphic3d_Vertex (thePoint.x(), thePoint.y(), thePoint.z()));
+ myParams->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
}
// =======================================================================
NCollection_String aText;
aText.FromUnicode (theText);
- myParams->Init (aText, Graphic3d_Vertex (thePoint.x(), thePoint.y(), thePoint.z()));
+ myParams->SetText (aText);
+ myParams->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
}
// =======================================================================
void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
const Standard_Utf8Char* theText,
const OpenGl_Vec3& thePoint,
- const OpenGl_TextParam& theParams)
+ const Graphic3d_Text& theParams)
{
- Init (theCtx, theText, thePoint, Standard_False, theParams.Height, theParams.HAlign, theParams.VAlign);
+ Init (theCtx, theText, thePoint, Standard_False, theParams.Height(), theParams.HAlignment(), theParams.VAlignment());
}
// =======================================================================
void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
const TCollection_ExtendedString& theText,
const OpenGl_Vec2& thePoint,
- const OpenGl_TextParam& theParams)
+ const Graphic3d_Text& theParams)
{
OpenGl_Vec3 aPoint;
aPoint.SetValues (thePoint, 0.0f);
NCollection_String aText;
aText.FromUnicode (theText.ToExtString());
- Init (theCtx, aText, aPoint, Standard_True, theParams.Height, theParams.HAlign, theParams.VAlign);
+ Init (theCtx, aText, aPoint, Standard_True, theParams.Height(), theParams.HAlignment(), theParams.VAlignment());
}
// =======================================================================
}
myIs2d = theIs2d;
- myParams->Init (theText, Graphic3d_Vertex (thePoint.x(), thePoint.y(), thePoint.z()), theHta, theVta);
+ myParams->SetText (theText);
+ myParams->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
+ myParams->SetHAlignment (theHta);
+ myParams->SetVAlignment (theVta);
}
// =======================================================================
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
const NCollection_String& theText,
const OpenGl_Aspects& theTextAspect,
- const OpenGl_TextParam& theParams,
+ const Standard_Real& theHeight,
const unsigned int theResolution,
Standard_ShortReal& theWidth,
Standard_ShortReal& theAscent,
theWidth = 0.0f;
theAscent = 0.0f;
theDescent = 0.0f;
- const TCollection_AsciiString aFontKey = FontKey (theTextAspect, theParams.Height, theResolution);
- Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, theParams.Height, theResolution, aFontKey);
+ const TCollection_AsciiString aFontKey = FontKey (theTextAspect, (Standard_Integer)theHeight, theResolution);
+ Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, (Standard_Integer)theHeight, theResolution, aFontKey);
if (aFont.IsNull() || !aFont->IsValid())
{
return;
aCtx->ReleaseResource (aFontKey, Standard_True);
}
+// =======================================================================
+// function : StringSize
+// purpose :
+// =======================================================================
+void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
+ const NCollection_String& theText,
+ const OpenGl_Aspects& theTextAspect,
+ const Graphic3d_Text& theParams,
+ const unsigned int theResolution,
+ Standard_ShortReal& theWidth,
+ Standard_ShortReal& theAscent,
+ Standard_ShortReal& theDescent)
+{
+ StringSize (theCtx, theText, theTextAspect, theParams.Height(), theResolution, theWidth, theAscent, theDescent);
+}
+
// =======================================================================
// function : Render
// purpose :
if (myIs2d)
{
- const Graphic3d_Vertex& aPoint = myParams->Position();
+ const gp_Pnt& aPoint = myParams->Position();
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, aPoint.X() + theDVec.x(), aPoint.Y() + theDVec.y(), 0.f);
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.f, 0.f, 1.f);
if (!hasAnchorPoint())
{
OpenGl_Mat4d aPosMat;
- const Graphic3d_Vertex& aPoint = myParams->Position();
+ const gp_Pnt& aPoint = myParams->Position();
aPosMat.SetColumn (3, OpenGl_Vec3d (aPoint.X(), aPoint.Y(), aPoint.Z()));
aPosMat *= aModViewMat;
aModViewMat.SetColumn (3, aPosMat.GetColumn (3));
// Note that using difference resolution in different Views in same Viewer
// will lead to performance regression (for example, text will be recreated every time).
- const TCollection_AsciiString aFontKey = FontKey (theTextAspect, myParams->Height(), theResolution);
+ const TCollection_AsciiString aFontKey = FontKey (theTextAspect, (Standard_Integer)myParams->Height(), theResolution);
if (!myFont.IsNull()
&& !myFont->ResourceKey().IsEqual (aFontKey))
{
if (myFont.IsNull())
{
- myFont = FindFont (theCtx, theTextAspect, myParams->Height(), theResolution, aFontKey);
+ myFont = FindFont (theCtx, theTextAspect, (Standard_Integer)myParams->Height(), theResolution, aFontKey);
}
if (!myFont->WasInitialized())
{
const GLdouble aPointSize = (GLdouble )myFont->FTFont()->PointSize();
if (!myIs2d)
{
- const Graphic3d_Vertex& aPoint = myParams->Position();
+ const gp_Pnt& aPoint = myParams->Position();
Graphic3d_TransformUtils::Project<Standard_Real> (aPoint.X(), aPoint.Y(), aPoint.Z(),
myModelMatrix, myProjMatrix, theCtx->Viewport(),
myWinX, myWinY, myWinZ);
#include <OpenGl_Aspects.hxx>
#include <NCollection_String.hxx>
-#include <OpenGl_TextParam.hxx>
#include <OpenGl_TextBuilder.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_RenderingParams.hxx>
-#include <Graphic3d_TextParams.hxx>
+#include <Graphic3d_Text.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <gp_Ax2.hxx>
public:
- //! Main constructor
- Standard_DEPRECATED("Deprecated method OpenGl_Text() with obsolete arguments")
- Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
- const OpenGl_Vec3& thePoint,
- const OpenGl_TextParam& theParams);
-
- //! Creates new text in 3D space.
- Standard_DEPRECATED("Deprecated method OpenGl_Text() with obsolete arguments")
- Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
- const gp_Ax2& theOrientation,
- const OpenGl_TextParam& theParams,
- const bool theHasOwnAnchor = true);
-
//! Creates new text in 3D space.
- Standard_EXPORT OpenGl_Text (const Handle(Graphic3d_TextParams)& theTextParams);
+ Standard_EXPORT OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams);
//! Destructor
Standard_EXPORT virtual ~OpenGl_Text();
const Standard_Utf8Char* theText,
const OpenGl_Vec3& thePoint);
- //! Setup new string and parameters
- Standard_DEPRECATED("Deprecated method Init(), obsolete parameter OpenGl_TextParam, use Graphic3d_TextParams instead of it")
- Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
- const Standard_Utf8Char* theText,
- const OpenGl_Vec3& thePoint,
- const OpenGl_TextParam& theParams);
-
//! Setup new string and parameters
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
const NCollection_String theText,
const Graphic3d_HorizontalTextAlignment theHta,
const Graphic3d_VerticalTextAlignment theVta);
- //! Setup new position
- Standard_DEPRECATED("Deprecated method SetPosition(), use Graphic3d_TextParams for it")
- Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
-
//! Setup new font size
Standard_EXPORT void SetFontSize (const Handle(OpenGl_Context)& theContext,
const Standard_Integer theFontSize);
const NCollection_String& Text() const { return myParams->Text(); }
//! Return text formatting parameters.
- const Handle(Graphic3d_TextParams)& FormatParams() const { return myParams; }
+ const Handle(Graphic3d_Text)& FormatParams() const { return myParams; }
public: //! @name methods for compatibility with layers
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
const NCollection_String& theText,
const OpenGl_Aspects& theTextAspect,
- const OpenGl_TextParam& theParams,
+ const Standard_Real& theHeight,
const unsigned int theResolution,
Standard_ShortReal& theWidth,
Standard_ShortReal& theAscent,
Standard_ShortReal& theDescent);
+ //! Perform rendering
+ Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
+ const OpenGl_Aspects& theTextAspect,
+ unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
+
+//! @name obsolete methods
+public:
+ //! Main constructor
+ Standard_DEPRECATED("Deprecated method OpenGl_Text() with obsolete arguments")
+ Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
+ const OpenGl_Vec3& thePoint,
+ const Graphic3d_Text& theParams);
+
+ //! Creates new text in 3D space.
+ Standard_DEPRECATED("Deprecated method OpenGl_Text() with obsolete arguments")
+ Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
+ const gp_Ax2& theOrientation,
+ const Graphic3d_Text& theParams,
+ const bool theHasOwnAnchor = true);
+
+ //! Setup new string and parameters
+ Standard_DEPRECATED("Deprecated method Init(), obsolete parameter Graphic3d_Text, use Graphic3d_Text instead of it")
+ Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
+ const Standard_Utf8Char* theText,
+ const OpenGl_Vec3& thePoint,
+ const Graphic3d_Text& theParams);
+
+ //! Setup new position
+ Standard_DEPRECATED("Deprecated method SetPosition(), use Graphic3d_Text for it")
+ Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
+
//! Setup new string and parameters
- Standard_DEPRECATED("Deprecated method Init(), obsolete parameter OpenGl_TextParam, use Graphic3d_TextParams instead of it")
+ Standard_DEPRECATED("Deprecated method Init(), obsolete parameter Graphic3d_Text, use Graphic3d_Text instead of it")
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
const TCollection_ExtendedString& theText,
const OpenGl_Vec2& thePoint,
- const OpenGl_TextParam& theParams);
+ const Graphic3d_Text& theParams);
- //! Perform rendering
- Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_Aspects& theTextAspect,
- unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
+ //! Compute text width
+ Standard_DEPRECATED("Deprecated method StringSize() with obsolete Graphic3d_Text argument")
+ Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
+ const NCollection_String& theText,
+ const OpenGl_Aspects& theTextAspect,
+ const Graphic3d_Text& theParams,
+ const unsigned int theResolution,
+ Standard_ShortReal& theWidth,
+ Standard_ShortReal& theAscent,
+ Standard_ShortReal& theDescent);
protected:
protected:
- Handle(Graphic3d_TextParams) myParams;
+ Handle(Graphic3d_Text) myParams;
bool myIs2d;
public:
#ifndef _OpenGl_TextParam_Header
#define _OpenGl_TextParam_Header
-#include <Graphic3d_HorizontalTextAlignment.hxx>
-#include <Graphic3d_VerticalTextAlignment.hxx>
+#include <Graphic3d_Text.hxx>
-struct OpenGl_TextParam
-{
- int Height;
- Graphic3d_HorizontalTextAlignment HAlign;
- Graphic3d_VerticalTextAlignment VAlign;
- DEFINE_STANDARD_ALLOC
-};
+Standard_DEPRECATED("This type name is deprecated - Graphic3d_Text should be used instead")
+typedef Graphic3d_Text OpenGl_TextParam;
#endif //_OpenGl_TextParam_Header
#include <gp_Pnt.hxx>
#include <Graphic3d_Group.hxx>
-#include <Graphic3d_TextParams.hxx>
+#include <Graphic3d_Text.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_TextAspect.hxx>
theGroup->SetPrimitivesAspect (theAspect->Aspect());
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theAspect->Height());
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theAspect->Height());
const NCollection_String aText (theText.ToExtString());
- aTextParams->Init (aText,
- Graphic3d_Vertex(x,y,z),
- theAspect->HorizontalJustification(),
- theAspect->VerticalJustification());
+ aTextParams->SetText (aText);
+ aTextParams->SetPosition (gp_Pnt (x,y,z));
+ aTextParams->SetHAlignment (theAspect->HorizontalJustification());
+ aTextParams->SetVAlignment (theAspect->VerticalJustification());
theGroup->AddText (aTextParams);
}
{
theGroup->SetPrimitivesAspect (theAspect->Aspect());
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (theAspect->Height());
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theAspect->Height());
const NCollection_String aText (theText.ToExtString());
- aTextParams->Init (aText,
- theOrientation,
- theHasOwnAnchor,
- theAspect->HorizontalJustification(),
- theAspect->VerticalJustification());
+ aTextParams->SetText (aText);
+ aTextParams->SetOrientation (theOrientation);
+ aTextParams->SetOwnAnchorPoint (theHasOwnAnchor);
+ aTextParams->SetHAlignment (theAspect->HorizontalJustification());
+ aTextParams->SetVAlignment (theAspect->VerticalJustification());
theGroup->AddText (aTextParams);
}
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_TextParams.hxx>
+#include <Graphic3d_Text.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Type.hxx>
#include <V3d.hxx>
const gp_Pnt pX (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.XDirection().XYZ());
aPrims->AddVertex (p0);
aPrims->AddVertex (pX);
- Handle(Graphic3d_TextParams) aTextParams = new Graphic3d_TextParams (1.0 / 81.0);
- aTextParams->Init ("X", Graphic3d_Vertex (pX.X(), pX.Y(), pX.Z()));
+ Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (1.0 / 81.0);
+ aTextParams->SetText ("X");
+ aTextParams->SetPosition (gp_Pnt (pX.X(), pX.Y(), pX.Z()));
aGroup->AddText (aTextParams);
const gp_Pnt pY (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.YDirection().XYZ());
aPrims->AddVertex (p0);
aPrims->AddVertex (pY);
- aTextParams = new Graphic3d_TextParams (1.0 / 81.0);
- aTextParams->Init ("Y", Graphic3d_Vertex (pY.X(), pY.Y(), pY.Z()));
+ aTextParams = new Graphic3d_Text (1.0 / 81.0);
+ aTextParams->SetText ("Y");
+ aTextParams->SetPosition (gp_Pnt (pY.X(), pY.Y(), pY.Z()));
aGroup->AddText (aTextParams);
const gp_Pnt pZ (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.Direction().XYZ());
aPrims->AddVertex (p0);
aPrims->AddVertex (pZ);
- aTextParams = new Graphic3d_TextParams (1.0 / 81.0);
- aTextParams->Init ("Z", Graphic3d_Vertex (pZ.X(), pZ.Y(), pZ.Z()));
+ aTextParams = new Graphic3d_Text (1.0 / 81.0);
+ aTextParams->SetText ("Z");
+ aTextParams->SetPosition (gp_Pnt (pZ.X(), pZ.Y(), pZ.Z()));
aGroup->AddText (aTextParams);
aGroup->AddPrimitiveArray (aPrims);