00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "example_pane.h"
00029 #include <rviz/window_manager_interface.h>
00030 #include <srs_env_model/ResetOctomap.h>
00031 #include <ros/service.h>
00032
00033
00037 srs_ui_but::CExamplePanel::CExamplePanel(wxWindow *parent, const wxString& title, rviz::WindowManagerInterface * wmi)
00038 : wxPanel( parent, wxID_ANY, wxDefaultPosition, wxSize(280, 180), wxTAB_TRAVERSAL, title)
00039 , m_wmi( wmi )
00040 {
00041
00042
00043 Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED,
00044 wxCommandEventHandler(CExamplePanel::OnQuit));
00045
00046 wxButton *button = new wxButton(this, wxID_EXIT, wxT("Quit"));
00047
00048 wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
00049 this->SetSizer(sizer);
00050
00051 sizer->Add(button, wxID_EXIT, wxALIGN_RIGHT);
00052
00053 sizer->SetSizeHints(this);
00054
00055
00056 Centre();
00057 }
00058
00060
00064 void srs_ui_but::CExamplePanel::OnQuit(wxCommandEvent& event)
00065 {
00066 std::cerr << "Close called..." << std::endl;
00067 if( m_wmi != 0 )
00068 m_wmi->closePane( this );
00069
00070 Close(true);
00071 }
00072
00075
00079 srs_ui_but::CExampleDialog::CExampleDialog(wxWindow *parent, const wxString& title)
00080 : wxDialog( parent, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180))
00081
00082 {
00083
00084
00085 Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED,
00086 wxCommandEventHandler(CExampleDialog::OnQuit));
00087
00088 wxButton *button = new wxButton(this, wxID_EXIT, wxT("Quit"));
00089
00090 wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
00091 this->SetSizer(sizer);
00092
00093 sizer->Add(button, wxID_EXIT, wxALIGN_RIGHT);
00094
00095 sizer->SetSizeHints(this);
00096
00097
00098 Centre();
00099 }
00100
00102
00106 void srs_ui_but::CExampleDialog::OnQuit(wxCommandEvent& event)
00107 {
00108 std::cerr << "Close called..." << std::endl;
00109 Close(true);
00110 }
00111
00114
00115 const int ID_CHECKBOX(100);
00116 const int ID_RESET_OCTOMAP_BUTTON(101);
00117
00121 srs_ui_but::CExamplePanelControls::CExamplePanelControls(wxWindow *parent, const wxString& title, rviz::WindowManagerInterface * wmi )
00122 : wxPanel( parent, wxID_ANY, wxDefaultPosition, wxSize(280, 180), wxTAB_TRAVERSAL, title)
00123 , m_wmi( wmi )
00124 {
00125
00126 m_button = new wxButton(this, ID_RESET_OCTOMAP_BUTTON, wxT("Reset map"));
00127
00128 m_chkb = new wxCheckBox(this, ID_CHECKBOX, wxT("Chceckbox sample"),
00129 wxPoint(20, 20));
00130 m_chkb->SetValue( true );
00131
00132
00133 wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
00134 this->SetSizer(sizer);
00135 wxSizer *hsizer = new wxBoxSizer(wxHORIZONTAL);
00136
00137 sizer->Add(m_button, ID_RESET_OCTOMAP_BUTTON, wxALIGN_RIGHT);
00138 sizer->Add(hsizer, 0, wxALIGN_LEFT);
00139
00140 hsizer->Add(m_chkb);
00141
00142 sizer->SetSizeHints(this);
00143
00144 }
00146
00150 void srs_ui_but::CExamplePanelControls::OnChckToggle(wxCommandEvent& event)
00151 {
00152 if( m_chkb->GetValue() )
00153 std::cerr << "Chcekbox toggle ON" << std::endl;
00154 else
00155 std::cerr << "Chcekbox toggle OFF" << std::endl;
00156 }
00157
00159
00163 void srs_ui_but::CExamplePanelControls::OnReset(wxCommandEvent& event)
00164 {
00165 srs_env_model::ResetOctomap reset;
00166
00167 if( ros::service::call("reset_octomap", reset) )
00168 {
00169 std::cerr << "Reseting octomap..." << std::endl;
00170 }
00171 }
00172
00174 BEGIN_EVENT_TABLE(srs_ui_but::CExamplePanelControls, wxPanel)
00175 EVT_BUTTON(ID_RESET_OCTOMAP_BUTTON, srs_ui_but::CExamplePanelControls::OnReset)
00176 EVT_CHECKBOX(ID_CHECKBOX, srs_ui_but::CExamplePanelControls::OnChckToggle )
00177 END_EVENT_TABLE()