12
12
* (at your option) any later version. *
14
14
***************************************************************************/
15
/* $Id: qgsrubberband.h 5878 2006-09-27 14:19:44Z wonder $ */
16
16
#ifndef QGSRUBBERBAND_H
17
17
#define QGSRUBBERBAND_H
19
19
#include "qgsmapcanvasitem.h"
23
23
#include <QPolygon>
26
class QgsRubberBand: public QgsMapCanvasItem
30
* A class for drawing transient features (e.g. digitising lines) on the map.
32
class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
29
QgsRubberBand(QgsMapCanvas* mapCanvas, bool isPolygon = false);
35
QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon = false );
32
void setColor(const QColor & color);
33
void setWidth(int width);
38
void setColor( const QColor & color );
39
void setWidth( int width );
35
void reset(bool isPolygon = false);
41
void reset( bool isPolygon = false );
37
43
//! Add point to rubberband and update canvas
38
44
//! If adding more points consider using update=false for better performance
39
void addPoint(const QgsPoint & p, bool update = true);
41
void movePoint(const QgsPoint & p);
42
void movePoint(int index, const QgsPoint& p);
45
//! geometryIndex is the index of the feature part (in case of multipart geometries)
46
void addPoint( const QgsPoint & p, bool update = true, int geometryIndex = 0 );
48
//!Removes the last point. Most useful in connection with undo operations
49
void removeLastPoint( int geometryIndex = 0 );
51
void movePoint( const QgsPoint & p, int geometryIndex = 0 );
52
/**Moves the rubber band point specified by index. Note that if the rubber band is
53
not used to track the last mouse position, the first point of the rubber band has two vertices*/
54
void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );
56
/**Sets this rubber band to the geometry of an existing feature.
57
This is useful for feature highlighting.
58
@param geom the geometry object
59
@param layer the layer containing the feature, used for coord transformation to map
60
crs. In case of 0 pointer, the coordinates are not going to be transformed.
61
@param render the maprender object (used for coord transformation)*/
62
void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
64
/**Adds translation to original coordinates (all in map coordinates)*/
65
void setTranslationOffset( double dx, double dy );
67
/**Returns count of vertices in all lists of mPoint*/
68
int numberOfVertices() const;
71
const QgsPoint *getPoint( int i, int j = 0 ) const;
45
virtual void drawShape(QPainter & p);
74
virtual void paint( QPainter* p );
47
76
//! recalculates needed rectangle
53
std::deque<QgsPoint> mPoints;
83
/**Nested lists used for multitypes*/
84
QList< QList <QgsPoint> > mPoints;
86
double mTranslationOffsetX;
87
double mTranslationOffsetY;