From afb1205b9aab8a17926e32fe41ebd012fb4a12fa Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 2 Sep 2019 18:44:07 +0300 Subject: [PATCH] 0030537: Visualization - wrapping text in font text formatter Font_TextFormatter inherits Standard_Transient, now it is given as a handle in functions. Graphic3d_Text - extended with Font_TextFormatter to be able to have it filled out of text render. If it is not defined here, the default text formatter of context is used. OpenGl_Context - has default Font_TextFormatter for rendering OpenGl_Text. # Conflicts: # src/Font/Font_TextFormatter.cxx # src/Font/Font_TextFormatter.hxx # src/Graphic3d/Graphic3d_Text.hxx # src/OpenGl/OpenGl_Context.cxx # src/OpenGl/OpenGl_Text.cxx # src/OpenGl/OpenGl_TextBuilder.cxx # src/StdPrs/StdPrs_BRepTextBuilder.cxx --- src/Font/Font_BRepTextBuilder.hxx | 2 ++ src/OpenGl/OpenGl_Context.cxx | 3 +++ src/OpenGl/OpenGl_Context.hxx | 5 +++++ src/OpenGl/OpenGl_Text.cxx | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Font/Font_BRepTextBuilder.hxx b/src/Font/Font_BRepTextBuilder.hxx index bf9bb8a1bc..61de10cf45 100644 --- a/src/Font/Font_BRepTextBuilder.hxx +++ b/src/Font/Font_BRepTextBuilder.hxx @@ -15,6 +15,8 @@ #define Font_BRepTextBuilder_Header #include +class Font_TextFormatter; + //! Alias for porting from old name. typedef StdPrs_BRepTextBuilder Font_BRepTextBuilder; diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 257f8d425f..a114f3c779 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -296,6 +297,8 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) memset (myFuncs.operator->(), 0, sizeof(OpenGl_GlFunctions)); myShaderManager = new OpenGl_ShaderManager (this); + + myDefaultFormatter = new Font_TextFormatter(); } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index 916478e1a4..05e22f78cb 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -136,6 +136,7 @@ template struct OpenGl_TmplCore45; typedef OpenGl_TmplCore45 OpenGl_GlCore45Back; typedef OpenGl_TmplCore45 OpenGl_GlCore45; +class Font_TextFormatter; class Graphic3d_Camera; class Graphic3d_PresentationAttributes; class OpenGl_Aspects; @@ -491,6 +492,9 @@ public: //! @return tool for management of shader programs within this context. inline const Handle(OpenGl_ShaderManager)& ShaderManager() const { return myShaderManager; } + //! @return default formatter of text withing this context + inline const Handle(Font_TextFormatter)& DefaultTextFormatter() const { return myDefaultFormatter; } + public: //! Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1). @@ -1163,6 +1167,7 @@ private: // context info Graphic3d_TextureUnit myPBRSpecIBLMapTexUnit; //!< samplerCube occSpecIBLMap, texture unit where specular IBL map is expected to be binded (0 if PBR is not supported) Handle(OpenGl_ShaderManager) myShaderManager; //! support object for managing shader programs + Handle(Font_TextFormatter) myDefaultFormatter;//!< default text formatter, an alternative to text params private: //! @name fields tracking current state diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index 09c63975d1..a75ece7909 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -689,7 +689,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, Handle(Font_TextFormatter) aFormatter = myText->TextFormatter(); if (aFormatter.IsNull()) { - aFormatter = new Font_TextFormatter(); + aFormatter = theCtx->DefaultTextFormatter(); } aFormatter->SetupAlignment (myText->HorizontalAlignment(), myText->VerticalAlignment()); aFormatter->Reset(); -- 2.39.5