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-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
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 (BSD,
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
mrpt::opengl::CText3D::m_text_kerning
double m_text_kerning
Definition: CText3D.h:53
mrpt::opengl::CText3D::setTextKerning
void setTextKerning(const double text_kerning)
Definition: CText3D.h:86
mrpt::opengl::CText3D::getTextStyle
mrpt::opengl::TOpenGLFontStyle getTextStyle() const
Gets the current drawing style.
Definition: CText3D.h:79
s
GLdouble s
Definition: glext.h:3676
mrpt::opengl::CText3D::setTextSpacing
void setTextSpacing(const double text_spacing)
Definition: CText3D.h:80
mrpt::opengl::TOpenGLFontStyle
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:36
mrpt::opengl::CText3D::setTextSpacing
double setTextSpacing() const
Definition: CText3D.h:85
mrpt::opengl::NICE
@ NICE
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:40
CRenderizableDisplayList.h
mrpt::opengl::CText3D::setTextStyle
void setTextStyle(const mrpt::opengl::TOpenGLFontStyle text_style)
Change drawing style: FILL, OUTLINE, NICE.
Definition: CText3D.h:73
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
mrpt::opengl::CRenderizableDisplayList::notifyChange
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
Definition: CRenderizableDisplayList.h:57
mrpt::opengl::CText3D::render_dl
void render_dl() const override
Render.
Definition: CText3D.cpp:56
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
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:98
mrpt::opengl::CText3D::~CText3D
virtual ~CText3D()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText3D.cpp:52
mrpt::opengl::CText3D::m_text_style
TOpenGLFontStyle m_text_style
Definition: CText3D.h:51
mrpt::opengl::CText3D::CText3D
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
mrpt::opengl::FILL
@ FILL
renders glyphs as filled polygons
Definition: opengl_fonts.h:38
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
scale
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:6503
mrpt::opengl::CText3D::setTextKerning
double setTextKerning() const
Definition: CText3D.h:91
mrpt::opengl::CText3D::Ptr
std::shared_ptr< CText3D > Ptr
Definition: CText3D.h:47
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::opengl::CText3D::setString
void setString(const std::string &s)
Sets the displayed string.
Definition: CText3D.h:57
mrpt::opengl::CText3D::m_str
std::string m_str
Definition: CText3D.h:49
mrpt::opengl::CText3D::Create
static Ptr Create(Args &&... args)
Definition: CText3D.h:47
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::opengl::CText3D
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style.
Definition: CText3D.h:45
mrpt::opengl::CText3D::setFont
void setFont(const std::string &font)
Changes the font name, among accepted values: "sans", "mono", "serif".
Definition: CText3D.h:65
mrpt::opengl::CText3D::getFont
const std::string & getFont() const
Returns the text font
Definition: CText3D.h:71
mrpt::opengl::CText3D::m_fontName
std::string m_fontName
Definition: CText3D.h:50
mrpt::opengl::CText3D::getString
const std::string & getString() const
Returns the currently text associated to this object.
Definition: CText3D.h:63
mrpt::opengl::CText3D::m_text_spacing
double m_text_spacing
Definition: CText3D.h:52



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST