QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
37  enum IconType
38  {
62  ICON_FULL_BOX
63  };
64 
70  QgsRubberBand( QgsMapCanvas* mapCanvas, QGis::GeometryType geometryType = QGis::Line );
77  QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon );
78  ~QgsRubberBand();
79 
84  void setColor( const QColor & color );
85 
91  void setFillColor( const QColor & color );
92 
98  void setBorderColor( const QColor & color );
99 
104  void setWidth( int width );
105 
110  void setIcon( IconType icon );
111 
115  void setIconSize( int iconSize );
116 
120  void setLineStyle( Qt::PenStyle penStyle );
121 
125  void setBrushStyle( Qt::BrushStyle brushStyle );
126 
132  void reset( QGis::GeometryType geometryType = QGis::Line );
133 
140  void reset( bool isPolygon );
141 
150  void addPoint( const QgsPoint & p, bool doUpdate = true, int geometryIndex = 0 );
151 
158  void removePoint( int index = 0, bool doUpdate = true, int geometryIndex = 0 );
159 
163  void removeLastPoint( int geometryIndex = 0, bool doUpdate = true );
164 
169  void movePoint( const QgsPoint & p, int geometryIndex = 0 );
170 
175  void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
176 
182  int partSize( int geometryIndex ) const;
183 
192  void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
193 
198  void setToCanvasRectangle( const QRect& rect );
199 
211  void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
212 
218  void setTranslationOffset( double dx, double dy );
219 
224  int size() const;
225 
230  int numberOfVertices() const;
231 
237  const QgsPoint *getPoint( int i, int j = 0 ) const;
238 
243  QgsGeometry* asGeometry();
244 
245  protected:
246  virtual void paint( QPainter* p );
247 
249  void updateRect();
250 
251  private:
252  QBrush mBrush;
253  QPen mPen;
254 
256  int mIconSize;
257 
259  IconType mIconType;
260 
264  QList< QList <QgsPoint> > mPoints;
265  QGis::GeometryType mGeometryType;
266  double mTranslationOffsetX;
267  double mTranslationOffsetY;
268 
269  QgsRubberBand();
270 
271  static QgsPolyline getPolyline( const QList<QgsPoint> & points );
272 
273 };
274 
275 #endif
static unsigned index
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
Definition: qgsgeometry.h:33
A box is used to highlight points (□)
Definition: qgsrubberband.h:54
An abstract class for items that can be placed on the map canvas.
GeometryType
Definition: qgis.h:155
static QIcon icon(QString icon)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:104
A circle is used to highlight points (○)
Definition: qgsrubberband.h:58
A class for drawing transient features (e.g.
Definition: qgsrubberband.h:32
A cross is used to highlight points (x)
Definition: qgsrubberband.h:50
A class to represent a point.
Definition: qgspoint.h:63
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
A cross is used to highlight points (+)
Definition: qgsrubberband.h:46
No icon is used.
Definition: qgsrubberband.h:42
Represents a vector layer which manages a vector based data sets.
double size
Definition: qgssvgcache.cpp:77