Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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
17namespace 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:
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 */
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()
62 const double x_frac,
63 const double y_frac,
64 const std::string &text,
65 const mrpt::utils::TColorf &color,
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.
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.
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...
void addTextMessage(const double x_frac, const double y_frac, const std::string &text, const mrpt::utils::TColorf &color=mrpt::utils::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.
void addTextMessage(const double x_frac, const double y_frac, const std::string &text, const mrpt::utils::TColorf &color, const std::string &font_name, const double font_size, const mrpt::opengl::TOpenGLFontStyle font_style=mrpt::opengl::NICE, const size_t unique_index=0, const double font_spacing=1.5, const double font_kerning=0.1, const bool has_shadow=false, const mrpt::utils::TColorf &shadow_color=mrpt::utils::TColorf(0, 0, 0))
std::map< size_t, mrpt::opengl::T2DTextData > m_2D_texts
TOpenGLFont
Existing fonts for 2D texts in mrpt::opengl methods.
Definition: opengl_fonts.h:27
@ MRPT_GLUT_BITMAP_TIMES_ROMAN_24
Definition: opengl_fonts.h:30
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:37
@ NICE
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:40
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:53



Page generated by Doxygen 1.9.2 for MRPT 1.4.0 SVN: at Mon Sep 20 00:21:40 UTC 2021