INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide Dashboard 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-2009 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 namespace hydroqguielementutil { 00019 class IHumanManager; 00020 }; 00021 00022 namespace orcaqgui2d 00023 { 00024 00025 // Data structure containing drawing information 00026 struct PixmapData 00027 { 00028 // Each pixel is a cell of size cellSize in [m] 00029 double cellSize; 00030 00031 // Pixmap size in number of cells 00032 QSize mapSizePix; 00033 00034 // Offset wrt the global coordinate system 00035 QPointF offset; 00036 00037 // Three color channels as a flat representation of the pixels: 00038 // vectorIndex = y*mapSizePix.width()+x 00039 // WARNING: need to make sure that vector is of size ( mapSizePix.width()*mapSizePix.height() ) 00040 std::vector<unsigned char> rgbR; 00041 std::vector<unsigned char> rgbG; 00042 std::vector<unsigned char> rgbB; 00043 }; 00044 00049 class PixmapPainter 00050 { 00051 00052 public: 00053 PixmapPainter(); 00054 PixmapPainter( PixmapData &pixmapData ); 00055 ~PixmapPainter(); 00056 00057 void setData( PixmapData &pixmapData ); 00058 00059 void paint( QPainter *p ); 00060 00061 void toggleDisplayMap(); 00062 int saveMap( const QString &fileName, 00063 const QString &fileExtension, 00064 hydroqguielementutil::IHumanManager *humanManager ); 00065 00066 // paint on the pixmap 00067 void drawCircle ( const QColor& color, const QPoint& center, qreal diameter ); 00068 00069 private: 00070 00071 bool updateWorldMatrix( const QMatrix & ); 00072 bool updateWindowSize( const QSize & ); 00073 void rescale(); 00074 00075 // Unscaled map storage 00076 QPixmap qMap_; 00077 00078 // qMap_ scaled and cropped to current window size 00079 QPixmap mapWin_; 00080 00081 // Current widget size in pixels (WorldView) 00082 QSize winSize_; 00083 00084 // Current meters-to-window transformation matrix 00085 QMatrix m2win_; 00086 00087 // Current map-to-window transformation matrix 00088 QMatrix map2win_; 00089 00090 PixmapData data_; 00091 00092 bool isDisplayMap_; 00093 00094 bool haveMap_; 00095 00096 // record the offset so that we can check if it's changed and then update 00097 // if necessary 00098 QPointF previousOffset_; 00099 00100 }; 00101 00102 } // namespace 00103 00104 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)