MRPT  2.0.4
CTextMessageCapable.cpp
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 
10 #include "opengl-precomp.h" // Precompiled header
11 
13 
14 #include <mrpt/opengl/opengl_api.h>
15 
16 using namespace std;
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 
20 void CTextMessageCapable::TListTextMessages::regenerateGLobjects() const
21 {
22  // (re)generate the opengl CText objects for each label:
23  for (auto& kv : messages)
24  {
25  const DataPerText& labelData = kv.second;
26  if (labelData.gl_text && labelData.gl_text_outdated) continue;
27 
28  if (!labelData.gl_text)
29  {
31  }
32  if (labelData.draw_shadow && !labelData.gl_text_shadow)
34 
35  if (!labelData.draw_shadow && labelData.gl_text_shadow)
36  labelData.gl_text_shadow.reset();
37 
38  kv.second.gl_text_outdated = false;
39  }
40 }
41 
42 void CTextMessageCapable::clearTextMessages() { m_2D_texts.messages.clear(); }
43 
44 /** Just updates the text of a given text message, without touching the other
45  * parameters.
46  * \return false if given ID doesn't exist.
47  */
48 bool CTextMessageCapable::updateTextMessage(
49  const size_t unique_index, const std::string& text)
50 {
51  auto it = m_2D_texts.messages.find(unique_index);
52  if (it == m_2D_texts.messages.end())
53  return false;
54  else
55  {
56  it->second.text = text;
57  it->second.gl_text_outdated = true;
58  return true;
59  }
60 }
61 
62 /// overload with more font parameters - refer to
63 /// mrpt::opengl::gl_utils::glDrawText()
64 void CTextMessageCapable::addTextMessage(
65  const double x_frac, const double y_frac, const std::string& text,
66  const size_t unique_index, const TFontParams& fontParams)
67 {
68  DataPerText d;
69  static_cast<TFontParams&>(d) = fontParams;
70  d.text = text;
71  d.x = x_frac;
72  d.y = y_frac;
73 
74  m_2D_texts.messages[unique_index] = std::move(d);
75 }
static Ptr Create(Args &&... args)
Definition: CText.h:37
A description of a bitmapped or vectorized text font.
Definition: opengl_fonts.h:36
STL namespace.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020