33 , mIconType( ICON_CIRCLE )
34 , mGeometryType( geometryType )
35 , mTranslationOffsetX( 0.0 )
36 , mTranslationOffsetY( 0.0 )
38 reset( geometryType );
39 QColor color( Qt::lightGray );
50 , mIconType( ICON_CIRCLE )
51 , mTranslationOffsetX( 0.0 )
52 , mTranslationOffsetY( 0.0 )
55 QColor color( Qt::lightGray );
76 mPen.setColor( color );
77 QColor fillColor( color.red(), color.green(), color.blue(), color.alpha() );
78 mBrush.setColor( fillColor );
86 mPen.setWidth( width );
101 mPen.setStyle( penStyle );
106 mBrush.setStyle( brushStyle );
133 if ( geometryIndex < 0 )
135 geometryIndex =
mPoints.size() - 1;
138 if ( geometryIndex < 0 || geometryIndex >
mPoints.size() )
143 if ( geometryIndex ==
mPoints.size() )
145 mPoints.push_back( QList<QgsPoint>() << p );
151 mPoints[geometryIndex].last() = p;
170 if (
mPoints.size() < geometryIndex + 1 )
181 index =
mPoints[geometryIndex].size() + index;
183 mPoints[geometryIndex].removeAt( index );
203 if (
mPoints.size() < geometryIndex + 1 )
208 if (
mPoints.at( geometryIndex ).size() < 1 )
213 mPoints[geometryIndex].last() = p;
221 if (
mPoints.size() < geometryIndex + 1 )
226 if (
mPoints.at( geometryIndex ).size() < index )
231 mPoints[geometryIndex][index] = p;
283 for (
int i = 0; i < mpt.size(); ++i, ++idx )
304 for (
int i = 0; i < line.count(); i++ )
323 for (
int i = 0; i < mline.size(); ++i, ++idx )
327 if ( line.size() == 0 )
332 for (
int j = 0; j < line.size(); ++j )
352 for (
int i = 0; i < line.count(); i++ )
371 for (
int i = 0; i < multipoly.size(); ++i, ++idx )
375 for (
int j = 0; j < line.count(); ++j )
427 Q_FOREACH(
const QList<QgsPoint>& line,
mPoints )
429 QVector<QPointF> pts;
430 Q_FOREACH(
const QgsPoint& pt, line )
433 if ( pts.empty() || std::abs( pts.back().x() - cur.x() ) > 1 || std::abs( pts.back().y() - cur.y() ) > 1 )
441 p->drawPolygon( pts );
447 Q_FOREACH(
const QPointF& pt, pts )
460 p->drawLine( QLineF( x - s, y, x + s, y ) );
461 p->drawLine( QLineF( x, y - s, x, y + s ) );
465 p->drawLine( QLineF( x - s, y - s, x + s, y + s ) );
466 p->drawLine( QLineF( x - s, y + s, x + s, y - s ) );
470 p->drawLine( QLineF( x - s, y - s, x + s, y - s ) );
471 p->drawLine( QLineF( x + s, y - s, x + s, y + s ) );
472 p->drawLine( QLineF( x + s, y + s, x - s, y + s ) );
473 p->drawLine( QLineF( x - s, y + s, x - s, y - s ) );
487 p->drawPolyline( pts );
500 QList<QgsPoint>::const_iterator it =
mPoints.at( 0 ).constBegin();
501 if ( it ==
mPoints.at( 0 ).constEnd() )
508 qreal p =
mPen.width() * scale;
513 for (
int i = 0; i <
mPoints.size(); ++i )
515 QList<QgsPoint>::const_iterator it =
mPoints.at( i ).constBegin();
516 for ( ; it !=
mPoints.at( i ).constEnd(); ++it )
529 setVisible(
mPoints.size() > 0 );
546 if ( geometryIndex < 0 || geometryIndex >=
mPoints.size() )
return 0;
547 return mPoints[geometryIndex].size();
553 QList<QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
554 for ( ; it !=
mPoints.constEnd(); ++it )
556 QList<QgsPoint>::const_iterator iter = it->constBegin();
557 for ( ; iter != it->constEnd(); ++iter )
582 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
583 for ( ; it !=
mPoints.constEnd(); ++it )
595 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
596 for ( ; it !=
mPoints.constEnd(); ++it )
612 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
613 for ( ; it !=
mPoints.constEnd(); ++it )
633 QList<QgsPoint>::const_iterator iter = points.constBegin();
634 for ( ; iter != points.constEnd(); ++iter )
636 polyline.append( *iter );
double mTranslationOffsetY
A cross is used to highlight points (x)
void setIconSize(int iconSize)
Set the size of the point icons.
void setWidth(int width)
Set the width of the line.
A rectangle specified with double values.
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
void setTranslationOffset(double dx, double dy)
Adds translation to original coordinates (all in map coordinates)
void setLineStyle(Qt::PenStyle penStyle)
Set the style of the line.
QgsMultiPolyline asMultiPolyline() const
return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list
void movePoint(const QgsPoint &p, int geometryIndex=0)
Moves the rubber band point specified by index.
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
QgsPolygon asPolygon() const
return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list ...
const QgsPoint * getPoint(int i, int j=0) const
Return vertex.
An abstract class for items that can be placed on the map canvas.
QGis::GeometryType type()
Returns type of the vector.
A geometry is the spatial representation of a feature.
int numberOfVertices() const
Returns count of vertices in all lists of mPoint.
A non GUI class for rendering a map layer set onto a QPainter.
A cross is used to highlight points (+)
QgsRectangle rect() const
returns canvas item rectangle
static QIcon icon(QString icon)
QgsGeometry * asGeometry()
Returns the rubberband as a Geometry.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsPoint layerToMapCoordinates(QgsMapLayer *theLayer, QgsPoint point)
transform point coordinates from layer's CRS to output CRS
QgsMultiPolygon asMultiPolygon() const
return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
Perform transforms between map coordinates and device coordinates.
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
QList< QList< QgsPoint > > mPoints
Nested lists used for multitypes.
A circle is used to highlight points (○)
QGis::GeometryType mGeometryType
void removePoint(int index=0, bool doUpdate=true, int geometryIndex=0)
Remove a vertex from the rubberband and (optionally) update canvas.
QVector< QgsPolygon > QgsMultiPolygon
a collection of QgsPolygons that share a common collection of attributes
void addPoint(const QgsPoint &p, bool doUpdate=true, int geometryIndex=0)
Add a vertex to the rubberband and update canvas.
QVector< QgsPoint > QgsMultiPoint
a collection of QgsPoints that share a common collection of attributes
void reset(QGis::GeometryType geometryType=QGis::Line)
Clears all the geometries in this rubberband.
QGis::WkbType wkbType() const
Returns type of wkb (point / linestring / polygon etc.)
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
void setToGeometry(QgsGeometry *geom, QgsVectorLayer *layer)
Sets this rubber band to the geometry of an existing feature.
static QgsPolyline getPolyline(const QList< QgsPoint > &points)
IconType mIconType
Icon to be shown.
A class to represent a point geometry.
QPointF toCanvasCoordinates(const QgsPoint &point)
transformation from map coordinates to screen coordinates
void setBrushStyle(Qt::BrushStyle brushStyle)
Set the style of the brush.
QVector< QgsPolyline > QgsMultiPolyline
a collection of QgsPolylines that share a common collection of attributes
static QgsGeometry * fromMultiPolyline(const QgsMultiPolyline &multiline)
construct geometry from a multipolyline
QgsPoint toMapCoordinates(int x, int y) const
void setIcon(IconType icon)
Set the icon type to highlight point geometries.
QgsPolyline asPolyline() const
return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list ...
A box is used to highlight points (□)
int size() const
Returns number of geometries.
void setToCanvasRectangle(const QRect &rect)
Sets this rubber band to a map canvas rectangle.
QgsMultiPoint asMultiPoint() const
return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list...
QgsMapCanvas * mMapCanvas
pointer to map canvas
QgsMapRenderer * mapRenderer()
int partSize(int geometryIndex) const
Returns number of vertices in feature part.
void setRect(const QgsRectangle &r)
sets canvas item rectangle
const QgsMapToPixel * getCoordinateTransform()
Get the current coordinate transform.
static QgsGeometry * fromMultiPoint(const QgsMultiPoint &multipoint)
construct geometry from a multipoint
static QgsGeometry * fromPolyline(const QgsPolyline &polyline)
construct geometry from a polyline
void setColor(const QColor &color)
Set the color for the rubberband.
double mTranslationOffsetX
static QgsGeometry * fromPolygon(const QgsPolygon &polygon)
construct geometry from a polygon
int mIconSize
The size of the icon for points.
void addGeometry(QgsGeometry *geom, QgsVectorLayer *layer)
Add the geometry of an existing feature to a rubberband This is useful for multi feature highlighting...
virtual void paint(QPainter *p)
QgsPoint asPoint() const
return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
Represents a vector layer which manages a vector based data sets.
void removeLastPoint(int geometryIndex=0, bool doUpdate=true)
Removes the last point.
IconType
Icons Added in 1.9.
void updateRect()
recalculates needed rectangle