Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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/synch.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 #if MRPT_HAS_WXWIDGETS
70 
71 
72 #ifndef _U
73 # ifdef wxUSE_UNICODE
74 # define _U(x) wxString::From8BitData(x)
75 # else
76 # define _U(x) (x)
77 # endif
78 #endif
79 
80 #ifndef WX_START_TRY
81 
82  #define WX_START_TRY \
83  try \
84  {
85 
86  #define WX_END_TRY \
87  } \
88  catch(std::exception &e) \
89  { \
90  wxMessageBox( wxString(e.what(),wxConvUTF8), wxT("Exception"), wxOK, NULL); \
91  } \
92  catch(...) \
93  { \
94  wxMessageBox( _("Untyped exception!"), _("Exception"), wxOK, NULL); \
95  }
96 
97 #endif
98 
99 
100  /** Create a wxImage from a MRPT image. The new object must be freed by the user when not required anymore.
101  * \sa MRPTImage2wxImage
102  */
103  wxImage GUI_IMPEXP * MRPTImage2wxImage( const mrpt::utils::CImage &img );
104 
105  /** Create a wxBitmap from a MRPT image. The new object must be freed by the user when not required anymore.
106  * \sa MRPTImage2wxImage
107  */
108  wxBitmap GUI_IMPEXP * MRPTImage2wxBitmap( const mrpt::utils::CImage &img );
109 
110 #if MRPT_HAS_OPENCV
111  /** Create a wxImage from a IPL image. The new object must be freed by the user when not required anymore.
112  * \sa IplImage2wxImage
113  */
114  wxImage GUI_IMPEXP * IplImage2wxImage( void* img );
115 #endif
116 
117  /** Create a MRPT image from a wxImage. The new object must be freed by the user when not required anymore.
118  * It is recommended to use wxImage2MRPTImagePtr instead since smart pointers are safer to manage.
119  * \sa wxImage2MRPTImage, wxImage2MRPTImagePtr
120  */
121  mrpt::utils::CImage GUI_IMPEXP * wxImage2MRPTImage( const wxImage &img );
122 
123  /** Create a MRPT image from a wxImage. The new object is returned as a smart pointer to a CImage object.
124  * \sa wxImage2MRPTImage
125  */
126  mrpt::utils::CImagePtr GUI_IMPEXP wxImage2MRPTImagePtr( const wxImage &img );
127 
128  /** Extracts the key modifiers from a wxKeyEvent */
129  mrptKeyModifier keyEventToMrptKeyModifier( const wxKeyEvent &ev );
130 
131  /** A custom control to display the bitmap and avoid flicker
132  */
133  class GUI_IMPEXP wxMRPTImageControl : public wxPanel
134  {
135  protected:
136  wxBitmap *m_img;
138 
139  wxPoint m_last_mouse_point, m_last_mouse_click;
141 
142  public:
143  wxMRPTImageControl( wxWindow *parent,wxWindowID winID,int x, int y, int width, int height);
144  virtual ~wxMRPTImageControl();
145 
146  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.
147  void AssignImage(const mrpt::utils::CImage &img); //!< Assigns this image. Remember to call Refresh to display the image.
148  void GetBitmap(wxBitmap &bmp);
149 
150  void OnPaint(wxPaintEvent &ev);
151  void OnMouseMove(wxMouseEvent& ev);
152  void OnMouseClick(wxMouseEvent& ev);
153 
154  void OnEraseBackground(wxEraseEvent &) { /* Do nothing */ }
155  };
156  // end wxMRPTImageControl -----------
157 
158  /** A panel to select the camera input from all the formats supported by MRPT */
159  class GUI_IMPEXP CPanelCameraSelection: public wxPanel
160  {
161  public:
162 
163  CPanelCameraSelection(wxWindow* parent,wxWindowID id=wxID_ANY);
164  virtual ~CPanelCameraSelection();
165 
167  const std::string &sect,
168  const mrpt::utils::CConfigFileBase *cfg ) const;
169 
171  const std::string &sect,
172  mrpt::utils::CConfigFileBase *cfg ) const;
173 
174  //(*Declarations(CPanelCameraSelection)
175  wxTextCtrl* edRawlogLabel;
176  wxStaticText* StaticText10;
177  wxStaticText* StaticText9;
178  wxPanel* Panel5;
179  wxButton* btnBrowseRawlogDir;
180  wxRadioBox* rbBumblebeeSel;
181  wxButton* btnBrowseVideo;
182  wxStaticText* StaticText2;
183  wxPanel* Panel4;
184  wxCheckBox* cbKinect_3D;
185  wxRadioBox* rbKinect_int;
186  wxCheckBox* cbSR_chConf;
187  wxStaticText* StaticText6;
188  wxSpinCtrl* opencvCamIndex;
189  wxTextCtrl* edIPcamURL;
190  wxStaticText* StaticText8;
191  wxStaticText* StaticText11;
192  wxTextCtrl* edCustomCamConfig;
193  wxTextCtrl* edSR_IP;
194  wxPanel* Panel1;
195  wxChoice* cbOpencvCamType;
196  wxStaticText* StaticText1;
197  wxStaticText* StaticText3;
198  wxRadioBox* rbSR_usb;
199  wxPanel* Panel6;
200  wxButton* btnBrowseRawlog;
201  wxPanel* Panel3;
202  wxCheckBox* cbGrayscale;
203  wxCheckBox* cbSR_chRange;
204  wxStaticText* StaticText5;
205  wxStaticText* StaticText7;
206  wxPanel* pnKinect;
207  wxTextCtrl* edVideoFile;
208  wxCheckBox* cbBumblebeeRectif;
209  wxCheckBox* cbKinect_Int;
210  wxCheckBox* cbSR_chIntensity;
211  wxCheckBox* cbKinect_Depth;
212  wxNotebook* pagesCameras;
213  wxPanel* pnSwissRanger;
214  wxTextCtrl* edRawlogFile;
215  wxTextCtrl* edRawlogImgDir;
216  wxPanel* Panel2;
217  wxCheckBox* cbSR_ch3D;
218  wxStaticText* StaticText4;
219  wxChoice* cbOpencvResolution;
220  //*)
221 
222  protected:
223 
224  //(*Identifiers(CPanelCameraSelection)
225  static const long ID_STATICTEXT1;
226  static const long ID_SPINCTRL1;
227  static const long ID_STATICTEXT3;
228  static const long ID_CHOICE1;
229  static const long ID_STATICTEXT6;
230  static const long ID_CHOICE2;
231  static const long ID_PANEL2;
232  static const long ID_STATICTEXT7;
233  static const long ID_TEXTCTRL1;
234  static const long ID_PANEL3;
235  static const long ID_TEXTCTRL6;
236  static const long ID_PANEL4;
237  static const long ID_STATICTEXT8;
238  static const long ID_TEXTCTRL2;
239  static const long ID_BUTTON7;
240  static const long ID_PANEL5;
241  static const long ID_STATICTEXT9;
242  static const long ID_TEXTCTRL3;
243  static const long ID_BUTTON8;
244  static const long ID_STATICTEXT5;
245  static const long ID_TEXTCTRL7;
246  static const long ID_BUTTON9;
247  static const long ID_STATICTEXT10;
248  static const long ID_TEXTCTRL8;
249  static const long ID_STATICTEXT11;
250  static const long ID_PANEL6;
251  static const long ID_RADIOBOX1;
252  static const long ID_CHECKBOX1;
253  static const long ID_STATICTEXT2;
254  static const long ID_PANEL7;
255  static const long ID_RADIOBOX2;
256  static const long ID_STATICTEXT4;
257  static const long ID_TEXTCTRL4;
258  static const long ID_CHECKBOX3;
259  static const long ID_CHECKBOX4;
260  static const long ID_CHECKBOX5;
261  static const long ID_CHECKBOX6;
262  static const long ID_PANEL1;
263  static const long ID_CHECKBOX7;
264  static const long ID_CHECKBOX8;
265  static const long ID_CHECKBOX9;
266  static const long ID_RADIOBOX3;
267  static const long ID_PANEL8;
268  static const long ID_NOTEBOOK1;
269  static const long ID_CHECKBOX2;
270  //*)
271 
272  private:
273 
274  //(*Handlers(CPanelCameraSelection)
275  //*)
276  void OnbtnBrowseVideoClick(wxCommandEvent& event);
277  void OnbtnBrowseRawlogClick(wxCommandEvent& event);
278  void OnbtnBrowseRawlogDirClick(wxCommandEvent& event);
279 
280  DECLARE_EVENT_TABLE()
281  };
282  // end -----------
283 
284  /** Auxiliary structures used internally to mrpt */
285  namespace detail
286  {
287  struct TReturnAskUserOpenCamera
288  {
289  mrpt::utils::CConfigFileMemory selectedConfig;
290  bool accepted_by_user;
291  };
292  }
293 
294 #endif
295 
296  } // End of namespace
297 } // End of namespace
298 
299 #endif
This class provides simple critical sections functionality.
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
mrptKeyModifier
Definition: keycodes.h:158
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...
This class allows loading and storing values and vectors of different types from a configuration text...
This class implements a config file-like interface over a memory-stored string list.
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.



Page generated by Doxygen 1.8.11 for MRPT 1.4.0 SVN:Unversioned directory at Sun Jul 10 11:38:36 UTC 2016