MRPT  1.9.9
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-2019, 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:
51 
52  public:
53  /** Sets the displayed string */
54  inline void setString(const std::string& s)
55  {
56  m_str = s;
58  }
59  /** Returns the currently text associated to this object */
60  inline const std::string& getString() const { return m_str; }
61  /** Changes the font name, among accepted values: "sans", "mono", "serif" */
62  inline void setFont(const std::string& font)
63  {
64  m_fontName = font;
66  }
67  /** Returns the text font */
68  inline const std::string& getFont() const { return m_fontName; }
69  /** Change drawing style: FILL, OUTLINE, NICE */
71  {
72  m_text_style = text_style;
74  }
75  /** Gets the current drawing style */
77  void setTextSpacing(const double text_spacing)
78  {
79  m_text_spacing = text_spacing;
81  }
82  double setTextSpacing() const { return m_text_spacing; }
83  void setTextKerning(const double text_kerning)
84  {
85  m_text_kerning = text_kerning;
87  }
88  double setTextKerning() const { return m_text_kerning; }
89  /** Render */
90  void render_dl() const override;
91 
92  /** Evaluates the bounding box of this object (including possible children)
93  * in the coordinate frame of the object parent. */
94  void getBoundingBox(
96  mrpt::math::TPoint3D& bb_max) const override;
97 
98  /** Constructor */
99  CText3D(
100  const std::string& str = std::string(""),
101  const std::string& fontName = std::string("sans"),
102  const double scale = 1.0,
104  const double text_spacing = 1.5, const double text_kerning = 0.1);
105 
106  /** Private, virtual destructor: only can be deleted from smart pointers */
107  ~CText3D() override;
108 };
109 
110 } // namespace mrpt::opengl
double setTextKerning() const
Definition: CText3D.h:88
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
TOpenGLFontStyle m_text_style
Definition: CText3D.h:48
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:6604
void setString(const std::string &s)
Sets the displayed string.
Definition: CText3D.h:54
~CText3D() override
Private, virtual destructor: only can be deleted from smart pointers.
GLdouble s
Definition: glext.h:3682
void setFont(const std::string &font)
Changes the font name, among accepted values: "sans", "mono", "serif".
Definition: CText3D.h:62
double m_text_kerning
Definition: CText3D.h:50
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
CText3D(const std::string &str=std::string(""), const std::string &fontName=std::string("sans"), const double scale=1.0, const mrpt::opengl::TOpenGLFontStyle text_style=mrpt::opengl::NICE, const double text_spacing=1.5, const double text_kerning=0.1)
Constructor.
Definition: CText3D.cpp:27
const std::string & getFont() const
Returns the text font.
Definition: CText3D.h:68
std::string m_fontName
Definition: CText3D.h:47
const std::string & getString() const
Returns the currently text associated to this object.
Definition: CText3D.h:60
std::string m_str
Definition: CText3D.h:46
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:33
GLsizei const GLchar ** string
Definition: glext.h:4116
void setTextKerning(const double text_kerning)
Definition: CText3D.h:83
void setTextStyle(const mrpt::opengl::TOpenGLFontStyle text_style)
Change drawing style: FILL, OUTLINE, NICE.
Definition: CText3D.h:70
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
double m_text_spacing
Definition: CText3D.h:49
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:37
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:15
double setTextSpacing() const
Definition: CText3D.h:82
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:89
mrpt::opengl::TOpenGLFontStyle getTextStyle() const
Gets the current drawing style.
Definition: CText3D.h:76
void setTextSpacing(const double text_spacing)
Definition: CText3D.h:77
const auto bb_min
Lightweight 3D point.
Definition: TPoint3D.h:90
void render_dl() const override
Render.
Definition: CText3D.cpp:47



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019