MRPT  1.9.9
CTextMessageCapable.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
13 #include <map>
14 
15 namespace mrpt::opengl
16 {
17 /** Keeps a list of text messages which can be rendered to OpenGL contexts by
18  * graphic classes.
19  * \ingroup mrpt_opengl_grp
20  */
22 {
23  protected:
24  std::map<size_t, mrpt::opengl::T2DTextData> m_2D_texts;
25 
26  /** Renders the messages to the current opengl rendering context (to be
27  * called OUT of MRPT mrpt::opengl render() methods ).
28  * (w,h) are the dimensions of the rendering area in pixels.
29  */
30  void render_text_messages(const int w, const int h) const;
31 
32  public:
33  void clearTextMessages();
34 
35  /** Add 2D text messages overlapped to the 3D rendered scene. The string
36  * will remain displayed in the 3D window
37  * until it's changed with subsequent calls to this same method, or all
38  * the texts are cleared with clearTextMessages().
39  *
40  * \param x The X position, interpreted as absolute pixels from the left
41  * if X>=1, absolute pixels from the left if X<0 or as a width factor if in
42  * the range [0,1[.
43  * \param y The Y position, interpreted as absolute pixels from the bottom
44  * if Y>=1, absolute pixels from the top if Y<0 or as a height factor if in
45  * the range [0,1[.
46  * \param text The text string to display.
47  * \param color The text color. For example: TColorf(1.0,1.0,1.0)
48  * \param unique_index An "index" for this text message, so that
49  * subsequent calls with the same index will overwrite this text message
50  * instead of creating new ones.
51  *
52  * You'll need to refresh the display manually with forceRepaint().
53  *
54  * \sa clearTextMessages
55  */
56  void addTextMessage(
57  const double x_frac, const double y_frac, const std::string& text,
58  const mrpt::img::TColorf& color = mrpt::img::TColorf(1.0, 1.0, 1.0),
59  const size_t unique_index = 0,
60  const mrpt::opengl::TOpenGLFont font =
62 
63  /// overload with more font parameters - refer to
64  /// mrpt::opengl::gl_utils::glDrawText()
65  void addTextMessage(
66  const double x_frac, const double y_frac, const std::string& text,
67  const mrpt::img::TColorf& color, const std::string& font_name,
68  const double font_size,
70  const size_t unique_index = 0, const double font_spacing = 1.5,
71  const double font_kerning = 0.1, const bool has_shadow = false,
72  const mrpt::img::TColorf& shadow_color = mrpt::img::TColorf(0, 0, 0));
73 
74  /** Just updates the text of a given text message, without touching the
75  * other parameters.
76  * \return false if given ID doesn't exist.
77  */
78  bool updateTextMessage(const size_t unique_index, const std::string& text);
79 
80 }; // end of CTextMessageCapable
81 
82 } // namespace mrpt::opengl
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:4199
GLuint color
Definition: glext.h:8459
TOpenGLFont
Existing fonts for 2D texts in mrpt::opengl methods.
Definition: opengl_fonts.h:22
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:33
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:4116
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...
A RGB color - floats in the range [0,1].
Definition: TColor.h:77
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:37
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019