MRPT  1.9.9
CDisplayWindow.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "gui-precomp.h" // Precompiled headers
11 
12 #include <mrpt/core/round.h>
14 #include <mrpt/img/CImage.h>
15 #include <mrpt/system/os.h>
16 
17 #include <mrpt/gui/WxSubsystem.h>
18 #include <mrpt/gui/WxUtils.h>
19 
20 using namespace mrpt;
21 using namespace mrpt::math;
22 using namespace mrpt::gui;
23 using namespace mrpt::system;
24 using namespace std;
25 using namespace mrpt::img;
26 
27 #if MRPT_HAS_WXWIDGETS
28 
29 BEGIN_EVENT_TABLE(CWindowDialog, wxFrame)
30 
31 END_EVENT_TABLE()
32 
33 const long CWindowDialog::ID_IMAGE_BITMAP = wxNewId();
34 const long ID_MENUITEM1 = wxNewId();
35 const long ID_MENUITEM2 = wxNewId();
36 const long ID_MENUITEM3 = wxNewId();
37 
39  wxWindow* parent, wxWindowID winID, int x, int y, int width, int height)
40  : m_img(nullptr)
41 {
42  this->Create(parent, winID, wxPoint(x, y), wxSize(width, height));
43 
44  Bind(wxEVT_PAINT, &CWindowDialog::wxMRPTImageControl::OnPaint, this);
45  Bind(wxEVT_MOTION, &CWindowDialog::wxMRPTImageControl::OnMouseMove, this);
46  Bind(
47  wxEVT_LEFT_DOWN, &CWindowDialog::wxMRPTImageControl::OnMouseClick,
48  this);
49  Bind(
50  wxEVT_CHAR, &CWindowDialog::wxMRPTImageControl::OnChar, this, wxID_ANY);
51  Bind(wxEVT_CHAR, &CWindowDialog::wxMRPTImageControl::OnChar, this);
52 }
53 
54 CWindowDialog::wxMRPTImageControl::~wxMRPTImageControl()
55 {
56  std::lock_guard<std::mutex> lock(m_img_cs);
57  if (m_img) m_img.reset();
58 }
59 
60 void CWindowDialog::wxMRPTImageControl::OnMouseMove(wxMouseEvent& ev)
61 {
62  // std::lock_guard<std::mutex> lock( m_mouse_cs);
63  m_last_mouse_point = ev.GetPosition();
64 }
65 
66 void CWindowDialog::wxMRPTImageControl::OnMouseClick(wxMouseEvent& ev)
67 {
68  // std::lock_guard<std::mutex> lock( m_mouse_cs);
69  m_last_mouse_click = ev.GetPosition();
70 }
71 
72 void CWindowDialog::wxMRPTImageControl::OnChar(wxKeyEvent& ev) {}
73 void CWindowDialog::wxMRPTImageControl::AssignImage(wxBitmap* img)
74 {
75  std::lock_guard<std::mutex> lock(m_img_cs);
76  m_img.reset(img);
77 }
78 
79 void CWindowDialog::wxMRPTImageControl::OnPaint(wxPaintEvent& ev)
80 {
81  wxPaintDC dc(this);
82 
83  std::lock_guard<std::mutex> lock(m_img_cs);
84  if (!m_img)
85  {
86  // Erase background:
87  return;
88  }
89 
90  dc.DrawBitmap(*m_img, 0, 0);
91 }
92 
93 void CWindowDialog::wxMRPTImageControl::GetBitmap(wxBitmap& bmp)
94 {
95  std::lock_guard<std::mutex> lock(m_img_cs);
96  if (!m_img) return;
97  bmp = *m_img;
98 }
99 
100 CWindowDialog::CWindowDialog(
101  CDisplayWindow* win2D, WxSubsystem::CWXMainFrame* parent, wxWindowID id,
102  const std::string& caption, wxSize initialSize)
103  : m_win2D(win2D), m_mainFrame(parent)
104 {
105  Create(
106  parent, id, caption.c_str(), wxDefaultPosition, initialSize,
107  wxDEFAULT_FRAME_STYLE, _T("id"));
108  SetClientSize(initialSize);
109 
110  wxIcon FrameIcon;
111  FrameIcon.CopyFromBitmap(mrpt::gui::WxSubsystem::getMRPTDefaultIcon());
112  SetIcon(FrameIcon);
113 
114  // Create the image object:
116  this, ID_IMAGE_BITMAP, 0, 0, 10, 10);
117 
118  // wxCLIP_CHILDREN seems to avoid flicker
119  SetWindowStyle(GetWindowStyle() | wxCLIP_CHILDREN);
120 
121  // Menu:
122  auto* MenuBar1 = new wxMenuBar();
123 
124  auto* Menu1 = new wxMenu();
125  wxMenuItem* MenuItem3 = new wxMenuItem(
126  Menu1, ID_MENUITEM3, _("Save to file..."), _(""), wxITEM_NORMAL);
127  Menu1->Append(MenuItem3);
128  wxMenuItem* MenuItem1 =
129  new wxMenuItem(Menu1, ID_MENUITEM1, _("Close"), _(""), wxITEM_NORMAL);
130  Menu1->Append(MenuItem1);
131  MenuBar1->Append(Menu1, _("&File"));
132 
133  auto* Menu2 = new wxMenu();
134  wxMenuItem* MenuItem2 = new wxMenuItem(
135  Menu2, ID_MENUITEM2, _("About..."), _(""), wxITEM_NORMAL);
136  Menu2->Append(MenuItem2);
137  MenuBar1->Append(Menu2, _("&Help"));
138 
139  SetMenuBar(MenuBar1);
140 
141  // Events:
142  Bind(wxEVT_CLOSE_WINDOW, &CWindowDialog::OnClose, this, wxID_ANY);
143  Bind(wxEVT_MENU, &CWindowDialog::OnMenuClose, this, ID_MENUITEM1);
144  Bind(wxEVT_MENU, &CWindowDialog::OnMenuAbout, this, ID_MENUITEM2);
145  Bind(wxEVT_MENU, &CWindowDialog::OnMenuSave, this, ID_MENUITEM3);
146 
147  Bind(wxEVT_KEY_DOWN, &CWindowDialog::OnChar, this, wxID_ANY);
148  Bind(wxEVT_CHAR, &CWindowDialog::OnChar, this, wxID_ANY);
149 
150  m_image->Bind(wxEVT_KEY_DOWN, &CWindowDialog::OnChar, this);
151  m_image->Bind(wxEVT_SIZE, &CWindowDialog::OnResize, this);
152 
153  m_image->Bind(wxEVT_LEFT_DOWN, &CWindowDialog::OnMouseDown, this);
154  m_image->Bind(wxEVT_RIGHT_DOWN, &CWindowDialog::OnMouseDown, this);
155  m_image->Bind(wxEVT_MOTION, &CWindowDialog::OnMouseMove, this);
156 
157  // Increment number of windows:
158  // int winCount =
160 
161  // this->Iconize(false);
162 }
163 
164 // Destructor
166 // OnClose event:
167 void CWindowDialog::OnClose(wxCloseEvent& event)
168 {
169  // Send the event:
170  bool allow_close = true;
171  try
172  {
173  mrptEventWindowClosed ev(m_win2D, true /* allow close */);
174  m_win2D->publishEvent(ev);
175  allow_close = ev.allow_close;
176  }
177  catch (...)
178  {
179  }
180  if (!allow_close) return; // Don't process this close event.
181 
182  // Set the m_hwnd=nullptr in our parent object.
184 
185  // Decrement number of windows:
187 
188  m_win2D->m_windowDestroyed.set_value();
189 
190  event.Skip(); // keep processing by parent classes.
191 }
192 
193 void CWindowDialog::OnKeyDown(wxKeyEvent& event)
194 {
195  event.Skip(); // So OnChar event is produced.
196 }
197 
198 void CWindowDialog::OnChar(wxKeyEvent& event)
199 {
200  if (m_win2D)
201  {
202  const int code = event.GetKeyCode();
204 
205  m_win2D->m_keyPushedCode = code;
207  m_win2D->m_keyPushed = true;
208 
209  // Send the event:
210  try
211  {
213  }
214  catch (...)
215  {
216  }
217  }
218  event.Skip();
219 }
220 
221 void CWindowDialog::OnResize(wxSizeEvent& event)
222 {
223  // Send the event:
224  if (m_win2D && m_win2D->hasSubscribers())
225  {
226  try
227  {
229  m_win2D, event.GetSize().GetWidth(),
230  event.GetSize().GetHeight()));
231  }
232  catch (...)
233  {
234  }
235  }
236  event.Skip(); // so it's processed by the wx system!
237 }
238 
239 void CWindowDialog::OnMouseDown(wxMouseEvent& event)
240 {
241  // Send the event:
242  if (m_win2D && m_win2D->hasSubscribers())
243  {
244  try
245  {
247  m_win2D, TPixelCoord(event.GetX(), event.GetY()),
248  event.LeftDown(), event.RightDown()));
249  }
250  catch (...)
251  {
252  }
253  }
254  event.Skip(); // so it's processed by the wx system!
255 }
256 
257 void CWindowDialog::OnMouseMove(wxMouseEvent& event)
258 {
259  // Send the event:
260  if (m_win2D && m_win2D->hasSubscribers())
261  {
262  try
263  {
265  m_win2D, TPixelCoord(event.GetX(), event.GetY()),
266  event.LeftDown(), event.RightDown()));
267  }
268  catch (...)
269  {
270  }
271  }
272  event.Skip(); // so it's processed by the wx system!
273 }
274 
275 // Menu: Close
276 void CWindowDialog::OnMenuClose(wxCommandEvent& event) { Close(); }
277 // Menu: About
278 void CWindowDialog::OnMenuAbout(wxCommandEvent& event)
279 {
280  ::wxMessageBox(
281  _("Image viewer\n Class gui::CDisplayWindow\n MRPT C++ library"),
282  _("About..."));
283 }
284 
285 // Menu: Save to file
286 void CWindowDialog::OnMenuSave(wxCommandEvent& event)
287 {
288  wxFileDialog dialog(
289  this, wxT("Save image as..."), wxT("."), wxT("image.png"),
290  wxT("PNG image files (*.png)|*.png"),
291  wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
292 
293  if (wxID_OK == dialog.ShowModal())
294  {
295  try
296  {
297  wxBitmap bmp;
298  m_image->GetBitmap(bmp);
299  bmp.SaveFile(dialog.GetPath(), wxBITMAP_TYPE_PNG);
300  }
301  catch (...)
302  {
303  }
304  }
305 }
306 
307 #endif
308 
310  const std::string& windowCaption, unsigned int initWidth,
311  unsigned int initHeight)
312 {
313  return std::make_shared<CDisplayWindow>(
314  windowCaption, initWidth, initHeight);
315 }
316 /*---------------------------------------------------------------
317  Constructor
318  ---------------------------------------------------------------*/
320  const std::string& windowCaption, unsigned int initWidth,
321  unsigned int initHeight)
322  : CBaseGUIWindow(static_cast<void*>(this), 200, 299, windowCaption)
323 
324 {
325  CBaseGUIWindow::createWxWindow(initWidth, initHeight);
326 }
327 
328 /*---------------------------------------------------------------
329  Destructor
330  ---------------------------------------------------------------*/
332 /** Set cursor style to default (cursorIsCross=false) or to a cross
333  * (cursorIsCross=true) */
334 void CDisplayWindow::setCursorCross(bool cursorIsCross)
335 {
336 #if MRPT_HAS_WXWIDGETS && MRPT_HAS_OPENGL_GLUT
337  const auto* win = (const CWindowDialog*)m_hwnd.get();
338  if (!win) return;
339  win->m_image->SetCursor(
340  *(cursorIsCross ? wxCROSS_CURSOR : wxSTANDARD_CURSOR));
341 #else
342  MRPT_UNUSED_PARAM(cursorIsCross);
343 #endif
344 }
345 
346 /*---------------------------------------------------------------
347  getLastMousePosition
348  ---------------------------------------------------------------*/
349 bool CDisplayWindow::getLastMousePosition(int& x, int& y) const
350 {
351 #if MRPT_HAS_WXWIDGETS && MRPT_HAS_OPENGL_GLUT
352  const auto* win = (const CWindowDialog*)m_hwnd.get();
353  if (!win) return false;
354  x = win->m_image->m_last_mouse_point.x;
355  y = win->m_image->m_last_mouse_point.y;
356  return true;
357 #else
360  return false;
361 #endif
362 }
363 
364 /*---------------------------------------------------------------
365  showImage
366  ---------------------------------------------------------------*/
368 {
369 #if MRPT_HAS_WXWIDGETS
370  MRPT_START
371 
372  // Send message of new image:
373  wxImage* newImg = mrpt::gui::MRPTImage2wxImage(img);
374 
375  // Send a request to destroy this object:
376  auto* REQ = new WxSubsystem::TRequestToWxMainThread[1];
377  REQ->source2D = this;
378  REQ->OPCODE = 201;
379  REQ->voidPtr = m_hwnd.get();
380  REQ->voidPtr2 = (void*)newImg;
382 
383  MRPT_END
384 #else
385  MRPT_UNUSED_PARAM(img);
386 #endif
387 }
388 
389 /*---------------------------------------------------------------
390  showImageAndPoints
391  ---------------------------------------------------------------*/
393  const CImage& img, const CVectorFloat& x_, const CVectorFloat& y_,
394  const TColor& color, bool showNumbers)
395 {
396  std::vector<float> x(x_.size()), y(y_.size());
397  for (size_t i = 0; i < x.size(); i++) x[i] = x_[i];
398  for (size_t i = 0; i < y.size(); i++) y[i] = y_[i];
399  showImageAndPoints(img, x, y, color, showNumbers);
400 }
401 
403  const CImage& img, const std::vector<float>& x, const std::vector<float>& y,
404  const TColor& color, bool showNumbers)
405 {
406 #if MRPT_HAS_WXWIDGETS
407  MRPT_START
408  ASSERT_(x.size() == y.size());
409 
410  CImage imgColor = img.colorImage(); // Create a colorimage
411  for (size_t i = 0; i < x.size(); i++)
412  {
413  imgColor.drawMark(round(x[i]), round(y[i]), color, '+');
414 
415  if (showNumbers)
416  {
417  char buf[15];
418  mrpt::system::os::sprintf(buf, 15, "%d", int(i));
419  imgColor.textOut(round(x[i]) - 10, round(y[i]), buf, color);
420  }
421  } // end-for
422  showImage(imgColor);
423  MRPT_END
424 #else
425  MRPT_UNUSED_PARAM(img);
428  MRPT_UNUSED_PARAM(color);
429  MRPT_UNUSED_PARAM(showNumbers);
430 #endif
431 }
432 
433 /*---------------------------------------------------------------
434  plot
435  ---------------------------------------------------------------*/
437 {
438  MRPT_START
439 
440  ASSERT_(x.size() == y.size());
441 
442  const int ox = 40;
443  const int oy = 40;
444 
445  // Suboptimal but...
446  CImage imgColor(640, 480, mrpt::img::CH_RGB);
447  // Draw axis:
448  imgColor.filledRectangle(0, 0, 640, 480, TColor(255, 255, 255));
449  imgColor.line(40, 40, 560, 40, TColor::black(), 3);
450  imgColor.line(40, 40, 40, 440, TColor::black(), 3);
451  imgColor.line(560, 40, 555, 45, TColor::black(), 3);
452  imgColor.line(560, 40, 555, 35, TColor::black(), 3);
453  imgColor.line(40, 440, 35, 435, TColor::black(), 3);
454  imgColor.line(40, 440, 45, 435, TColor::black(), 3);
455 
456  // imgColor.textOut( 550, 25, "x", TColor::black );
457  // imgColor.textOut( 25, 430, "y", TColor::black );
458 
460  CVectorFloat::const_iterator itymx, itymn;
461  itymx = std::max_element(y.begin(), y.end());
462  itymn = std::min_element(y.begin(), y.end());
463  float px = (x[x.size() - 1] - x[0]) / 520;
464  float py = (*itymx - *itymn) / 400;
465 
466  float tpxA = 0, tpyA = 0;
467 
468  for (itx = x.begin(), ity = y.begin(); itx != x.end(); ++itx, ++ity)
469  {
470  float tpx = (*itx - x[0]) / px + ox;
471  float tpy = (*ity - *itymn) / py + oy;
472  imgColor.drawMark(round(tpx), round(tpy), TColor(255, 0, 0), 'x');
473  if (itx != x.begin())
474  imgColor.line(
475  round(tpxA), round(tpyA), round(tpx), round(tpy),
476  TColor(0, 0, 255), 3);
477  tpxA = tpx;
478  tpyA = tpy;
479  } // end for
480 
481  showImage(imgColor);
482 
483  MRPT_END
484 }
485 
486 /*---------------------------------------------------------------
487  plot
488  ---------------------------------------------------------------*/
490 {
491  MRPT_START
492 
493  ASSERT_(y.size() >= 0);
494 
495  const int ox = 40;
496  const int oy = 40;
497 
498  // Suboptimal but...
499  CImage imgColor(640, 480, mrpt::img::CH_RGB);
500  // Draw axis:
501  imgColor.filledRectangle(0, 0, 640, 480, TColor::white());
502  imgColor.line(40, 40, 560, 40, TColor::black(), 3);
503  imgColor.line(40, 40, 40, 440, TColor::black(), 3);
504  imgColor.line(560, 40, 555, 45, TColor::black(), 3);
505  imgColor.line(560, 40, 555, 35, TColor::black(), 3);
506  imgColor.line(40, 440, 35, 435, TColor::black(), 3);
507  imgColor.line(40, 440, 45, 435, TColor::black(), 3);
508 
509  imgColor.textOut(550, 25, "x", TColor::black());
510  imgColor.textOut(25, 430, "y", TColor::black());
511 
513  CVectorFloat::const_iterator itymx, itymn;
514  itymx = std::max_element(y.begin(), y.end());
515  itymn = std::min_element(y.begin(), y.end());
516  float px = y.size() / 520.0f;
517  float py = (*itymx - *itymn) / 400.0f;
518  int tpxA = 0, tpyA = 0;
519 
520  unsigned int k = 0;
521 
522  for (k = 0, ity = y.begin(); ity != y.end(); ++k, ++ity)
523  {
524  auto tpx = round(k / px + ox);
525  auto tpy = round((*ity - *itymn) / py + oy);
526  imgColor.drawMark(tpx, tpy, TColor::red(), 'x');
527  if (k > 0) imgColor.line(tpxA, tpyA, tpx, tpy, TColor::blue(), 3);
528  tpxA = tpx;
529  tpyA = tpy;
530  } // end for
531 
532  showImage(imgColor);
533 
534  MRPT_END
535 }
536 
537 /*---------------------------------------------------------------
538  resize
539  ---------------------------------------------------------------*/
540 void CDisplayWindow::resize(unsigned int width, unsigned int height)
541 {
542 #if MRPT_HAS_WXWIDGETS
543  if (!isOpen())
544  {
545  cerr << "[CDisplayWindow::resize] Window closed!: " << m_caption
546  << endl;
547  return;
548  }
549 
550  // Send a request to destroy this object:
551  auto* REQ = new WxSubsystem::TRequestToWxMainThread[1];
552  REQ->source2D = this;
553  REQ->OPCODE = 203;
554  REQ->x = width;
555  REQ->y = height;
557 #else
558  MRPT_UNUSED_PARAM(width);
559  MRPT_UNUSED_PARAM(height);
560 #endif
561 }
562 
563 /*---------------------------------------------------------------
564  setPos
565  ---------------------------------------------------------------*/
566 void CDisplayWindow::setPos(int x, int y)
567 {
568 #if MRPT_HAS_WXWIDGETS
569  if (!isOpen())
570  {
571  cerr << "[CDisplayWindow::setPos] Window closed!: " << m_caption
572  << endl;
573  return;
574  }
575 
576  // Send a request to destroy this object:
577  auto* REQ = new WxSubsystem::TRequestToWxMainThread[1];
578  REQ->source2D = this;
579  REQ->OPCODE = 202;
580  REQ->x = x;
581  REQ->y = y;
583 #else
586 #endif
587 }
588 
589 /*---------------------------------------------------------------
590  setWindowTitle
591  ---------------------------------------------------------------*/
592 void CDisplayWindow::setWindowTitle(const std::string& str)
593 {
594 #if MRPT_HAS_WXWIDGETS
595  if (!isOpen())
596  {
597  cerr << "[CDisplayWindow::setWindowTitle] Window closed!: " << m_caption
598  << endl;
599  return;
600  }
601 
602  // Send a request to destroy this object:
603  auto* REQ = new WxSubsystem::TRequestToWxMainThread[1];
604  REQ->source2D = this;
605  REQ->OPCODE = 204;
606  REQ->str = str;
608 #else
609  MRPT_UNUSED_PARAM(str);
610 #endif
611 }
An event sent by a window upon resize.
static void pushPendingWxRequest(TRequestToWxMainThread *data)
Thread-safe method to insert a new pending request (The memory must be dinamically allocated with "ne...
void line(int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) override
Draws a line.
Definition: CImage.cpp:1117
An event sent by a window upon a mouse click, giving the (x,y) pixel coordinates. ...
std::atomic_int m_keyPushedCode
#define MRPT_START
Definition: exceptions.h:241
void OnMenuSave(wxCommandEvent &event)
void OnResize(wxSizeEvent &event)
The data structure for each inter-thread request:
Definition: WxSubsystem.h:189
Template for column vectors of dynamic size, compatible with Eigen.
mrpt::void_ptr_noncopy m_hwnd
The window handle.
void setCursorCross(bool cursorIsCross) override
Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true) ...
std::string m_caption
The caption of the window.
static int notifyWindowCreation()
Atomically increments the number of windows created with the main frame as parent.
~CDisplayWindow() override
Destructor.
size_type size() const
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))
mrptKeyModifier
Definition: keycodes.h:156
static wxBitmap getMRPTDefaultIcon()
STL namespace.
wxImage * MRPTImage2wxImage(const mrpt::img::CImage &img)
Create a wxImage from a MRPT image.
Definition: WxUtils.cpp:24
const long ID_MENUITEM3
An event sent by a window upon when it&#39;s about to be closed, either manually by the user or programma...
An event sent by a window when the mouse is moved over it.
void setWindowTitle(const std::string &str) override
Changes the window title text.
void plot(const mrpt::math::CVectorFloat &x, const mrpt::math::CVectorFloat &y)
Plots a graph in MATLAB-like style.
void notifyChildWindowDestruction()
Called by wx main thread to set m_hwnd to NULL.
wxMRPTImageControl * m_image
Definition: WxSubsystem.h:363
CImage colorImage() const
Returns a color (RGB) version of the grayscale image, or a shallow copy of itself if it is already a ...
Definition: CImage.cpp:1861
void OnKeyDown(wxKeyEvent &event)
void OnMouseDown(wxMouseEvent &event)
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
void OnMenuClose(wxCommandEvent &event)
const long ID_MENUITEM1
This base provides a set of functions for maths stuff.
A custom control to display the bitmap and avoid flicker.
Definition: WxSubsystem.h:320
void showImageAndPoints(const mrpt::img::CImage &img, const mrpt::math::CVectorFloat &x, const mrpt::math::CVectorFloat &y, const mrpt::img::TColor &color=mrpt::img::TColor::red(), bool showNumbers=false)
Show a given color or grayscale image on the window and print a set of points on it.
virtual void filledRectangle(int x0, int y0, int x1, int y1, const mrpt::img::TColor color)
Draws a filled rectangle.
Definition: CCanvas.cpp:217
bool getLastMousePosition(int &x, int &y) const override
Gets the last x,y pixel coordinates of the mouse.
This class creates a window as a graphical user interface (GUI) for displaying images to the user...
bool isOpen()
Returns false if the user has already closed the window.
std::atomic< mrptKeyModifier > m_keyPushedModifier
The main frame of the wxWidgets application.
Definition: WxSubsystem.h:132
A pair (x,y) of pixel coordinates (integer resolution).
Definition: TPixelCoord.h:40
CDisplayWindow * m_win2D
Definition: WxSubsystem.h:359
The wx dialog for gui::CDisplayWindow.
Definition: WxSubsystem.h:315
typename vec_t::const_iterator const_iterator
An event sent by a window upon a char pressed by the user.
const long ID_MENUITEM2
void OnMouseMove(wxMouseEvent &event)
mrpt::gui::CDisplayWindow3D::Ptr win
void resize(unsigned int width, unsigned int height) override
Resizes the window, stretching the image to fit into the display area.
mrptKeyModifier keyEventToMrptKeyModifier(const wxKeyEvent &ev)
Extracts the key modifiers from a wxKeyEvent.
Definition: WxUtils.cpp:939
void setPos(int x, int y) override
Changes the position of the window on the screen.
void OnChar(wxKeyEvent &event)
void drawMark(int x0, int y0, const mrpt::img::TColor color, char type, int size=5, unsigned int width=1)
Draw a mark.
Definition: CCanvas.cpp:320
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void OnClose(wxCloseEvent &event)
void OnMenuAbout(wxCommandEvent &event)
std::atomic_bool m_keyPushed
#define MRPT_END
Definition: exceptions.h:245
bool hasSubscribers() const
Can be called by a derived class before preparing an event for publishing with publishEvent to determ...
Definition: CObservable.h:53
void publishEvent(const mrptEvent &e) const
Called when you want this object to emit an event to all the observers currently subscribed to this o...
Definition: CObservable.cpp:57
static const long ID_IMAGE_BITMAP
Definition: WxSubsystem.h:365
void showImage(const mrpt::img::CImage &img)
Show a given color or grayscale image on the window.
void destroyWxWindow()
Must be called by child classes in their destructors.
virtual void textOut(int x0, int y0, const std::string &str, const mrpt::img::TColor color)
Renders 2D text using bitmap fonts.
Definition: CCanvas.cpp:390
CDisplayWindow(const std::string &windowCaption=std::string(), unsigned int initWidth=400, unsigned int initHeight=400)
Constructor.
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:14
void createWxWindow(unsigned int initialWidth, unsigned int initialHeight)
Must be called by child classes just within the constructor.
static CDisplayWindow::Ptr Create(const std::string &windowCaption, unsigned int initWidth=400, unsigned int initHeight=400)
Class factory returning a smart pointer.
A RGB color - 8bit.
Definition: TColor.h:25
mrpt::gui::CDisplayWindow * source2D
Only one of source* can be non-nullptr, indicating the class that generated the request.
Definition: WxSubsystem.h:195
std::promise< void > m_windowDestroyed
This semaphore will be signaled when the wx window is destroyed.
The base class for GUI window classes based on wxWidgets.
static int notifyWindowDestruction()
Atomically decrements the number of windows created with the main frame as parent.
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
Definition: os.cpp:191
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:148
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
int round(const T value)
Returns the closer integer (int) to x.
Definition: round.h:24



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 3a26b90fd Wed Mar 25 20:17:03 2020 +0100 at miƩ mar 25 23:05:41 CET 2020