Main MRPT website > C++ reference for MRPT 1.5.9
CWindowManager.h
Go to the documentation of this file.
1 #ifndef CWINDOWMANAGER_H
2 #define CWINDOWMANAGER_H
3 
7 
9 #include "CWindowObserver.h"
10 
11 namespace mrpt { namespace graphslam {
12 
13 /**\brief Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D,
14  * mrpt::graphslam::CWindowObserver instances.
15  *
16  * CWindowManager also provides methods for adding/positioning textMessages
17  * and viewports in the CDisplayWindow in a compact and consistent way.
18  *
19  * \ingroup mrpt_graphslam_grp
20  */
21 class GRAPHSLAM_IMPEXP CWindowManager : public mrpt::utils::COutputLogger {
22  public:
23  /**\brief Default class constructor */
25  this->initCWindowManager();
26  }
27  /**\brief Class constructor*/
29  {
30  this->initCWindowManager();
31  this->setCDisplayWindow3DPtr(win_in);
32  }
33  /**\brief Class constructor*/
36  {
37  this->initCWindowManager();
38 
39  this->setWindowObserverPtr(observer_in);
40  this->setCDisplayWindow3DPtr(win_in);
41  }
42  /**\brief Class destructor. */
44 
45  /**\brief Store the CDisplayWindow3D pointer in the CWindowManager
46  * instance.
47  *
48  * \sa setWindowObserverPtr
49  */
51  m_fetched_displaywindow_pointer = true;
52  win = win_in;
53 
54  MRPT_LOG_DEBUG_STREAM( "Fetched the CDisplayWindow3D* successfully");
55  }
56  /**\brief Store the CWindowObserver pointer in the CWindowManager instance.
57  *
58  * \sa setCDisplayWindow3DPtr
59  */
61  m_fetched_observer_pointer = true;
62  observer = obsever_in;
63 
64  MRPT_LOG_DEBUG_STREAM( "Fetched the CWindowObserver* successfully");
65  }
66 
67  /**\brief Assign the next available offset_y and text_index for the
68  * textMessage under construction.
69  *
70  * Used for consistent positioning of textMessages in the
71  * CDisplayWindow3D.
72  *
73  * \sa assignViewPortParameters
74  */
76  double* offset_y, int* text_index) {
77 
78  *offset_y = m_curr_offset_y;
79  m_curr_offset_y += m_offset_y_step;
80 
81  *text_index = m_curr_text_index;
82  m_curr_text_index += m_index_text_step;
83  }
84 
85  /**\brief Wrapper call around the CWindowDisplay3D */
86  bool isOpen() {
87  if (win) {
88  return win->isOpen();
89  }
90  else {
91  return false;
92  }
93  }
94 
95  /**\brief Wrapper around the CDisplayWindow3D::addTextMessage method, so that the
96  * user does not have to specify the font name and size.
97  *
98  * \note see initCWindowManager method for the default fontName and
99  * fontSize used.
100  */
102  const double x, const double y,
103  const std::string& text,
104  const mrpt::utils::TColorf& color=mrpt::utils::TColorf(1.0, 1.0, 1.0),
105  const size_t unique_index=0) {
106  if (!win) {
107  return;
108  }
109 
110  win->addTextMessage(x,y,
111  text,
112  color,
113  m_font_name, m_font_size,
115  unique_index);
116  }
117 
118  /**\brief Assign position and size values for the placement of the next viewport
119  *
120  * Used for consistent positioning of the Viewports in the CDisplayWindow3D
121  *
122  * \sa assignTextMessageParameters
123  */
124  void assignViewportParameters(double *x, double *y, double *width, double *height) {
125  *x = m_viewp_x;
126  *y = m_viewp_y;
127 
128  *width = m_viewp_width;
129  *height = m_viewp_height;
130 
131  m_viewp_y -= m_viewp_height + m_viewp_margin;
132  }
133 
134  mrpt::gui::CDisplayWindow3D* win; /**< CDisplayWindow instance */
135  mrpt::graphslam::CWindowObserver* observer; /**< CWindowObserver instance */
136  private:
137  /**\brief Initialization method, to be called from the various Constructors.
138  */
140  m_fetched_displaywindow_pointer = false;
141  m_fetched_observer_pointer= false;
142  win = NULL;
143  observer = NULL;
144 
145  m_offset_y_step = 20.0;
146  m_index_text_step = 1;
147  m_font_name = "sans";
148  m_font_size = 12;
149  m_curr_offset_y = 30;
150  m_curr_text_index = 1;
151 
152  m_viewp_width = 0.2;
153  m_viewp_height = 0.2;
154  m_viewp_x = 0.75;
155  m_viewp_margin = 0.01;
156  m_viewp_y = 0.72;
157 
158  // loger related directives
159  this->setLoggerName("CWindowManager");
160  MRPT_LOG_DEBUG_STREAM( "Initializing...");
161  }
162 
165 
170 
173 
174  // viewports configuration
177  double m_viewp_x;
178  double m_viewp_y; /**< vertical layout of the viewports */
180 
181 };
182 
183 } } // END OF NAMESPACES
184 
185 #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:3513
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:7093
bool isOpen()
Wrapper call around the CWindowDisplay3D.
~CWindowManager()
Class destructor.
mrpt::gui::CDisplayWindow3D * win
CDisplayWindow instance.
mrpt::graphslam::CWindowObserver * observer
CWindowObserver instance.
CWindowManager()
Default class constructor.
GLsizei const GLchar ** string
Definition: glext.h:3919
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:80
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:3516
GLenum GLint x
Definition: glext.h:3516
GLenum GLsizei GLsizei height
Definition: glext.h:3523
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
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.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020