QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrubberband.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrubberband.h - Rubberband widget for drawing multilines and polygons
3  --------------------------------------
4  Date : 07-Jan-2006
5  Copyright : (C) 2006 by Tom Elwertowski
6  Email : telwertowski at users dot sourceforge dot net
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSRUBBERBAND_H
16 #define QGSRUBBERBAND_H
17 
18 #include "qgsmapcanvasitem.h"
19 #include "qgsgeometry.h"
20 #include <QBrush>
21 #include <QList>
22 #include <QPen>
23 #include <QPolygon>
24 
25 class QgsVectorLayer;
26 class QPaintEvent;
27 
32 class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
33 {
34  public:
35 
38  enum IconType
39  {
59  ICON_CIRCLE
60  };
61 
68  QgsRubberBand( QgsMapCanvas* mapCanvas, QGis::GeometryType geometryType = QGis::Line );
75  QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon );
76  ~QgsRubberBand();
77 
82  void setColor( const QColor & color );
83 
88  void setWidth( int width );
89 
95  void setIcon( IconType icon );
96 
101  void setIconSize( int iconSize );
102 
107  void setLineStyle( Qt::PenStyle penStyle );
108 
113  void setBrushStyle( Qt::BrushStyle brushStyle );
114 
121  void reset( QGis::GeometryType geometryType = QGis::Line );
122 
129  void reset( bool isPolygon );
130 
139  void addPoint( const QgsPoint & p, bool doUpdate = true, int geometryIndex = 0 );
140 
147  void removePoint( int index = 0, bool doUpdate = true, int geometryIndex = 0 );
148 
152  void removeLastPoint( int geometryIndex = 0 , bool doUpdate = true );
153 
158  void movePoint( const QgsPoint & p, int geometryIndex = 0 );
159 
164  void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
165 
171  int partSize( int geometryIndex ) const;
172 
181  void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
182 
188  void setToCanvasRectangle( const QRect& rect );
189 
202  void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
203 
209  void setTranslationOffset( double dx, double dy );
210 
216  int size() const;
217 
222  int numberOfVertices() const;
223 
229  const QgsPoint *getPoint( int i, int j = 0 ) const;
230 
236  QgsGeometry* asGeometry();
237 
238  protected:
239  virtual void paint( QPainter* p );
240 
242  void updateRect();
243 
244  private:
245  QBrush mBrush;
246  QPen mPen;
247 
251 
255 
259  QList< QList <QgsPoint> > mPoints;
263 
264  QgsRubberBand();
265 
266  static QgsPolyline getPolyline( const QList<QgsPoint> & points );
267 
268 };
269 
270 #endif
double mTranslationOffsetY
A cross is used to highlight points (x)
Definition: qgsrubberband.h:51
GeometryType
Definition: qgis.h:115
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
Definition: qgsgeometry.h:38
An abstract class for items that can be placed on the map canvas.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:72
A cross is used to highlight points (+)
Definition: qgsrubberband.h:47
static QIcon icon(QString icon)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:99
QList< QList< QgsPoint > > mPoints
Nested lists used for multitypes.
A class for drawing transient features (e.g.
Definition: qgsrubberband.h:32
QGis::GeometryType mGeometryType
IconType mIconType
Icon to be shown.
A class to represent a point geometry.
Definition: qgspoint.h:63
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
A box is used to highlight points (□)
Definition: qgsrubberband.h:55
double mTranslationOffsetX
No icon is used.
Definition: qgsrubberband.h:43
int mIconSize
The size of the icon for points.
Represents a vector layer which manages a vector based data sets.
double size
Definition: qgssvgcache.cpp:75
IconType
Icons Added in 1.9.
Definition: qgsrubberband.h:38