QGIS API Documentation  2.5.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 
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 setFillColor( const QColor & color );
93 
98  void setBorderColor( const QColor & color );
99 
104  void setWidth( int width );
105 
111  void setIcon( IconType icon );
112 
117  void setIconSize( int iconSize );
118 
123  void setLineStyle( Qt::PenStyle penStyle );
124 
129  void setBrushStyle( Qt::BrushStyle brushStyle );
130 
137  void reset( QGis::GeometryType geometryType = QGis::Line );
138 
145  void reset( bool isPolygon );
146 
155  void addPoint( const QgsPoint & p, bool doUpdate = true, int geometryIndex = 0 );
156 
163  void removePoint( int index = 0, bool doUpdate = true, int geometryIndex = 0 );
164 
168  void removeLastPoint( int geometryIndex = 0, bool doUpdate = true );
169 
174  void movePoint( const QgsPoint & p, int geometryIndex = 0 );
175 
180  void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
181 
187  int partSize( int geometryIndex ) const;
188 
197  void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
198 
204  void setToCanvasRectangle( const QRect& rect );
205 
218  void addGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
219 
225  void setTranslationOffset( double dx, double dy );
226 
232  int size() const;
233 
238  int numberOfVertices() const;
239 
245  const QgsPoint *getPoint( int i, int j = 0 ) const;
246 
252  QgsGeometry* asGeometry();
253 
254  protected:
255  virtual void paint( QPainter* p );
256 
258  void updateRect();
259 
260  private:
261  QBrush mBrush;
262  QPen mPen;
263 
266  int mIconSize;
267 
270  IconType mIconType;
271 
275  QList< QList <QgsPoint> > mPoints;
276  QGis::GeometryType mGeometryType;
277  double mTranslationOffsetX;
278  double mTranslationOffsetY;
279 
280  QgsRubberBand();
281 
282  static QgsPolyline getPolyline( const QList<QgsPoint> & points );
283 
284 };
285 
286 #endif
static unsigned index
Definition: mersenne-twister.cpp:36
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:55
An abstract class for items that can be placed on the map canvas.
Definition: qgsmapcanvasitem.h:30
Definition: qgsgeometry.h:69
GeometryType
Definition: qgis.h:155
static QIcon icon(QString icon)
Definition: qgsmessagelogviewer.cpp:32
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:59
A class for drawing transient features (e.g.
Definition: qgsrubberband.h:32
A cross is used to highlight points (x)
Definition: qgsrubberband.h:51
A class to represent a point geometry.
Definition: qgspoint.h:63
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
Definition: qgis.h:158
A cross is used to highlight points (+)
Definition: qgsrubberband.h:47
No icon is used.
Definition: qgsrubberband.h:43
IconType
Icons Added in 1.9.
Definition: qgsrubberband.h:38
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:470
double size
Definition: qgssvgcache.cpp:77