Quantum GIS API Documentation
1.7.5-Wroclaw
|
A class for drawing transient features (e.g. More...
#include <qgsrubberband.h>
Public Member Functions | |
QgsRubberBand (QgsMapCanvas *mapCanvas, bool isPolygon=false) | |
~QgsRubberBand () | |
void | setColor (const QColor &color) |
void | setWidth (int width) |
void | reset (bool isPolygon=false) |
void | addPoint (const QgsPoint &p, bool update=true, int geometryIndex=0) |
Add point to rubberband and update canvas If adding more points consider using update=false for better performance geometryIndex is the index of the feature part (in case of multipart geometries) | |
void | removeLastPoint (int geometryIndex=0) |
Removes the last point. Most useful in connection with undo operations. | |
void | movePoint (const QgsPoint &p, int geometryIndex=0) |
void | movePoint (int index, const QgsPoint &p, int geometryIndex=0) |
Moves the rubber band point specified by index. | |
void | setToGeometry (QgsGeometry *geom, QgsVectorLayer *layer) |
Sets this rubber band to the geometry of an existing feature. | |
void | setToCanvasRectangle (const QRect &rect) |
Sets this rubber band to a map canvas rectangle. | |
void | addGeometry (QgsGeometry *geom, QgsVectorLayer *layer) |
Add the geometry of an existing feature to a rubberband This is useful for multi feature highlighting. | |
void | setTranslationOffset (double dx, double dy) |
Adds translation to original coordinates (all in map coordinates) | |
int | size () const |
Returns number of geometries added in 1.5. | |
int | numberOfVertices () const |
Returns count of vertices in all lists of mPoint. | |
const QgsPoint * | getPoint (int i, int j=0) const |
Return vertex. | |
QgsGeometry * | asGeometry () |
Returns the rubberband as a Geometry. | |
![]() | |
virtual void | updatePosition () |
called on changed extent or resize event to update position of the item | |
virtual QRectF | boundingRect () const |
default implementation for canvas items | |
void | setPanningOffset (const QPoint &point) |
sets current offset, to be called from QgsMapCanvas | |
QgsRectangle | rect () const |
returns canvas item rectangle | |
void | setRect (const QgsRectangle &r) |
sets canvas item rectangle | |
QgsPoint | toMapCoordinates (const QPoint &point) |
transformation from screen coordinates to map coordinates | |
QPointF | toCanvasCoordinates (const QgsPoint &point) |
transformation from map coordinates to screen coordinates |
Protected Member Functions | |
virtual void | paint (QPainter *p) |
void | updateRect () |
recalculates needed rectangle | |
![]() | |
QgsMapCanvasItem (QgsMapCanvas *mapCanvas) | |
protected constructor: cannot be constructed directly | |
virtual | ~QgsMapCanvasItem () |
virtual void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) |
paint function called by map canvas | |
void | updateCanvas () |
schedules map canvas for repaint | |
bool | setRenderContextVariables (QPainter *p, QgsRenderContext &context) const |
Sets render context parameters. |
Private Member Functions | |
QgsRubberBand () |
Static Private Member Functions | |
static QgsPolyline | getPolyline (const QList< QgsPoint > &points) |
Private Attributes | |
QBrush | mBrush |
QPen | mPen |
QList< QList< QgsPoint > > | mPoints |
Nested lists used for multitypes. | |
bool | mIsPolygon |
double | mTranslationOffsetX |
double | mTranslationOffsetY |
Additional Inherited Members | |
![]() | |
QgsMapCanvas * | mMapCanvas |
pointer to map canvas | |
QgsRectangle | mRect |
canvas item rectangle (in map coordinates) | |
QPoint | mPanningOffset |
offset from normal position due current panning operation, used when converting map coordinates to move map canvas items | |
QSizeF | mItemSize |
cached size of the item (to return in boundingRect()) |
A class for drawing transient features (e.g.
The QgsRubberBand class provides a transparent overlay widget for tracking the mouse while drawing polylines or polygons.
digitising lines) on the map.
Definition at line 32 of file qgsrubberband.h.
QgsRubberBand::QgsRubberBand | ( | QgsMapCanvas * | mapCanvas, |
bool | isPolygon = false |
||
) |
Definition at line 31 of file qgsrubberband.cpp.
References reset(), and setColor().
QgsRubberBand::~QgsRubberBand | ( | ) |
Definition at line 45 of file qgsrubberband.cpp.
|
private |
Definition at line 41 of file qgsrubberband.cpp.
void QgsRubberBand::addGeometry | ( | QgsGeometry * | geom, |
QgsVectorLayer * | layer | ||
) |
Add the geometry of an existing feature to a rubberband This is useful for multi feature highlighting.
geom | the geometry object |
layer | the layer containing the feature, used for coord transformation to map crs. In case of 0 pointer, the coordinates are not going to be transformed. |
Definition at line 178 of file qgsrubberband.cpp.
References addPoint(), QgsGeometry::asMultiPoint(), QgsGeometry::asMultiPolygon(), QgsGeometry::asMultiPolyline(), QgsGeometry::asPoint(), QgsGeometry::asPolygon(), QgsGeometry::asPolyline(), QgsMapCanvas::extent(), QgsMapRenderer::layerToMapCoordinates(), QgsMapCanvas::mapRenderer(), mIsPolygon, QgsMapCanvasItem::mMapCanvas, mPoints, updateRect(), QgsRectangle::width(), QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, QgsGeometry::wkbType(), QGis::WKBUnknown, QgsPoint::x(), and QgsPoint::y().
Referenced by setToGeometry().
void QgsRubberBand::addPoint | ( | const QgsPoint & | p, |
bool | do_update = true , |
||
int | geometryIndex = 0 |
||
) |
Add point to rubberband and update canvas If adding more points consider using update=false for better performance geometryIndex is the index of the feature part (in case of multipart geometries)
Add a point to the shape being created.
Definition at line 82 of file qgsrubberband.cpp.
References mPoints, size(), and updateRect().
Referenced by addGeometry(), and setToCanvasRectangle().
QgsGeometry * QgsRubberBand::asGeometry | ( | ) |
Returns the rubberband as a Geometry.
added in 1.6
Definition at line 459 of file qgsrubberband.cpp.
References QgsGeometry::fromMultiPolyline(), QgsGeometry::fromPolygon(), QgsGeometry::fromPolyline(), getPolyline(), mIsPolygon, and mPoints.
const QgsPoint * QgsRubberBand::getPoint | ( | int | i, |
int | j = 0 |
||
) | const |
|
staticprivate |
Definition at line 495 of file qgsrubberband.cpp.
Referenced by asGeometry().
void QgsRubberBand::movePoint | ( | const QgsPoint & | p, |
int | geometryIndex = 0 |
||
) |
Update the line between the last added point and the mouse position.
Definition at line 136 of file qgsrubberband.cpp.
References mPoints, and updateRect().
void QgsRubberBand::movePoint | ( | int | index, |
const QgsPoint & | p, | ||
int | geometryIndex = 0 |
||
) |
Moves the rubber band point specified by index.
Note that if the rubber band is not used to track the last mouse position, the first point of the rubber band has two vertices
Definition at line 154 of file qgsrubberband.cpp.
References mPoints, and updateRect().
int QgsRubberBand::numberOfVertices | ( | ) | const |
Returns count of vertices in all lists of mPoint.
Definition at line 436 of file qgsrubberband.cpp.
References mPoints.
|
protectedvirtual |
Draw the shape in response to an update event.
Implements QgsMapCanvasItem.
Definition at line 365 of file qgsrubberband.cpp.
References mBrush, mIsPolygon, mPen, mPoints, mTranslationOffsetX, mTranslationOffsetY, and QgsMapCanvasItem::toCanvasCoordinates().
void QgsRubberBand::removeLastPoint | ( | int | geometryIndex = 0 | ) |
Removes the last point. Most useful in connection with undo operations.
Definition at line 117 of file qgsrubberband.cpp.
References mPoints, size(), and updateRect().
void QgsRubberBand::reset | ( | bool | isPolygon = false | ) |
Remove all points from the shape being created.
Definition at line 71 of file qgsrubberband.cpp.
References mIsPolygon, mPoints, and updateRect().
Referenced by QgsRubberBand(), setToCanvasRectangle(), and setToGeometry().
void QgsRubberBand::setColor | ( | const QColor & | color | ) |
Set the outline and fill color.
Definition at line 52 of file qgsrubberband.cpp.
Referenced by QgsRubberBand().
void QgsRubberBand::setToCanvasRectangle | ( | const QRect & | rect | ) |
Sets this rubber band to a map canvas rectangle.
rect | rectangle in canvas coordinates |
Definition at line 344 of file qgsrubberband.cpp.
References addPoint(), QgsMapCanvas::getCoordinateTransform(), QgsMapCanvasItem::mMapCanvas, reset(), QgsMapToPixel::toMapCoordinates(), QgsPoint::x(), and QgsPoint::y().
Referenced by QgsMapToolZoom::canvasMoveEvent().
void QgsRubberBand::setToGeometry | ( | QgsGeometry * | geom, |
QgsVectorLayer * | layer | ||
) |
Sets this rubber band to the geometry of an existing feature.
This is useful for feature highlighting.
geom | the geometry object |
layer | the layer containing the feature, used for coord transformation to map crs. In case of 0 pointer, the coordinates are not going to be transformed. |
Definition at line 172 of file qgsrubberband.cpp.
References addGeometry(), mIsPolygon, and reset().
void QgsRubberBand::setTranslationOffset | ( | double | dx, |
double | dy | ||
) |
Adds translation to original coordinates (all in map coordinates)
Definition at line 424 of file qgsrubberband.cpp.
References mTranslationOffsetX, mTranslationOffsetY, and updateRect().
void QgsRubberBand::setWidth | ( | int | width | ) |
int QgsRubberBand::size | ( | void | ) | const |
Returns number of geometries added in 1.5.
Definition at line 431 of file qgsrubberband.cpp.
References mPoints.
Referenced by addPoint(), and removeLastPoint().
|
protected |
recalculates needed rectangle
Definition at line 394 of file qgsrubberband.cpp.
References mPoints, mTranslationOffsetX, mTranslationOffsetY, and QgsMapCanvasItem::setRect().
Referenced by addGeometry(), addPoint(), movePoint(), removeLastPoint(), reset(), and setTranslationOffset().
|
private |
Definition at line 102 of file qgsrubberband.h.
Referenced by paint(), and setColor().
|
private |
Definition at line 107 of file qgsrubberband.h.
Referenced by addGeometry(), asGeometry(), paint(), reset(), and setToGeometry().
|
private |
Definition at line 103 of file qgsrubberband.h.
Referenced by paint(), setColor(), and setWidth().
|
private |
Nested lists used for multitypes.
Definition at line 106 of file qgsrubberband.h.
Referenced by addGeometry(), addPoint(), asGeometry(), getPoint(), movePoint(), numberOfVertices(), paint(), removeLastPoint(), reset(), size(), and updateRect().
|
private |
Definition at line 108 of file qgsrubberband.h.
Referenced by paint(), setTranslationOffset(), and updateRect().
|
private |
Definition at line 109 of file qgsrubberband.h.
Referenced by paint(), setTranslationOffset(), and updateRect().