QgsMapCanvasItem class
An abstract class for items that can be placed on the map canvas.
Contents
Derived classes
- class QgsAdvancedDigitizingCanvasItem
- The QgsAdvancedDigitizingCanvasItem class draws the graphical elements of the CAD tools (.
- class QgsGeometryRubberBand
- A rubberband class for QgsAbstractGeometry (considering curved geometries)
- class QgsHighlight
- A class for highlight features on the map.
- class QgsMapCanvasAnnotationItem
- An interactive map canvas item which displays a QgsAnnotation.
- class QgsRubberBand
- A class for drawing transient features (e.g.
- class QgsSnapToGridCanvasItem
- Shows a grid on the map canvas given a spatial resolution.
- class QgsVertexMarker
- A class for marking vertices of features using e.g.
Constructors, destructors, conversion operators
- QgsMapCanvasItem(QgsMapCanvas* mapCanvas) protected
- protected constructor: cannot be constructed directly
Public functions
- auto rect() const -> QgsRectangle
- returns canvas item rectangle in map units
- void setRect(const QgsRectangle& r, bool resetRotation = true)
- sets canvas item rectangle in map units
- auto toCanvasCoordinates(const QgsPointXY& point) const -> QPointF
- transformation from map coordinates to screen coordinates
- auto toMapCoordinates(QPoint point) const -> QgsPointXY
- transformation from screen coordinates to map coordinates
- void updatePosition() virtual
- called on changed extent or resize event to update position of the item
Protected functions
- void paint(QPainter* painter) pure virtual
- function to be implemented by derived classes
- auto setRenderContextVariables(QPainter* p, QgsRenderContext& context) const -> bool
- Sets render context parameters.
- void updateCanvas()
- schedules map canvas for repaint
Protected variables
- QSizeF mItemSize
- cached size of the item (to return in boundingRect())
- QgsMapCanvas* mMapCanvas
- pointer to map canvas
- QgsRectangle mRect
- cached canvas item rectangle in map coordinates encodes position (xmin,ymax) and size (width/height) used to re-position and re-size the item on zoom/pan while waiting for the renderer to complete.
Function documentation
bool QgsMapCanvasItem:: setRenderContextVariables(QPainter* p,
QgsRenderContext& context) const protected
Sets render context parameters.
| Parameters | |
|---|---|
| p | painter for rendering |
| context | out: configured context |
| Returns | true in case of success |
Variable documentation
QgsRectangle QgsMapCanvasItem:: mRect protected
cached canvas item rectangle in map coordinates encodes position (xmin,ymax) and size (width/height) used to re-position and re-size the item on zoom/pan while waiting for the renderer to complete.
NOTE: does not include rotation information, so cannot be used to correctly present pre-rendered map on rotation change