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-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
18 {
19 namespace graphslam
20 {
21 /**\brief Class acts as a container for storing pointers to
22  * mrpt::gui::CDisplayWindow3D,
23  * mrpt::graphslam::CWindowObserver instances.
24  *
25  * CWindowManager also provides methods for adding/positioning textMessages
26  * and viewports in the CDisplayWindow in a compact and consistent way.
27  *
28  * \ingroup mrpt_graphslam_grp
29  */
31 {
32  public:
33  /**\brief Default class constructor */
35  /**\brief Class constructor*/
37  {
38  this->initCWindowManager();
39  this->setCDisplayWindow3DPtr(win_in);
40  }
41  /**\brief Class constructor*/
45  {
46  this->initCWindowManager();
47 
48  this->setWindowObserverPtr(observer_in);
49  this->setCDisplayWindow3DPtr(win_in);
50  }
51  /**\brief Class destructor. */
53  /**\brief Store the CDisplayWindow3D pointer in the CWindowManager
54  * instance.
55  *
56  * \sa setWindowObserverPtr
57  */
59  {
61  win = win_in;
62 
63  MRPT_LOG_DEBUG_STREAM("Fetched the CDisplayWindow3D* successfully");
64  }
65  /**\brief Store the CWindowObserver pointer in the CWindowManager instance.
66  *
67  * \sa setCDisplayWindow3DPtr
68  */
70  {
72  observer = obsever_in;
73 
74  MRPT_LOG_DEBUG_STREAM("Fetched the CWindowObserver* successfully");
75  }
76 
77  /**\brief Assign the next available offset_y and text_index for the
78  * textMessage under construction.
79  *
80  * Used for consistent positioning of textMessages in the
81  * CDisplayWindow3D.
82  *
83  * \sa assignViewPortParameters
84  */
85  void assignTextMessageParameters(double* offset_y, int* text_index)
86  {
87  *offset_y = m_curr_offset_y;
89 
90  *text_index = m_curr_text_index;
92  }
93 
94  /**\brief Wrapper call around the CWindowDisplay3D */
95  bool isOpen()
96  {
97  if (win)
98  {
99  return win->isOpen();
100  }
101  else
102  {
103  return false;
104  }
105  }
106 
107  /**\brief Wrapper around the CDisplayWindow3D::addTextMessage method, so
108  * that the
109  * user does not have to specify the font name and size.
110  *
111  * \note see initCWindowManager method for the default fontName and
112  * fontSize used.
113  */
115  const double x, const double y, const std::string& text,
116  const mrpt::img::TColorf& color = mrpt::img::TColorf(1.0, 1.0, 1.0),
117  const size_t unique_index = 0)
118  {
119  if (!win)
120  {
121  return;
122  }
123 
126  unique_index);
127  }
128 
129  /**\brief Assign position and size values for the placement of the next
130  * viewport
131  *
132  * Used for consistent positioning of the Viewports in the CDisplayWindow3D
133  *
134  * \sa assignTextMessageParameters
135  */
137  double* x, double* y, double* width, double* height)
138  {
139  *x = m_viewp_x;
140  *y = m_viewp_y;
141 
142  *width = m_viewp_width;
144 
146  }
147 
148  mrpt::gui::CDisplayWindow3D* win; /**< CDisplayWindow instance */
149  mrpt::graphslam::CWindowObserver* observer; /**< CWindowObserver instance */
150  private:
151  /**\brief Initialization method, to be called from the various Constructors.
152  */
154  {
157  win = nullptr;
158  observer = nullptr;
159 
160  m_offset_y_step = 20.0;
161  m_index_text_step = 1;
162  m_font_name = "sans";
163  m_font_size = 12;
164  m_curr_offset_y = 30;
165  m_curr_text_index = 1;
166 
167  m_viewp_width = 0.2;
168  m_viewp_height = 0.2;
169  m_viewp_x = 0.75;
170  m_viewp_margin = 0.01;
171  m_viewp_y = 0.72;
172 
173  // loger related directives
174  this->setLoggerName("CWindowManager");
175  MRPT_LOG_DEBUG_STREAM("Initializing...");
176  }
177 
180 
185 
188 
189  // viewports configuration
192  double m_viewp_x;
193  double m_viewp_y; /**< vertical layout of the viewports */
195 };
196 }
197 } // END OF NAMESPACES
198 
199 #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
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.
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
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Monitor events in the visualization window.
A RGB color - floats in the range [0,1].
Definition: TColor.h:79
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:40
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: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019