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 )
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 )
285 for (
int i = 0; i < mpt.size(); ++i, ++idx )
306 for (
int i = 0; i < line.count(); i++ )
325 for (
int i = 0; i < mline.size(); ++i, ++idx )
329 if ( line.size() == 0 )
334 for (
int j = 0; j < line.size(); ++j )
354 for (
int i = 0; i < line.count(); i++ )
373 for (
int i = 0; i < multipoly.size(); ++i, ++idx )
377 for (
int j = 0; j < line.count(); ++j )
429 Q_FOREACH(
const QList<QgsPoint>& line,
mPoints )
431 QVector<QPointF> pts;
432 Q_FOREACH(
const QgsPoint& pt, line )
435 if ( pts.empty() || std::abs( pts.back().x() - cur.x() ) > 1 || std::abs( pts.back().y() - cur.y() ) > 1 )
443 p->drawPolygon( pts );
449 Q_FOREACH(
const QPointF& pt, pts )
462 p->drawLine( QLineF( x - s, y, x + s, y ) );
463 p->drawLine( QLineF( x, y - s, x, y + s ) );
467 p->drawLine( QLineF( x - s, y - s, x + s, y + s ) );
468 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 ) );
474 p->drawLine( QLineF( x + s, y + s, x - s, y + s ) );
475 p->drawLine( QLineF( x - s, y + s, x - s, y - s ) );
493 p->drawPolyline( pts );
506 QList<QgsPoint>::const_iterator it =
mPoints.at( 0 ).constBegin();
507 if ( it ==
mPoints.at( 0 ).constEnd() )
514 qreal p =
mPen.width() * scale;
519 for (
int i = 0; i <
mPoints.size(); ++i )
521 QList<QgsPoint>::const_iterator it =
mPoints.at( i ).constBegin();
522 for ( ; it !=
mPoints.at( i ).constEnd(); ++it )
535 setVisible(
mPoints.size() > 0 );
552 if ( geometryIndex < 0 || geometryIndex >=
mPoints.size() )
return 0;
553 return mPoints[geometryIndex].size();
559 QList<QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
560 for ( ; it !=
mPoints.constEnd(); ++it )
562 QList<QgsPoint>::const_iterator iter = it->constBegin();
563 for ( ; iter != it->constEnd(); ++iter )
588 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
589 for ( ; it !=
mPoints.constEnd(); ++it )
601 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
602 for ( ; it !=
mPoints.constEnd(); ++it )
618 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
619 for ( ; it !=
mPoints.constEnd(); ++it )
639 QList<QgsPoint>::const_iterator iter = points.constBegin();
640 for ( ; iter != points.constEnd(); ++iter )
642 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.
QgsPoint layerToMapCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from layer's CRS to output CRS
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.
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
int numberOfVertices() const
Returns count of vertices in all lists of mPoint.
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.
QgsMultiPolygon asMultiPolygon() const
return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
The QgsMapSettings class contains configuration for rendering of the map.
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
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
A full box is used to highlight points (■)