MRPT  2.0.1
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
double setTextKerning() const
Definition: CText3D.h:90
TOpenGLFontStyle m_text_style
Definition: CText3D.h:48
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
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
void setString(const std::string &s)
Sets the displayed string.
Definition: CText3D.h:56
void setFont(const std::string &font)
Changes the font name, among accepted values: "sans", "mono", "serif".
Definition: CText3D.h:64
double m_text_kerning
Definition: CText3D.h:50
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
const std::string & getFont() const
Returns the text font.
Definition: CText3D.h:70
std::string m_fontName
Definition: CText3D.h:47
const std::string & getString() const
Returns the currently text associated to this object.
Definition: CText3D.h:62
std::string m_str
Definition: CText3D.h:46
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:19
void setTextKerning(const double text_kerning)
Definition: CText3D.h:85
void setTextStyle(const mrpt::opengl::TOpenGLFontStyle text_style)
Change drawing style: FILL, OUTLINE, NICE.
Definition: CText3D.h:72
Renderizable generic renderer for objects using the "text shader".
double m_text_spacing
Definition: CText3D.h:49
This was "renders glyphs filled with antialiased outlines", but since antialiased is not properly imp...
Definition: opengl_fonts.h:27
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style...
Definition: CText3D.h:42
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
double setTextSpacing() const
Definition: CText3D.h:84
const auto bb_max
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
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
mrpt::opengl::TOpenGLFontStyle getTextStyle() const
Gets the current drawing style.
Definition: CText3D.h:78
void setTextSpacing(const double text_spacing)
Definition: CText3D.h:79
const auto bb_min



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020