]> OCCT Git - occt-copy.git/commitdiff
0030537: Visualization - wrapping text in font text formatter
authornds <nds@opencascade.com>
Mon, 2 Sep 2019 15:44:07 +0000 (18:44 +0300)
committersnn <sergey.nikonov@opencascade.com>
Tue, 16 Mar 2021 12:03:53 +0000 (15:03 +0300)
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
src/OpenGl/OpenGl_Context.cxx
src/OpenGl/OpenGl_Context.hxx
src/OpenGl/OpenGl_Text.cxx

index bf9bb8a1bc15abbf88c299c77733b60f29f16a33..61de10cf45e0f91b989887e22a30df5825a532c8 100644 (file)
@@ -15,6 +15,8 @@
 #define Font_BRepTextBuilder_Header
 
 #include <StdPrs_BRepTextBuilder.hxx>
+class Font_TextFormatter;
+
 
 //! Alias for porting from old name.
 typedef StdPrs_BRepTextBuilder Font_BRepTextBuilder;
index 257f8d425faa5979f61318fd9ecc3c515f120782..a114f3c7793910d5aa27cae6360b69ce7997f121 100644 (file)
@@ -38,6 +38,7 @@
 #include <Graphic3d_TransformUtils.hxx>
 #include <Graphic3d_RenderingParams.hxx>
 #include <Image_SupportedFormats.hxx>
+#include <Font_TextFormatter.hxx>
 #include <Message_Messenger.hxx>
 #include <NCollection_Vector.hxx>
 #include <Standard_ProgramError.hxx>
@@ -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();
 }
 
 // =======================================================================
index 916478e1a47f26f7fe4a6c014f7e3d01ee522e5d..05e22f78cbd02d094a19e874122d3980f3159ec9 100644 (file)
@@ -136,6 +136,7 @@ template<typename theBaseClass_t> struct OpenGl_TmplCore45;
 typedef OpenGl_TmplCore45<OpenGl_GlCore44Back> OpenGl_GlCore45Back;
 typedef OpenGl_TmplCore45<OpenGl_GlCore44>     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
 
index 09c63975d1efaae1f0338895464e6874b1e59d52..a75ece79094e38f0383acc94dece659965692cd0 100644 (file)
@@ -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();