QGIS API Documentation  2.3.0-Master
 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  {
63  ICON_FULL_BOX
64  };
65 
72  QgsRubberBand( QgsMapCanvas* mapCanvas, QGis::GeometryType geometryType = QGis::Line );
79  QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon );
80  ~QgsRubberBand();
81 
86  void setColor( const QColor & color );
87 
92  void setWidth( int width );
93 
99  void setIcon( IconType icon );
100 
105  void setIconSize( int iconSize );
106 
111  void setLineStyle( Qt::PenStyle penStyle );
112 
117  void setBrushStyle( Qt::BrushStyle brushStyle );
118 
125  void reset( QGis::GeometryType geometryType = QGis::Line );
126 
133  void reset( bool isPolygon );
134 
143  void addPoint( const QgsPoint & p, bool doUpdate = true, int geometryIndex = 0 );
144 
151  void removePoint( int index = 0, bool doUpdate = true, int geometryIndex = 0 );
152 
156  void removeLastPoint( int geometryIndex = 0 , bool doUpdate = true );
157 
162  void movePoint( const QgsPoint & p, int geometryIndex = 0 );
163 
168  void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
169 
175  int partSize( int geometryIndex ) const;
176 
185  void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
186 
192  void setToCanvasRectangle( const QRect& rect );
193 
206  void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
207 
213  void setTranslationOffset( double dx, double dy );
214 
220  int size() const;
221 
226  int numberOfVertices() const;
227 
233  const QgsPoint *getPoint( int i, int j = 0 ) const;
234 
240  QgsGeometry* asGeometry();
241 
242  protected:
243  virtual void paint( QPainter* p );
244 
246  void updateRect();
247 
248  private:
249  QBrush mBrush;
250  QPen mPen;
251 
255 
259 
263  QList< QList <QgsPoint> > mPoints;
267 
268  QgsRubberBand();
269 
270  static QgsPolyline getPolyline( const QList<QgsPoint> & points );
271 
272 };
273 
274 #endif
double mTranslationOffsetY
A cross is used to highlight points (x)
Definition: qgsrubberband.h:51
static unsigned index
GeometryType
Definition: qgis.h:155
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 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:105
QList< QList< QgsPoint > > mPoints
Nested lists used for multitypes.
A circle is used to highlight points (○)
Definition: qgsrubberband.h:59
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:77
IconType
Icons Added in 1.9.
Definition: qgsrubberband.h:38