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