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



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