MRPT  2.0.4
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-2020, 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 
12 #include <mrpt/opengl/CText.h>
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  public:
25  void clearTextMessages();
26 
27  /** Add 2D text messages overlapped to the 3D rendered scene. The string
28  * will remain displayed in the 3D window
29  * until it's changed with subsequent calls to this same method, or all
30  * the texts are cleared with clearTextMessages().
31  *
32  * \param x The X position, interpreted as absolute pixels from the left
33  * if X>=1, absolute pixels from the left if X<0 or as a width factor if in
34  * the range [0,1[.
35  * \param y The Y position, interpreted as absolute pixels from the bottom
36  * if Y>=1, absolute pixels from the top if Y<0 or as a height factor if in
37  * the range [0,1[.
38  * \param text The text string to display.
39  * \param color The text color. For example: TColorf(1.0,1.0,1.0)
40  * \param unique_index An "index" for this text message, so that
41  * subsequent calls with the same index will overwrite this text message
42  * instead of creating new ones.
43  *
44  * You'll need to refresh the display manually with forceRepaint().
45  *
46  * \sa clearTextMessages, updateTextMessage
47  */
48  void addTextMessage(
49  const double x_frac, const double y_frac, const std::string& text,
50  const size_t unique_index = 0,
51  const TFontParams& fontParams = TFontParams());
52 
53  /** Just updates the text of a given text message, without touching the
54  * other parameters.
55  * \return false if given ID doesn't exist.
56  */
57  bool updateTextMessage(const size_t unique_index, const std::string& text);
58 
60  {
62  mutable bool gl_text_outdated = true;
63  };
64 
66  {
67  std::map<size_t, DataPerText> messages;
68 
69  /** (re)generate all CText objects in the gl_text fields */
70  void regenerateGLobjects() const;
71  };
72 
73  const TListTextMessages& getTextMessages() const { return m_2D_texts; }
74 
75  protected:
77 
78 }; // end of CTextMessageCapable
79 
80 } // 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...
A description of a bitmapped or vectorized text font.
Definition: opengl_fonts.h:36
void addTextMessage(const double x_frac, const double y_frac, const std::string &text, const size_t unique_index=0, const TFontParams &fontParams=TFontParams())
Add 2D text messages overlapped to the 3D rendered scene.
An auxiliary struct for holding a list of text messages in some mrpt::opengl & mrpt::gui classes The ...
Definition: opengl_fonts.h:67
void regenerateGLobjects() const
(re)generate all CText objects in the gl_text fields
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
const TListTextMessages & getTextMessages() const



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 44b1e7295 Fri Jun 5 12:35:25 2020 +0200 at vie jun 5 12:45:10 CEST 2020