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



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019