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-2019, 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  Connect(
45  wxEVT_PAINT,
46  wxPaintEventHandler(CWindowDialog::wxMRPTImageControl::OnPaint));
47  Connect(
48  wxEVT_MOTION,
49  wxMouseEventHandler(CWindowDialog::wxMRPTImageControl::OnMouseMove));
50  Connect(
51  wxID_ANY, wxEVT_LEFT_DOWN,
52  wxMouseEventHandler(CWindowDialog::wxMRPTImageControl::OnMouseClick));
53 
54  Connect(
55  wxID_ANY, wxEVT_CHAR,
56  (wxObjectEventFunction)&CWindowDialog::wxMRPTImageControl::OnChar);
57  Connect(
58  wxEVT_CHAR,
59  (wxObjectEventFunction)&CWindowDialog::wxMRPTImageControl::OnChar);
60 
61  // Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::wxMRPTImageControl::OnChar);
62  // Connect(wxID_ANY,wxEVT_KEY_DOWN,(wxObjectEventFunction)&CWindowDialog::wxMRPTImageControl::OnChar);
63 }
64 
65 CWindowDialog::wxMRPTImageControl::~wxMRPTImageControl()
66 {
67  std::lock_guard<std::mutex> lock(m_img_cs);
68  if (m_img)
69  {
70  delete m_img;
71  m_img = nullptr;
72  }
73 }
74 
75 void CWindowDialog::wxMRPTImageControl::OnMouseMove(wxMouseEvent& ev)
76 {
77  // std::lock_guard<std::mutex> lock( m_mouse_cs);
78  m_last_mouse_point = ev.GetPosition();
79 }
80 
81 void CWindowDialog::wxMRPTImageControl::OnMouseClick(wxMouseEvent& ev)
82 {
83  // std::lock_guard<std::mutex> lock( m_mouse_cs);
84  m_last_mouse_click = ev.GetPosition();
85 }
86 
87 void CWindowDialog::wxMRPTImageControl::OnChar(wxKeyEvent& ev) {}
88 void CWindowDialog::wxMRPTImageControl::AssignImage(wxBitmap* img)
89 {
90  std::lock_guard<std::mutex> lock(m_img_cs);
91  if (m_img)
92  {
93  delete m_img;
94  m_img = nullptr;
95  }
96 
97  m_img = img;
98 }
99 
100 void CWindowDialog::wxMRPTImageControl::OnPaint(wxPaintEvent& ev)
101 {
102  wxPaintDC dc(this);
103 
104  std::lock_guard<std::mutex> lock(m_img_cs);
105  if (!m_img)
106  {
107  // Erase background:
108  return;
109  }
110 
111  dc.DrawBitmap(*m_img, 0, 0);
112 }
113 
114 void CWindowDialog::wxMRPTImageControl::GetBitmap(wxBitmap& bmp)
115 {
116  std::lock_guard<std::mutex> lock(m_img_cs);
117  if (!m_img) return;
118  bmp = *m_img;
119 }
120 
121 CWindowDialog::CWindowDialog(
122  CDisplayWindow* win2D, WxSubsystem::CWXMainFrame* parent, wxWindowID id,
123  const std::string& caption, wxSize initialSize)
124  : m_win2D(win2D), m_mainFrame(parent)
125 {
126  Create(
127  parent, id, caption.c_str(), wxDefaultPosition, initialSize,
128  wxDEFAULT_FRAME_STYLE, _T("id"));
129  SetClientSize(initialSize);
130 
131  wxIcon FrameIcon;
132  FrameIcon.CopyFromBitmap(mrpt::gui::WxSubsystem::getMRPTDefaultIcon());
133  SetIcon(FrameIcon);
134 
135  // Create the image object:
137  this, ID_IMAGE_BITMAP, 0, 0, 10, 10);
138 
139  // wxCLIP_CHILDREN seems to avoid flicker
140  SetWindowStyle(GetWindowStyle() | wxCLIP_CHILDREN);
141 
142  // Menu:
143  auto* MenuBar1 = new wxMenuBar();
144 
145  auto* Menu1 = new wxMenu();
146  wxMenuItem* MenuItem3 = new wxMenuItem(
147  Menu1, ID_MENUITEM3, _("Save to file..."), _(""), wxITEM_NORMAL);
148  Menu1->Append(MenuItem3);
149  wxMenuItem* MenuItem1 =
150  new wxMenuItem(Menu1, ID_MENUITEM1, _("Close"), _(""), wxITEM_NORMAL);
151  Menu1->Append(MenuItem1);
152  MenuBar1->Append(Menu1, _("&File"));
153 
154  auto* Menu2 = new wxMenu();
155  wxMenuItem* MenuItem2 = new wxMenuItem(
156  Menu2, ID_MENUITEM2, _("About..."), _(""), wxITEM_NORMAL);
157  Menu2->Append(MenuItem2);
158  MenuBar1->Append(Menu2, _("&Help"));
159 
160  SetMenuBar(MenuBar1);
161 
162  // Events:
163  Connect(
164  wxID_ANY, wxEVT_CLOSE_WINDOW,
165  (wxObjectEventFunction)&CWindowDialog::OnClose);
166  Connect(
167  ID_MENUITEM1, wxEVT_COMMAND_MENU_SELECTED,
168  (wxObjectEventFunction)&CWindowDialog::OnMenuClose);
169  Connect(
170  ID_MENUITEM2, wxEVT_COMMAND_MENU_SELECTED,
171  (wxObjectEventFunction)&CWindowDialog::OnMenuAbout);
172  Connect(
173  ID_MENUITEM3, wxEVT_COMMAND_MENU_SELECTED,
174  (wxObjectEventFunction)&CWindowDialog::OnMenuSave);
175 
176  // Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::OnChar);
177  Connect(
178  wxID_ANY, wxEVT_KEY_DOWN,
179  (wxObjectEventFunction)&CWindowDialog::OnChar);
180  // Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::OnChar);
181  Connect(wxEVT_CHAR, (wxObjectEventFunction)&CWindowDialog::OnChar);
182 
183  m_image->Connect(
184  wxID_ANY, wxEVT_KEY_DOWN, (wxObjectEventFunction)&CWindowDialog::OnChar,
185  nullptr, this);
186  m_image->Connect(
187  wxEVT_SIZE, (wxObjectEventFunction)&CWindowDialog::OnResize, nullptr,
188  this);
189 
190  m_image->Connect(
191  wxEVT_LEFT_DOWN, (wxObjectEventFunction)&CWindowDialog::OnMouseDown,
192  nullptr, this);
193  m_image->Connect(
194  wxEVT_RIGHT_DOWN, (wxObjectEventFunction)&CWindowDialog::OnMouseDown,
195  nullptr, this);
196  m_image->Connect(
197  wxEVT_MOTION, (wxObjectEventFunction)&CWindowDialog::OnMouseMove,
198  nullptr, this);
199 
200  // Increment number of windows:
201  // int winCount =
203 
204  // this->Iconize(false);
205 }
206 
207 // Destructor
209 // OnClose event:
210 void CWindowDialog::OnClose(wxCloseEvent& event)
211 {
212  // Send the event:
213  bool allow_close = true;
214  try
215  {
216  mrptEventWindowClosed ev(m_win2D, true /* allow close */);
217  m_win2D->publishEvent(ev);
218  allow_close = ev.allow_close;
219  }
220  catch (...)
221  {
222  }
223  if (!allow_close) return; // Don't process this close event.
224 
225  // Set the m_hwnd=nullptr in our parent object.
227 
228  // Decrement number of windows:
230 
231  m_win2D->m_windowDestroyed.set_value();
232 
233  event.Skip(); // keep processing by parent classes.
234 }
235 
236 void CWindowDialog::OnKeyDown(wxKeyEvent& event)
237 {
238  event.Skip(); // So OnChar event is produced.
239 }
240 
241 void CWindowDialog::OnChar(wxKeyEvent& event)
242 {
243  if (m_win2D)
244  {
245  const int code = event.GetKeyCode();
247 
250  m_win2D->m_keyPushed = true;
251 
252  // Send the event:
253  try
254  {
256  }
257  catch (...)
258  {
259  }
260  }
261  event.Skip();
262 }
263 
264 void CWindowDialog::OnResize(wxSizeEvent& event)
265 {
266  // Send the event:
267  if (m_win2D && m_win2D->hasSubscribers())
268  {
269  try
270  {
272  m_win2D, event.GetSize().GetWidth(),
273  event.GetSize().GetHeight()));
274  }
275  catch (...)
276  {
277  }
278  }
279  event.Skip(); // so it's processed by the wx system!
280 }
281 
282 void CWindowDialog::OnMouseDown(wxMouseEvent& event)
283 {
284  // Send the event:
285  if (m_win2D && m_win2D->hasSubscribers())
286  {
287  try
288  {
290  m_win2D, TPixelCoord(event.GetX(), event.GetY()),
291  event.LeftDown(), event.RightDown()));
292  }
293  catch (...)
294  {
295  }
296  }
297  event.Skip(); // so it's processed by the wx system!
298 }
299 
300 void CWindowDialog::OnMouseMove(wxMouseEvent& event)
301 {
302  // Send the event:
303  if (m_win2D && m_win2D->hasSubscribers())
304  {
305  try
306  {
308  m_win2D, TPixelCoord(event.GetX(), event.GetY()),
309  event.LeftDown(), event.RightDown()));
310  }
311  catch (...)
312  {
313  }
314  }
315  event.Skip(); // so it's processed by the wx system!
316 }
317 
318 // Menu: Close
319 void CWindowDialog::OnMenuClose(wxCommandEvent& event) { Close(); }
320 // Menu: About
321 void CWindowDialog::OnMenuAbout(wxCommandEvent& event)
322 {
323  ::wxMessageBox(
324  _("Image viewer\n Class gui::CDisplayWindow\n MRPT C++ library"),
325  _("About..."));
326 }
327 
328 // Menu: Save to file
329 void CWindowDialog::OnMenuSave(wxCommandEvent& event)
330 {
331  wxFileDialog dialog(
332  this, wxT("Save image as..."), wxT("."), wxT("image.png"),
333  wxT("PNG image files (*.png)|*.png"),
334  wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
335 
336  if (wxID_OK == dialog.ShowModal())
337  {
338  try
339  {
340  wxBitmap bmp;
341  m_image->GetBitmap(bmp);
342  bmp.SaveFile(dialog.GetPath(), wxBITMAP_TYPE_PNG);
343  }
344  catch (...)
345  {
346  }
347  }
348 }
349 
350 #endif
351 
353  const std::string& windowCaption, unsigned int initWidth,
354  unsigned int initHeight)
355 {
356  return std::make_shared<CDisplayWindow>(
357  windowCaption, initWidth, initHeight);
358 }
359 /*---------------------------------------------------------------
360  Constructor
361  ---------------------------------------------------------------*/
363  const std::string& windowCaption, unsigned int initWidth,
364  unsigned int initHeight)
365  : CBaseGUIWindow(static_cast<void*>(this), 200, 299, windowCaption)
366 
367 {
368  CBaseGUIWindow::createWxWindow(initWidth, initHeight);
369 }
370 
371 /*---------------------------------------------------------------
372  Destructor
373  ---------------------------------------------------------------*/
375 /** Set cursor style to default (cursorIsCross=false) or to a cross
376  * (cursorIsCross=true) */
377 void CDisplayWindow::setCursorCross(bool cursorIsCross)
378 {
379 #if MRPT_HAS_WXWIDGETS && MRPT_HAS_OPENGL_GLUT
380  const auto* win = (const CWindowDialog*)m_hwnd.get();
381  if (!win) return;
382  win->m_image->SetCursor(
383  *(cursorIsCross ? wxCROSS_CURSOR : wxSTANDARD_CURSOR));
384 #else
385  MRPT_UNUSED_PARAM(cursorIsCross);
386 #endif
387 }
388 
389 /*---------------------------------------------------------------
390  getLastMousePosition
391  ---------------------------------------------------------------*/
393 {
394 #if MRPT_HAS_WXWIDGETS && MRPT_HAS_OPENGL_GLUT
395  const auto* win = (const CWindowDialog*)m_hwnd.get();
396  if (!win) return false;
397  x = win->m_image->m_last_mouse_point.x;
398  y = win->m_image->m_last_mouse_point.y;
399  return true;
400 #else
403  return false;
404 #endif
405 }
406 
407 /*---------------------------------------------------------------
408  showImage
409  ---------------------------------------------------------------*/
411 {
412 #if MRPT_HAS_WXWIDGETS
413  MRPT_START
414 
415  // Send message of new image:
416  wxImage* newImg = mrpt::gui::MRPTImage2wxImage(img);
417 
418  // Send a request to destroy this object:
419  auto* REQ = new WxSubsystem::TRequestToWxMainThread[1];
420  REQ->source2D = this;
421  REQ->OPCODE = 201;
422  REQ->voidPtr = m_hwnd.get();
423  REQ->voidPtr2 = (void*)newImg;
425 
426  MRPT_END
427 #else
429 #endif
430 }
431 
432 /*---------------------------------------------------------------
433  showImageAndPoints
434  ---------------------------------------------------------------*/
436  const CImage& img, const CVectorFloat& x_, const CVectorFloat& y_,
437  const TColor& color, const bool& showNumbers)
438 {
439  std::vector<float> x(x_.size()), y(y_.size());
440  for (size_t i = 0; i < x.size(); i++) x[i] = x_[i];
441  for (size_t i = 0; i < y.size(); i++) y[i] = y_[i];
442  showImageAndPoints(img, x, y, color, showNumbers);
443 }
444 
446  const CImage& img, const std::vector<float>& x, const std::vector<float>& y,
447  const TColor& color, const bool& showNumbers)
448 {
449 #if MRPT_HAS_WXWIDGETS
450  MRPT_START
451  ASSERT_(x.size() == y.size());
452 
453  CImage imgColor = img.colorImage(); // Create a colorimage
454  for (size_t i = 0; i < x.size(); i++)
455  {
456  imgColor.drawMark(round(x[i]), round(y[i]), color, '+');
457 
458  if (showNumbers)
459  {
460  char buf[15];
461  mrpt::system::os::sprintf(buf, 15, "%d", int(i));
462  imgColor.textOut(round(x[i]) - 10, round(y[i]), buf, color);
463  }
464  } // end-for
465  showImage(imgColor);
466  MRPT_END
467 #else
472  MRPT_UNUSED_PARAM(showNumbers);
473 #endif
474 }
475 
476 /*---------------------------------------------------------------
477  plot
478  ---------------------------------------------------------------*/
480 {
481  MRPT_START
482 
483  ASSERT_(x.size() == y.size());
484 
485  const int ox = 40;
486  const int oy = 40;
487 
488  // Suboptimal but...
489  CImage imgColor(640, 480, mrpt::img::CH_RGB);
490  // Draw axis:
491  imgColor.filledRectangle(0, 0, 640, 480, TColor(255, 255, 255));
492  imgColor.line(40, 40, 560, 40, TColor::black(), 3);
493  imgColor.line(40, 40, 40, 440, TColor::black(), 3);
494  imgColor.line(560, 40, 555, 45, TColor::black(), 3);
495  imgColor.line(560, 40, 555, 35, TColor::black(), 3);
496  imgColor.line(40, 440, 35, 435, TColor::black(), 3);
497  imgColor.line(40, 440, 45, 435, TColor::black(), 3);
498 
499  // imgColor.textOut( 550, 25, "x", TColor::black );
500  // imgColor.textOut( 25, 430, "y", TColor::black );
501 
503  CVectorFloat::const_iterator itymx, itymn;
504  itymx = std::max_element(y.begin(), y.end());
505  itymn = std::min_element(y.begin(), y.end());
506  float px = (x[x.size() - 1] - x[0]) / 520;
507  float py = (*itymx - *itymn) / 400;
508 
509  float tpxA = 0, tpyA = 0;
510 
511  for (itx = x.begin(), ity = y.begin(); itx != x.end(); ++itx, ++ity)
512  {
513  float tpx = (*itx - x[0]) / px + ox;
514  float tpy = (*ity - *itymn) / py + oy;
515  imgColor.drawMark(tpx, tpy, TColor(255, 0, 0), 'x');
516  if (itx != x.begin())
517  imgColor.line(tpxA, tpyA, tpx, tpy, TColor(0, 0, 255), 3);
518  tpxA = tpx;
519  tpyA = tpy;
520  } // end for
521 
522  showImage(imgColor);
523 
524  MRPT_END
525 }
526 
527 /*---------------------------------------------------------------
528  plot
529  ---------------------------------------------------------------*/
531 {
532  MRPT_START
533 
534  ASSERT_(y.size() >= 0);
535 
536  const int ox = 40;
537  const int oy = 40;
538 
539  // Suboptimal but...
540  CImage imgColor(640, 480, mrpt::img::CH_RGB);
541  // Draw axis:
542  imgColor.filledRectangle(0, 0, 640, 480, TColor::white());
543  imgColor.line(40, 40, 560, 40, TColor::black(), 3);
544  imgColor.line(40, 40, 40, 440, TColor::black(), 3);
545  imgColor.line(560, 40, 555, 45, TColor::black(), 3);
546  imgColor.line(560, 40, 555, 35, TColor::black(), 3);
547  imgColor.line(40, 440, 35, 435, TColor::black(), 3);
548  imgColor.line(40, 440, 45, 435, TColor::black(), 3);
549 
550  imgColor.textOut(550, 25, "x", TColor::black());
551  imgColor.textOut(25, 430, "y", TColor::black());
552 
554  CVectorFloat::const_iterator itymx, itymn;
555  itymx = std::max_element(y.begin(), y.end());
556  itymn = std::min_element(y.begin(), y.end());
557  float px = y.size() / 520.0f;
558  float py = (*itymx - *itymn) / 400.0f;
559  float tpxA = 0, tpyA = 0;
560 
561  unsigned int k = 0;
562 
563  for (k = 0, ity = y.begin(); ity != y.end(); ++k, ++ity)
564  {
565  float tpx = k / px + ox;
566  float tpy = (*ity - *itymn) / py + oy;
567  imgColor.drawMark(tpx, tpy, TColor::red(), 'x');
568  if (k > 0) imgColor.line(tpxA, tpyA, tpx, tpy, TColor::blue(), 3);
569  tpxA = tpx;
570  tpyA = tpy;
571  } // end for
572 
573  showImage(imgColor);
574 
575  MRPT_END
576 }
577 
578 /*---------------------------------------------------------------
579  resize
580  ---------------------------------------------------------------*/
581 void CDisplayWindow::resize(unsigned int width, unsigned int height)
582 {
583 #if MRPT_HAS_WXWIDGETS
584  if (!isOpen())
585  {
586  cerr << "[CDisplayWindow::resize] Window closed!: " << m_caption
587  << endl;
588  return;
589  }
590 
591  // Send a request to destroy this object:
592  auto* REQ = new WxSubsystem::TRequestToWxMainThread[1];
593  REQ->source2D = this;
594  REQ->OPCODE = 203;
595  REQ->x = width;
596  REQ->y = height;
598 #else
601 #endif
602 }
603 
604 /*---------------------------------------------------------------
605  setPos
606  ---------------------------------------------------------------*/
607 void CDisplayWindow::setPos(int x, int y)
608 {
609 #if MRPT_HAS_WXWIDGETS
610  if (!isOpen())
611  {
612  cerr << "[CDisplayWindow::setPos] Window closed!: " << m_caption
613  << endl;
614  return;
615  }
616 
617  // Send a request to destroy this object:
618  auto* REQ = new WxSubsystem::TRequestToWxMainThread[1];
619  REQ->source2D = this;
620  REQ->OPCODE = 202;
621  REQ->x = x;
622  REQ->y = y;
624 #else
627 #endif
628 }
629 
630 /*---------------------------------------------------------------
631  setWindowTitle
632  ---------------------------------------------------------------*/
634 {
635 #if MRPT_HAS_WXWIDGETS
636  if (!isOpen())
637  {
638  cerr << "[CDisplayWindow::setWindowTitle] Window closed!: " << m_caption
639  << endl;
640  return;
641  }
642 
643  // Send a request to destroy this object:
644  auto* REQ = new WxSubsystem::TRequestToWxMainThread[1];
645  REQ->source2D = this;
646  REQ->OPCODE = 204;
647  REQ->str = str;
649 #else
650  MRPT_UNUSED_PARAM(str);
651 #endif
652 }
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:1143
An event sent by a window upon a mouse click, giving the (x,y) pixel coordinates. ...
#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
unsigned char red[10]
Definition: PbMapMaker.cpp:810
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.
GLenum GLsizei width
Definition: glext.h:3535
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:365
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:1811
void OnKeyDown(wxKeyEvent &event)
GLuint color
Definition: glext.h:8459
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:322
virtual void filledRectangle(int x0, int y0, int x1, int y1, const mrpt::img::TColor color)
Draws a filled rectangle.
Definition: CCanvas.cpp:213
GLint GLvoid * img
Definition: glext.h:3769
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.
The main frame of the wxWidgets application.
Definition: WxSubsystem.h:132
A pair (x,y) of pixel coordinates (integer resolution).
Definition: TPixelCoord.h:39
CDisplayWindow * m_win2D
Definition: WxSubsystem.h:361
The wx dialog for gui::CDisplayWindow.
Definition: WxSubsystem.h:317
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
GLsizei const GLchar ** string
Definition: glext.h:4116
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:942
void setPos(int x, int y) override
Changes the position of the window on the screen.
void OnChar(wxKeyEvent &event)
volatile mrptKeyModifier m_keyPushedModifier
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:305
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: inftrees.h:28
void OnClose(wxCloseEvent &event)
void OnMenuAbout(wxCommandEvent &event)
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(), const bool &showNumbers=false)
Show a given color or grayscale image on the window and print a set of points on it.
#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:367
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.
GLenum GLint GLint y
Definition: glext.h:3542
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:375
CDisplayWindow(const std::string &windowCaption=std::string(), unsigned int initWidth=400, unsigned int initHeight=400)
Constructor.
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
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:20
GLclampf GLclampf blue
Definition: glext.h:3529
GLenum GLint x
Definition: glext.h:3542
mrpt::gui::CDisplayWindow * source2D
Only one of source* can be non-nullptr, indicating the class that generated the request.
Definition: WxSubsystem.h:195
GLenum GLsizei GLsizei height
Definition: glext.h:3558
std::promise< void > m_windowDestroyed
This semaphore will be signaled when the wx window is destroyed.
The base class for GUI window classes.
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:147
#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:23



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 1de0e027c Sat Sep 14 16:15:22 2019 +0200 at sáb sep 14 16:20:14 CEST 2019