MRPT  1.9.9
CText3D.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef opengl_CText3D_H
11 #define opengl_CText3D_H
12 
14 
15 namespace mrpt::opengl
16 {
17 /** A 3D text (rendered with OpenGL primitives), with selectable font face and
18  * drawing style.
19  * Use \a setString and \a setFont to change the text displayed by this object
20  * (can be multi-lined).
21  *
22  * Text is drawn along the (+X,+Y) axes.
23  *
24  * Default size of characters is "1.0 units". Change it with the standard
25  * method \a CRenderizable::setScale() as with any other 3D object.
26  * The color can be also changed with standard methods in the base class \a
27  * CRenderizable.
28  *
29  * \sa opengl::COpenGLScene, CText
30  *
31  * <div align="center">
32  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
33  * border-style: solid;">
34  * <tr> <td> mrpt::opengl::CText3D </td> <td> \image html preview_CText3D.png
35  * </td> </tr>
36  * </table>
37  * </div>
38  *
39  * \note This class is based on code from libcvd (BSD,
40  * http://www.edwardrosten.com/cvd/ )
41  * \ingroup mrpt_opengl_grp
42  */
44 {
46  protected:
52 
53  public:
54  /** Sets the displayed string */
55  inline void setString(const std::string& s)
56  {
57  m_str = s;
59  }
60  /** Returns the currently text associated to this object */
61  inline const std::string& getString() const { return m_str; }
62  /** Changes the font name, among accepted values: "sans", "mono", "serif" */
63  inline void setFont(const std::string& font)
64  {
65  m_fontName = font;
67  }
68  /** Returns the text font */
69  inline const std::string& getFont() const { return m_fontName; }
70  /** Change drawing style: FILL, OUTLINE, NICE */
72  {
73  m_text_style = text_style;
75  }
76  /** Gets the current drawing style */
78  void setTextSpacing(const double text_spacing)
79  {
80  m_text_spacing = text_spacing;
82  }
83  double setTextSpacing() const { return m_text_spacing; }
84  void setTextKerning(const double text_kerning)
85  {
86  m_text_kerning = text_kerning;
88  }
89  double setTextKerning() const { return m_text_kerning; }
90  /** Render */
91  void render_dl() const override;
92 
93  /** Evaluates the bounding box of this object (including possible children)
94  * in the coordinate frame of the object parent. */
95  void getBoundingBox(
96  mrpt::math::TPoint3D& bb_min,
97  mrpt::math::TPoint3D& bb_max) const override;
98 
99  /** Class factory */
100  static CText3D::Ptr Create(
101  const std::string& str,
102  const std::string& fontName = std::string("sans"),
103  const double scale = 1.0,
105  const double text_spacing = 1.5, const double text_kerning = 0.1);
106 
107  /** Constructor */
108  CText3D(
109  const std::string& str = std::string(""),
110  const std::string& fontName = std::string("sans"),
111  const double scale = 1.0,
113  const double text_spacing = 1.5, const double text_kerning = 0.1);
114 
115  /** Private, virtual destructor: only can be deleted from smart pointers */
116  virtual ~CText3D();
117 };
118 
119 }
120 #endif
121 
122 
double setTextKerning() const
Definition: CText3D.h:89
TOpenGLFontStyle m_text_style
Definition: CText3D.h:49
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:6502
virtual ~CText3D()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText3D.cpp:52
void setString(const std::string &s)
Sets the displayed string.
Definition: CText3D.h:55
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
GLdouble s
Definition: glext.h:3676
void setFont(const std::string &font)
Changes the font name, among accepted values: "sans", "mono", "serif".
Definition: CText3D.h:63
double m_text_kerning
Definition: CText3D.h:51
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:36
const std::string & getFont() const
Returns the text font.
Definition: CText3D.h:69
std::string m_fontName
Definition: CText3D.h:48
const std::string & getString() const
Returns the currently text associated to this object.
Definition: CText3D.h:61
std::string m_str
Definition: CText3D.h:47
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:34
static Ptr Create(Args &&... args)
Definition: CText3D.h:45
GLsizei const GLchar ** string
Definition: glext.h:4101
void setTextKerning(const double text_kerning)
Definition: CText3D.h:84
void setTextStyle(const mrpt::opengl::TOpenGLFontStyle text_style)
Change drawing style: FILL, OUTLINE, NICE.
Definition: CText3D.h:71
#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:50
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:38
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style...
Definition: CText3D.h:43
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
double setTextSpacing() const
Definition: CText3D.h:83
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:98
mrpt::opengl::TOpenGLFontStyle getTextStyle() const
Gets the current drawing style.
Definition: CText3D.h:77
void setTextSpacing(const double text_spacing)
Definition: CText3D.h:78
Lightweight 3D point.
void render_dl() const override
Render.
Definition: CText3D.cpp:56
renders glyphs as filled polygons
Definition: opengl_fonts.h:36



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020