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 )
289 for (
int i = 0; i < mpt.size(); ++i, ++idx )
310 for (
int i = 0; i < line.count(); i++ )
329 for (
int i = 0; i < mline.size(); ++i, ++idx )
333 if ( line.size() == 0 )
338 for (
int j = 0; j < line.size(); ++j )
358 for (
int i = 0; i < line.count(); i++ )
377 for (
int i = 0; i < multipoly.size(); ++i, ++idx )
381 for (
int j = 0; j < line.count(); ++j )
433 Q_FOREACH(
const QList<QgsPoint>& line,
mPoints )
435 QVector<QPointF> pts;
436 Q_FOREACH(
const QgsPoint& pt, line )
439 if ( pts.empty() || std::abs( pts.back().x() - cur.x() ) > 1 || std::abs( pts.back().y() - cur.y() ) > 1 )
447 p->drawPolygon( pts );
453 Q_FOREACH(
const QPointF& pt, pts )
466 p->drawLine( QLineF( x - s, y, x + s, y ) );
467 p->drawLine( QLineF( x, y - s, x, 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 ) );
476 p->drawLine( QLineF( x - s, y - s, x + s, y - s ) );
477 p->drawLine( QLineF( x + s, y - s, x + s, y + s ) );
478 p->drawLine( QLineF( x + s, y + s, x - s, y + s ) );
479 p->drawLine( QLineF( x - s, y + s, x - s, y - s ) );
497 p->drawPolyline( pts );
510 QList<QgsPoint>::const_iterator it =
mPoints.at( 0 ).constBegin();
511 if ( it ==
mPoints.at( 0 ).constEnd() )
518 qreal p =
mPen.width() * scale;
523 for (
int i = 0; i <
mPoints.size(); ++i )
525 QList<QgsPoint>::const_iterator it =
mPoints.at( i ).constBegin();
526 for ( ; it !=
mPoints.at( i ).constEnd(); ++it )
539 setVisible(
mPoints.size() > 0 );
556 if ( geometryIndex < 0 || geometryIndex >=
mPoints.size() )
return 0;
557 return mPoints[geometryIndex].size();
563 QList<QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
564 for ( ; it !=
mPoints.constEnd(); ++it )
566 QList<QgsPoint>::const_iterator iter = it->constBegin();
567 for ( ; iter != it->constEnd(); ++iter )
592 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
593 for ( ; it !=
mPoints.constEnd(); ++it )
605 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
606 for ( ; it !=
mPoints.constEnd(); ++it )
622 QList< QList<QgsPoint> >::const_iterator it =
mPoints.constBegin();
623 for ( ; it !=
mPoints.constEnd(); ++it )
643 QList<QgsPoint>::const_iterator iter = points.constBegin();
644 for ( ; iter != points.constEnd(); ++iter )
646 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.
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
A full box is used to highlight points (■)