orca-robotics INTRODUCTION Overview Download and Install Quick Start Documentation Publications REPOSITORY Interfaces Components Libraries Utilities Software Map DEVELOPER Tutorials Examples Dev Guide Dashboard Wiki login/pass: orca/orca PEOPLE Contributors Users Project Download Mailing lists
|
pixmappainter.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef ORCAGUI_PIXMAP_PAINTER_H 00012 #define ORCAGUI_PIXMAP_PAINTER_H 00013 00014 #include <vector> 00015 #include <QPixmap> 00016 #include <QMatrix> 00017 00018 #include <hydroqgui/hydroqgui.h> 00019 #include <hydroqguielementutil/hydroqguielementutil.h> 00020 00021 namespace orcaqgui2d 00022 { 00023 00024 // Data structure containing drawing information 00025 struct PixmapData 00026 { 00027 // Each pixel is a cell of size cellSize in [m] 00028 QSizeF cellSize; 00029 00030 // Pixmap size in number of cells 00031 QSize mapSizePix; 00032 00033 // Offset wrt the global coordinate system 00034 QPointF offset; 00035 00036 // Three color channels as a flat representation of the pixels: 00037 // vectorIndex = y*mapSizePix.width()+x 00038 // WARNING: need to make sure that vector is of size ( mapSizePix.width()*mapSizePix.height() ) 00039 std::vector<unsigned char> rgbR; 00040 std::vector<unsigned char> rgbG; 00041 std::vector<unsigned char> rgbB; 00042 }; 00043 00048 class PixmapPainter 00049 { 00050 00051 public: 00052 PixmapPainter(); 00053 PixmapPainter( PixmapData &pixmapData ); 00054 ~PixmapPainter(); 00055 00056 void setData( PixmapData &pixmapData ); 00057 00058 void paint( QPainter *p ); 00059 00060 void toggleDisplayMap(); 00061 int saveMap( const QString &fileName, 00062 const QString &fileExtension, 00063 hydroqguielementutil::IHumanManager *humanManager ); 00064 00065 private: 00066 00067 bool updateWorldMatrix( const QMatrix & ); 00068 bool updateWindowSize( const QSize & ); 00069 void rescale(); 00070 00071 // Unscaled map storage 00072 QPixmap qMap_; 00073 00074 // qMap_ scaled and cropped to current window size 00075 QPixmap mapWin_; 00076 00077 // Current widget size in pixels (WorldView) 00078 QSize winSize_; 00079 00080 // Current meters-to-window transformation matrix 00081 QMatrix m2win_; 00082 00083 // Current map-to-window transformation matrix 00084 QMatrix map2win_; 00085 00086 PixmapData data_; 00087 00088 bool isDisplayMap_; 00089 00090 bool haveMap_; 00091 00092 // record the offset so that we can check if it's changed and then update 00093 // if necessary 00094 QPointF previousOffset_; 00095 00096 }; 00097 00098 } // namespace 00099 00100 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)