QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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  Q_DECL_DEPRECATED 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  Q_DECL_DEPRECATED void reset( bool isPolygon );
141 
150  void addPoint( const QgsPoint & p, bool doUpdate = true, int geometryIndex = 0 );
151 
158  void closePoints( bool doUpdate = true, int geometryIndex = 0 );
159 
166  void removePoint( int index = 0, bool doUpdate = true, int geometryIndex = 0 );
167 
171  void removeLastPoint( int geometryIndex = 0, bool doUpdate = true );
172 
177  void movePoint( const QgsPoint & p, int geometryIndex = 0 );
178 
183  void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
184 
190  int partSize( int geometryIndex ) const;
191 
200  void setToGeometry( const QgsGeometry *geom, QgsVectorLayer* layer );
201 
206  void setToCanvasRectangle( QRect rect );
207 
219  void addGeometry( const QgsGeometry *geom, QgsVectorLayer* layer );
220 
226  void setTranslationOffset( double dx, double dy );
227 
232  int size() const;
233 
238  int numberOfVertices() const;
239 
245  const QgsPoint *getPoint( int i, int j = 0 ) const;
246 
251  QgsGeometry* asGeometry();
252 
253  virtual void updatePosition() override;
254 
255  protected:
256  virtual void paint( QPainter* p ) override;
257 
259  void updateRect();
260 
261  private:
262  QBrush mBrush;
263  QPen mPen;
264 
266  int mIconSize;
267 
269  IconType mIconType;
270 
274  QList< QList <QgsPoint> > mPoints;
275  QGis::GeometryType mGeometryType;
276  double mTranslationOffsetX;
277  double mTranslationOffsetY;
278 
279  QgsRubberBand();
280 
281  static QgsPolyline getPolyline( const QList<QgsPoint> & points );
282 
283 };
284 
285 #endif
A cross is used to highlight points (x)
Definition: qgsrubberband.h:50
static unsigned index
GeometryType
Definition: qgis.h:115
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:76
A cross is used to highlight points (+)
Definition: qgsrubberband.h:46
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
A circle is used to highlight points (○)
Definition: qgsrubberband.h:58
A class for drawing transient features (e.g.
Definition: qgsrubberband.h:32
A class to represent a point.
Definition: qgspoint.h:117
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
A box is used to highlight points (□)
Definition: qgsrubberband.h:54
No icon is used.
Definition: qgsrubberband.h:42
Represents a vector layer which manages a vector based data sets.
virtual void updatePosition()
called on changed extent or resize event to update position of the item