|
QGIS API Documentation
master-3f58142
|
00001 /*************************************************************************** 00002 qgsrubberband.h - Rubberband widget for drawing multilines and polygons 00003 -------------------------------------- 00004 Date : 07-Jan-2006 00005 Copyright : (C) 2006 by Tom Elwertowski 00006 Email : telwertowski at users dot sourceforge dot net 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 #ifndef QGSRUBBERBAND_H 00016 #define QGSRUBBERBAND_H 00017 00018 #include "qgsmapcanvasitem.h" 00019 #include "qgsgeometry.h" 00020 #include <QBrush> 00021 #include <QList> 00022 #include <QPen> 00023 #include <QPolygon> 00024 00025 class QgsVectorLayer; 00026 class QPaintEvent; 00027 00032 class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem 00033 { 00034 public: 00035 00038 enum IconType 00039 { 00043 ICON_NONE, 00047 ICON_CROSS, 00051 ICON_X, 00055 ICON_BOX, 00059 ICON_CIRCLE 00060 }; 00061 00068 QgsRubberBand( QgsMapCanvas* mapCanvas, QGis::GeometryType geometryType = QGis::Line ); 00075 QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon ); 00076 ~QgsRubberBand(); 00077 00082 void setColor( const QColor & color ); 00083 00088 void setWidth( int width ); 00089 00095 void setIcon( IconType icon ); 00096 00101 void setIconSize( int iconSize ); 00102 00109 void reset( QGis::GeometryType geometryType = QGis::Line ); 00110 00117 void reset( bool isPolygon ); 00118 00127 void addPoint( const QgsPoint & p, bool doUpdate = true, int geometryIndex = 0 ); 00128 00135 void removePoint( int index = 0, bool doUpdate = true, int geometryIndex = 0 ); 00136 00140 void removeLastPoint( int geometryIndex = 0 ); 00141 00146 void movePoint( const QgsPoint & p, int geometryIndex = 0 ); 00147 00152 void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 ); 00153 00162 void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer ); 00163 00169 void setToCanvasRectangle( const QRect& rect ); 00170 00183 void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer ); 00184 00190 void setTranslationOffset( double dx, double dy ); 00191 00197 int size() const; 00198 00203 int numberOfVertices() const; 00204 00210 const QgsPoint *getPoint( int i, int j = 0 ) const; 00211 00217 QgsGeometry* asGeometry(); 00218 00219 protected: 00220 virtual void paint( QPainter* p ); 00221 00223 void updateRect(); 00224 00225 private: 00226 QBrush mBrush; 00227 QPen mPen; 00228 00230 int mWidth; 00231 00234 int mIconSize; 00235 00238 IconType mIconType ; 00239 00243 QList< QList <QgsPoint> > mPoints; 00244 QGis::GeometryType mGeometryType; 00245 double mTranslationOffsetX; 00246 double mTranslationOffsetY; 00247 00248 QgsRubberBand(); 00249 00250 static QgsPolyline getPolyline( const QList<QgsPoint> & points ); 00251 00252 }; 00253 00254 #endif