Main MRPT website > C++ reference for MRPT 1.5.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 
29 
30 
31 #if MRPT_HAS_WXWIDGETS
32 
33 
34 BEGIN_EVENT_TABLE(CWindowDialog,wxFrame)
35 
36 END_EVENT_TABLE()
37 
38 
39 
40 const long CWindowDialog::ID_IMAGE_BITMAP = wxNewId();
41 const long ID_MENUITEM1 = wxNewId();
42 const long ID_MENUITEM2 = wxNewId();
43 const long ID_MENUITEM3 = wxNewId();
44 
45 
47  wxWindow *parent,
48  wxWindowID winID,
49  int x, int y, int width, int height ) : m_img(NULL)
50 {
51  this->Create(parent,winID,wxPoint(x,y),wxSize(width,height));
52 
53  Connect(wxEVT_PAINT, wxPaintEventHandler(CWindowDialog::wxMRPTImageControl::OnPaint));
54  Connect(wxEVT_MOTION, wxMouseEventHandler(CWindowDialog::wxMRPTImageControl::OnMouseMove));
55  Connect(wxID_ANY,wxEVT_LEFT_DOWN,wxMouseEventHandler(CWindowDialog::wxMRPTImageControl::OnMouseClick));
56 
57  Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::wxMRPTImageControl::OnChar);
58  Connect(wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::wxMRPTImageControl::OnChar);
59 
60 // Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::wxMRPTImageControl::OnChar);
61 // Connect(wxID_ANY,wxEVT_KEY_DOWN,(wxObjectEventFunction)&CWindowDialog::wxMRPTImageControl::OnChar);
62 }
63 
64 CWindowDialog::wxMRPTImageControl::~wxMRPTImageControl()
65 {
66  mrpt::synch::CCriticalSectionLocker lock(& m_img_cs);
67  if (m_img)
68  {
69  delete m_img;
70  m_img=NULL;
71  }
72 }
73 
74 void CWindowDialog::wxMRPTImageControl::OnMouseMove(wxMouseEvent& ev)
75 {
76  //mrpt::synch::CCriticalSectionLocker lock(& m_mouse_cs);
77  m_last_mouse_point = ev.GetPosition();
78 }
79 
80 void CWindowDialog::wxMRPTImageControl::OnMouseClick(wxMouseEvent& ev)
81 {
82  //mrpt::synch::CCriticalSectionLocker lock(& m_mouse_cs);
83  m_last_mouse_click= ev.GetPosition();
84 }
85 
86 void CWindowDialog::wxMRPTImageControl::OnChar(wxKeyEvent & ev)
87 {
88 }
89 
90 void CWindowDialog::wxMRPTImageControl::AssignImage(wxBitmap *img)
91 {
92  mrpt::synch::CCriticalSectionLocker lock(& m_img_cs);
93  if (m_img)
94  {
95  delete m_img;
96  m_img=NULL;
97  }
98 
99  m_img = img;
100 }
101 
102 void CWindowDialog::wxMRPTImageControl::OnPaint(wxPaintEvent &ev)
103 {
104  wxPaintDC dc(this);
105 
106  mrpt::synch::CCriticalSectionLocker lock(& m_img_cs);
107  if (!m_img)
108  {
109  // Erase background:
110  return;
111  }
112 
113  dc.DrawBitmap(*m_img,0,0);
114 }
115 
116 void CWindowDialog::wxMRPTImageControl::GetBitmap(wxBitmap &bmp)
117 {
118  mrpt::synch::CCriticalSectionLocker lock(& m_img_cs);
119  if (!m_img) return;
120  bmp = *m_img;
121 }
122 
123 
124 CWindowDialog::CWindowDialog(
125  CDisplayWindow *win2D,
127  wxWindowID id,
128  const std::string &caption,
129  wxSize initialSize ) :
130  m_win2D( win2D ),
131  m_mainFrame(parent)
132 {
133  Create(
134  parent,
135  id,
136  _U(caption.c_str()),
137  wxDefaultPosition,
138  initialSize,
139  wxDEFAULT_FRAME_STYLE,
140  _T("id"));
141  SetClientSize(initialSize);
142 
143  wxIcon FrameIcon;
144  FrameIcon.CopyFromBitmap(mrpt::gui::WxSubsystem::getMRPTDefaultIcon());
145  SetIcon(FrameIcon);
146 
147  // Create the image object:
149 
150  // wxCLIP_CHILDREN seems to avoid flicker
151  SetWindowStyle( GetWindowStyle() | wxCLIP_CHILDREN );
152 
153  // Menu:
154  wxMenuBar *MenuBar1 = new wxMenuBar();
155 
156  wxMenu *Menu1 = new wxMenu();
157  wxMenuItem *MenuItem3 = new wxMenuItem(Menu1, ID_MENUITEM3, _("Save to file..."), _(""), wxITEM_NORMAL);
158  Menu1->Append(MenuItem3);
159  wxMenuItem *MenuItem1 = new wxMenuItem(Menu1, ID_MENUITEM1, _("Close"), _(""), wxITEM_NORMAL);
160  Menu1->Append(MenuItem1);
161  MenuBar1->Append(Menu1, _("&File"));
162 
163  wxMenu *Menu2 = new wxMenu();
164  wxMenuItem *MenuItem2 = new wxMenuItem(Menu2, ID_MENUITEM2, _("About..."), _(""), wxITEM_NORMAL);
165  Menu2->Append(MenuItem2);
166  MenuBar1->Append(Menu2, _("&Help"));
167 
168  SetMenuBar(MenuBar1);
169 
170 
171  // Events:
172  Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&CWindowDialog::OnClose);
173  Connect(ID_MENUITEM1,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CWindowDialog::OnMenuClose);
174  Connect(ID_MENUITEM2,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CWindowDialog::OnMenuAbout);
175  Connect(ID_MENUITEM3,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CWindowDialog::OnMenuSave);
176 
177 // Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::OnChar);
178  Connect(wxID_ANY,wxEVT_KEY_DOWN,(wxObjectEventFunction)&CWindowDialog::OnChar);
179  //Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::OnChar);
180  Connect(wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::OnChar);
181 
182  m_image->Connect(wxID_ANY,wxEVT_KEY_DOWN,(wxObjectEventFunction)&CWindowDialog::OnChar,NULL,this);
183  //m_image->Connect(wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialog::OnChar,NULL,this);
184  m_image->Connect(wxEVT_SIZE,(wxObjectEventFunction)&CWindowDialog::OnResize,NULL,this);
185 
186  m_image->Connect(wxEVT_LEFT_DOWN,(wxObjectEventFunction)&CWindowDialog::OnMouseDown,NULL,this);
187  m_image->Connect(wxEVT_RIGHT_DOWN,(wxObjectEventFunction)&CWindowDialog::OnMouseDown,NULL,this);
188  m_image->Connect(wxEVT_MOTION, (wxObjectEventFunction)&CWindowDialog::OnMouseMove, NULL, this);
189 
190  // Increment number of windows:
191  //int winCount =
193 
194  //this->Iconize(false);
195 }
196 
197 // Destructor
199 {
200 }
201 
202 // OnClose event:
203 void CWindowDialog::OnClose(wxCloseEvent& event)
204 {
205  // Send the event:
206  bool allow_close=true;
207  try {
208  mrptEventWindowClosed ev(m_win2D, true /* allow close */);
209  m_win2D->publishEvent(ev);
210  allow_close = ev.allow_close;
211  } catch(...){}
212  if (!allow_close) return; // Don't process this close event.
213 
214  // Set the m_hwnd=NULL in our parent object.
216 
217  // Decrement number of windows:
219 
220  // Signal we are destroyed:
222 
223  event.Skip(); // keep processing by parent classes.
224 }
225 
226 void CWindowDialog::OnKeyDown(wxKeyEvent& event)
227 {
228  event.Skip(); // So OnChar event is produced.
229 }
230 
231 void CWindowDialog::OnChar(wxKeyEvent& event)
232 {
233  if (m_win2D)
234  {
235  const int code = event.GetKeyCode();
237 
240  m_win2D->m_keyPushed = true;
241 
242  // Send the event:
243  try {
245  } catch(...){}
246  }
247  event.Skip();
248 }
249 
250 void CWindowDialog::OnResize(wxSizeEvent& event)
251 {
252  // Send the event:
253  if (m_win2D && m_win2D->hasSubscribers())
254  {
255  try {
256  m_win2D->publishEvent( mrptEventWindowResize(m_win2D,event.GetSize().GetWidth(),event.GetSize().GetHeight()));
257  } catch(...) { }
258  }
259  event.Skip(); // so it's processed by the wx system!
260 }
261 
262 void CWindowDialog::OnMouseDown(wxMouseEvent& event)
263 {
264  // Send the event:
265  if (m_win2D && m_win2D->hasSubscribers())
266  {
267  try {
268  m_win2D->publishEvent( mrptEventMouseDown(m_win2D, TPixelCoord(event.GetX(), event.GetY()), event.LeftDown(), event.RightDown() ) );
269  } catch(...) { }
270  }
271  event.Skip(); // so it's processed by the wx system!
272 }
273 
274 void CWindowDialog::OnMouseMove(wxMouseEvent& event)
275 {
276  // Send the event:
277  if (m_win2D && m_win2D->hasSubscribers())
278  {
279  try {
280  m_win2D->publishEvent(mrptEventMouseMove(m_win2D, TPixelCoord(event.GetX(), event.GetY()), event.LeftDown(), event.RightDown()));
281  }
282  catch (...) {}
283  }
284  event.Skip(); // so it's processed by the wx system!
285 }
286 
287 
288 // Menu: Close
289 void CWindowDialog::OnMenuClose(wxCommandEvent& event)
290 {
291  Close();
292 }
293 // Menu: About
294 void CWindowDialog::OnMenuAbout(wxCommandEvent& event)
295 {
296  ::wxMessageBox(_("Image viewer\n Class gui::CDisplayWindow\n MRPT C++ library"),_("About..."));
297 }
298 
299 // Menu: Save to file
300 void CWindowDialog::OnMenuSave(wxCommandEvent& event)
301 {
302  wxFileDialog dialog(
303  this,
304  wxT("Save image as..."),
305  wxT("."),
306  wxT("image.png"),
307  wxT("PNG image files (*.png)|*.png"),
308 #if wxCHECK_VERSION(2, 8, 0)
309  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
310 #else
311  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
312 #endif
313 
314  if (wxID_OK == dialog.ShowModal())
315  {
316  try
317  {
318  wxBitmap bmp;
319  m_image->GetBitmap(bmp);
320  bmp.SaveFile( dialog.GetPath(), wxBITMAP_TYPE_PNG );
321  }
322  catch(...)
323  {
324  }
325  }
326 }
327 
328 
329 #endif
330 
331 CDisplayWindowPtr CDisplayWindow::Create(
332  const std::string &windowCaption,
333  unsigned int initWidth,
334  unsigned int initHeight )
335 {
336  return CDisplayWindowPtr(new CDisplayWindow(windowCaption,initWidth,initHeight));
337 }
338 /*---------------------------------------------------------------
339  Constructor
340  ---------------------------------------------------------------*/
341 CDisplayWindow::CDisplayWindow( const std::string &windowCaption, unsigned int initWidth, unsigned int initHeight )
342  : CBaseGUIWindow(static_cast<void*>(this),200,299, windowCaption),
343  m_enableCursorCoordinates( true )
344 {
345  CBaseGUIWindow::createWxWindow(initWidth, initHeight);
346 }
347 
348 /*---------------------------------------------------------------
349  Destructor
350  ---------------------------------------------------------------*/
352 {
354 }
355 
356 /** Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true) */
357 void CDisplayWindow::setCursorCross(bool cursorIsCross)
358 {
359 #if MRPT_HAS_WXWIDGETS && MRPT_HAS_OPENGL_GLUT
360  const CWindowDialog *win = (const CWindowDialog*) m_hwnd.get();
361  if (!win) return;
362  win->m_image->SetCursor( *(cursorIsCross ? wxCROSS_CURSOR : wxSTANDARD_CURSOR) );
363 #else
364  MRPT_UNUSED_PARAM(cursorIsCross);
365 #endif
366 }
367 
368 /*---------------------------------------------------------------
369  getLastMousePosition
370  ---------------------------------------------------------------*/
372 {
373 #if MRPT_HAS_WXWIDGETS && MRPT_HAS_OPENGL_GLUT
374  const CWindowDialog *win = (const CWindowDialog*) m_hwnd.get();
375  if (!win) return false;
376  x = win->m_image->m_last_mouse_point.x;
377  y = win->m_image->m_last_mouse_point.y;
378  return true;
379 #else
381  return false;
382 #endif
383 }
384 
385 
386 
387 /*---------------------------------------------------------------
388  showImage
389  ---------------------------------------------------------------*/
391 {
392 #if MRPT_HAS_WXWIDGETS
393  MRPT_START
394 
395  // Send message of new image:
396  wxImage *newImg = mrpt::gui::MRPTImage2wxImage( img );
397 
398  // Send a request to destroy this object:
400  REQ->source2D = this;
401  REQ->OPCODE = 201;
402  REQ->voidPtr = m_hwnd.get();
403  REQ->voidPtr2 = (void*) newImg;
405 
406 
407  MRPT_END
408 #else
410 #endif
411 }
412 
413 /*---------------------------------------------------------------
414  showImageAndPoints
415  ---------------------------------------------------------------*/
416 void CDisplayWindow::showImageAndPoints( const CImage &img, const CVectorFloat &x_, const CVectorFloat &y_, const TColor &color, const bool &showNumbers )
417 {
418  std::vector<float> x(x_.size()),y(y_.size());
419  for (size_t i=0;i<x.size();i++) x[i]=x_[i];
420  for (size_t i=0;i<y.size();i++) y[i]=y_[i];
421  showImageAndPoints(img,x,y,color,showNumbers);
422 }
423 
424 
425 void CDisplayWindow::showImageAndPoints( const CImage &img, const std::vector<float> &x, const std::vector<float> &y, const TColor &color, const bool &showNumbers )
426 {
427 #if MRPT_HAS_WXWIDGETS
428  MRPT_START
429  ASSERT_( x.size() == y.size() );
430 
431  CImage imgColor(1,1,3);
432  img.colorImage( imgColor ); // Create a colorimage
433  for(size_t i = 0; i < x.size(); i++)
434  {
435  imgColor.cross(round(x[i]),round(y[i]),color,'+');
436 
437  if( showNumbers )
438  {
439  char buf[15];
440  mrpt::system::os::sprintf( buf, 15, "%d", int(i) );
441  imgColor.textOut( round(x[i]) - 10, round(y[i]), buf, color );
442  }
443  } // end-for
444  showImage(imgColor);
445  MRPT_END
446 #else
449 #endif
450 }
451 
452 /*---------------------------------------------------------------
453  plot
454  ---------------------------------------------------------------*/
456 {
457  MRPT_START
458 
459  ASSERT_( x.size() == y.size() );
460 
461  const int ox = 40;
462  const int oy = 40;
463 
464  // Suboptimal but...
465  CImage imgColor(1,1,3);
466 
467  imgColor.resize( 640, 480, 3, 0 );
468  // Draw axis:
469  imgColor.filledRectangle( 0, 0, 640, 480, TColor(255,255,255) );
470  imgColor.line( 40, 40, 560, 40, TColor::black, 3 );
471  imgColor.line( 40, 40, 40, 440, TColor::black, 3 );
472  imgColor.line( 560, 40, 555, 45, TColor::black, 3 );
473  imgColor.line( 560, 40, 555, 35, TColor::black, 3 );
474  imgColor.line( 40, 440, 35, 435, TColor::black, 3 );
475  imgColor.line( 40, 440, 45, 435, TColor::black, 3 );
476 
477  //imgColor.textOut( 550, 25, "x", TColor::black );
478  //imgColor.textOut( 25, 430, "y", TColor::black );
479 
481  CVectorFloat::const_iterator itymx, itymn;
482  itymx = std::max_element( y.begin(), y.end() );
483  itymn = std::min_element( y.begin(), y.end() );
484  float px = (x[x.size()-1] - x[0])/520;
485  float py = (*itymx - *itymn)/400;
486 
487  float tpxA=0, tpyA=0;
488 
489  for( itx = x.begin(), ity = y.begin(); itx != x.end(); ++itx, ++ity )
490  {
491  float tpx = (*itx-x[0])/px + ox;
492  float tpy = (*ity-*itymn)/py + oy;
493  imgColor.cross( tpx, tpy, TColor(255,0,0), 'x' );
494  if( itx != x.begin() )
495  imgColor.line( tpxA, tpyA, tpx, tpy, TColor(0,0,255), 3 );
496  tpxA = tpx;
497  tpyA = tpy;
498  } // end for
499 
500  showImage( imgColor );
501 
502  MRPT_END
503 }
504 
505 /*---------------------------------------------------------------
506  plot
507  ---------------------------------------------------------------*/
509 {
510  MRPT_START
511 
512  ASSERT_( y.size() >= 0 );
513 
514  const int ox = 40;
515  const int oy = 40;
516 
517  // Suboptimal but...
518  CImage imgColor(1,1,3);
519 
520  imgColor.resize( 640, 480, 3, 0 );
521  // Draw axis:
522  imgColor.filledRectangle( 0, 0, 640, 480, TColor::white);
523  imgColor.line( 40, 40, 560, 40, TColor::black, 3 );
524  imgColor.line( 40, 40, 40, 440, TColor::black, 3 );
525  imgColor.line( 560, 40, 555, 45, TColor::black, 3 );
526  imgColor.line( 560, 40, 555, 35, TColor::black, 3 );
527  imgColor.line( 40, 440, 35, 435, TColor::black, 3 );
528  imgColor.line( 40, 440, 45, 435, TColor::black, 3 );
529 
530  imgColor.textOut( 550, 25, "x", TColor::black );
531  imgColor.textOut( 25, 430, "y", TColor::black );
532 
534  CVectorFloat::const_iterator itymx, itymn;
535  itymx = std::max_element( y.begin(), y.end() );
536  itymn = std::min_element( y.begin(), y.end() );
537  float px = y.size()/520.0f;
538  float py = (*itymx - *itymn)/400.0f;
539  float tpxA=0, tpyA=0;
540 
541  unsigned int k = 0;
542 
543  for( k = 0, ity = y.begin(); ity != y.end(); ++k, ++ity )
544  {
545  float tpx = k/px + ox;
546  float tpy = (*ity-*itymn)/py + oy;
547  imgColor.cross( tpx, tpy, TColor::red, 'x' );
548  if( k > 0 )
549  imgColor.line( tpxA, tpyA, tpx, tpy, TColor::blue, 3 );
550  tpxA = tpx;
551  tpyA = tpy;
552  } // end for
553 
554  showImage( imgColor );
555 
556  MRPT_END
557 }
558 
559 /*---------------------------------------------------------------
560  resize
561  ---------------------------------------------------------------*/
563  unsigned int width,
564  unsigned int height )
565 {
566 #if MRPT_HAS_WXWIDGETS
567  if (!isOpen())
568  {
569  cerr << "[CDisplayWindow::resize] Window closed!: " << m_caption << endl;
570  return;
571  }
572 
573  // Send a request to destroy this object:
575  REQ->source2D = this;
576  REQ->OPCODE = 203;
577  REQ->x = width;
578  REQ->y = height;
580 #else
582 #endif
583 }
584 
585 /*---------------------------------------------------------------
586  setPos
587  ---------------------------------------------------------------*/
588 void CDisplayWindow::setPos( int x, int y )
589 {
590 #if MRPT_HAS_WXWIDGETS
591  if (!isOpen())
592  {
593  cerr << "[CDisplayWindow::setPos] Window closed!: " << m_caption << endl;
594  return;
595  }
596 
597  // Send a request to destroy this object:
599  REQ->source2D = this;
600  REQ->OPCODE = 202;
601  REQ->x = x;
602  REQ->y = y;
604 #else
606 #endif
607 }
608 
609 /*---------------------------------------------------------------
610  setWindowTitle
611  ---------------------------------------------------------------*/
613 {
614 #if MRPT_HAS_WXWIDGETS
615  if (!isOpen())
616  {
617  cerr << "[CDisplayWindow::setWindowTitle] Window closed!: " << m_caption << endl;
618  return;
619  }
620 
621  // Send a request to destroy this object:
623  REQ->source2D = this;
624  REQ->OPCODE = 204;
625  REQ->str = str;
627 #else
628  MRPT_UNUSED_PARAM(str);
629 #endif
630 }
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:397
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:214
A class acquiring a CCriticalSection at its constructor, and releasing it at destructor.
An event sent by a window upon a mouse click, giving the (x,y) pixel coordinates. ...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
void resize(unsigned int width, unsigned int height) MRPT_OVERRIDE
Resizes the window, stretching the image to fit into the display area.
void OnMenuSave(wxCommandEvent &event)
void OnResize(wxSizeEvent &event)
The data structure for each inter-thread request:
Definition: WxSubsystem.h:182
#define _U(x)
Definition: WxSubsystem.h:470
unsigned char red[10]
Definition: PbMapMaker.cpp:976
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:29
#define IMPLEMENTS_MRPT_OBJECT(class_name, base, NameSpace)
This must be inserted in all CObject classes implementation files.
Definition: CObject.h:268
std::string m_caption
The caption of the window.
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
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:209
A pair (x,y) of pixel coordinates (integer resolution).
Definition: TPixelCoord.h:37
virtual ~CDisplayWindow()
Destructor.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:35
mrptKeyModifier
Definition: keycodes.h:158
static wxBitmap getMRPTDefaultIcon()
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:24
bool hasSubscribers() const
Can be called by a derived class before preparing an event for publishing with publishEvent to determ...
Definition: CObservable.h:52
const long ID_MENUITEM3
int OPCODE
Valid codes are: For CDisplayWindow:
Definition: WxSubsystem.h:259
An event sent by a window upon when it&#39;s about to be closed, either manually by the user or programat...
An event sent by a window when the mouse is moved over it.
GLenum GLsizei width
Definition: glext.h:3513
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:330
void OnKeyDown(wxKeyEvent &event)
GLuint color
Definition: glext.h:7093
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:49
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:295
#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:3645
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:329
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:130
void release(unsigned int increaseCount=1)
Increments the count of the semaphore by a given amount.
Definition: CSemaphore.cpp:41
A RGB color - 8bit.
Definition: TColor.h:26
void line(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) MRPT_OVERRIDE
Draws a line.
Definition: CImage.cpp:1301
CDisplayWindow * m_win2D
Definition: WxSubsystem.h:326
The wx dialog for gui::CDisplayWindow.
Definition: WxSubsystem.h:290
wxImage GUI_IMPEXP * MRPTImage2wxImage(const mrpt::utils::CImage &img)
Create a wxImage from a MRPT image.
Definition: WxUtils.cpp:29
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.
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:3919
mrptKeyModifier keyEventToMrptKeyModifier(const wxKeyEvent &ev)
Extracts the key modifiers from a wxKeyEvent.
Definition: WxUtils.cpp:944
virtual void filledRectangle(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color)
Draws a filled rectangle.
Definition: CCanvas.cpp:229
virtual void setCursorCross(bool cursorIsCross) MRPT_OVERRIDE
Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true) ...
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.
static CDisplayWindowPtr Create()
Definition: inftrees.h:28
void OnClose(wxCloseEvent &event)
void OnMenuAbout(wxCommandEvent &event)
synch::CSemaphore m_semWindowDestroyed
This semaphore will be signaled when the wx window is destroyed.
static const long ID_IMAGE_BITMAP
Definition: WxSubsystem.h:332
void setWindowTitle(const std::string &str) MRPT_OVERRIDE
Changes the window title text.
void setPos(int x, int y) MRPT_OVERRIDE
Changes the position of the window on the screen.
#define ASSERT_(f)
int round(const T value)
Returns the closer integer (int) to x.
Definition: round.h:26
void destroyWxWindow()
Must be called by child classes in their destructors. The code cannot be put into this class&#39; destruc...
GLenum GLint GLint y
Definition: glext.h:3516
int BASE_IMPEXP sprintf(char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS 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
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.
void createWxWindow(unsigned int initialWidth, unsigned int initialHeight)
Must be called by child classes just within the constructor.
GLclampf GLclampf blue
Definition: glext.h:3510
virtual bool getLastMousePosition(int &x, int &y) const MRPT_OVERRIDE
Gets the last x,y pixel coordinates of the mouse.
GLenum GLint x
Definition: glext.h:3516
mrpt::gui::CDisplayWindow * source2D
Only one of source* can be non-NULL, indicating the class that generated the request.
Definition: WxSubsystem.h:197
GLenum GLsizei GLsizei height
Definition: glext.h:3523
std::string str
Parameters, depending on OPCODE.
Definition: WxSubsystem.h:210
mrpt::utils::void_ptr_noncopy m_hwnd
The window handle.
The base class for GUI window classes.
static int notifyWindowDestruction()
Atomically decrements the number of windows created with the main frame as parent.



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