mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +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:
parent
077a220c51
commit
8ed0708507
@ -1716,6 +1716,41 @@ aGroup->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< next array
|
|||||||
aGroup->AddPrimitiveArray (aLines);
|
aGroup->AddPrimitiveArray (aLines);
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
|
@subsection upgrade_740_text Changes in Graphic3d_Text and OpenGl_Text API
|
||||||
|
|
||||||
|
Parameters of *Text* in *Graphic3d_Group* are moved into a new *Graphic3d_Text* class. *AddText* of *Graphic3d_Group* should be used instead of the previous *Text*.
|
||||||
|
|
||||||
|
The previous code:
|
||||||
|
~~~~
|
||||||
|
Standard_Real x, y, z;
|
||||||
|
theAttachmentPoint.Coord(x,y,z);
|
||||||
|
theGroup->Text (theText,
|
||||||
|
Graphic3d_Vertex(x,y,z),
|
||||||
|
theAspect->Height(),
|
||||||
|
theAspect->Angle(),
|
||||||
|
theAspect->Orientation(),
|
||||||
|
theAspect->HorizontalJustification(),
|
||||||
|
theAspect->VerticalJustification());
|
||||||
|
~~~~
|
||||||
|
should be replaced by the new code:
|
||||||
|
~~~~
|
||||||
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text (theAspect->Height());
|
||||||
|
aText->SetText (theText.ToExtString());
|
||||||
|
aText->SetPosition (theAttachmentPoint);
|
||||||
|
aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
|
||||||
|
aText->SetVerticalAlignment (theAspect->VerticalJustification());
|
||||||
|
theGroup->AddText (aText);
|
||||||
|
~~~~
|
||||||
|
|
||||||
|
*OpenGl_Text* contains *Graphic3d_Text* field.
|
||||||
|
|
||||||
|
*OpenGl_TextParam* struct is removed. Constructor and *Init* of *OpenGl_Text* with *OpenGl_TextParam* are also removed.
|
||||||
|
Instead of using them, change *OpenGl_Text*.
|
||||||
|
|
||||||
|
Please, note, that after modifying *OpenGl_Text*, *Reset* of *OpenGl_Text* should be called.
|
||||||
|
|
||||||
|
*FormatParams* of *OpenGl_Text* is replaced by *Text*.
|
||||||
|
|
||||||
@subsection upgrade_740_prsupdate Presentation invalidation
|
@subsection upgrade_740_prsupdate Presentation invalidation
|
||||||
|
|
||||||
Historically AIS_InteractiveObject provided two independent mechanisms invalidating presentation (asking presentation manager to recompute specific display mode or all modes):
|
Historically AIS_InteractiveObject provided two independent mechanisms invalidating presentation (asking presentation manager to recompute specific display mode or all modes):
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <Graphic3d_AspectText3d.hxx>
|
#include <Graphic3d_AspectText3d.hxx>
|
||||||
#include <Graphic3d_GraphicDriver.hxx>
|
#include <Graphic3d_GraphicDriver.hxx>
|
||||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||||
|
#include <Graphic3d_Text.hxx>
|
||||||
#include <Prs3d_LineAspect.hxx>
|
#include <Prs3d_LineAspect.hxx>
|
||||||
#include <Prs3d_Root.hxx>
|
#include <Prs3d_Root.hxx>
|
||||||
#include <Prs3d_ShadingAspect.hxx>
|
#include <Prs3d_ShadingAspect.hxx>
|
||||||
@ -796,16 +797,14 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup,
|
|||||||
const Graphic3d_VerticalTextAlignment theVertAlignment)
|
const Graphic3d_VerticalTextAlignment theVertAlignment)
|
||||||
{
|
{
|
||||||
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
|
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
|
||||||
theGroup->Text (theText,
|
|
||||||
gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
|
|
||||||
anAspect->Height(),
|
|
||||||
anAspect->Angle(),
|
|
||||||
anAspect->Orientation(),
|
|
||||||
Graphic3d_HTA_LEFT,
|
|
||||||
theVertAlignment,
|
|
||||||
Standard_True,
|
|
||||||
Standard_False); // has own anchor
|
|
||||||
|
|
||||||
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)anAspect->Height());
|
||||||
|
aText->SetText (theText.ToExtString());
|
||||||
|
aText->SetOrientation (gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()));
|
||||||
|
aText->SetOwnAnchorPoint (Standard_False);
|
||||||
|
aText->SetVerticalAlignment (theVertAlignment);
|
||||||
|
|
||||||
|
theGroup->AddText (aText);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <gp_Dir.hxx>
|
#include <gp_Dir.hxx>
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||||
|
#include <Graphic3d_Text.hxx>
|
||||||
#include <Graphic3d_Group.hxx>
|
#include <Graphic3d_Group.hxx>
|
||||||
#include <Prs3d_Arrow.hxx>
|
#include <Prs3d_Arrow.hxx>
|
||||||
#include <Prs3d_ArrowAspect.hxx>
|
#include <Prs3d_ArrowAspect.hxx>
|
||||||
@ -36,7 +37,7 @@ void DsgPrs_XYZAxisPresentation::Add(
|
|||||||
const Handle(Prs3d_LineAspect)& aLineAspect,
|
const Handle(Prs3d_LineAspect)& aLineAspect,
|
||||||
const gp_Dir & aDir,
|
const gp_Dir & aDir,
|
||||||
const Standard_Real aVal,
|
const Standard_Real aVal,
|
||||||
const Standard_CString aText,
|
const Standard_CString theText,
|
||||||
const gp_Pnt& aPfirst,
|
const gp_Pnt& aPfirst,
|
||||||
const gp_Pnt& aPlast)
|
const gp_Pnt& aPlast)
|
||||||
{
|
{
|
||||||
@ -50,10 +51,12 @@ void DsgPrs_XYZAxisPresentation::Add(
|
|||||||
|
|
||||||
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast,aDir, M_PI/180.*10., aVal/10.);
|
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast,aDir, M_PI/180.*10., aVal/10.);
|
||||||
|
|
||||||
if (*aText != '\0')
|
if (*theText != '\0')
|
||||||
{
|
{
|
||||||
Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f/81.0f);
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
|
aText->SetText (theText);
|
||||||
|
aText->SetPosition (aPlast);
|
||||||
|
Prs3d_Root::CurrentGroup(aPresentation)->AddText (aText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +67,7 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
|
|||||||
const Handle(Prs3d_TextAspect)& aTextAspect,
|
const Handle(Prs3d_TextAspect)& aTextAspect,
|
||||||
const gp_Dir & aDir,
|
const gp_Dir & aDir,
|
||||||
const Standard_Real aVal,
|
const Standard_Real aVal,
|
||||||
const Standard_CString aText,
|
const Standard_CString theText,
|
||||||
const gp_Pnt& aPfirst,
|
const gp_Pnt& aPfirst,
|
||||||
const gp_Pnt& aPlast)
|
const gp_Pnt& aPlast)
|
||||||
{
|
{
|
||||||
@ -81,9 +84,11 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
|
|||||||
|
|
||||||
G->SetPrimitivesAspect(aTextAspect->Aspect());
|
G->SetPrimitivesAspect(aTextAspect->Aspect());
|
||||||
|
|
||||||
if (*aText != '\0')
|
if (*theText != '\0')
|
||||||
{
|
{
|
||||||
Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f/81.0f);
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
|
aText->SetText (theText);
|
||||||
|
aText->SetPosition (aPlast);
|
||||||
|
Prs3d_Root::CurrentGroup(aPresentation)->AddText(aText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,8 @@ Graphic3d_StructureDefinitionError.hxx
|
|||||||
Graphic3d_StructureManager.cxx
|
Graphic3d_StructureManager.cxx
|
||||||
Graphic3d_StructureManager.hxx
|
Graphic3d_StructureManager.hxx
|
||||||
Graphic3d_TextPath.hxx
|
Graphic3d_TextPath.hxx
|
||||||
|
Graphic3d_Text.cxx
|
||||||
|
Graphic3d_Text.hxx
|
||||||
Graphic3d_Texture1D.cxx
|
Graphic3d_Texture1D.cxx
|
||||||
Graphic3d_Texture1D.hxx
|
Graphic3d_Texture1D.hxx
|
||||||
Graphic3d_Texture1Dmanual.cxx
|
Graphic3d_Texture1Dmanual.cxx
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <Graphic3d_Structure.hxx>
|
#include <Graphic3d_Structure.hxx>
|
||||||
#include "Graphic3d_Structure.pxx"
|
#include "Graphic3d_Structure.pxx"
|
||||||
#include <Graphic3d_StructureManager.hxx>
|
#include <Graphic3d_StructureManager.hxx>
|
||||||
|
#include <Graphic3d_Text.hxx>
|
||||||
#include <Graphic3d_TextureMap.hxx>
|
#include <Graphic3d_TextureMap.hxx>
|
||||||
#include <Graphic3d_TransModeFlags.hxx>
|
#include <Graphic3d_TransModeFlags.hxx>
|
||||||
#include <Message.hxx>
|
#include <Message.hxx>
|
||||||
@ -310,31 +311,21 @@ void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
|
|||||||
// function : Text
|
// function : Text
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
|
void Graphic3d_Group::Text (const Standard_CString theText,
|
||||||
const Graphic3d_Vertex& thePoint,
|
const Graphic3d_Vertex& thePoint,
|
||||||
const Standard_Real /*theHeight*/,
|
const Standard_Real theHeight,
|
||||||
const Standard_Real /*theAngle*/,
|
const Standard_Real /*theAngle*/,
|
||||||
const Graphic3d_TextPath /*theTp*/,
|
const Graphic3d_TextPath /*theTp*/,
|
||||||
const Graphic3d_HorizontalTextAlignment /*theHta*/,
|
const Graphic3d_HorizontalTextAlignment theHta,
|
||||||
const Graphic3d_VerticalTextAlignment /*theVta*/,
|
const Graphic3d_VerticalTextAlignment theVta,
|
||||||
const Standard_Boolean theToEvalMinMax)
|
const Standard_Boolean theToEvalMinMax)
|
||||||
{
|
{
|
||||||
if (IsDeleted())
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||||
{
|
aText->SetText (theText);
|
||||||
return;
|
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||||
}
|
aText->SetHorizontalAlignment (theHta);
|
||||||
|
aText->SetVerticalAlignment (theVta);
|
||||||
if (theToEvalMinMax)
|
AddText (aText, 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -346,8 +337,10 @@ void Graphic3d_Group::Text (const Standard_CString theText,
|
|||||||
const Standard_Real theHeight,
|
const Standard_Real theHeight,
|
||||||
const Standard_Boolean theToEvalMinMax)
|
const Standard_Boolean theToEvalMinMax)
|
||||||
{
|
{
|
||||||
Text (theText, thePoint, theHeight, 0.0,
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||||
Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
|
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,
|
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||||
const Graphic3d_Vertex& thePoint,
|
const Graphic3d_Vertex& thePoint,
|
||||||
const Standard_Real theHeight,
|
const Standard_Real theHeight,
|
||||||
const Standard_Real theAngle,
|
const Standard_Real /*theAngle*/,
|
||||||
const Graphic3d_TextPath theTp,
|
const Graphic3d_TextPath /*theTp*/,
|
||||||
const Graphic3d_HorizontalTextAlignment theHta,
|
const Graphic3d_HorizontalTextAlignment theHta,
|
||||||
const Graphic3d_VerticalTextAlignment theVta,
|
const Graphic3d_VerticalTextAlignment theVta,
|
||||||
const Standard_Boolean theToEvalMinMax)
|
const Standard_Boolean theToEvalMinMax)
|
||||||
{
|
{
|
||||||
const NCollection_String aText (theText.ToExtString());
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||||
Text (aText.ToCString(), thePoint, theHeight, theAngle,
|
aText->SetText (theText.ToExtString());
|
||||||
theTp, theHta, theVta, theToEvalMinMax);
|
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,
|
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||||
const gp_Ax2& theOrientation,
|
const gp_Ax2& theOrientation,
|
||||||
const Standard_Real theHeight,
|
const Standard_Real theHeight,
|
||||||
const Standard_Real theAngle,
|
const Standard_Real /*theAngle*/,
|
||||||
const Graphic3d_TextPath theTP,
|
const Graphic3d_TextPath /*theTP*/,
|
||||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
const Graphic3d_HorizontalTextAlignment theHta,
|
||||||
const Graphic3d_VerticalTextAlignment theVTA,
|
const Graphic3d_VerticalTextAlignment theVta,
|
||||||
const Standard_Boolean theToEvalMinMax,
|
const Standard_Boolean theToEvalMinMax,
|
||||||
const Standard_Boolean theHasOwnAnchor)
|
const Standard_Boolean theHasOwnAnchor)
|
||||||
{
|
{
|
||||||
const NCollection_String aText (theText.ToExtString());
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||||
Text (aText.ToCString(),
|
aText->SetText (theText.ToExtString());
|
||||||
theOrientation,
|
aText->SetOrientation (theOrientation);
|
||||||
theHeight,
|
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||||
theAngle,
|
aText->SetHorizontalAlignment (theHta);
|
||||||
theTP,
|
aText->SetVerticalAlignment (theVta);
|
||||||
theHTA,
|
AddText (aText, theToEvalMinMax);
|
||||||
theVTA,
|
|
||||||
theToEvalMinMax,
|
|
||||||
theHasOwnAnchor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : Text
|
// function : Text
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
|
void Graphic3d_Group::Text (const Standard_CString theText,
|
||||||
const gp_Ax2& theOrientation,
|
const gp_Ax2& theOrientation,
|
||||||
const Standard_Real /*theHeight*/,
|
const Standard_Real theHeight,
|
||||||
const Standard_Real /*theAngle*/,
|
const Standard_Real /*theAngle*/,
|
||||||
const Graphic3d_TextPath /*theTp*/,
|
const Graphic3d_TextPath /*theTp*/,
|
||||||
const Graphic3d_HorizontalTextAlignment /*theHta*/,
|
const Graphic3d_HorizontalTextAlignment theHta,
|
||||||
const Graphic3d_VerticalTextAlignment /*theVta*/,
|
const Graphic3d_VerticalTextAlignment theVta,
|
||||||
const Standard_Boolean theToEvalMinMax,
|
const Standard_Boolean theToEvalMinMax,
|
||||||
const Standard_Boolean /*theHasOwnAnchor*/)
|
const Standard_Boolean theHasOwnAnchor)
|
||||||
{
|
{
|
||||||
if (IsDeleted())
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||||
{
|
aText->SetText (theText);
|
||||||
return;
|
aText->SetOrientation (theOrientation);
|
||||||
}
|
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||||
|
aText->SetHorizontalAlignment (theHta);
|
||||||
if (theToEvalMinMax)
|
aText->SetVerticalAlignment (theVta);
|
||||||
{
|
AddText (aText, 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -433,7 +419,31 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
|||||||
const Standard_Real theHeight,
|
const Standard_Real theHeight,
|
||||||
const Standard_Boolean theToEvalMinMax)
|
const Standard_Boolean theToEvalMinMax)
|
||||||
{
|
{
|
||||||
const NCollection_String aText (theText.ToExtString());
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||||
Text (aText.ToCString(), thePoint, theHeight, 0.0,
|
aText->SetText (theText.ToExtString());
|
||||||
Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
|
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_Structure;
|
||||||
class Graphic3d_ArrayOfPrimitives;
|
class Graphic3d_ArrayOfPrimitives;
|
||||||
|
class Graphic3d_Text;
|
||||||
|
|
||||||
//! This class allows the definition of groups
|
//! This class allows the definition of groups
|
||||||
//! of primitives inside of graphic objects (presentations).
|
//! of primitives inside of graphic objects (presentations).
|
||||||
@ -110,87 +111,16 @@ public:
|
|||||||
//! Replace aspects specified in the replacement map.
|
//! Replace aspects specified in the replacement map.
|
||||||
virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
|
virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
|
||||||
|
|
||||||
public:
|
//! Adds a text for display
|
||||||
|
Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||||
//! Creates the string <AText> at position <APoint>.
|
const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||||
//! 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 an array of primitives for display
|
//! 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
|
//! Adds an array of primitives for display
|
||||||
Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
|
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).
|
//! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
|
||||||
bool IsClosed() const { return myIsClosed; }
|
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:
|
protected:
|
||||||
|
|
||||||
//! Creates a group in the structure <AStructure>.
|
//! 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
|
@ -18,6 +18,7 @@
|
|||||||
#include <Graphic3d_ArrayOfPoints.hxx>
|
#include <Graphic3d_ArrayOfPoints.hxx>
|
||||||
#include <Graphic3d_AspectMarker3d.hxx>
|
#include <Graphic3d_AspectMarker3d.hxx>
|
||||||
#include <Graphic3d_AspectText3d.hxx>
|
#include <Graphic3d_AspectText3d.hxx>
|
||||||
|
#include <Graphic3d_Text.hxx>
|
||||||
#include <Graphic3d_Group.hxx>
|
#include <Graphic3d_Group.hxx>
|
||||||
#include <Graphic3d_Vertex.hxx>
|
#include <Graphic3d_Vertex.hxx>
|
||||||
#include <MeshVS_Buffer.hxx>
|
#include <MeshVS_Buffer.hxx>
|
||||||
@ -251,8 +252,11 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
aPnts.Append (Graphic3d_Vec3 ((float )X, (float )Y, (float )Z));
|
aPnts.Append (Graphic3d_Vec3 ((float )X, (float )Y, (float )Z));
|
||||||
Graphic3d_Vertex aPoint (X, Y, Z);
|
|
||||||
aTextGroup->Text (aStr.ToCString(), aPoint, aHeight);
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)aHeight);
|
||||||
|
aText->SetText (aStr);
|
||||||
|
aText->SetPosition (gp_Pnt (X, Y, Z));
|
||||||
|
aTextGroup->AddText(aText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ OpenGl_Material.hxx
|
|||||||
OpenGl_MaterialState.hxx
|
OpenGl_MaterialState.hxx
|
||||||
OpenGl_Matrix.hxx
|
OpenGl_Matrix.hxx
|
||||||
OpenGl_MatrixState.hxx
|
OpenGl_MatrixState.hxx
|
||||||
OpenGl_TextParam.hxx
|
|
||||||
OpenGl_LineAttributes.hxx
|
OpenGl_LineAttributes.hxx
|
||||||
OpenGl_LineAttributes.cxx
|
OpenGl_LineAttributes.cxx
|
||||||
OpenGl_Window.hxx
|
OpenGl_Window.hxx
|
||||||
|
@ -91,41 +91,45 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
|
|||||||
myTextAspect.SetAspect (aRendParams.StatsTextAspect);
|
myTextAspect.SetAspect (aRendParams.StatsTextAspect);
|
||||||
|
|
||||||
// adjust text alignment depending on corner
|
// adjust text alignment depending on corner
|
||||||
OpenGl_TextParam aParams;
|
Graphic3d_Text aParams ((Standard_ShortReal)aRendParams.StatsTextHeight);
|
||||||
aParams.Height = aRendParams.StatsTextHeight;
|
aParams.SetHorizontalAlignment (Graphic3d_HTA_CENTER);
|
||||||
aParams.HAlign = Graphic3d_HTA_CENTER;
|
aParams.SetVerticalAlignment (Graphic3d_VTA_CENTER);
|
||||||
aParams.VAlign = Graphic3d_VTA_CENTER;
|
|
||||||
if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_LEFT) != 0)
|
if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_LEFT) != 0)
|
||||||
{
|
{
|
||||||
aParams.HAlign = Graphic3d_HTA_LEFT;
|
aParams.SetHorizontalAlignment (Graphic3d_HTA_LEFT);
|
||||||
}
|
}
|
||||||
else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
|
else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
|
||||||
{
|
{
|
||||||
aParams.HAlign = Graphic3d_HTA_RIGHT;
|
aParams.SetHorizontalAlignment (Graphic3d_HTA_RIGHT);
|
||||||
}
|
}
|
||||||
if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_TOP) != 0)
|
if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_TOP) != 0)
|
||||||
{
|
{
|
||||||
aParams.VAlign = Graphic3d_VTA_TOP;
|
aParams.SetVerticalAlignment (Graphic3d_VTA_TOP);
|
||||||
}
|
}
|
||||||
else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_BOTTOM) != 0)
|
else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_BOTTOM) != 0)
|
||||||
{
|
{
|
||||||
aParams.VAlign = Graphic3d_VTA_BOTTOM;
|
aParams.SetVerticalAlignment (Graphic3d_VTA_BOTTOM);
|
||||||
}
|
}
|
||||||
if (aParams.Height != myCountersText.FormatParams().Height
|
if (aParams.Height() != myCountersText.Text()->Height()
|
||||||
|| aParams.HAlign != myCountersText.FormatParams().HAlign
|
|| aParams.HorizontalAlignment() != myCountersText.Text()->HorizontalAlignment()
|
||||||
|| aParams.VAlign != myCountersText.FormatParams().VAlign)
|
|| aParams.VerticalAlignment() != myCountersText.Text()->VerticalAlignment())
|
||||||
{
|
{
|
||||||
myCountersText.Release (aCtx.operator->());
|
myCountersText.Release (aCtx.operator->());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aStats->IsFrameUpdated (myStatsPrev)
|
if (!aStats->IsFrameUpdated (myStatsPrev)
|
||||||
&& !myCountersText.Text().IsEmpty())
|
&& !myCountersText.Text()->Text().IsEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats);
|
Handle(Graphic3d_Text) aText = myCountersText.Text();
|
||||||
myCountersText.Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
|
aText->SetText (aStats->FormatStats (aRendParams.CollectedStats).ToCString());
|
||||||
|
aText->SetHeight (aParams.Height());
|
||||||
|
aText->SetPosition (gp_Pnt());
|
||||||
|
aText->SetHorizontalAlignment (aParams.HorizontalAlignment());
|
||||||
|
aText->SetVerticalAlignment (aParams.VerticalAlignment());
|
||||||
|
myCountersText.Reset (aCtx);
|
||||||
|
|
||||||
updateChart (theWorkspace);
|
updateChart (theWorkspace);
|
||||||
}
|
}
|
||||||
@ -323,14 +327,13 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
OpenGl_TextParam aParams;
|
Graphic3d_Text aParams ((Standard_ShortReal)aRendParams.StatsTextHeight);
|
||||||
aParams.Height = aRendParams.StatsTextHeight;
|
aParams.SetHorizontalAlignment ((!myChartTrsfPers.IsNull()
|
||||||
aParams.HAlign = (!myChartTrsfPers.IsNull()
|
|
||||||
&& myChartTrsfPers->IsTrihedronOr2d()
|
&& myChartTrsfPers->IsTrihedronOr2d()
|
||||||
&& (myChartTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
|
&& (myChartTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
|
||||||
? Graphic3d_HTA_RIGHT
|
? Graphic3d_HTA_RIGHT
|
||||||
: Graphic3d_HTA_LEFT;
|
: Graphic3d_HTA_LEFT);
|
||||||
aParams.VAlign = Graphic3d_VTA_CENTER;
|
aParams.SetVerticalAlignment (Graphic3d_VTA_CENTER);
|
||||||
TCollection_AsciiString aLabels[3] =
|
TCollection_AsciiString aLabels[3] =
|
||||||
{
|
{
|
||||||
TCollection_AsciiString() + 0 + " ms",
|
TCollection_AsciiString() + 0 + " ms",
|
||||||
@ -338,12 +341,27 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
|
|||||||
formatTimeMs(aMaxDuration)
|
formatTimeMs(aMaxDuration)
|
||||||
};
|
};
|
||||||
|
|
||||||
const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT
|
const float aLabX = aParams.HorizontalAlignment() == Graphic3d_HTA_RIGHT
|
||||||
? float(anOffset.x())
|
? float(anOffset.x())
|
||||||
: float(anOffset.x() + aCharSize.x());
|
: float(anOffset.x() + aCharSize.x());
|
||||||
myChartLabels[0].Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f), aParams);
|
|
||||||
myChartLabels[1].Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
|
myChartLabels[0].Text()->SetText (aLabels[isTopDown ? 0 : 2].ToCString());
|
||||||
myChartLabels[2].Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f), aParams);
|
myChartLabels[0].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y()), 0.0f));
|
||||||
|
|
||||||
|
myChartLabels[1].Text()->SetText (aLabels[isTopDown ? 1 : 1].ToCString());
|
||||||
|
myChartLabels[1].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f));
|
||||||
|
|
||||||
|
myChartLabels[2].Text()->SetText (aLabels[isTopDown ? 2 : 0].ToCString());
|
||||||
|
myChartLabels[2].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f));
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
myChartLabels[i].Text()->SetHeight (aParams.Height());
|
||||||
|
myChartLabels[i].Text()->SetHorizontalAlignment (aParams.HorizontalAlignment());
|
||||||
|
myChartLabels[i].Text()->SetVerticalAlignment (aParams.VerticalAlignment());
|
||||||
|
|
||||||
|
myChartLabels[i].Reset(aCtx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||||
#include <Graphic3d_GraphicDriver.hxx>
|
#include <Graphic3d_GraphicDriver.hxx>
|
||||||
|
#include <Graphic3d_Text.hxx>
|
||||||
#include <Graphic3d_TransformPers.hxx>
|
#include <Graphic3d_TransformPers.hxx>
|
||||||
#include <Graphic3d_TransformUtils.hxx>
|
#include <Graphic3d_TransformUtils.hxx>
|
||||||
#include <gp_Ax3.hxx>
|
#include <gp_Ax3.hxx>
|
||||||
@ -33,10 +34,9 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static const OpenGl_TextParam THE_LABEL_PARAMS =
|
static Standard_ShortReal THE_LABEL_HEIGHT = 16;
|
||||||
{
|
static Graphic3d_HorizontalTextAlignment THE_LABEL_HALIGH = Graphic3d_HTA_LEFT;
|
||||||
16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
|
static Graphic3d_VerticalTextAlignment THE_LABEL_VALIGH = Graphic3d_VTA_BOTTOM;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -522,7 +522,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
|||||||
|
|
||||||
myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
|
myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
|
||||||
theWorkspace->SetAspects (&myAspectLabels);
|
theWorkspace->SetAspects (&myAspectLabels);
|
||||||
anAxis.Label.SetPosition (aMiddle);
|
anAxis.Label.Text()->SetPosition (gp_Pnt (aMiddle.x(), aMiddle.y(), aMiddle.z()));
|
||||||
anAxis.Label.Render (theWorkspace);
|
anAxis.Label.Render (theWorkspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +536,12 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
|||||||
{
|
{
|
||||||
sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep);
|
sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep);
|
||||||
OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset));
|
OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset));
|
||||||
myLabelValues.Init (theWorkspace->GetGlContext(), aTextValue, aPos);
|
|
||||||
|
Handle(Graphic3d_Text) aText = myLabelValues.Text();
|
||||||
|
aText->SetText (aTextValue);
|
||||||
|
aText->SetPosition (gp_Pnt(aPos.x(), aPos.y(), aPos.z()));
|
||||||
|
|
||||||
|
myLabelValues.Reset (theWorkspace->GetGlContext());
|
||||||
myLabelValues.Render (theWorkspace);
|
myLabelValues.Render (theWorkspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -715,11 +720,16 @@ void OpenGl_GraduatedTrihedron::SetMinMax (const OpenGl_Vec3& theMin, const Open
|
|||||||
OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
|
OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
|
||||||
const OpenGl_Vec3& theDirection)
|
const OpenGl_Vec3& theDirection)
|
||||||
: Direction (theDirection),
|
: Direction (theDirection),
|
||||||
Label (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS),
|
|
||||||
Tickmark (NULL),
|
Tickmark (NULL),
|
||||||
Line (NULL),
|
Line (NULL),
|
||||||
Arrow (NULL)
|
Arrow (NULL)
|
||||||
{
|
{
|
||||||
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text (THE_LABEL_HEIGHT);
|
||||||
|
aText->SetText ((Standard_Utf16Char* )theAspect.Name().ToExtString());
|
||||||
|
aText->SetPosition (gp_Pnt (theDirection.x(), theDirection.y(), theDirection.z()));
|
||||||
|
aText->SetHorizontalAlignment (THE_LABEL_HALIGH);
|
||||||
|
aText->SetVerticalAlignment (THE_LABEL_VALIGH);
|
||||||
|
Label = OpenGl_Text (aText);
|
||||||
NameColor = theAspect.NameColor();
|
NameColor = theAspect.NameColor();
|
||||||
LineAspect.Aspect()->SetColor (theAspect.Color());
|
LineAspect.Aspect()->SetColor (theAspect.Color());
|
||||||
}
|
}
|
||||||
|
@ -520,12 +520,10 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
|
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
|
||||||
OpenGl_TextParam aTextParam;
|
|
||||||
aTextParam.Height = (int )aHeight;
|
|
||||||
OpenGl_Aspects aTextAspect;
|
OpenGl_Aspects aTextAspect;
|
||||||
TCollection_ExtendedString anExtText = theText;
|
TCollection_ExtendedString anExtText = theText;
|
||||||
NCollection_String aText (anExtText.ToExtString());
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -206,75 +206,27 @@ void OpenGl_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : Text
|
// function : AddText
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
void OpenGl_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||||
const Graphic3d_Vertex& thePoint,
|
const Standard_Boolean theToEvalMinMax)
|
||||||
const Standard_Real theHeight,
|
|
||||||
const Standard_Real theAngle,
|
|
||||||
const Graphic3d_TextPath theTp,
|
|
||||||
const Graphic3d_HorizontalTextAlignment theHta,
|
|
||||||
const Graphic3d_VerticalTextAlignment theVta,
|
|
||||||
const Standard_Boolean theToEvalMinMax)
|
|
||||||
{
|
{
|
||||||
if (IsDeleted())
|
if (IsDeleted())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGl_TextParam aParams;
|
if (theTextParams->Height() < 2.0)
|
||||||
OpenGl_Structure* aStruct = GlStruct();
|
|
||||||
aParams.Height = int ((theHeight < 2.0) ? aStruct->GlDriver()->DefaultTextHeight() : theHeight);
|
|
||||||
aParams.HAlign = theHta;
|
|
||||||
aParams.VAlign = theVta;
|
|
||||||
const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
|
|
||||||
OpenGl_Text* aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
|
|
||||||
AddElement (aText);
|
|
||||||
Graphic3d_Group::Text (theTextUtf, thePoint, theHeight, theAngle,
|
|
||||||
theTp, theHta, theVta, theToEvalMinMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : Text
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void OpenGl_Group::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,
|
|
||||||
const Standard_Boolean theHasOwnAnchor)
|
|
||||||
{
|
|
||||||
if (IsDeleted())
|
|
||||||
{
|
{
|
||||||
return;
|
// TODO - this should be handled in different way (throw exception / take default text height without modifying Graphic3d_Text / log warning, etc.)
|
||||||
|
OpenGl_Structure* aStruct = GlStruct();
|
||||||
|
theTextParams->SetHeight (aStruct->GlDriver()->DefaultTextHeight());
|
||||||
}
|
}
|
||||||
|
OpenGl_Text* aText = new OpenGl_Text (theTextParams);
|
||||||
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, theHasOwnAnchor != Standard_False);
|
|
||||||
|
|
||||||
AddElement (aText);
|
AddElement (aText);
|
||||||
|
Graphic3d_Group::AddText (theTextParams, theToEvalMinMax);
|
||||||
Graphic3d_Group::Text (theTextUtf,
|
|
||||||
theOrientation,
|
|
||||||
theHeight,
|
|
||||||
theAngle,
|
|
||||||
theTp,
|
|
||||||
theHTA,
|
|
||||||
theVTA,
|
|
||||||
theToEvalMinMax,
|
|
||||||
theHasOwnAnchor);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
@ -71,27 +71,9 @@ public:
|
|||||||
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||||
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
|
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
|
||||||
|
|
||||||
//! Add text element
|
//! Adds a text for display
|
||||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||||
const Graphic3d_Vertex& thePoint,
|
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
|
||||||
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_OVERRIDE;
|
|
||||||
|
|
||||||
//! Add text element 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,
|
|
||||||
const Standard_Boolean theHasOwnAnchor = Standard_True) Standard_OVERRIDE;
|
|
||||||
|
|
||||||
//! Add flipping element
|
//! Add flipping element
|
||||||
Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
|
Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
|
||||||
const gp_Ax2& theRefPlane) Standard_OVERRIDE;
|
const gp_Ax2& theRefPlane) Standard_OVERRIDE;
|
||||||
|
@ -75,56 +75,21 @@ namespace
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
OpenGl_Text::OpenGl_Text()
|
OpenGl_Text::OpenGl_Text()
|
||||||
: myScaleHeight (1.0f),
|
: myScaleHeight (1.0f),
|
||||||
myPoint (0.0f, 0.0f, 0.0f),
|
myIs2d (Standard_False)
|
||||||
myIs2d (false),
|
|
||||||
myHasPlane (false),
|
|
||||||
myHasAnchorPoint (true)
|
|
||||||
{
|
{
|
||||||
myParams.Height = 10;
|
myText = new Graphic3d_Text (10.);
|
||||||
myParams.HAlign = Graphic3d_HTA_LEFT;
|
|
||||||
myParams.VAlign = Graphic3d_VTA_BOTTOM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : OpenGl_Text
|
// function : OpenGl_Text
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
|
OpenGl_Text::OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams)
|
||||||
const OpenGl_Vec3& thePoint,
|
: myText (theTextParams),
|
||||||
const OpenGl_TextParam& theParams)
|
myScaleHeight (1.0f),
|
||||||
: myScaleHeight (1.0f),
|
myIs2d (Standard_False)
|
||||||
myExportHeight (1.0f),
|
|
||||||
myParams (theParams),
|
|
||||||
myString (theText),
|
|
||||||
myPoint (thePoint),
|
|
||||||
myIs2d (false),
|
|
||||||
myHasPlane (false),
|
|
||||||
myHasAnchorPoint (true)
|
|
||||||
{
|
{
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : OpenGl_Text
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
|
|
||||||
const gp_Ax2& theOrientation,
|
|
||||||
const OpenGl_TextParam& theParams,
|
|
||||||
const bool theHasOwnAnchor)
|
|
||||||
: myScaleHeight (1.0),
|
|
||||||
myExportHeight (1.0),
|
|
||||||
myParams (theParams),
|
|
||||||
myString (theText),
|
|
||||||
myIs2d (false),
|
|
||||||
myOrientation (theOrientation),
|
|
||||||
myHasPlane (true),
|
|
||||||
myHasAnchorPoint (theHasOwnAnchor)
|
|
||||||
{
|
|
||||||
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()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -133,7 +98,7 @@ OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
|
void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
|
||||||
{
|
{
|
||||||
myPoint = thePoint;
|
myText->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -143,11 +108,27 @@ void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
|
|||||||
void OpenGl_Text::SetFontSize (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Text::SetFontSize (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Standard_Integer theFontSize)
|
const Standard_Integer theFontSize)
|
||||||
{
|
{
|
||||||
if (myParams.Height != theFontSize)
|
if (myText->Height() != theFontSize)
|
||||||
{
|
{
|
||||||
Release (theCtx.operator->());
|
Release (theCtx.operator->());
|
||||||
}
|
}
|
||||||
myParams.Height = theFontSize;
|
myText->SetHeight ((Standard_ShortReal)theFontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : Reset
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_Text::Reset (const Handle(OpenGl_Context)& theCtx)
|
||||||
|
{
|
||||||
|
if (!myFont.IsNull() && myFont->FTFont()->PointSize() != myText->Height())
|
||||||
|
{
|
||||||
|
Release (theCtx.operator->());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
releaseVbos (theCtx.operator->());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -158,56 +139,13 @@ void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
|
|||||||
const Standard_Utf8Char* theText,
|
const Standard_Utf8Char* theText,
|
||||||
const OpenGl_Vec3& thePoint)
|
const OpenGl_Vec3& thePoint)
|
||||||
{
|
{
|
||||||
releaseVbos (theCtx.operator->());
|
Reset (theCtx);
|
||||||
myIs2d = false;
|
Set2D (Standard_False);
|
||||||
myPoint = thePoint;
|
|
||||||
myString.FromUnicode (theText);
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
NCollection_String aText;
|
||||||
// function : Init
|
aText.FromUnicode (theText);
|
||||||
// purpose :
|
myText->SetText (aText);
|
||||||
// =======================================================================
|
myText->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)
|
|
||||||
{
|
|
||||||
if (myParams.Height != theParams.Height)
|
|
||||||
{
|
|
||||||
Release (theCtx.operator->());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
releaseVbos (theCtx.operator->());
|
|
||||||
}
|
|
||||||
myIs2d = false;
|
|
||||||
myParams = theParams;
|
|
||||||
myPoint = thePoint;
|
|
||||||
myString.FromUnicode (theText);
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : Init
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
|
|
||||||
const TCollection_ExtendedString& theText,
|
|
||||||
const OpenGl_Vec2& thePoint,
|
|
||||||
const OpenGl_TextParam& theParams)
|
|
||||||
{
|
|
||||||
if (myParams.Height != theParams.Height)
|
|
||||||
{
|
|
||||||
Release (theCtx.operator->());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
releaseVbos (theCtx.operator->());
|
|
||||||
}
|
|
||||||
myIs2d = true;
|
|
||||||
myParams = theParams;
|
|
||||||
myPoint.SetValues (thePoint, 0.0f);
|
|
||||||
myString.FromUnicode (theText.ToExtString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -275,7 +213,7 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx)
|
|||||||
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||||
const NCollection_String& theText,
|
const NCollection_String& theText,
|
||||||
const OpenGl_Aspects& theTextAspect,
|
const OpenGl_Aspects& theTextAspect,
|
||||||
const OpenGl_TextParam& theParams,
|
const Standard_ShortReal theHeight,
|
||||||
const unsigned int theResolution,
|
const unsigned int theResolution,
|
||||||
Standard_ShortReal& theWidth,
|
Standard_ShortReal& theWidth,
|
||||||
Standard_ShortReal& theAscent,
|
Standard_ShortReal& theAscent,
|
||||||
@ -284,8 +222,8 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
|||||||
theWidth = 0.0f;
|
theWidth = 0.0f;
|
||||||
theAscent = 0.0f;
|
theAscent = 0.0f;
|
||||||
theDescent = 0.0f;
|
theDescent = 0.0f;
|
||||||
const TCollection_AsciiString aFontKey = FontKey (theTextAspect, theParams.Height, theResolution);
|
const TCollection_AsciiString aFontKey = FontKey (theTextAspect, (Standard_Integer)theHeight, theResolution);
|
||||||
Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, theParams.Height, theResolution, aFontKey);
|
Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, (Standard_Integer)theHeight, theResolution, aFontKey);
|
||||||
if (aFont.IsNull() || !aFont->IsValid())
|
if (aFont.IsNull() || !aFont->IsValid())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -347,7 +285,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
|||||||
// Bind custom shader program or generate default version
|
// Bind custom shader program or generate default version
|
||||||
aCtx->ShaderManager()->BindFontProgram (aTextAspect->ShaderProgramRes (aCtx));
|
aCtx->ShaderManager()->BindFontProgram (aTextAspect->ShaderProgramRes (aCtx));
|
||||||
|
|
||||||
if (myHasPlane && myHasAnchorPoint)
|
if (myText->HasPlane() && myText->HasOwnAnchorPoint())
|
||||||
{
|
{
|
||||||
myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
|
myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
|
||||||
// reset translation part
|
// reset translation part
|
||||||
@ -411,7 +349,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
|||||||
const OpenGl_Vec3& theDVec) const
|
const OpenGl_Vec3& theDVec) const
|
||||||
{
|
{
|
||||||
OpenGl_Mat4d aModViewMat, aProjectMat;
|
OpenGl_Mat4d aModViewMat, aProjectMat;
|
||||||
if (myHasPlane && myHasAnchorPoint)
|
if (myText->HasPlane() && myText->HasOwnAnchorPoint())
|
||||||
{
|
{
|
||||||
aProjectMat = myProjMatrix * myOrientationMatrix;
|
aProjectMat = myProjMatrix * myOrientationMatrix;
|
||||||
}
|
}
|
||||||
@ -422,7 +360,8 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
|||||||
|
|
||||||
if (myIs2d)
|
if (myIs2d)
|
||||||
{
|
{
|
||||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
|
const gp_Pnt& aPoint = myText->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::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
|
||||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.f, 0.f, 1.f);
|
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.f, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
@ -430,7 +369,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
|||||||
{
|
{
|
||||||
OpenGl_Vec3d anObjXYZ;
|
OpenGl_Vec3d anObjXYZ;
|
||||||
OpenGl_Vec3d aWinXYZ = myWinXYZ + OpenGl_Vec3d (theDVec);
|
OpenGl_Vec3d aWinXYZ = myWinXYZ + OpenGl_Vec3d (theDVec);
|
||||||
if (!myHasPlane && !theTextAspect.Aspect()->IsTextZoomable())
|
if (!myText->HasPlane() && !theTextAspect.Aspect()->IsTextZoomable())
|
||||||
{
|
{
|
||||||
// Align coordinates to the nearest integer to avoid extra interpolation issues.
|
// Align coordinates to the nearest integer to avoid extra interpolation issues.
|
||||||
// Note that for better readability we could also try aligning freely rotated in 3D text (myHasPlane),
|
// Note that for better readability we could also try aligning freely rotated in 3D text (myHasPlane),
|
||||||
@ -443,20 +382,22 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
|||||||
THE_IDENTITY_MATRIX, aProjectMat, theCtx->Viewport(),
|
THE_IDENTITY_MATRIX, aProjectMat, theCtx->Viewport(),
|
||||||
anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
|
anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
|
||||||
|
|
||||||
if (myHasPlane)
|
if (myText->HasPlane())
|
||||||
{
|
{
|
||||||
const gp_Dir& aVectorDir = myOrientation.XDirection();
|
const gp_Ax2& anOrientation = myText->Orientation();
|
||||||
const gp_Dir& aVectorUp = myOrientation.Direction();
|
const gp_Dir& aVectorDir = anOrientation.XDirection();
|
||||||
const gp_Dir& aVectorRight = myOrientation.YDirection();
|
const gp_Dir& aVectorUp = anOrientation.Direction();
|
||||||
|
const gp_Dir& aVectorRight = anOrientation.YDirection();
|
||||||
|
|
||||||
aModViewMat.SetColumn (2, OpenGl_Vec3d (aVectorUp.X(), aVectorUp.Y(), aVectorUp.Z()));
|
aModViewMat.SetColumn (2, OpenGl_Vec3d (aVectorUp.X(), aVectorUp.Y(), aVectorUp.Z()));
|
||||||
aModViewMat.SetColumn (1, OpenGl_Vec3d (aVectorRight.X(), aVectorRight.Y(), aVectorRight.Z()));
|
aModViewMat.SetColumn (1, OpenGl_Vec3d (aVectorRight.X(), aVectorRight.Y(), aVectorRight.Z()));
|
||||||
aModViewMat.SetColumn (0, OpenGl_Vec3d (aVectorDir.X(), aVectorDir.Y(), aVectorDir.Z()));
|
aModViewMat.SetColumn (0, OpenGl_Vec3d (aVectorDir.X(), aVectorDir.Y(), aVectorDir.Z()));
|
||||||
|
|
||||||
if (!myHasAnchorPoint)
|
if (!myText->HasOwnAnchorPoint())
|
||||||
{
|
{
|
||||||
OpenGl_Mat4d aPosMat;
|
OpenGl_Mat4d aPosMat;
|
||||||
aPosMat.SetColumn (3, OpenGl_Vec3d (myPoint.x(), myPoint.y(), myPoint.z()));
|
const gp_Pnt& aPoint = myText->Position();
|
||||||
|
aPosMat.SetColumn (3, OpenGl_Vec3d (aPoint.X(), aPoint.Y(), aPoint.Z()));
|
||||||
aPosMat *= aModViewMat;
|
aPosMat *= aModViewMat;
|
||||||
aModViewMat.SetColumn (3, aPosMat.GetColumn (3));
|
aModViewMat.SetColumn (3, aPosMat.GetColumn (3));
|
||||||
}
|
}
|
||||||
@ -481,7 +422,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myHasPlane && !myHasAnchorPoint)
|
if (myText->HasPlane() && !myText->HasOwnAnchorPoint())
|
||||||
{
|
{
|
||||||
OpenGl_Mat4d aCurrentWorldViewMat;
|
OpenGl_Mat4d aCurrentWorldViewMat;
|
||||||
aCurrentWorldViewMat.Convert (theCtx->WorldViewState.Current());
|
aCurrentWorldViewMat.Convert (theCtx->WorldViewState.Current());
|
||||||
@ -666,14 +607,14 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
const OpenGl_Vec4& theColorSubs,
|
const OpenGl_Vec4& theColorSubs,
|
||||||
unsigned int theResolution) const
|
unsigned int theResolution) const
|
||||||
{
|
{
|
||||||
if (myString.IsEmpty())
|
if (myText->Text().IsEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that using difference resolution in different Views in same Viewer
|
// Note that using difference resolution in different Views in same Viewer
|
||||||
// will lead to performance regression (for example, text will be recreated every time).
|
// 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)myText->Height(), theResolution);
|
||||||
if (!myFont.IsNull()
|
if (!myFont.IsNull()
|
||||||
&& !myFont->ResourceKey().IsEqual (aFontKey))
|
&& !myFont->ResourceKey().IsEqual (aFontKey))
|
||||||
{
|
{
|
||||||
@ -683,7 +624,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
|
|
||||||
if (myFont.IsNull())
|
if (myFont.IsNull())
|
||||||
{
|
{
|
||||||
myFont = FindFont (theCtx, theTextAspect, myParams.Height, theResolution, aFontKey);
|
myFont = FindFont (theCtx, theTextAspect, (Standard_Integer)myText->Height(), theResolution, aFontKey);
|
||||||
}
|
}
|
||||||
if (!myFont->WasInitialized())
|
if (!myFont->WasInitialized())
|
||||||
{
|
{
|
||||||
@ -693,10 +634,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
if (myTextures.IsEmpty())
|
if (myTextures.IsEmpty())
|
||||||
{
|
{
|
||||||
Font_TextFormatter aFormatter;
|
Font_TextFormatter aFormatter;
|
||||||
aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
|
|
||||||
|
aFormatter.SetupAlignment (myText->HorizontalAlignment(), myText->VerticalAlignment());
|
||||||
aFormatter.Reset();
|
aFormatter.Reset();
|
||||||
|
|
||||||
aFormatter.Append (myString, *myFont->FTFont().operator->());
|
aFormatter.Append (myText->Text(), *myFont->FTFont());
|
||||||
aFormatter.Format();
|
aFormatter.Format();
|
||||||
|
|
||||||
OpenGl_TextBuilder aBuilder;
|
OpenGl_TextBuilder aBuilder;
|
||||||
@ -720,7 +662,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
myExportHeight = 1.0f;
|
|
||||||
myScaleHeight = 1.0f;
|
myScaleHeight = 1.0f;
|
||||||
|
|
||||||
theCtx->WorldViewState.Push();
|
theCtx->WorldViewState.Push();
|
||||||
@ -729,16 +670,13 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
const GLdouble aPointSize = (GLdouble )myFont->FTFont()->PointSize();
|
const GLdouble aPointSize = (GLdouble )myFont->FTFont()->PointSize();
|
||||||
if (!myIs2d)
|
if (!myIs2d)
|
||||||
{
|
{
|
||||||
Graphic3d_TransformUtils::Project<Standard_Real> (myPoint.x(), myPoint.y(), myPoint.z(),
|
const gp_Pnt& aPoint = myText->Position();
|
||||||
|
Graphic3d_TransformUtils::Project<Standard_Real> (aPoint.X(), aPoint.Y(), aPoint.Z(),
|
||||||
myModelMatrix, myProjMatrix, theCtx->Viewport(),
|
myModelMatrix, myProjMatrix, theCtx->Viewport(),
|
||||||
myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z());
|
myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z());
|
||||||
|
|
||||||
// compute scale factor for constant text height
|
// compute scale factor for constant text height
|
||||||
if (theTextAspect.Aspect()->IsTextZoomable())
|
if (!theTextAspect.Aspect()->IsTextZoomable())
|
||||||
{
|
|
||||||
myExportHeight = aPointSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Graphic3d_Vec3d aPnt1, aPnt2;
|
Graphic3d_Vec3d aPnt1, aPnt2;
|
||||||
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z(),
|
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z(),
|
||||||
@ -750,7 +688,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
myScaleHeight = (aPnt2.y() - aPnt1.y()) / aPointSize;
|
myScaleHeight = (aPnt2.y() - aPnt1.y()) / aPointSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myExportHeight = aPointSize / myExportHeight;
|
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
if (theCtx->core11 != NULL
|
if (theCtx->core11 != NULL
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
#include <OpenGl_Element.hxx>
|
#include <OpenGl_Element.hxx>
|
||||||
|
|
||||||
#include <OpenGl_Aspects.hxx>
|
#include <OpenGl_Aspects.hxx>
|
||||||
#include <OpenGl_TextParam.hxx>
|
|
||||||
#include <OpenGl_TextBuilder.hxx>
|
#include <OpenGl_TextBuilder.hxx>
|
||||||
|
|
||||||
#include <TCollection_ExtendedString.hxx>
|
#include <TCollection_ExtendedString.hxx>
|
||||||
#include <Graphic3d_Vertex.hxx>
|
#include <Graphic3d_Vertex.hxx>
|
||||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||||
#include <Graphic3d_RenderingParams.hxx>
|
#include <Graphic3d_RenderingParams.hxx>
|
||||||
|
#include <Graphic3d_Text.hxx>
|
||||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||||
|
|
||||||
#include <gp_Ax2.hxx>
|
#include <gp_Ax2.hxx>
|
||||||
@ -36,33 +36,30 @@ class OpenGl_Text : public OpenGl_Element
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Main constructor
|
|
||||||
Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
|
|
||||||
const OpenGl_Vec3& thePoint,
|
|
||||||
const OpenGl_TextParam& theParams);
|
|
||||||
|
|
||||||
//! Creates new text in 3D space.
|
//! Creates new text in 3D space.
|
||||||
Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
|
Standard_EXPORT OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams);
|
||||||
const gp_Ax2& theOrientation,
|
|
||||||
const OpenGl_TextParam& theParams,
|
|
||||||
const bool theHasOwnAnchor = true);
|
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
Standard_EXPORT virtual ~OpenGl_Text();
|
Standard_EXPORT virtual ~OpenGl_Text();
|
||||||
|
|
||||||
//! Setup new string and position
|
//! Release cached VBO resources and the previous font if height changed.
|
||||||
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
|
//! Cached structures will be refilled by the next render.
|
||||||
const Standard_Utf8Char* theText,
|
//! Call Reset after modifying text parameters.
|
||||||
const OpenGl_Vec3& thePoint);
|
Standard_EXPORT void Reset (const Handle(OpenGl_Context)& theCtx);
|
||||||
|
|
||||||
//! Setup new string and parameters
|
//! Returns text parameters
|
||||||
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
|
//! @sa Reset()
|
||||||
const Standard_Utf8Char* theText,
|
const Handle(Graphic3d_Text)& Text() const { return myText; }
|
||||||
const OpenGl_Vec3& thePoint,
|
|
||||||
const OpenGl_TextParam& theParams);
|
|
||||||
|
|
||||||
//! Setup new position
|
//! Sets text parameters
|
||||||
Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
|
//! @sa Reset()
|
||||||
|
void SetText (const Handle(Graphic3d_Text)& theText) { myText = theText; }
|
||||||
|
|
||||||
|
//! Return true if text is 2D
|
||||||
|
Standard_Boolean Is2D() const { return myIs2d; }
|
||||||
|
|
||||||
|
//! Set true if text is 2D
|
||||||
|
void Set2D (const Standard_Boolean theEnable) { myIs2d = theEnable; }
|
||||||
|
|
||||||
//! Setup new font size
|
//! Setup new font size
|
||||||
Standard_EXPORT void SetFontSize (const Handle(OpenGl_Context)& theContext,
|
Standard_EXPORT void SetFontSize (const Handle(OpenGl_Context)& theContext,
|
||||||
@ -71,12 +68,6 @@ public:
|
|||||||
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||||
Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
|
Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
|
||||||
|
|
||||||
//! Return defined text.
|
|
||||||
const NCollection_String& Text() const { return myString; }
|
|
||||||
|
|
||||||
//! Return text formatting parameters.
|
|
||||||
const OpenGl_TextParam& FormatParams() const { return myParams; }
|
|
||||||
|
|
||||||
public: //! @name methods for compatibility with layers
|
public: //! @name methods for compatibility with layers
|
||||||
|
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
@ -98,23 +89,30 @@ public: //! @name methods for compatibility with layers
|
|||||||
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||||
const NCollection_String& theText,
|
const NCollection_String& theText,
|
||||||
const OpenGl_Aspects& theTextAspect,
|
const OpenGl_Aspects& theTextAspect,
|
||||||
const OpenGl_TextParam& theParams,
|
const Standard_ShortReal theHeight,
|
||||||
const unsigned int theResolution,
|
const unsigned int theResolution,
|
||||||
Standard_ShortReal& theWidth,
|
Standard_ShortReal& theWidth,
|
||||||
Standard_ShortReal& theAscent,
|
Standard_ShortReal& theAscent,
|
||||||
Standard_ShortReal& theDescent);
|
Standard_ShortReal& theDescent);
|
||||||
|
|
||||||
//! Setup new string and parameters
|
|
||||||
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
|
|
||||||
const TCollection_ExtendedString& theText,
|
|
||||||
const OpenGl_Vec2& thePoint,
|
|
||||||
const OpenGl_TextParam& theParams);
|
|
||||||
|
|
||||||
//! Perform rendering
|
//! Perform rendering
|
||||||
Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
|
||||||
const OpenGl_Aspects& theTextAspect,
|
const OpenGl_Aspects& theTextAspect,
|
||||||
unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
|
unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
|
||||||
|
|
||||||
|
//! @name obsolete methods
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Setup new string and position
|
||||||
|
Standard_DEPRECATED("Deprecated method Init() with obsolete arguments, use Init() and Text() instead of it")
|
||||||
|
Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
|
||||||
|
const Standard_Utf8Char* theText,
|
||||||
|
const OpenGl_Vec3& thePoint);
|
||||||
|
|
||||||
|
//! Setup new position
|
||||||
|
Standard_DEPRECATED("Deprecated method SetPosition(), use Graphic3d_Text for it")
|
||||||
|
Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
friend class OpenGl_Trihedron;
|
friend class OpenGl_Trihedron;
|
||||||
@ -148,6 +146,7 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Handle(Graphic3d_Text) myText; //!< text parameters
|
||||||
mutable Handle(OpenGl_Font) myFont;
|
mutable Handle(OpenGl_Font) myFont;
|
||||||
mutable NCollection_Vector<GLuint> myTextures; //!< textures' IDs
|
mutable NCollection_Vector<GLuint> myTextures; //!< textures' IDs
|
||||||
mutable NCollection_Vector<Handle(OpenGl_VertexBuffer)> myVertsVbo; //!< VBOs of vertices
|
mutable NCollection_Vector<Handle(OpenGl_VertexBuffer)> myVertsVbo; //!< VBOs of vertices
|
||||||
@ -162,18 +161,10 @@ protected:
|
|||||||
mutable OpenGl_Mat4d myOrientationMatrix;
|
mutable OpenGl_Mat4d myOrientationMatrix;
|
||||||
mutable OpenGl_Vec3d myWinXYZ;
|
mutable OpenGl_Vec3d myWinXYZ;
|
||||||
mutable GLdouble myScaleHeight;
|
mutable GLdouble myScaleHeight;
|
||||||
mutable GLdouble myExportHeight;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
OpenGl_TextParam myParams;
|
Standard_Boolean myIs2d;
|
||||||
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.
|
|
||||||
bool myHasAnchorPoint; //!< Shows if it has own attach point
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DEFINE_STANDARD_ALLOC
|
DEFINE_STANDARD_ALLOC
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
// Created on: 2011-09-20
|
|
||||||
// Created by: Sergey ZERCHANINOV
|
|
||||||
// Copyright (c) 2011-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 _OpenGl_TextParam_Header
|
|
||||||
#define _OpenGl_TextParam_Header
|
|
||||||
|
|
||||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
|
||||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
|
||||||
|
|
||||||
struct OpenGl_TextParam
|
|
||||||
{
|
|
||||||
int Height;
|
|
||||||
Graphic3d_HorizontalTextAlignment HAlign;
|
|
||||||
Graphic3d_VerticalTextAlignment VAlign;
|
|
||||||
DEFINE_STANDARD_ALLOC
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //_OpenGl_TextParam_Header
|
|
@ -25,7 +25,6 @@
|
|||||||
#include <OpenGl_Matrix.hxx>
|
#include <OpenGl_Matrix.hxx>
|
||||||
#include <OpenGl_ShaderObject.hxx>
|
#include <OpenGl_ShaderObject.hxx>
|
||||||
#include <OpenGl_ShaderProgram.hxx>
|
#include <OpenGl_ShaderProgram.hxx>
|
||||||
#include <OpenGl_TextParam.hxx>
|
|
||||||
#include <OpenGl_TextureBufferArb.hxx>
|
#include <OpenGl_TextureBufferArb.hxx>
|
||||||
#include <OpenGl_RenderFilter.hxx>
|
#include <OpenGl_RenderFilter.hxx>
|
||||||
#include <OpenGl_Vec.hxx>
|
#include <OpenGl_Vec.hxx>
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <Graphic3d_Group.hxx>
|
#include <Graphic3d_Group.hxx>
|
||||||
|
#include <Graphic3d_Text.hxx>
|
||||||
#include <Graphic3d_Vertex.hxx>
|
#include <Graphic3d_Vertex.hxx>
|
||||||
#include <Prs3d_Presentation.hxx>
|
#include <Prs3d_Presentation.hxx>
|
||||||
#include <Prs3d_TextAspect.hxx>
|
#include <Prs3d_TextAspect.hxx>
|
||||||
@ -33,17 +34,14 @@ void Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup,
|
|||||||
const TCollection_ExtendedString& theText,
|
const TCollection_ExtendedString& theText,
|
||||||
const gp_Pnt& theAttachmentPoint)
|
const gp_Pnt& theAttachmentPoint)
|
||||||
{
|
{
|
||||||
Standard_Real x, y, z;
|
|
||||||
theAttachmentPoint.Coord(x,y,z);
|
|
||||||
|
|
||||||
theGroup->SetPrimitivesAspect (theAspect->Aspect());
|
theGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||||
theGroup->Text (theText,
|
|
||||||
Graphic3d_Vertex(x,y,z),
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height());
|
||||||
theAspect->Height(),
|
aText->SetText (theText.ToExtString());
|
||||||
theAspect->Angle(),
|
aText->SetPosition (theAttachmentPoint);
|
||||||
theAspect->Orientation(),
|
aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
|
||||||
theAspect->HorizontalJustification(),
|
aText->SetVerticalAlignment (theAspect->VerticalJustification());
|
||||||
theAspect->VerticalJustification());
|
theGroup->AddText (aText);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -57,13 +55,12 @@ void Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup,
|
|||||||
const Standard_Boolean theHasOwnAnchor)
|
const Standard_Boolean theHasOwnAnchor)
|
||||||
{
|
{
|
||||||
theGroup->SetPrimitivesAspect (theAspect->Aspect());
|
theGroup->SetPrimitivesAspect (theAspect->Aspect());
|
||||||
theGroup->Text (theText,
|
|
||||||
theOrientation,
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height());
|
||||||
theAspect->Height(),
|
aText->SetText (theText.ToExtString());
|
||||||
theAspect->Angle(),
|
aText->SetOrientation (theOrientation);
|
||||||
theAspect->Orientation(),
|
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||||
theAspect->HorizontalJustification(),
|
aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
|
||||||
theAspect->VerticalJustification(),
|
aText->SetVerticalAlignment (theAspect->VerticalJustification());
|
||||||
Standard_True,
|
theGroup->AddText (aText);
|
||||||
theHasOwnAnchor);
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <Graphic3d_GraphicDriver.hxx>
|
#include <Graphic3d_GraphicDriver.hxx>
|
||||||
#include <Graphic3d_Group.hxx>
|
#include <Graphic3d_Group.hxx>
|
||||||
#include <Graphic3d_Structure.hxx>
|
#include <Graphic3d_Structure.hxx>
|
||||||
|
#include <Graphic3d_Text.hxx>
|
||||||
#include <Standard_ErrorHandler.hxx>
|
#include <Standard_ErrorHandler.hxx>
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
#include <V3d.hxx>
|
#include <V3d.hxx>
|
||||||
@ -547,17 +548,26 @@ void V3d_Viewer::DisplayPrivilegedPlane (const Standard_Boolean theOnOff, const
|
|||||||
const gp_Pnt pX (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.XDirection().XYZ());
|
const gp_Pnt pX (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.XDirection().XYZ());
|
||||||
aPrims->AddVertex (p0);
|
aPrims->AddVertex (p0);
|
||||||
aPrims->AddVertex (pX);
|
aPrims->AddVertex (pX);
|
||||||
aGroup->Text ("X", Graphic3d_Vertex (pX.X(), pX.Y(), pX.Z()), 1.0 / 81.0);
|
Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f / 81.0f);
|
||||||
|
aText->SetText ("X");
|
||||||
|
aText->SetPosition (pX);
|
||||||
|
aGroup->AddText (aText);
|
||||||
|
|
||||||
const gp_Pnt pY (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.YDirection().XYZ());
|
const gp_Pnt pY (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.YDirection().XYZ());
|
||||||
aPrims->AddVertex (p0);
|
aPrims->AddVertex (p0);
|
||||||
aPrims->AddVertex (pY);
|
aPrims->AddVertex (pY);
|
||||||
aGroup->Text ("Y", Graphic3d_Vertex (pY.X(), pY.Y(), pY.Z()), 1.0 / 81.0);
|
aText = new Graphic3d_Text (1.0f / 81.0f);
|
||||||
|
aText->SetText ("Y");
|
||||||
|
aText->SetPosition (pY);
|
||||||
|
aGroup->AddText (aText);
|
||||||
|
|
||||||
const gp_Pnt pZ (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.Direction().XYZ());
|
const gp_Pnt pZ (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.Direction().XYZ());
|
||||||
aPrims->AddVertex (p0);
|
aPrims->AddVertex (p0);
|
||||||
aPrims->AddVertex (pZ);
|
aPrims->AddVertex (pZ);
|
||||||
aGroup->Text ("Z", Graphic3d_Vertex (pZ.X(), pZ.Y(), pZ.Z()), 1.0 / 81.0);
|
aText = new Graphic3d_Text (1.0f / 81.0f);
|
||||||
|
aText->SetText ("Z");
|
||||||
|
aText->SetPosition (pZ);
|
||||||
|
aGroup->AddText (aText);
|
||||||
|
|
||||||
aGroup->AddPrimitiveArray (aPrims);
|
aGroup->AddPrimitiveArray (aPrims);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user