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 */
mrpt::graphslam::CWindowManager::~CWindowManager
~CWindowManager()
Class destructor.
Definition: CWindowManager.h:52
mrpt::opengl::NICE
@ NICE
renders glyphs filled with antialiased outlines
Definition: opengl_fonts.h:40
mrpt::graphslam::CWindowManager::m_viewp_margin
double m_viewp_margin
Definition: CWindowManager.h:194
mrpt::graphslam::CWindowManager::m_viewp_height
double m_viewp_height
Definition: CWindowManager.h:191
mrpt::graphslam::CWindowManager::CWindowManager
CWindowManager(mrpt::gui::CDisplayWindow3D *win_in)
Class constructor.
Definition: CWindowManager.h:36
mrpt::graphslam::CWindowManager::assignViewportParameters
void assignViewportParameters(double *x, double *y, double *width, double *height)
Assign position and size values for the placement of the next viewport.
Definition: CWindowManager.h:136
mrpt::graphslam::CWindowManager::m_viewp_x
double m_viewp_x
Definition: CWindowManager.h:192
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::gui::CDisplayWindow3D::addTextMessage
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.
Definition: CDisplayWindow3D.cpp:899
mrpt::graphslam::CWindowObserver
Monitor events in the visualization window.
Definition: CWindowObserver.h:27
CDisplayWindow3D.h
mrpt::graphslam::CWindowManager
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
Definition: CWindowManager.h:30
mrpt::graphslam::CWindowManager::m_offset_y_step
double m_offset_y_step
Definition: CWindowManager.h:181
mrpt::graphslam::CWindowManager::assignTextMessageParameters
void assignTextMessageParameters(double *offset_y, int *text_index)
Assign the next available offset_y and text_index for the textMessage under construction.
Definition: CWindowManager.h:85
mrpt::graphslam::CWindowManager::isOpen
bool isOpen()
Wrapper call around the CWindowDisplay3D.
Definition: CWindowManager.h:95
mrpt::graphslam::CWindowManager::win
mrpt::gui::CDisplayWindow3D * win
CDisplayWindow instance.
Definition: CWindowManager.h:148
mrpt::graphslam::CWindowManager::m_viewp_y
double m_viewp_y
vertical layout of the viewports
Definition: CWindowManager.h:193
mrpt::graphslam::CWindowManager::setWindowObserverPtr
void setWindowObserverPtr(mrpt::graphslam::CWindowObserver *obsever_in)
Store the CWindowObserver pointer in the CWindowManager instance.
Definition: CWindowManager.h:69
mrpt::gui::CBaseGUIWindow::isOpen
bool isOpen()
Returns false if the user has already closed the window.
Definition: CBaseGUIWindow.cpp:213
mrpt::graphslam::CWindowManager::setCDisplayWindow3DPtr
void setCDisplayWindow3DPtr(mrpt::gui::CDisplayWindow3D *win_in)
Store the CDisplayWindow3D pointer in the CWindowManager instance.
Definition: CWindowManager.h:58
COutputLogger.h
mrpt::img::TColorf
A RGB color - floats in the range [0,1].
Definition: TColor.h:79
color
GLuint color
Definition: glext.h:8300
mrpt::graphslam::CWindowManager::observer
mrpt::graphslam::CWindowObserver * observer
CWindowObserver instance.
Definition: CWindowManager.h:149
mrpt::graphslam::CWindowManager::CWindowManager
CWindowManager(mrpt::gui::CDisplayWindow3D *win_in, mrpt::graphslam::CWindowObserver *observer_in)
Class constructor.
Definition: CWindowManager.h:42
CWindowObserver.h
mrpt::graphslam::CWindowManager::m_viewp_width
double m_viewp_width
Definition: CWindowManager.h:190
height
GLenum GLsizei GLsizei height
Definition: glext.h:3554
mrpt::graphslam::CWindowManager::initCWindowManager
void initCWindowManager()
Initialization method, to be called from the various Constructors.
Definition: CWindowManager.h:153
mrpt::system::COutputLogger
Versatile class for consistent logging and management of output messages.
Definition: system/COutputLogger.h:117
mrpt::graphslam::CWindowManager::m_curr_offset_y
double m_curr_offset_y
Definition: CWindowManager.h:183
MRPT_LOG_DEBUG_STREAM
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
Use: MRPT_LOG_DEBUG_STREAM("Var=" << value << " foo=" << foo_var);
Definition: system/COutputLogger.h:471
mrpt::graphslam::CWindowManager::m_index_text_step
int m_index_text_step
Definition: CWindowManager.h:182
mrpt::graphslam::CWindowManager::m_font_name
std::string m_font_name
Definition: CWindowManager.h:186
width
GLenum GLsizei width
Definition: glext.h:3531
mrpt::graphslam::CWindowManager::m_font_size
int m_font_size
Definition: CWindowManager.h:187
mrpt::graphslam::CWindowManager::CWindowManager
CWindowManager()
Default class constructor.
Definition: CWindowManager.h:34
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::graphslam::CWindowManager::addTextMessage
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...
Definition: CWindowManager.h:114
mrpt::system::COutputLogger::setLoggerName
void setLoggerName(const std::string &name)
Set the name of the COutputLogger instance.
Definition: COutputLogger.cpp:127
mrpt::graphslam::CWindowManager::m_fetched_displaywindow_pointer
bool m_fetched_displaywindow_pointer
Definition: CWindowManager.h:179
mrpt::graphslam::CWindowManager::m_curr_text_index
int m_curr_text_index
Definition: CWindowManager.h:184
y
GLenum GLint GLint y
Definition: glext.h:3538
mrpt::gui::CDisplayWindow3D
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
Definition: CDisplayWindow3D.h:117
x
GLenum GLint x
Definition: glext.h:3538
mrpt::graphslam::CWindowManager::m_fetched_observer_pointer
bool m_fetched_observer_pointer
Definition: CWindowManager.h:178



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST