Main MRPT website > C++ reference for MRPT 1.5.6
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 
20 
21  // This must be added to any CSerializable derived class:
22  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CText3D, CRenderizableDisplayList, OPENGL_IMPEXP )
23 
24  /** A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style.
25  * Use \a setString and \a setFont to change the text displayed by this object (can be multi-lined).
26  *
27  * Text is drawn along the (+X,+Y) axes.
28  *
29  * Default size of characters is "1.0 units". Change it with the standard method \a CRenderizable::setScale() as with any other 3D object.
30  * The color can be also changed with standard methods in the base class \a CRenderizable.
31  *
32  * \sa opengl::COpenGLScene, CText
33  *
34  * <div align="center">
35  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
36  * <tr> <td> mrpt::opengl::CText3D </td> <td> \image html preview_CText3D.png </td> </tr>
37  * </table>
38  * </div>
39  *
40  * \note This class is based on code from libcvd (LGPL, http://www.edwardrosten.com/cvd/ )
41  * \ingroup mrpt_opengl_grp
42  */
44  {
46  protected:
47  std::string m_str;
48  std::string m_fontName;
49  TOpenGLFontStyle m_text_style;
50  double m_text_spacing;
51  double m_text_kerning;
52 
53  public:
54  /** Sets the displayed string */
55  inline void setString( const std::string &s ) {
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 
62  /** Changes the font name, among accepted values: "sans", "mono", "serif" */
63  inline void setFont( const std::string &font ) {
64  m_fontName=font;
66  }
67  /** Returns the text font */
68  inline const std::string &getFont() const { return m_fontName; }
69 
70  /** Change drawing style: FILL, OUTLINE, NICE */
72  m_text_style = text_style;
74  }
75  /** Gets the current drawing style */
76  mrpt::opengl::TOpenGLFontStyle getTextStyle() const { return m_text_style; }
77 
78  void setTextSpacing(const double text_spacing) {
79  m_text_spacing = text_spacing;
81  }
82  double setTextSpacing() const { return m_text_spacing; }
83 
84  void setTextKerning(const double text_kerning) {
85  m_text_kerning = text_kerning;
87  }
88  double setTextKerning() const { return m_text_kerning; }
89 
90 
91  /** Render */
92  void render_dl() const MRPT_OVERRIDE;
93 
94  /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
95  void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
96 
97  /** Class factory */
98  static CText3DPtr Create(
99  const std::string &str,
100  const std::string &fontName = std::string("sans"),
101  const double scale = 1.0,
102  const mrpt::opengl::TOpenGLFontStyle text_style = mrpt::opengl::FILL,
103  const double text_spacing = 1.5,
104  const double text_kerning = 0.1 );
105 
106  private:
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,
112  const mrpt::opengl::TOpenGLFontStyle text_style = mrpt::opengl::NICE,
113  const double text_spacing = 1.5,
114  const double text_kerning = 0.1 );
115 
116  /** Private, virtual destructor: only can be deleted from smart pointers */
117  virtual ~CText3D();
118  };
119  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CText3D, CRenderizableDisplayList, OPENGL_IMPEXP )
120 
121  } // end namespace
122 
123 } // End of namespace
124 
125 
126 #endif
GLenum GLenum GLenum GLenum GLenum scale
Definition: glew.h:8359
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void setFont(const std::string &font)
Changes the font name, among accepted values: "sans", "mono", "serif".
Definition: CText3D.h:63
A renderizable object suitable for rendering with OpenGL's display lists.
const std::string & getString() const
Returns the currently text associated to this object.
Definition: CText3D.h:60
GLdouble s
Definition: glew.h:1295
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:37
double setTextKerning() const
Definition: CText3D.h:88
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...
GLsizei const GLcharARB ** string
Definition: glew.h:3293
mrpt::opengl::TOpenGLFontStyle getTextStyle() const
Gets the current drawing style.
Definition: CText3D.h:76
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:43
const std::string & getFont() const
Returns the text font.
Definition: CText3D.h:68
void setTextSpacing(const double text_spacing)
Definition: CText3D.h:78
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
renders glyphs as filled polygons
Definition: opengl_fonts.h:38
double setTextSpacing() const
Definition: CText3D.h:82



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018