Main MRPT website > C++ reference for 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-2017, 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 
15 
16 #include "CWindowObserver.h"
17 
18 namespace mrpt
19 {
20 namespace graphslam
21 {
22 /**\brief Class acts as a container for storing pointers to
23  * mrpt::gui::CDisplayWindow3D,
24  * mrpt::graphslam::CWindowObserver instances.
25  *
26  * CWindowManager also provides methods for adding/positioning textMessages
27  * and viewports in the CDisplayWindow in a compact and consistent way.
28  *
29  * \ingroup mrpt_graphslam_grp
30  */
31 class CWindowManager : public mrpt::utils::COutputLogger
32 {
33  public:
34  /**\brief Default class constructor */
36  /**\brief Class constructor*/
38  {
39  this->initCWindowManager();
40  this->setCDisplayWindow3DPtr(win_in);
41  }
42  /**\brief Class constructor*/
46  {
47  this->initCWindowManager();
48 
49  this->setWindowObserverPtr(observer_in);
50  this->setCDisplayWindow3DPtr(win_in);
51  }
52  /**\brief Class destructor. */
54  /**\brief Store the CDisplayWindow3D pointer in the CWindowManager
55  * instance.
56  *
57  * \sa setWindowObserverPtr
58  */
60  {
62  win = win_in;
63 
64  MRPT_LOG_DEBUG_STREAM("Fetched the CDisplayWindow3D* successfully");
65  }
66  /**\brief Store the CWindowObserver pointer in the CWindowManager instance.
67  *
68  * \sa setCDisplayWindow3DPtr
69  */
71  {
73  observer = obsever_in;
74 
75  MRPT_LOG_DEBUG_STREAM("Fetched the CWindowObserver* successfully");
76  }
77 
78  /**\brief Assign the next available offset_y and text_index for the
79  * textMessage under construction.
80  *
81  * Used for consistent positioning of textMessages in the
82  * CDisplayWindow3D.
83  *
84  * \sa assignViewPortParameters
85  */
86  void assignTextMessageParameters(double* offset_y, int* text_index)
87  {
88  *offset_y = m_curr_offset_y;
90 
91  *text_index = m_curr_text_index;
93  }
94 
95  /**\brief Wrapper call around the CWindowDisplay3D */
96  bool isOpen()
97  {
98  if (win)
99  {
100  return win->isOpen();
101  }
102  else
103  {
104  return false;
105  }
106  }
107 
108  /**\brief Wrapper around the CDisplayWindow3D::addTextMessage method, so
109  * that the
110  * user does not have to specify the font name and size.
111  *
112  * \note see initCWindowManager method for the default fontName and
113  * fontSize used.
114  */
116  const double x, const double y, const std::string& text,
117  const mrpt::utils::TColorf& color = mrpt::utils::TColorf(1.0, 1.0, 1.0),
118  const size_t unique_index = 0)
119  {
120  if (!win)
121  {
122  return;
123  }
124 
127  unique_index);
128  }
129 
130  /**\brief Assign position and size values for the placement of the next
131  * viewport
132  *
133  * Used for consistent positioning of the Viewports in the CDisplayWindow3D
134  *
135  * \sa assignTextMessageParameters
136  */
138  double* x, double* y, double* width, double* height)
139  {
140  *x = m_viewp_x;
141  *y = m_viewp_y;
142 
143  *width = m_viewp_width;
145 
147  }
148 
149  mrpt::gui::CDisplayWindow3D* win; /**< CDisplayWindow instance */
150  mrpt::graphslam::CWindowObserver* observer; /**< CWindowObserver instance */
151  private:
152  /**\brief Initialization method, to be called from the various Constructors.
153  */
155  {
158  win = nullptr;
159  observer = nullptr;
160 
161  m_offset_y_step = 20.0;
162  m_index_text_step = 1;
163  m_font_name = "sans";
164  m_font_size = 12;
165  m_curr_offset_y = 30;
166  m_curr_text_index = 1;
167 
168  m_viewp_width = 0.2;
169  m_viewp_height = 0.2;
170  m_viewp_x = 0.75;
171  m_viewp_margin = 0.01;
172  m_viewp_y = 0.72;
173 
174  // loger related directives
175  this->setLoggerName("CWindowManager");
176  MRPT_LOG_DEBUG_STREAM("Initializing...");
177  }
178 
181 
186 
189 
190  // viewports configuration
193  double m_viewp_x;
194  double m_viewp_y; /**< vertical layout of the viewports */
196 };
197 }
198 } // END OF NAMESPACES
199 
200 #endif /* end of include guard: CWINDOWMANAGER_H */
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
void addTextMessage(const double x, const double y, const std::string &text, const mrpt::utils::TColorf &color=mrpt::utils::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...
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.
mrpt::gui::CDisplayWindow3D * win
CDisplayWindow instance.
mrpt::graphslam::CWindowObserver * observer
CWindowObserver instance.
bool isOpen()
Returns false if the user has already closed the window.
CWindowManager()
Default class constructor.
GLsizei const GLchar ** string
Definition: glext.h:4101
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Monitor events in the visualization window.
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:40
A RGB color - floats in the range [0,1].
Definition: TColor.h:78
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
GLenum GLint x
Definition: glext.h:3538
GLenum GLsizei GLsizei height
Definition: glext.h:3554
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
void addTextMessage(const double x, const double y, 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 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: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019