00001 /**************************************************************** 00002 * 00003 * Copyright (c) 2010 00004 * 00005 * Fraunhofer Institute for Manufacturing Engineering 00006 * and Automation (IPA) 00007 * 00008 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: care-o-bot 00011 * ROS stack name: cob_3d_environment_perception_intern 00012 * ROS package name: cob_3d_mapping_demonstrator 00013 * Description: Feature Map for storing and handling geometric features 00014 * 00015 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 * 00017 * Author: Georg Arbeiter, email:georg.arbeiter@ipa.fhg.de 00018 * Supervised by: Georg Arbeiter, email:georg.arbeiter@ipa.fhg.de 00019 * 00020 * Date of creation: 04/2012 00021 * ToDo: 00022 * 00023 * 00024 * 00025 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00026 * 00027 * Redistribution and use in source and binary forms, with or without 00028 * modification, are permitted provided that the following conditions are met: 00029 * 00030 * * Redistributions of source code must retain the above copyright 00031 * notice, this list of conditions and the following disclaimer. 00032 * * Redistributions in binary form must reproduce the above copyright 00033 * notice, this list of conditions and the following disclaimer in the 00034 * documentation and/or other materials provided with the distribution. 00035 * * Neither the name of the Fraunhofer Institute for Manufacturing 00036 * Engineering and Automation (IPA) nor the names of its 00037 * contributors may be used to endorse or promote products derived from 00038 * this software without specific prior written permission. 00039 * 00040 * This program is free software: you can redistribute it and/or modify 00041 * it under the terms of the GNU Lesser General Public License LGPL as 00042 * published by the Free Software Foundation, either version 3 of the 00043 * License, or (at your option) any later version. 00044 * 00045 * This program is distributed in the hope that it will be useful, 00046 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00047 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00048 * GNU Lesser General Public License LGPL for more details. 00049 * 00050 * You should have received a copy of the GNU Lesser General Public 00051 * License LGPL along with this program. 00052 * If not, see <http://www.gnu.org/licenses/>. 00053 * 00054 ****************************************************************/ 00055 #include "cob_3d_mapping_demonstrator/wx_rviz_logo_panel.h" 00056 00057 BEGIN_EVENT_TABLE(wxImagePanel, wxPanel) 00058 // some useful events 00059 /* 00060 EVT_MOTION(wxImagePanel::mouseMoved) 00061 EVT_LEFT_DOWN(wxImagePanel::mouseDown) 00062 EVT_LEFT_UP(wxImagePanel::mouseReleased) 00063 EVT_RIGHT_DOWN(wxImagePanel::rightClick) 00064 EVT_LEAVE_WINDOW(wxImagePanel::mouseLeftWindow) 00065 EVT_KEY_DOWN(wxImagePanel::keyPressed) 00066 EVT_KEY_UP(wxImagePanel::keyReleased) 00067 EVT_MOUSEWHEEL(wxImagePanel::mouseWheelMoved) 00068 */ 00069 00070 // catch paint events 00071 EVT_PAINT(wxImagePanel::paintEvent) 00072 //Size event 00073 EVT_SIZE(wxImagePanel::OnSize) 00074 END_EVENT_TABLE() 00075 00076 00077 // some useful events 00078 /* 00079 void wxImagePanel::mouseMoved(wxMouseEvent& event) {} 00080 void wxImagePanel::mouseDown(wxMouseEvent& event) {} 00081 void wxImagePanel::mouseWheelMoved(wxMouseEvent& event) {} 00082 void wxImagePanel::mouseReleased(wxMouseEvent& event) {} 00083 void wxImagePanel::rightClick(wxMouseEvent& event) {} 00084 void wxImagePanel::mouseLeftWindow(wxMouseEvent& event) {} 00085 void wxImagePanel::keyPressed(wxKeyEvent& event) {} 00086 void wxImagePanel::keyReleased(wxKeyEvent& event) {} 00087 */ 00088 00089 wxImagePanel::wxImagePanel(wxWindow* parent, wxString file, wxBitmapType format) : 00090 wxPanel(parent) 00091 { 00092 // load the file... ideally add a check to see if loading was successful 00093 image.LoadFile(file, format); 00094 w = -1; 00095 h = -1; 00096 } 00097 00098 /* 00099 * Called by the system of by wxWidgets when the panel needs 00100 * to be redrawn. You can also trigger this call by 00101 * calling Refresh()/Update(). 00102 */ 00103 00104 void wxImagePanel::paintEvent(wxPaintEvent & evt) 00105 { 00106 // depending on your system you may need to look at double-buffered dcs 00107 wxPaintDC dc(this); 00108 render(dc); 00109 } 00110 00111 /* 00112 * Alternatively, you can use a clientDC to paint on the panel 00113 * at any time. Using this generally does not free you from 00114 * catching paint events, since it is possible that e.g. the window 00115 * manager throws away your drawing when the window comes to the 00116 * background, and expects you will redraw it when the window comes 00117 * back (by sending a paint event). 00118 */ 00119 void wxImagePanel::paintNow() 00120 { 00121 // depending on your system you may need to look at double-buffered dcs 00122 wxClientDC dc(this); 00123 render(dc); 00124 } 00125 00126 /* 00127 * Here we do the actual rendering. I put it in a separate 00128 * method so that it can work no matter what type of DC 00129 * (e.g. wxPaintDC or wxClientDC) is used. 00130 */ 00131 void wxImagePanel::render(wxDC& dc) 00132 { 00133 int neww, newh; 00134 dc.GetSize( &neww, &newh ); 00135 00136 if( neww != w || newh != h ) 00137 { 00138 resized = wxBitmap( image.Scale( neww, newh /*, wxIMAGE_QUALITY_HIGH*/ ) ); 00139 w = neww; 00140 h = newh; 00141 dc.DrawBitmap( resized, 0, 0, false ); 00142 }else{ 00143 dc.DrawBitmap( resized, 0, 0, false ); 00144 } 00145 } 00146 00147 /* 00148 * Here we call refresh to tell the panel to draw itself again. 00149 * So when the user resizes the image panel the image should be resized too. 00150 */ 00151 void wxImagePanel::OnSize(wxSizeEvent& event){ 00152 Refresh(); 00153 //skip the event. 00154 event.Skip(); 00155 }