00001 /****************************************************************************** 00002 STDR Simulator - Simple Two DImensional Robot Simulator 00003 Copyright (C) 2013 STDR Simulator 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 3 of the License, or 00007 (at your option) any later version. 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 You should have received a copy of the GNU General Public License 00013 along with this program; if not, write to the Free Software Foundation, 00014 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00015 00016 Authors : 00017 * Manos Tsardoulias, etsardou@gmail.com 00018 * Aris Thallas, aris.thallas@gmail.com 00019 * Chris Zalidis, zalidis@gmail.com 00020 ******************************************************************************/ 00021 00022 #ifndef STDR_MAP_LOADER 00023 #define STDR_MAP_LOADER 00024 00025 #include "ui_map.h" 00026 #include "stdr_gui/stdr_tools.h" 00027 00028 #define ZOOM_RATIO 1.1 00029 00034 namespace stdr_gui 00035 { 00040 class CMapLoader : 00041 public QWidget, 00042 public Ui_mapWidget 00043 { 00044 //------------------------------------------------------------------------// 00045 private: 00047 int argc_; 00049 char** argv_; 00051 int zoom_; 00052 00054 QImage* internal_img_; 00055 00057 QPoint map_min_; 00058 00060 QPoint map_max_; 00061 00063 QSize initial_image_size_; 00064 00070 QPoint pointUnscaled(QPoint p); 00071 00078 std::pair<int,int> checkDimensions(int w,int h); 00079 00080 //------------------------------------------------------------------------// 00081 public: 00082 00089 CMapLoader(int argc, char **argv); 00090 00096 void setInitialImageSize(QSize s); 00097 00103 void resizeEvent(QResizeEvent *e); 00104 00110 void updateImage(QImage *img); 00111 00118 void drawGrid(QImage *img,float resolution); 00119 00126 void updateZoom(QPoint p,bool zoomIn); 00127 00133 void updateCenter(QPoint p); 00134 00140 void moveDirectionally(int key); 00141 00146 void resetZoom(void); 00147 00153 QPoint getGlobalPoint(QPoint p); 00154 00155 }; 00156 } 00157 00158 #endif