MRPT  2.0.4
CText3D.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
13 
14 namespace mrpt::opengl
15 {
16 /** A 3D text (rendered with OpenGL primitives), with selectable font face and
17  * drawing style.
18  * Use \a setString and \a setFont to change the text displayed by this object
19  * (can be multi-lined).
20  *
21  * Text is drawn along the (+X,+Y) axes.
22  *
23  * Default size of characters is "1.0 units". Change it with the standard
24  * method \a CRenderizable::setScale() as with any other 3D object.
25  * The color can be also changed with standard methods in the base class \a
26  * CRenderizable.
27  *
28  * \sa opengl::COpenGLScene, CText
29  *
30  * <div align="center">
31  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
32  * border-style: solid;">
33  * <tr> <td> mrpt::opengl::CText3D </td> <td> \image html preview_CText3D.png
34  * </td> </tr>
35  * </table>
36  * </div>
37  *
38  * \note This class is based on code from libcvd (BSD,
39  * http://www.edwardrosten.com/cvd/ )
40  * \ingroup mrpt_opengl_grp
41  */
43 {
45  protected:
46  std::string m_str;
47  std::string m_fontName = "sans";
49  double m_text_spacing = 1.5;
50  double m_text_kerning = 0.1;
51 
52  void onUpdateBuffers_Text() override;
53 
54  public:
55  /** Sets the displayed string */
56  inline void setString(const std::string& s)
57  {
58  m_str = s;
60  }
61  /** Returns the currently text associated to this object */
62  inline const std::string& getString() const { return m_str; }
63  /** Changes the font name, among accepted values: "sans", "mono", "serif" */
64  inline void setFont(const std::string& font)
65  {
66  m_fontName = font;
68  }
69  /** Returns the text font */
70  inline const std::string& getFont() const { return m_fontName; }
71  /** Change drawing style: FILL, OUTLINE, NICE */
73  {
74  m_text_style = text_style;
76  }
77  /** Gets the current drawing style */
79  void setTextSpacing(const double text_spacing)
80  {
81  m_text_spacing = text_spacing;
83  }
84  double setTextSpacing() const { return m_text_spacing; }
85  void setTextKerning(const double text_kerning)
86  {
87  m_text_kerning = text_kerning;
89  }
90  double setTextKerning() const { return m_text_kerning; }
91 
92  void getBoundingBox(
94  mrpt::math::TPoint3D& bb_max) const override;
95 
96  CText3D(
97  const std::string& str = std::string(""),
98  const std::string& fontName = std::string("sans"),
99  const float scale = 1.0,
101  const double text_spacing = 1.5, const double text_kerning = 0.1);
102 
103  ~CText3D() override;
104 };
105 
106 } // namespace mrpt::opengl
mrpt::opengl::CText3D::m_text_kerning
double m_text_kerning
Definition: CText3D.h:50
mrpt::opengl::CText3D::setTextKerning
void setTextKerning(const double text_kerning)
Definition: CText3D.h:85
mrpt::opengl::CRenderizable::notifyChange
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
Definition: CRenderizable.h:315
mrpt::opengl::CText3D::getTextStyle
mrpt::opengl::TOpenGLFontStyle getTextStyle() const
Gets the current drawing style.
Definition: CText3D.h:78
mrpt::opengl::CText3D::setTextSpacing
void setTextSpacing(const double text_spacing)
Definition: CText3D.h:79
mrpt::math::TPoint3D_< double >
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:152
mrpt::opengl::TOpenGLFontStyle
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:19
mrpt::opengl::CText3D::setTextSpacing
double setTextSpacing() const
Definition: CText3D.h:84
mrpt::opengl::NICE
@ NICE
This was "renders glyphs filled with antialiased outlines", but since antialiased is not properly imp...
Definition: opengl_fonts.h:27
CRenderizableShaderText.h
mrpt::opengl::CText3D::setTextStyle
void setTextStyle(const mrpt::opengl::TOpenGLFontStyle text_style)
Change drawing style: FILL, OUTLINE, NICE.
Definition: CText3D.h:72
mrpt::opengl::CText3D::getBoundingBox
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: CText3D.cpp:84
mrpt::opengl::CText3D::CText3D
CText3D(const std::string &str=std::string(""), const std::string &fontName=std::string("sans"), const float scale=1.0, const mrpt::opengl::TOpenGLFontStyle text_style=mrpt::opengl::NICE, const double text_spacing=1.5, const double text_kerning=0.1)
Definition: CText3D.cpp:23
bb_max
const auto bb_max
Definition: CPose3DPDFGrid_unittest.cpp:25
bb_min
const auto bb_min
Definition: CPose3DPDFGrid_unittest.cpp:23
mrpt::opengl::CText3D::m_text_style
TOpenGLFontStyle m_text_style
Definition: CText3D.h:48
mrpt::opengl::CText3D::~CText3D
~CText3D() override
mrpt::opengl::CText3D::setTextKerning
double setTextKerning() const
Definition: CText3D.h:90
mrpt::opengl::CText3D::setString
void setString(const std::string &s)
Sets the displayed string.
Definition: CText3D.h:56
mrpt::opengl::CText3D::m_str
std::string m_str
Definition: CText3D.h:46
mrpt::opengl::CRenderizableShaderText
Renderizable generic renderer for objects using the "text shader".
Definition: CRenderizableShaderText.h:25
mrpt::opengl::CText3D
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style.
Definition: CText3D.h:42
mrpt::opengl::CText3D::setFont
void setFont(const std::string &font)
Changes the font name, among accepted values: "sans", "mono", "serif".
Definition: CText3D.h:64
mrpt::opengl::CText3D::onUpdateBuffers_Text
void onUpdateBuffers_Text() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
Definition: CText3D.cpp:38
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
mrpt::opengl::CText3D::getFont
const std::string & getFont() const
Returns the text font
Definition: CText3D.h:70
mrpt::opengl::CText3D::m_fontName
std::string m_fontName
Definition: CText3D.h:47
mrpt::opengl::CText3D::getString
const std::string & getString() const
Returns the currently text associated to this object.
Definition: CText3D.h:62
mrpt::opengl::CText3D::m_text_spacing
double m_text_spacing
Definition: CText3D.h:49



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 15:15:43 UTC 2020