MRPT  1.9.9
CWindowManager.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-2019, 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 
13 
14 #include "CWindowObserver.h"
15 
16 namespace mrpt::graphslam
17 {
18 /**\brief Class acts as a container for storing pointers to
19  * mrpt::gui::CDisplayWindow3D,
20  * mrpt::graphslam::CWindowObserver instances.
21  *
22  * CWindowManager also provides methods for adding/positioning textMessages
23  * and viewports in the CDisplayWindow in a compact and consistent way.
24  *
25  * \ingroup mrpt_graphslam_grp
26  */
28 {
29  public:
30  /**\brief Default class constructor */
32  /**\brief Class constructor*/
34  {
35  this->initCWindowManager();
36  this->setCDisplayWindow3DPtr(win_in);
37  }
38  /**\brief Class constructor*/
42  {
43  this->initCWindowManager();
44 
45  this->setWindowObserverPtr(observer_in);
46  this->setCDisplayWindow3DPtr(win_in);
47  }
48  /**\brief Class destructor. */
49  ~CWindowManager() override = default;
50  /**\brief Store the CDisplayWindow3D pointer in the CWindowManager
51  * instance.
52  *
53  * \sa setWindowObserverPtr
54  */
56  {
58  win = win_in;
59 
60  MRPT_LOG_DEBUG_STREAM("Fetched the CDisplayWindow3D* successfully");
61  }
62  /**\brief Store the CWindowObserver pointer in the CWindowManager instance.
63  *
64  * \sa setCDisplayWindow3DPtr
65  */
67  {
69  observer = obsever_in;
70 
71  MRPT_LOG_DEBUG_STREAM("Fetched the CWindowObserver* successfully");
72  }
73 
74  /**\brief Assign the next available offset_y and text_index for the
75  * textMessage under construction.
76  *
77  * Used for consistent positioning of textMessages in the
78  * CDisplayWindow3D.
79  *
80  * \sa assignViewPortParameters
81  */
82  void assignTextMessageParameters(double* offset_y, int* text_index)
83  {
84  *offset_y = m_curr_offset_y;
86 
87  *text_index = m_curr_text_index;
89  }
90 
91  /**\brief Wrapper call around the CWindowDisplay3D */
92  bool isOpen()
93  {
94  if (win)
95  {
96  return win->isOpen();
97  }
98  else
99  {
100  return false;
101  }
102  }
103 
104  /**\brief Wrapper around the CDisplayWindow3D::addTextMessage method, so
105  * that the
106  * user does not have to specify the font name and size.
107  *
108  * \note see initCWindowManager method for the default fontName and
109  * fontSize used.
110  */
112  const double x, const double y, const std::string& text,
113  const mrpt::img::TColorf& color = mrpt::img::TColorf(1.0, 1.0, 1.0),
114  const size_t unique_index = 0)
115  {
116  if (!win)
117  {
118  return;
119  }
120 
123  unique_index);
124  }
125 
126  /**\brief Assign position and size values for the placement of the next
127  * viewport
128  *
129  * Used for consistent positioning of the Viewports in the CDisplayWindow3D
130  *
131  * \sa assignTextMessageParameters
132  */
134  double* x, double* y, double* width, double* height)
135  {
136  *x = m_viewp_x;
137  *y = m_viewp_y;
138 
139  *width = m_viewp_width;
141 
143  }
144 
145  mrpt::gui::CDisplayWindow3D* win; /**< CDisplayWindow instance */
146  mrpt::graphslam::CWindowObserver* observer; /**< CWindowObserver instance */
147  private:
148  /**\brief Initialization method, to be called from the various Constructors.
149  */
151  {
154  win = nullptr;
155  observer = nullptr;
156 
157  m_offset_y_step = 20.0;
158  m_index_text_step = 1;
159  m_font_name = "sans";
160  m_font_size = 12;
161  m_curr_offset_y = 30;
162  m_curr_text_index = 1;
163 
164  m_viewp_width = 0.2;
165  m_viewp_height = 0.2;
166  m_viewp_x = 0.75;
167  m_viewp_margin = 0.01;
168  m_viewp_y = 0.72;
169 
170  // loger related directives
171  this->setLoggerName("CWindowManager");
172  }
173 
176 
181 
184 
185  // viewports configuration
188  double m_viewp_x;
189  double m_viewp_y; /**< vertical layout of the viewports */
191 };
192 } // namespace mrpt::graphslam
void setCDisplayWindow3DPtr(mrpt::gui::CDisplayWindow3D *win_in)
Store the CDisplayWindow3D pointer in the CWindowManager instance.
CWindowManager(mrpt::gui::CDisplayWindow3D *win_in, mrpt::graphslam::CWindowObserver *observer_in)
Class constructor.
void setWindowObserverPtr(mrpt::graphslam::CWindowObserver *obsever_in)
Store the CWindowObserver pointer in the CWindowManager instance.
double m_viewp_y
vertical layout of the viewports
GLenum GLsizei width
Definition: glext.h:3535
void assignViewportParameters(double *x, double *y, double *width, double *height)
Assign position and size values for the placement of the next viewport.
GLuint color
Definition: glext.h:8459
bool isOpen()
Wrapper call around the CWindowDisplay3D.
SLAM methods related to graphs of pose constraints.
mrpt::gui::CDisplayWindow3D * win
CDisplayWindow instance.
mrpt::graphslam::CWindowObserver * observer
CWindowObserver instance.
Versatile class for consistent logging and management of output messages.
void setLoggerName(const std::string &name)
Set the name of the COutputLogger instance.
bool isOpen()
Returns false if the user has already closed the window.
CWindowManager()
Default class constructor.
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
Use: MRPT_LOG_DEBUG_STREAM("Var=" << value << " foo=" << foo_var);
GLsizei const GLchar ** string
Definition: glext.h:4116
Monitor events in the visualization window.
~CWindowManager() override=default
Class destructor.
A RGB color - floats in the range [0,1].
Definition: TColor.h:77
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:37
void addTextMessage(const double x, const double y, const std::string &text, const mrpt::img::TColorf &color=mrpt::img::TColorf(1.0, 1.0, 1.0), const size_t unique_index=0)
Wrapper around the CDisplayWindow3D::addTextMessage method, so that the user does not have to specify...
void initCWindowManager()
Initialization method, to be called from the various Constructors.
CWindowManager(mrpt::gui::CDisplayWindow3D *win_in)
Class constructor.
GLenum GLint GLint y
Definition: glext.h:3542
void addTextMessage(const double x, const double y, 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.
GLenum GLint x
Definition: glext.h:3542
GLenum GLsizei GLsizei height
Definition: glext.h:3558
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
void assignTextMessageParameters(double *offset_y, int *text_index)
Assign the next available offset_y and text_index for the textMessage under construction.
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019