MRPT  1.9.9
CWindowManager.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-2018, 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 CWINDOWMANAGER_H
10 #define CWINDOWMANAGER_H
11 
14 
15 #include "CWindowObserver.h"
16 
17 namespace mrpt::graphslam
18 {
19 /**\brief Class acts as a container for storing pointers to
20  * mrpt::gui::CDisplayWindow3D,
21  * mrpt::graphslam::CWindowObserver instances.
22  *
23  * CWindowManager also provides methods for adding/positioning textMessages
24  * and viewports in the CDisplayWindow in a compact and consistent way.
25  *
26  * \ingroup mrpt_graphslam_grp
27  */
29 {
30  public:
31  /**\brief Default class constructor */
33  /**\brief Class constructor*/
35  {
36  this->initCWindowManager();
37  this->setCDisplayWindow3DPtr(win_in);
38  }
39  /**\brief Class constructor*/
43  {
44  this->initCWindowManager();
45 
46  this->setWindowObserverPtr(observer_in);
47  this->setCDisplayWindow3DPtr(win_in);
48  }
49  /**\brief Class destructor. */
51  /**\brief Store the CDisplayWindow3D pointer in the CWindowManager
52  * instance.
53  *
54  * \sa setWindowObserverPtr
55  */
57  {
59  win = win_in;
60 
61  MRPT_LOG_DEBUG_STREAM("Fetched the CDisplayWindow3D* successfully");
62  }
63  /**\brief Store the CWindowObserver pointer in the CWindowManager instance.
64  *
65  * \sa setCDisplayWindow3DPtr
66  */
68  {
70  observer = obsever_in;
71 
72  MRPT_LOG_DEBUG_STREAM("Fetched the CWindowObserver* successfully");
73  }
74 
75  /**\brief Assign the next available offset_y and text_index for the
76  * textMessage under construction.
77  *
78  * Used for consistent positioning of textMessages in the
79  * CDisplayWindow3D.
80  *
81  * \sa assignViewPortParameters
82  */
83  void assignTextMessageParameters(double* offset_y, int* text_index)
84  {
85  *offset_y = m_curr_offset_y;
87 
88  *text_index = m_curr_text_index;
90  }
91 
92  /**\brief Wrapper call around the CWindowDisplay3D */
93  bool isOpen()
94  {
95  if (win)
96  {
97  return win->isOpen();
98  }
99  else
100  {
101  return false;
102  }
103  }
104 
105  /**\brief Wrapper around the CDisplayWindow3D::addTextMessage method, so
106  * that the
107  * user does not have to specify the font name and size.
108  *
109  * \note see initCWindowManager method for the default fontName and
110  * fontSize used.
111  */
113  const double x, const double y, const std::string& text,
114  const mrpt::img::TColorf& color = mrpt::img::TColorf(1.0, 1.0, 1.0),
115  const size_t unique_index = 0)
116  {
117  if (!win)
118  {
119  return;
120  }
121 
124  unique_index);
125  }
126 
127  /**\brief Assign position and size values for the placement of the next
128  * viewport
129  *
130  * Used for consistent positioning of the Viewports in the CDisplayWindow3D
131  *
132  * \sa assignTextMessageParameters
133  */
135  double* x, double* y, double* width, double* height)
136  {
137  *x = m_viewp_x;
138  *y = m_viewp_y;
139 
140  *width = m_viewp_width;
142 
144  }
145 
146  mrpt::gui::CDisplayWindow3D* win; /**< CDisplayWindow instance */
147  mrpt::graphslam::CWindowObserver* observer; /**< CWindowObserver instance */
148  private:
149  /**\brief Initialization method, to be called from the various Constructors.
150  */
152  {
155  win = nullptr;
156  observer = nullptr;
157 
158  m_offset_y_step = 20.0;
159  m_index_text_step = 1;
160  m_font_name = "sans";
161  m_font_size = 12;
162  m_curr_offset_y = 30;
163  m_curr_text_index = 1;
164 
165  m_viewp_width = 0.2;
166  m_viewp_height = 0.2;
167  m_viewp_x = 0.75;
168  m_viewp_margin = 0.01;
169  m_viewp_y = 0.72;
170 
171  // loger related directives
172  this->setLoggerName("CWindowManager");
173  MRPT_LOG_DEBUG_STREAM("Initializing...");
174  }
175 
178 
183 
186 
187  // viewports configuration
190  double m_viewp_x;
191  double m_viewp_y; /**< vertical layout of the viewports */
193 };
194 }
195 #endif /* end of include guard: CWINDOWMANAGER_H */
196 
197 
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:3531
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:8300
bool isOpen()
Wrapper call around the CWindowDisplay3D.
~CWindowManager()
Class destructor.
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:4101
Monitor events in the visualization window.
A RGB color - floats in the range [0,1].
Definition: TColor.h:77
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:38
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:3538
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:3538
GLenum GLsizei GLsizei height
Definition: glext.h:3554
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020