example_pane.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * \file
00003  *
00004  * $Id: example_pane.cpp 825 2012-05-23 14:29:07Z spanel $
00005  *
00006  * Copyright (C) Brno University of Technology
00007  *
00008  * This file is part of software developed by dcgm-robotics@FIT group.
00009  *
00010  * Author: Vit Stancl (stancl@fit.vutbr.cz)
00011  * Supervised by: Michal Spanel (spanel@fit.vutbr.cz)
00012  * Date: dd/mm/2011
00013  * 
00014  * This file is free software: you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser 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  * This file 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 Lesser General Public License for more details.
00023  * 
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this file.  If not, see <http://www.gnu.org/licenses/>.
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     // Connect event handler
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     // Set pane position
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     // Connect event handler
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     // Set pane position
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     // Create controls
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     // Create layout
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()


srs_ui_but
Author(s): Vit Stancl (stancl@fit.vutbr.cz), Michal Spanel (spanel@fit.vutbr.cz), Tomas Lokaj
autogenerated on Mon Oct 6 2014 08:49:30