Main MRPT website > C++ reference for MRPT 1.9.9
CTextMessageCapable.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 #ifndef opengl_CTextMessageCapable_H
10 #define opengl_CTextMessageCapable_H
11 
14 #include <map>
15 
16 namespace mrpt
17 {
18 namespace opengl
19 {
20 /** Keeps a list of text messages which can be rendered to OpenGL contexts by
21  * graphic classes.
22  * \ingroup mrpt_opengl_grp
23  */
25 {
26  protected:
27  std::map<size_t, mrpt::opengl::T2DTextData> m_2D_texts;
28 
29  /** Renders the messages to the current opengl rendering context (to be
30  * called OUT of MRPT mrpt::opengl render() methods ).
31  * (w,h) are the dimensions of the rendering area in pixels.
32  */
33  void render_text_messages(const int w, const int h) const;
34 
35  public:
36  void clearTextMessages();
37 
38  /** Add 2D text messages overlapped to the 3D rendered scene. The string
39  * will remain displayed in the 3D window
40  * until it's changed with subsequent calls to this same method, or all
41  * the texts are cleared with clearTextMessages().
42  *
43  * \param x The X position, interpreted as absolute pixels from the left
44  * if X>=1, absolute pixels from the left if X<0 or as a width factor if in
45  * the range [0,1[.
46  * \param y The Y position, interpreted as absolute pixels from the bottom
47  * if Y>=1, absolute pixels from the top if Y<0 or as a height factor if in
48  * the range [0,1[.
49  * \param text The text string to display.
50  * \param color The text color. For example: TColorf(1.0,1.0,1.0)
51  * \param unique_index An "index" for this text message, so that
52  * subsequent calls with the same index will overwrite this text message
53  * instead of creating new ones.
54  *
55  * You'll need to refresh the display manually with forceRepaint().
56  *
57  * \sa clearTextMessages
58  */
59  void addTextMessage(
60  const double x_frac, const double y_frac, const std::string& text,
61  const mrpt::img::TColorf& color = mrpt::img::TColorf(1.0, 1.0, 1.0),
62  const size_t unique_index = 0,
63  const mrpt::opengl::TOpenGLFont font =
65 
66  /// overload with more font parameters - refer to
67  /// mrpt::opengl::gl_utils::glDrawText()
68  void addTextMessage(
69  const double x_frac, const double y_frac, const std::string& text,
70  const mrpt::img::TColorf& color, const std::string& font_name,
71  const double font_size,
73  const size_t unique_index = 0, const double font_spacing = 1.5,
74  const double font_kerning = 0.1, const bool has_shadow = false,
75  const mrpt::img::TColorf& shadow_color = mrpt::img::TColorf(0, 0, 0));
76 
77  /** Just updates the text of a given text message, without touching the
78  * other parameters.
79  * \return false if given ID doesn't exist.
80  */
81  bool updateTextMessage(const size_t unique_index, const std::string& text);
82 
83 }; // end of CTextMessageCapable
84 
85 } // end namespace
86 } // End of namespace
87 
88 #endif
bool updateTextMessage(const size_t unique_index, const std::string &text)
Just updates the text of a given text message, without touching the other parameters.
Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes...
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
GLuint color
Definition: glext.h:8300
TOpenGLFont
Existing fonts for 2D texts in mrpt::opengl methods.
Definition: opengl_fonts.h:25
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:36
std::map< size_t, mrpt::opengl::T2DTextData > m_2D_texts
void addTextMessage(const double x_frac, const double y_frac, const std::string &text, const mrpt::img::TColorf &color=mrpt::img::TColorf(1.0, 1.0, 1.0), const size_t unique_index=0, const mrpt::opengl::TOpenGLFont font=mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_24)
Add 2D text messages overlapped to the 3D rendered scene.
GLsizei const GLchar ** string
Definition: glext.h:4101
void render_text_messages(const int w, const int h) const
Renders the messages to the current opengl rendering context (to be called OUT of MRPT mrpt::opengl r...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A RGB color - floats in the range [0,1].
Definition: TColor.h:79
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:40



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019