QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsMapCanvasItem Class Referenceabstract

An abstract class for items that can be placed on the map canvas. More...

#include <qgsmapcanvasitem.h>

Inheritance diagram for QgsMapCanvasItem:
Inheritance graph
[legend]

Public Member Functions

QRectF boundingRect () const override
 
QgsRectangle rect () const
 returns canvas item rectangle in map units More...
 
void setRect (const QgsRectangle &r, bool resetRotation=true)
 sets canvas item rectangle in map units More...
 
QPointF toCanvasCoordinates (const QgsPointXY &point) const
 transformation from map coordinates to screen coordinates More...
 
QgsPointXY toMapCoordinates (QPoint point) const
 transformation from screen coordinates to map coordinates More...
 
virtual void updatePosition ()
 called on changed extent or resize event to update position of the item More...
 

Protected Member Functions

 QgsMapCanvasItem (QgsMapCanvas *mapCanvas)
 protected constructor: cannot be constructed directly More...
 
 ~QgsMapCanvasItem () override
 
virtual void paint (QPainter *painter)=0
 function to be implemented by derived classes More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
 
bool setRenderContextVariables (QPainter *p, QgsRenderContext &context) const
 Sets render context parameters. More...
 
void updateCanvas ()
 schedules map canvas for repaint More...
 

Protected Attributes

QSizeF mItemSize
 cached size of the item (to return in boundingRect()) More...
 
QgsMapCanvasmMapCanvas = nullptr
 pointer to map canvas More...
 
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. More...
 
double mRectRotation
 

Detailed Description

An abstract class for items that can be placed on the map canvas.

Definition at line 33 of file qgsmapcanvasitem.h.

Constructor & Destructor Documentation

◆ QgsMapCanvasItem()

QgsMapCanvasItem::QgsMapCanvasItem ( QgsMapCanvas mapCanvas)
protected

protected constructor: cannot be constructed directly

Definition at line 28 of file qgsmapcanvasitem.cpp.

◆ ~QgsMapCanvasItem()

QgsMapCanvasItem::~QgsMapCanvasItem ( )
overrideprotected

Definition at line 37 of file qgsmapcanvasitem.cpp.

Member Function Documentation

◆ boundingRect()

QRectF QgsMapCanvasItem::boundingRect ( ) const
override

Definition at line 106 of file qgsmapcanvasitem.cpp.

◆ paint() [1/2]

virtual void QgsMapCanvasItem::paint ( QPainter *  painter)
protectedpure virtual

◆ paint() [2/2]

void QgsMapCanvasItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = nullptr 
)
overrideprotected

Definition at line 42 of file qgsmapcanvasitem.cpp.

◆ rect()

QgsRectangle QgsMapCanvasItem::rect ( ) const

returns canvas item rectangle in map units

Definition at line 68 of file qgsmapcanvasitem.cpp.

◆ setRect()

void QgsMapCanvasItem::setRect ( const QgsRectangle r,
bool  resetRotation = true 
)

sets canvas item rectangle in map units

Definition at line 74 of file qgsmapcanvasitem.cpp.

◆ setRenderContextVariables()

bool QgsMapCanvasItem::setRenderContextVariables ( QPainter *  p,
QgsRenderContext context 
) const
protected

Sets render context parameters.

Parameters
ppainter for rendering
contextout: configured context
Returns
true in case of success

Definition at line 119 of file qgsmapcanvasitem.cpp.

◆ toCanvasCoordinates()

QPointF QgsMapCanvasItem::toCanvasCoordinates ( const QgsPointXY point) const

transformation from map coordinates to screen coordinates

Definition at line 61 of file qgsmapcanvasitem.cpp.

◆ toMapCoordinates()

QgsPointXY QgsMapCanvasItem::toMapCoordinates ( QPoint  point) const

transformation from screen coordinates to map coordinates

Definition at line 55 of file qgsmapcanvasitem.cpp.

◆ updateCanvas()

void QgsMapCanvasItem::updateCanvas ( )
protected

schedules map canvas for repaint

Definition at line 112 of file qgsmapcanvasitem.cpp.

◆ updatePosition()

void QgsMapCanvasItem::updatePosition ( )
virtual

called on changed extent or resize event to update position of the item

Reimplemented in QgsAdvancedDigitizingCanvasItem, QgsGeometryRubberBand, QgsHighlight, QgsMapCanvasAnnotationItem, QgsRubberBand, and QgsVertexMarker.

Definition at line 135 of file qgsmapcanvasitem.cpp.

Member Data Documentation

◆ mItemSize

QSizeF QgsMapCanvasItem::mItemSize
protected

cached size of the item (to return in boundingRect())

Definition at line 99 of file qgsmapcanvasitem.h.

◆ mMapCanvas

QgsMapCanvas* QgsMapCanvasItem::mMapCanvas = nullptr
protected

pointer to map canvas

Definition at line 82 of file qgsmapcanvasitem.h.

◆ mRect

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

Definition at line 94 of file qgsmapcanvasitem.h.

◆ mRectRotation

double QgsMapCanvasItem::mRectRotation
protected

Definition at line 96 of file qgsmapcanvasitem.h.


The documentation for this class was generated from the following files: