Main MRPT website > C++ reference for MRPT 1.5.9
WxUtils.h
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 #ifndef MRPT_WX_UTILS_H
10 #define MRPT_WX_UTILS_H
11 
12 #include <mrpt/utils/utils_defs.h>
13 #include <mrpt/utils/CImage.h>
17 #include <mrpt/gui/keycodes.h>
18 
19 #include <mrpt/gui/link_pragmas.h>
20 
21 #if MRPT_HAS_WXWIDGETS
22 
23 #include <wx/sizer.h>
24 #include <wx/statbmp.h>
25 #include <wx/menu.h>
26 #include <wx/toolbar.h>
27 #include <wx/frame.h>
28 #include <wx/timer.h>
29 #include <wx/statusbr.h>
30 #include <wx/msgdlg.h>
31 #include <wx/artprov.h>
32 #include <wx/bitmap.h>
33 #include <wx/intl.h>
34 #include <wx/image.h>
35 #include <wx/string.h>
36 #include <wx/msgdlg.h>
37 #include <wx/panel.h>
38 #include <wx/filedlg.h>
39 #include <wx/progdlg.h>
40 #include <wx/imaglist.h>
41 #include <wx/busyinfo.h>
42 #include <wx/log.h>
43 #include <wx/textdlg.h>
44 #include <wx/dirdlg.h>
45 #include <wx/colordlg.h>
46 #include <wx/dcmemory.h>
47 #include <wx/app.h>
48 #include <wx/pen.h>
49 #include <wx/spinctrl.h>
50 #include <wx/sizer.h>
51 #include <wx/notebook.h>
52 #include <wx/button.h>
53 #include <wx/panel.h>
54 #include <wx/stattext.h>
55 #include <wx/textctrl.h>
56 #include <wx/choice.h>
57 #include <wx/radiobox.h>
58 #include <wx/settings.h>
59 #include <wx/checkbox.h>
60 #include <wx/dc.h>
61 #include <wx/dcclient.h>
62 
63 #endif
64 
65 namespace mrpt
66 {
67  namespace gui
68  {
69  /** \addtogroup mrpt_gui_wxutils Utilities for MRPT-wxWidgets interfacing (in #include <mrpt/gui/WxUtils.h>)
70  * \ingroup mrpt_gui_grp
71 
72  * @{ */
73 #if MRPT_HAS_WXWIDGETS
74 
75 
76 #ifndef _U
77 # ifdef wxUSE_UNICODE
78 # define _U(x) wxString::From8BitData(x)
79 # else
80 # define _U(x) (x)
81 # endif
82 #endif
83 
84 #ifndef WX_START_TRY
85 
86  #define WX_START_TRY \
87  try \
88  {
89 
90  #define WX_END_TRY \
91  } \
92  catch(std::exception &e) \
93  { \
94  wxMessageBox( wxString(e.what(),wxConvUTF8), wxT("Exception"), wxOK, NULL); \
95  } \
96  catch(...) \
97  { \
98  wxMessageBox( _("Untyped exception!"), _("Exception"), wxOK, NULL); \
99  }
100 
101 #endif
102 
103 
104  /** Create a wxImage from a MRPT image. The new object must be freed by the user when not required anymore.
105  * \sa MRPTImage2wxImage
106  */
108 
109  /** Create a wxBitmap from a MRPT image. The new object must be freed by the user when not required anymore.
110  * \sa MRPTImage2wxImage
111  */
113 
114 #if MRPT_HAS_OPENCV
115  /** Create a wxImage from a IPL image. The new object must be freed by the user when not required anymore.
116  * \sa IplImage2wxImage
117  */
118  wxImage GUI_IMPEXP * IplImage2wxImage( void* img );
119 #endif
120 
121  /** Create a MRPT image from a wxImage. The new object must be freed by the user when not required anymore.
122  * It is recommended to use wxImage2MRPTImagePtr instead since smart pointers are safer to manage.
123  * \sa wxImage2MRPTImage, wxImage2MRPTImagePtr
124  */
126 
127  /** Create a MRPT image from a wxImage. The new object is returned as a smart pointer to a CImage object.
128  * \sa wxImage2MRPTImage
129  */
130  mrpt::utils::CImagePtr GUI_IMPEXP wxImage2MRPTImagePtr( const wxImage &img );
131 
132  /** Extracts the key modifiers from a wxKeyEvent */
133  mrptKeyModifier keyEventToMrptKeyModifier( const wxKeyEvent &ev );
134 
135  /** A custom control to display the bitmap and avoid flicker
136  */
137  class GUI_IMPEXP wxMRPTImageControl : public wxPanel
138  {
139  protected:
140  wxBitmap *m_img;
142 
143  wxPoint m_last_mouse_point, m_last_mouse_click;
145 
146  public:
147  wxMRPTImageControl( wxWindow *parent,wxWindowID winID,int x, int y, int width, int height);
148  virtual ~wxMRPTImageControl();
149 
150  void AssignImage(wxBitmap *img); //!< Assigns this image. This object has the ownship of the image and will delete it when appropriate. Remember to call Refresh to display the image.
151  void AssignImage(const mrpt::utils::CImage &img); //!< Assigns this image. Remember to call Refresh to display the image.
152  void GetBitmap(wxBitmap &bmp);
153 
154  void OnPaint(wxPaintEvent &ev);
155  void OnMouseMove(wxMouseEvent& ev);
156  void OnMouseClick(wxMouseEvent& ev);
157 
158  void OnEraseBackground(wxEraseEvent &) { /* Do nothing */ }
159  };
160  // end wxMRPTImageControl -----------
161 
162  /** A panel to select the camera input from all the formats supported by MRPT */
163  class GUI_IMPEXP CPanelCameraSelection: public wxPanel
164  {
165  public:
166 
167  CPanelCameraSelection(wxWindow* parent,wxWindowID id=wxID_ANY);
168  virtual ~CPanelCameraSelection();
169 
171  const std::string &sect,
172  const mrpt::utils::CConfigFileBase *cfg ) const;
173 
175  const std::string &sect,
176  mrpt::utils::CConfigFileBase *cfg ) const;
177 
178  //(*Declarations(CPanelCameraSelection)
179  wxTextCtrl* edRawlogLabel;
180  wxStaticText* StaticText10;
181  wxStaticText* StaticText9;
182  wxPanel* Panel5;
184  wxRadioBox* rbBumblebeeSel;
185  wxButton* btnBrowseVideo;
186  wxStaticText* StaticText2;
187  wxPanel* Panel4;
188  wxCheckBox* cbKinect_3D;
189  wxRadioBox* rbKinect_int;
190  wxCheckBox* cbSR_chConf;
191  wxStaticText* StaticText6;
192  wxSpinCtrl* opencvCamIndex;
193  wxTextCtrl* edIPcamURL;
194  wxStaticText* StaticText8;
195  wxStaticText* StaticText11;
196  wxTextCtrl* edCustomCamConfig;
197  wxTextCtrl* edSR_IP;
198  wxPanel* Panel1;
199  wxChoice* cbOpencvCamType;
200  wxStaticText* StaticText1;
201  wxStaticText* StaticText3;
202  wxRadioBox* rbSR_usb;
203  wxPanel* Panel6;
204  wxButton* btnBrowseRawlog;
205  wxPanel* Panel3;
206  wxCheckBox* cbGrayscale;
207  wxCheckBox* cbSR_chRange;
208  wxStaticText* StaticText5;
209  wxStaticText* StaticText7;
210  wxPanel* pnKinect;
211  wxTextCtrl* edVideoFile;
212  wxCheckBox* cbBumblebeeRectif;
213  wxCheckBox* cbKinect_Int;
214  wxCheckBox* cbSR_chIntensity;
215  wxCheckBox* cbKinect_Depth;
216  wxNotebook* pagesCameras;
217  wxPanel* pnSwissRanger;
218  wxTextCtrl* edRawlogFile;
219  wxTextCtrl* edRawlogImgDir;
220  wxPanel* Panel2;
221  wxCheckBox* cbSR_ch3D;
222  wxStaticText* StaticText4;
224  //*)
225 
226  protected:
227 
228  //(*Identifiers(CPanelCameraSelection)
229  static const long ID_STATICTEXT1;
230  static const long ID_SPINCTRL1;
231  static const long ID_STATICTEXT3;
232  static const long ID_CHOICE1;
233  static const long ID_STATICTEXT6;
234  static const long ID_CHOICE2;
235  static const long ID_PANEL2;
236  static const long ID_STATICTEXT7;
237  static const long ID_TEXTCTRL1;
238  static const long ID_PANEL3;
239  static const long ID_TEXTCTRL6;
240  static const long ID_PANEL4;
241  static const long ID_STATICTEXT8;
242  static const long ID_TEXTCTRL2;
243  static const long ID_BUTTON7;
244  static const long ID_PANEL5;
245  static const long ID_STATICTEXT9;
246  static const long ID_TEXTCTRL3;
247  static const long ID_BUTTON8;
248  static const long ID_STATICTEXT5;
249  static const long ID_TEXTCTRL7;
250  static const long ID_BUTTON9;
251  static const long ID_STATICTEXT10;
252  static const long ID_TEXTCTRL8;
253  static const long ID_STATICTEXT11;
254  static const long ID_PANEL6;
255  static const long ID_RADIOBOX1;
256  static const long ID_CHECKBOX1;
257  static const long ID_STATICTEXT2;
258  static const long ID_PANEL7;
259  static const long ID_RADIOBOX2;
260  static const long ID_STATICTEXT4;
261  static const long ID_TEXTCTRL4;
262  static const long ID_CHECKBOX3;
263  static const long ID_CHECKBOX4;
264  static const long ID_CHECKBOX5;
265  static const long ID_CHECKBOX6;
266  static const long ID_PANEL1;
267  static const long ID_CHECKBOX7;
268  static const long ID_CHECKBOX8;
269  static const long ID_CHECKBOX9;
270  static const long ID_RADIOBOX3;
271  static const long ID_PANEL8;
272  static const long ID_NOTEBOOK1;
273  static const long ID_CHECKBOX2;
274  //*)
275 
276  private:
277 
278  //(*Handlers(CPanelCameraSelection)
279  //*)
280  void OnbtnBrowseVideoClick(wxCommandEvent& event);
281  void OnbtnBrowseRawlogClick(wxCommandEvent& event);
282  void OnbtnBrowseRawlogDirClick(wxCommandEvent& event);
283 
284  DECLARE_EVENT_TABLE()
285  };
286  // end -----------
287 
288  /** Auxiliary structures used internally to mrpt */
289  namespace detail
290  {
292  {
295  };
296  }
297 
298 #endif
299  /** @} */
300  } // End of namespace
301 } // End of namespace
302 
303 #endif
This class provides simple critical sections functionality.
static const long ID_BUTTON9
Definition: WxUtils.h:250
static const long ID_CHOICE1
Definition: WxUtils.h:232
static const long ID_PANEL3
Definition: WxUtils.h:238
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
static const long ID_SPINCTRL1
Definition: WxUtils.h:230
static const long ID_STATICTEXT9
Definition: WxUtils.h:245
static const long ID_STATICTEXT1
Definition: WxUtils.h:229
static const long ID_CHECKBOX4
Definition: WxUtils.h:263
static const long ID_RADIOBOX3
Definition: WxUtils.h:270
static const long ID_RADIOBOX2
Definition: WxUtils.h:259
static const long ID_PANEL1
Definition: WxUtils.h:266
static const long ID_CHECKBOX1
Definition: WxUtils.h:256
static const long ID_TEXTCTRL6
Definition: WxUtils.h:239
mrptKeyModifier
Definition: keycodes.h:158
static const long ID_NOTEBOOK1
Definition: WxUtils.h:272
static const long ID_CHECKBOX6
Definition: WxUtils.h:265
mrpt::utils::CImagePtr GUI_IMPEXP wxImage2MRPTImagePtr(const wxImage &img)
Create a MRPT image from a wxImage.
Definition: WxUtils.cpp:280
static const long ID_CHECKBOX5
Definition: WxUtils.h:264
void OnEraseBackground(wxEraseEvent &)
Definition: WxUtils.h:158
wxImage GUI_IMPEXP * IplImage2wxImage(void *img)
Create a wxImage from a IPL image.
Definition: WxUtils.cpp:221
GLenum GLsizei width
Definition: glext.h:3513
static const long ID_CHECKBOX3
Definition: WxUtils.h:262
static const long ID_TEXTCTRL8
Definition: WxUtils.h:252
This class allows loading and storing values and vectors of different types from a configuration text...
static const long ID_TEXTCTRL3
Definition: WxUtils.h:246
This class implements a config file-like interface over a memory-stored string list.
wxBitmap GUI_IMPEXP * MRPTImage2wxBitmap(const mrpt::utils::CImage &img)
Create a wxBitmap from a MRPT image.
Definition: WxUtils.cpp:158
static const long ID_TEXTCTRL1
Definition: WxUtils.h:237
mrpt::synch::CCriticalSection m_mouse_cs
Definition: WxUtils.h:144
static const long ID_CHECKBOX8
Definition: WxUtils.h:268
mrpt::utils::CImage GUI_IMPEXP * wxImage2MRPTImage(const wxImage &img)
Create a MRPT image from a wxImage.
Definition: WxUtils.cpp:265
static const long ID_CHECKBOX7
Definition: WxUtils.h:267
GLint GLvoid * img
Definition: glext.h:3645
static const long ID_CHOICE2
Definition: WxUtils.h:234
static const long ID_STATICTEXT6
Definition: WxUtils.h:233
wxImage GUI_IMPEXP * MRPTImage2wxImage(const mrpt::utils::CImage &img)
Create a wxImage from a MRPT image.
Definition: WxUtils.cpp:29
static const long ID_TEXTCTRL2
Definition: WxUtils.h:242
static const long ID_CHECKBOX2
Definition: WxUtils.h:273
static const long ID_PANEL2
Definition: WxUtils.h:235
static const long ID_STATICTEXT3
Definition: WxUtils.h:231
static const long ID_PANEL5
Definition: WxUtils.h:244
GLsizei const GLchar ** string
Definition: glext.h:3919
mrptKeyModifier keyEventToMrptKeyModifier(const wxKeyEvent &ev)
Extracts the key modifiers from a wxKeyEvent.
Definition: WxUtils.cpp:944
static const long ID_STATICTEXT2
Definition: WxUtils.h:257
mrpt::synch::CCriticalSection m_img_cs
Definition: WxUtils.h:141
static const long ID_STATICTEXT11
Definition: WxUtils.h:253
void HWDRIVERS_IMPEXP readConfigIntoVideoSourcePanel(void *panel, const std::string &in_cfgfile_section_name, const mrpt::utils::CConfigFileBase *in_cfgfile)
Parse the given section of the given configuration file and set accordingly the controls of the wxWid...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A custom control to display the bitmap and avoid flicker.
Definition: WxUtils.h:137
static const long ID_STATICTEXT10
Definition: WxUtils.h:251
static const long ID_TEXTCTRL7
Definition: WxUtils.h:249
static const long ID_TEXTCTRL4
Definition: WxUtils.h:261
static const long ID_STATICTEXT5
Definition: WxUtils.h:248
A panel to select the camera input from all the formats supported by MRPT.
Definition: WxUtils.h:163
static const long ID_CHECKBOX9
Definition: WxUtils.h:269
GLenum GLint GLint y
Definition: glext.h:3516
static const long ID_PANEL8
Definition: WxUtils.h:271
static const long ID_RADIOBOX1
Definition: WxUtils.h:255
static const long ID_PANEL4
Definition: WxUtils.h:240
mrpt::utils::CConfigFileMemory selectedConfig
Definition: WxUtils.h:293
static const long ID_PANEL7
Definition: WxUtils.h:258
void HWDRIVERS_IMPEXP writeConfigFromVideoSourcePanel(void *panel, const std::string &in_cfgfile_section_name, mrpt::utils::CConfigFileBase *out_cfgfile)
Parse the user options in the wxWidgets "panel" and write the configuration into the given section of...
GLenum GLint x
Definition: glext.h:3516
GLenum GLsizei GLsizei height
Definition: glext.h:3523
static const long ID_BUTTON7
Definition: WxUtils.h:243
static const long ID_STATICTEXT4
Definition: WxUtils.h:260
static const long ID_STATICTEXT7
Definition: WxUtils.h:236
static const long ID_PANEL6
Definition: WxUtils.h:254
static const long ID_BUTTON8
Definition: WxUtils.h:247
static const long ID_STATICTEXT8
Definition: WxUtils.h:241



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