Main MRPT website > C++ reference
MRPT logo

WxUtils.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef  MRPT_WX_UTILS_H
00029 #define  MRPT_WX_UTILS_H
00030 
00031 #include <mrpt/utils/utils_defs.h>
00032 #include <mrpt/utils/CImage.h>
00033 #include <mrpt/utils/CConfigFileBase.h>
00034 #include <mrpt/utils/CConfigFileMemory.h>
00035 #include <mrpt/synch.h>
00036 #include <mrpt/gui/keycodes.h>
00037 
00038 #include <mrpt/gui/link_pragmas.h>
00039 
00040 #if MRPT_HAS_WXWIDGETS
00041 
00042 #include <wx/sizer.h>
00043 #include <wx/statbmp.h>
00044 #include <wx/menu.h>
00045 #include <wx/toolbar.h>
00046 #include <wx/frame.h>
00047 #include <wx/timer.h>
00048 #include <wx/statusbr.h>
00049 #include <wx/msgdlg.h>
00050 #include <wx/artprov.h>
00051 #include <wx/bitmap.h>
00052 #include <wx/intl.h>
00053 #include <wx/image.h>
00054 #include <wx/string.h>
00055 #include <wx/msgdlg.h>
00056 #include <wx/panel.h>
00057 #include <wx/filedlg.h>
00058 #include <wx/progdlg.h>
00059 #include <wx/imaglist.h>
00060 #include <wx/busyinfo.h>
00061 #include <wx/log.h>
00062 #include <wx/textdlg.h>
00063 #include <wx/dirdlg.h>
00064 #include <wx/colordlg.h>
00065 #include <wx/dcmemory.h>
00066 #include <wx/app.h>
00067 #include <wx/pen.h>
00068 #include <wx/spinctrl.h>
00069 #include <wx/sizer.h>
00070 #include <wx/notebook.h>
00071 #include <wx/button.h>
00072 #include <wx/panel.h>
00073 #include <wx/stattext.h>
00074 #include <wx/textctrl.h>
00075 #include <wx/choice.h>
00076 #include <wx/radiobox.h>
00077 #include <wx/settings.h>
00078 #include <wx/checkbox.h>
00079 #include <wx/dc.h>
00080 #include <wx/dcclient.h>
00081 
00082 #endif
00083 
00084 namespace mrpt
00085 {
00086         namespace gui
00087         {
00088 #if MRPT_HAS_WXWIDGETS
00089 
00090 
00091 #ifndef _U
00092 #       ifdef wxUSE_UNICODE
00093 #               define _U(x) wxString::From8BitData(x)
00094 #       else
00095 #               define _U(x) (x)
00096 #       endif
00097 #endif
00098 
00099 
00100                 /** Create a wxImage from a MRPT image. The new object must be freed by the user when not required anymore.
00101                   * \sa MRPTImage2wxImage
00102                   */
00103                 wxImage GUI_IMPEXP * MRPTImage2wxImage( const mrpt::utils::CImage &img );
00104 
00105                 /** Create a wxBitmap from a MRPT image. The new object must be freed by the user when not required anymore.
00106                   * \sa MRPTImage2wxImage
00107                   */
00108                 wxBitmap GUI_IMPEXP * MRPTImage2wxBitmap( const mrpt::utils::CImage &img );
00109 
00110 #if MRPT_HAS_OPENCV
00111                 /** Create a wxImage from a IPL image. The new object must be freed by the user when not required anymore.
00112                   * \sa IplImage2wxImage
00113                   */
00114                 wxImage GUI_IMPEXP * IplImage2wxImage( void* img );
00115 #endif
00116 
00117                 /** Create a MRPT image from a wxImage. The new object must be freed by the user when not required anymore.
00118                   *  It is recommended to use wxImage2MRPTImagePtr instead since smart pointers are safer to manage.
00119                   * \sa wxImage2MRPTImage, wxImage2MRPTImagePtr
00120                   */
00121                 mrpt::utils::CImage GUI_IMPEXP * wxImage2MRPTImage( const wxImage &img );
00122 
00123                 /** Create a MRPT image from a wxImage. The new object is returned as a smart pointer to a CImage object.
00124                   * \sa wxImage2MRPTImage
00125                   */
00126                 mrpt::utils::CImagePtr GUI_IMPEXP wxImage2MRPTImagePtr( const wxImage &img );
00127 
00128                 /** Extracts the key modifiers from a wxKeyEvent */
00129                 mrptKeyModifier keyEventToMrptKeyModifier( const wxKeyEvent &ev );
00130 
00131                 /** A custom control to display the bitmap and avoid flicker
00132                   */
00133                 class GUI_IMPEXP wxMRPTImageControl : public wxPanel
00134                 {
00135                 protected:
00136                         wxBitmap *m_img;
00137                         mrpt::synch::CCriticalSection   m_img_cs;
00138 
00139                         wxPoint m_last_mouse_point, m_last_mouse_click;
00140                         mrpt::synch::CCriticalSection   m_mouse_cs;
00141 
00142                 public:
00143                         wxMRPTImageControl(     wxWindow *parent,wxWindowID winID,int x, int y, int width, int height);
00144                         virtual ~wxMRPTImageControl();
00145 
00146                         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.
00147                         void AssignImage(const mrpt::utils::CImage &img); //!< Assigns this image. Remember to call Refresh to display the image.
00148                         void GetBitmap(wxBitmap &bmp);
00149 
00150                         void OnPaint(wxPaintEvent &ev);
00151                         void OnMouseMove(wxMouseEvent& ev);
00152                         void OnMouseClick(wxMouseEvent& ev);
00153 
00154                         void OnEraseBackground(wxEraseEvent &ev) { /* Do nothing */ }
00155                 };
00156                 // end wxMRPTImageControl  -----------
00157 
00158                 /** A panel to select the camera input from all the formats supported by MRPT */
00159                 class GUI_IMPEXP CPanelCameraSelection: public wxPanel
00160                 {
00161                 public:
00162 
00163                         CPanelCameraSelection(wxWindow* parent,wxWindowID id=wxID_ANY);
00164                         virtual ~CPanelCameraSelection();
00165 
00166                         void readConfigIntoVideoSourcePanel(
00167                                 const std::string &sect,
00168                                 const mrpt::utils::CConfigFileBase *cfg ) const;
00169 
00170                         void writeConfigFromVideoSourcePanel(
00171                                 const std::string &sect,
00172                                 mrpt::utils::CConfigFileBase *cfg ) const;
00173 
00174                 //(*Declarations(CPanelCameraSelection)
00175                 wxNotebook* pagesCameras;
00176                 wxPanel* Panel1;
00177                 wxPanel* Panel6;
00178                 wxPanel* pnSwissRanger;
00179                 wxTextCtrl* edCustomCamConfig;
00180                 wxCheckBox* cbSR_chRange;
00181                 wxCheckBox* cbSR_chIntensity;
00182                 wxTextCtrl* edIPcamURL;
00183                 wxCheckBox* cbSR_ch3D;
00184                 wxRadioBox* rbSR_usb;
00185                 wxStaticText* StaticText1;
00186                 wxStaticText* StaticText10;
00187                 wxButton* btnBrowseVideo;
00188                 wxPanel* Panel2;
00189                 wxCheckBox* cbKinect_3D;
00190                 wxStaticText* StaticText3;
00191                 wxPanel* Panel4;
00192                 wxTextCtrl* edRawlogFile;
00193                 wxButton* btnBrowseRawlog;
00194                 wxChoice* cbOpencvResolution;
00195                 wxPanel* Panel5;
00196                 wxStaticText* StaticText8;
00197                 wxPanel* Panel3;
00198                 wxStaticText* StaticText7;
00199                 wxCheckBox* cbGrayscale;
00200                 wxChoice* cbOpencvCamType;
00201                 wxCheckBox* cbKinect_Depth;
00202                 wxPanel* pnKinect;
00203                 wxRadioBox* rbBumblebeeSel;
00204                 wxTextCtrl* edRawlogLabel;
00205                 wxStaticText* StaticText4;
00206                 wxCheckBox* cbSR_chConf;
00207                 wxCheckBox* cbKinect_Int;
00208                 wxStaticText* StaticText5;
00209                 wxStaticText* StaticText2;
00210                 wxTextCtrl* edSR_IP;
00211                 wxStaticText* StaticText6;
00212                 wxCheckBox* cbBumblebeeRectif;
00213                 wxButton* btnBrowseRawlogDir;
00214                 wxTextCtrl* edRawlogImgDir;
00215                 wxSpinCtrl* opencvCamIndex;
00216                 wxStaticText* StaticText9;
00217                 wxStaticText* StaticText11;
00218                 wxTextCtrl* edVideoFile;
00219                 //*)
00220 
00221         protected:
00222 
00223                 //(*Identifiers(CPanelCameraSelection)
00224                 static const long ID_STATICTEXT1;
00225                 static const long ID_SPINCTRL1;
00226                 static const long ID_STATICTEXT3;
00227                 static const long ID_CHOICE1;
00228                 static const long ID_STATICTEXT6;
00229                 static const long ID_CHOICE2;
00230                 static const long ID_PANEL2;
00231                 static const long ID_STATICTEXT7;
00232                 static const long ID_TEXTCTRL1;
00233                 static const long ID_PANEL3;
00234                 static const long ID_TEXTCTRL6;
00235                 static const long ID_PANEL4;
00236                 static const long ID_STATICTEXT8;
00237                 static const long ID_TEXTCTRL2;
00238                 static const long ID_BUTTON7;
00239                 static const long ID_PANEL5;
00240                 static const long ID_STATICTEXT9;
00241                 static const long ID_TEXTCTRL3;
00242                 static const long ID_BUTTON8;
00243                 static const long ID_STATICTEXT5;
00244                 static const long ID_TEXTCTRL7;
00245                 static const long ID_BUTTON9;
00246                 static const long ID_STATICTEXT10;
00247                 static const long ID_TEXTCTRL8;
00248                 static const long ID_STATICTEXT11;
00249                 static const long ID_PANEL6;
00250                 static const long ID_RADIOBOX1;
00251                 static const long ID_CHECKBOX1;
00252                 static const long ID_STATICTEXT2;
00253                 static const long ID_PANEL7;
00254                 static const long ID_RADIOBOX2;
00255                 static const long ID_STATICTEXT4;
00256                 static const long ID_TEXTCTRL4;
00257                 static const long ID_CHECKBOX3;
00258                 static const long ID_CHECKBOX4;
00259                 static const long ID_CHECKBOX5;
00260                 static const long ID_CHECKBOX6;
00261                 static const long ID_PANEL1;
00262                 static const long ID_CHECKBOX7;
00263                 static const long ID_CHECKBOX8;
00264                 static const long ID_CHECKBOX9;
00265                 static const long ID_PANEL8;
00266                 static const long ID_NOTEBOOK1;
00267                 static const long ID_CHECKBOX2;
00268                 //*)
00269 
00270                 private:
00271 
00272                         //(*Handlers(CPanelCameraSelection)
00273                         //*)
00274                         void OnbtnBrowseVideoClick(wxCommandEvent& event);
00275                         void OnbtnBrowseRawlogClick(wxCommandEvent& event);
00276                         void OnbtnBrowseRawlogDirClick(wxCommandEvent& event);
00277 
00278                         DECLARE_EVENT_TABLE()
00279                 };
00280                 // end   -----------
00281 
00282                 /** Auxiliary structures used internally to mrpt */
00283                 namespace detail
00284                 {
00285                         struct TReturnAskUserOpenCamera
00286                         {
00287                                 mrpt::utils::CConfigFileMemory  selectedConfig;
00288                                 bool  accepted_by_user;
00289                         };
00290                 }
00291 
00292 #endif
00293 
00294     } // End of namespace
00295 } // End of namespace
00296 
00297 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011