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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020