Main MRPT website > C++ reference for MRPT 1.9.9
CDisplayWindow.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, 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 
10 #include "gui-precomp.h" // Precompiled headers
11 
13 #include <mrpt/system/os.h>
14 #include <mrpt/utils/CImage.h>
15 #include <mrpt/utils/round.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::utils;
24 using namespace mrpt::system;
25 using namespace std;
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, _U(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  wxMenuBar* MenuBar1 = new wxMenuBar();
144 
145  wxMenu* 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  wxMenu* 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  {
273  m_win2D, event.GetSize().GetWidth(),
274  event.GetSize().GetHeight()));
275  }
276  catch (...)
277  {
278  }
279  }
280  event.Skip(); // so it's processed by the wx system!
281 }
282 
283 void CWindowDialog::OnMouseDown(wxMouseEvent& event)
284 {
285  // Send the event:
286  if (m_win2D && m_win2D->hasSubscribers())
287  {
288  try
289  {
292  m_win2D, TPixelCoord(event.GetX(), event.GetY()),
293  event.LeftDown(), event.RightDown()));
294  }
295  catch (...)
296  {
297  }
298  }
299  event.Skip(); // so it's processed by the wx system!
300 }
301 
302 void CWindowDialog::OnMouseMove(wxMouseEvent& event)
303 {
304  // Send the event:
305  if (m_win2D && m_win2D->hasSubscribers())
306  {
307  try
308  {
311  m_win2D, TPixelCoord(event.GetX(), event.GetY()),
312  event.LeftDown(), event.RightDown()));
313  }
314  catch (...)
315  {
316  }
317  }
318  event.Skip(); // so it's processed by the wx system!
319 }
320 
321 // Menu: Close
322 void CWindowDialog::OnMenuClose(wxCommandEvent& event) { Close(); }
323 // Menu: About
324 void CWindowDialog::OnMenuAbout(wxCommandEvent& event)
325 {
326  ::wxMessageBox(
327  _("Image viewer\n Class gui::CDisplayWindow\n MRPT C++ library"),
328  _("About..."));
329 }
330 
331 // Menu: Save to file
332 void CWindowDialog::OnMenuSave(wxCommandEvent& event)
333 {
334  wxFileDialog dialog(
335  this, wxT("Save image as..."), wxT("."), wxT("image.png"),
336  wxT("PNG image files (*.png)|*.png"),
337 #if wxCHECK_VERSION(2, 8, 0)
338  wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
339 #else
340  wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
341 #endif
342 
343  if (wxID_OK == dialog.ShowModal())
344  {
345  try
346  {
347  wxBitmap bmp;
348  m_image->GetBitmap(bmp);
349  bmp.SaveFile(dialog.GetPath(), wxBITMAP_TYPE_PNG);
350  }
351  catch (...)
352  {
353  }
354  }
355 }
356 
357 #endif
358 
360  const std::string& windowCaption, unsigned int initWidth,
361  unsigned int initHeight)
362 {
363  return CDisplayWindow::Ptr(
364  new CDisplayWindow(windowCaption, initWidth, initHeight));
365 }
366 /*---------------------------------------------------------------
367  Constructor
368  ---------------------------------------------------------------*/
370  const std::string& windowCaption, unsigned int initWidth,
371  unsigned int initHeight)
372  : CBaseGUIWindow(static_cast<void*>(this), 200, 299, windowCaption),
373  m_enableCursorCoordinates(true)
374 {
375  CBaseGUIWindow::createWxWindow(initWidth, initHeight);
376 }
377 
378 /*---------------------------------------------------------------
379  Destructor
380  ---------------------------------------------------------------*/
382 /** Set cursor style to default (cursorIsCross=false) or to a cross
383  * (cursorIsCross=true) */
384 void CDisplayWindow::setCursorCross(bool cursorIsCross)
385 {
386 #if MRPT_HAS_WXWIDGETS && MRPT_HAS_OPENGL_GLUT
387  const CWindowDialog* win = (const CWindowDialog*)m_hwnd.get();
388  if (!win) return;
389  win->m_image->SetCursor(
390  *(cursorIsCross ? wxCROSS_CURSOR : wxSTANDARD_CURSOR));
391 #else
392  MRPT_UNUSED_PARAM(cursorIsCross);
393 #endif
394 }
395 
396 /*---------------------------------------------------------------
397  getLastMousePosition
398  ---------------------------------------------------------------*/
400 {
401 #if MRPT_HAS_WXWIDGETS && MRPT_HAS_OPENGL_GLUT
402  const CWindowDialog* win = (const CWindowDialog*)m_hwnd.get();
403  if (!win) return false;
404  x = win->m_image->m_last_mouse_point.x;
405  y = win->m_image->m_last_mouse_point.y;
406  return true;
407 #else
410  return false;
411 #endif
412 }
413 
414 /*---------------------------------------------------------------
415  showImage
416  ---------------------------------------------------------------*/
418 {
419 #if MRPT_HAS_WXWIDGETS
420  MRPT_START
421 
422  // Send message of new image:
423  wxImage* newImg = mrpt::gui::MRPTImage2wxImage(img);
424 
425  // Send a request to destroy this object:
428  REQ->source2D = this;
429  REQ->OPCODE = 201;
430  REQ->voidPtr = m_hwnd.get();
431  REQ->voidPtr2 = (void*)newImg;
433 
434  MRPT_END
435 #else
437 #endif
438 }
439 
440 /*---------------------------------------------------------------
441  showImageAndPoints
442  ---------------------------------------------------------------*/
444  const CImage& img, const CVectorFloat& x_, const CVectorFloat& y_,
445  const TColor& color, const bool& showNumbers)
446 {
447  std::vector<float> x(x_.size()), y(y_.size());
448  for (size_t i = 0; i < x.size(); i++) x[i] = x_[i];
449  for (size_t i = 0; i < y.size(); i++) y[i] = y_[i];
450  showImageAndPoints(img, x, y, color, showNumbers);
451 }
452 
454  const CImage& img, const std::vector<float>& x, const std::vector<float>& y,
455  const TColor& color, const bool& showNumbers)
456 {
457 #if MRPT_HAS_WXWIDGETS
458  MRPT_START
459  ASSERT_(x.size() == y.size());
460 
461  CImage imgColor(1, 1, 3);
462  img.colorImage(imgColor); // Create a colorimage
463  for (size_t i = 0; i < x.size(); i++)
464  {
465  imgColor.cross(round(x[i]), round(y[i]), color, '+');
466 
467  if (showNumbers)
468  {
469  char buf[15];
470  mrpt::system::os::sprintf(buf, 15, "%d", int(i));
471  imgColor.textOut(round(x[i]) - 10, round(y[i]), buf, color);
472  }
473  } // end-for
474  showImage(imgColor);
475  MRPT_END
476 #else
481  MRPT_UNUSED_PARAM(showNumbers);
482 #endif
483 }
484 
485 /*---------------------------------------------------------------
486  plot
487  ---------------------------------------------------------------*/
489 {
490  MRPT_START
491 
492  ASSERT_(x.size() == y.size());
493 
494  const int ox = 40;
495  const int oy = 40;
496 
497  // Suboptimal but...
498  CImage imgColor(1, 1, 3);
499 
500  imgColor.resize(640, 480, 3, 0);
501  // Draw axis:
502  imgColor.filledRectangle(0, 0, 640, 480, TColor(255, 255, 255));
503  imgColor.line(40, 40, 560, 40, TColor::black(), 3);
504  imgColor.line(40, 40, 40, 440, TColor::black(), 3);
505  imgColor.line(560, 40, 555, 45, TColor::black(), 3);
506  imgColor.line(560, 40, 555, 35, TColor::black(), 3);
507  imgColor.line(40, 440, 35, 435, TColor::black(), 3);
508  imgColor.line(40, 440, 45, 435, TColor::black(), 3);
509 
510  // imgColor.textOut( 550, 25, "x", TColor::black );
511  // imgColor.textOut( 25, 430, "y", TColor::black );
512 
514  CVectorFloat::const_iterator itymx, itymn;
515  itymx = std::max_element(y.begin(), y.end());
516  itymn = std::min_element(y.begin(), y.end());
517  float px = (x[x.size() - 1] - x[0]) / 520;
518  float py = (*itymx - *itymn) / 400;
519 
520  float tpxA = 0, tpyA = 0;
521 
522  for (itx = x.begin(), ity = y.begin(); itx != x.end(); ++itx, ++ity)
523  {
524  float tpx = (*itx - x[0]) / px + ox;
525  float tpy = (*ity - *itymn) / py + oy;
526  imgColor.cross(tpx, tpy, TColor(255, 0, 0), 'x');
527  if (itx != x.begin())
528  imgColor.line(tpxA, tpyA, tpx, tpy, TColor(0, 0, 255), 3);
529  tpxA = tpx;
530  tpyA = tpy;
531  } // end for
532 
533  showImage(imgColor);
534 
535  MRPT_END
536 }
537 
538 /*---------------------------------------------------------------
539  plot
540  ---------------------------------------------------------------*/
542 {
543  MRPT_START
544 
545  ASSERT_(y.size() >= 0);
546 
547  const int ox = 40;
548  const int oy = 40;
549 
550  // Suboptimal but...
551  CImage imgColor(1, 1, 3);
552 
553  imgColor.resize(640, 480, 3, 0);
554  // Draw axis:
555  imgColor.filledRectangle(0, 0, 640, 480, TColor::white());
556  imgColor.line(40, 40, 560, 40, TColor::black(), 3);
557  imgColor.line(40, 40, 40, 440, TColor::black(), 3);
558  imgColor.line(560, 40, 555, 45, TColor::black(), 3);
559  imgColor.line(560, 40, 555, 35, TColor::black(), 3);
560  imgColor.line(40, 440, 35, 435, TColor::black(), 3);
561  imgColor.line(40, 440, 45, 435, TColor::black(), 3);
562 
563  imgColor.textOut(550, 25, "x", TColor::black());
564  imgColor.textOut(25, 430, "y", TColor::black());
565 
567  CVectorFloat::const_iterator itymx, itymn;
568  itymx = std::max_element(y.begin(), y.end());
569  itymn = std::min_element(y.begin(), y.end());
570  float px = y.size() / 520.0f;
571  float py = (*itymx - *itymn) / 400.0f;
572  float tpxA = 0, tpyA = 0;
573 
574  unsigned int k = 0;
575 
576  for (k = 0, ity = y.begin(); ity != y.end(); ++k, ++ity)
577  {
578  float tpx = k / px + ox;
579  float tpy = (*ity - *itymn) / py + oy;
580  imgColor.cross(tpx, tpy, TColor::red(), 'x');
581  if (k > 0) imgColor.line(tpxA, tpyA, tpx, tpy, TColor::blue(), 3);
582  tpxA = tpx;
583  tpyA = tpy;
584  } // end for
585 
586  showImage(imgColor);
587 
588  MRPT_END
589 }
590 
591 /*---------------------------------------------------------------
592  resize
593  ---------------------------------------------------------------*/
594 void CDisplayWindow::resize(unsigned int width, unsigned int height)
595 {
596 #if MRPT_HAS_WXWIDGETS
597  if (!isOpen())
598  {
599  cerr << "[CDisplayWindow::resize] Window closed!: " << m_caption
600  << endl;
601  return;
602  }
603 
604  // Send a request to destroy this object:
607  REQ->source2D = this;
608  REQ->OPCODE = 203;
609  REQ->x = width;
610  REQ->y = height;
612 #else
615 #endif
616 }
617 
618 /*---------------------------------------------------------------
619  setPos
620  ---------------------------------------------------------------*/
621 void CDisplayWindow::setPos(int x, int y)
622 {
623 #if MRPT_HAS_WXWIDGETS
624  if (!isOpen())
625  {
626  cerr << "[CDisplayWindow::setPos] Window closed!: " << m_caption
627  << endl;
628  return;
629  }
630 
631  // Send a request to destroy this object:
634  REQ->source2D = this;
635  REQ->OPCODE = 202;
636  REQ->x = x;
637  REQ->y = y;
639 #else
642 #endif
643 }
644 
645 /*---------------------------------------------------------------
646  setWindowTitle
647  ---------------------------------------------------------------*/
649 {
650 #if MRPT_HAS_WXWIDGETS
651  if (!isOpen())
652  {
653  cerr << "[CDisplayWindow::setWindowTitle] Window closed!: " << m_caption
654  << endl;
655  return;
656  }
657 
658  // Send a request to destroy this object:
661  REQ->source2D = this;
662  REQ->OPCODE = 204;
663  REQ->str = str;
665 #else
666  MRPT_UNUSED_PARAM(str);
667 #endif
668 }
virtual void textOut(int x0, int y0, const std::string &str, const mrpt::utils::TColor color)
Renders 2D text using bitmap fonts.
Definition: CCanvas.cpp:371
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 * voidPtr
Parameters, depending on OPCODE.
Definition: WxSubsystem.h:230
An event sent by a window upon a mouse click, giving the (x,y) pixel coordinates. ...
void showImageAndPoints(const mrpt::utils::CImage &img, const mrpt::math::CVectorFloat &x, const mrpt::math::CVectorFloat &y, const mrpt::utils::TColor &color=mrpt::utils::TColor::red(), const bool &showNumbers=false)
Show a given color or grayscale image on the window and print a set of points on it.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void OnMenuSave(wxCommandEvent &event)
void OnResize(wxSizeEvent &event)
The data structure for each inter-thread request:
Definition: WxSubsystem.h:193
#define _U(x)
Definition: WxSubsystem.h:506
unsigned char red[10]
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
virtual 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.
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:118
static int notifyWindowCreation()
Atomically increments the number of windows created with the main frame as parent.
void resize(unsigned int width, unsigned int height, TImageChannels nChannels, bool originTopLeft)
Changes the size of the image, erasing previous contents (does NOT scale its current content...
Definition: CImage.h:249
A pair (x,y) of pixel coordinates (integer resolution).
Definition: TPixelCoord.h:38
virtual ~CDisplayWindow()
Destructor.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:42
mrptKeyModifier
Definition: keycodes.h:159
static wxBitmap getMRPTDefaultIcon()
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:27
bool hasSubscribers() const
Can be called by a derived class before preparing an event for publishing with publishEvent to determ...
Definition: CObservable.h:57
const long ID_MENUITEM3
int OPCODE
Valid codes are: For CDisplayWindow:
Definition: WxSubsystem.h:300
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:3531
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:378
void OnKeyDown(wxKeyEvent &event)
GLuint color
Definition: glext.h:8300
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:47
void OnMouseDown(wxMouseEvent &event)
void OnMenuClose(wxCommandEvent &event)
const long ID_MENUITEM1
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
A custom control to display the bitmap and avoid flicker.
Definition: WxSubsystem.h:337
#define MRPT_END
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
GLint GLvoid * img
Definition: glext.h:3763
void cross(int x0, int y0, const mrpt::utils::TColor color, char type, unsigned int size=5, unsigned int width=1)
Draw a cross.
Definition: CCanvas.cpp:307
virtual 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:136
A RGB color - 8bit.
Definition: TColor.h:25
CDisplayWindow * m_win2D
Definition: WxSubsystem.h:374
The wx dialog for gui::CDisplayWindow.
Definition: WxSubsystem.h:332
wxImage * MRPTImage2wxImage(const mrpt::utils::CImage &img)
Create a wxImage from a MRPT image.
Definition: WxUtils.cpp:29
An event sent by a window upon a char pressed by the user.
const long ID_MENUITEM2
void OnMouseMove(wxMouseEvent &event)
GLsizei const GLchar ** string
Definition: glext.h:4101
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:1135
std::shared_ptr< CDisplayWindow > Ptr
void setPos(int x, int y) override
Changes the position of the window on the screen.
virtual void filledRectangle(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color)
Draws a filled rectangle.
Definition: CCanvas.cpp:216
void OnChar(wxKeyEvent &event)
volatile mrptKeyModifier m_keyPushedModifier
void showImage(const mrpt::utils::CImage &img)
Show a given color or grayscale image on the window.
#define MRPT_START
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)
static const long ID_IMAGE_BITMAP
Definition: WxSubsystem.h:380
#define ASSERT_(f)
int round(const T value)
Returns the closer integer (int) to x.
Definition: round.h:25
void destroyWxWindow()
Must be called by child classes in their destructors.
GLenum GLint GLint y
Definition: glext.h:3538
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:16
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.
GLclampf GLclampf blue
Definition: glext.h:3525
GLenum GLint x
Definition: glext.h:3538
mrpt::gui::CDisplayWindow * source2D
Only one of source* can be non-nullptr, indicating the class that generated the request.
Definition: WxSubsystem.h:210
GLenum GLsizei GLsizei height
Definition: glext.h:3554
std::string str
Parameters, depending on OPCODE.
Definition: WxSubsystem.h:226
std::promise< void > m_windowDestroyed
This semaphore will be signaled when the wx window is destroyed.
mrpt::utils::void_ptr_noncopy m_hwnd
The window handle.
void line(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) override
Draws a line.
Definition: CImage.cpp:1304
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:188



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019