Main MRPT website > C++ reference for 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-2017, 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
16 {
17 namespace opengl
18 {
19 /** A 3D text (rendered with OpenGL primitives), with selectable font face and
20  * drawing style.
21  * Use \a setString and \a setFont to change the text displayed by this object
22  * (can be multi-lined).
23  *
24  * Text is drawn along the (+X,+Y) axes.
25  *
26  * Default size of characters is "1.0 units". Change it with the standard
27  * method \a CRenderizable::setScale() as with any other 3D object.
28  * The color can be also changed with standard methods in the base class \a
29  * CRenderizable.
30  *
31  * \sa opengl::COpenGLScene, CText
32  *
33  * <div align="center">
34  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
35  * border-style: solid;">
36  * <tr> <td> mrpt::opengl::CText3D </td> <td> \image html preview_CText3D.png
37  * </td> </tr>
38  * </table>
39  * </div>
40  *
41  * \note This class is based on code from libcvd (LGPL,
42  * http://www.edwardrosten.com/cvd/ )
43  * \ingroup mrpt_opengl_grp
44  */
46 {
48  protected:
54 
55  public:
56  /** Sets the displayed string */
57  inline void setString(const std::string& s)
58  {
59  m_str = s;
61  }
62  /** Returns the currently text associated to this object */
63  inline const std::string& getString() const { return m_str; }
64  /** Changes the font name, among accepted values: "sans", "mono", "serif" */
65  inline void setFont(const std::string& font)
66  {
67  m_fontName = font;
69  }
70  /** Returns the text font */
71  inline const std::string& getFont() const { return m_fontName; }
72  /** Change drawing style: FILL, OUTLINE, NICE */
74  {
75  m_text_style = text_style;
77  }
78  /** Gets the current drawing style */
80  void setTextSpacing(const double text_spacing)
81  {
82  m_text_spacing = text_spacing;
84  }
85  double setTextSpacing() const { return m_text_spacing; }
86  void setTextKerning(const double text_kerning)
87  {
88  m_text_kerning = text_kerning;
90  }
91  double setTextKerning() const { return m_text_kerning; }
92  /** Render */
93  void render_dl() const override;
94 
95  /** Evaluates the bounding box of this object (including possible children)
96  * in the coordinate frame of the object parent. */
97  void getBoundingBox(
98  mrpt::math::TPoint3D& bb_min,
99  mrpt::math::TPoint3D& bb_max) const override;
100 
101  /** Class factory */
102  static CText3D::Ptr Create(
103  const std::string& str,
104  const std::string& fontName = std::string("sans"),
105  const double scale = 1.0,
107  const double text_spacing = 1.5, const double text_kerning = 0.1);
108 
109  /** Constructor */
110  CText3D(
111  const std::string& str = std::string(""),
112  const std::string& fontName = std::string("sans"),
113  const double scale = 1.0,
115  const double text_spacing = 1.5, const double text_kerning = 0.1);
116 
117  /** Private, virtual destructor: only can be deleted from smart pointers */
118  virtual ~CText3D();
119 };
120 
121 } // end namespace
122 
123 } // End of namespace
124 
125 #endif
double setTextKerning() const
Definition: CText3D.h:91
TOpenGLFontStyle m_text_style
Definition: CText3D.h:51
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:57
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:65
double m_text_kerning
Definition: CText3D.h:53
std::shared_ptr< CText3D > Ptr
Definition: CText3D.h:47
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:71
std::string m_fontName
Definition: CText3D.h:50
const std::string & getString() const
Returns the currently text associated to this object.
Definition: CText3D.h:63
std::string m_str
Definition: CText3D.h:49
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:36
static Ptr Create(Args &&... args)
Definition: CText3D.h:47
GLsizei const GLchar ** string
Definition: glext.h:4101
void setTextKerning(const double text_kerning)
Definition: CText3D.h:86
void setTextStyle(const mrpt::opengl::TOpenGLFontStyle text_style)
Change drawing style: FILL, OUTLINE, NICE.
Definition: CText3D.h:73
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#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:52
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:40
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style...
Definition: CText3D.h:45
double setTextSpacing() const
Definition: CText3D.h:85
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:110
mrpt::opengl::TOpenGLFontStyle getTextStyle() const
Gets the current drawing style.
Definition: CText3D.h:79
void setTextSpacing(const double text_spacing)
Definition: CText3D.h:80
Lightweight 3D point.
void render_dl() const override
Render.
Definition: CText3D.cpp:56
renders glyphs as filled polygons
Definition: opengl_fonts.h:38



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019