21#include <QGraphicsScene>
29 : mMapCanvas( mapCanvas )
30 , mRectRotation( 0.0 )
33 Q_ASSERT( mapCanvas && mapCanvas->scene() );
34 mapCanvas->scene()->addItem(
this );
43 const QStyleOptionGraphicsItem *option,
50 painter->setRenderHint( QPainter::Antialiasing );
63 qreal x = point.
x(), y = point.
y();
65 return QPointF( x, y );
91 prepareGeometryChange();
92 setPos( r.topLeft() );
93 mItemSize = QSizeF( r.width() + 2, r.height() + 2 );
108 return QRectF( QPointF( -1, -1 ),
mItemSize );
QRectF boundingRect() const override
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
QSizeF mItemSize
cached size of the item (to return in boundingRect())
QgsRectangle rect() const
returns canvas item rectangle in map units
QgsRectangle mRect
cached canvas item rectangle in map coordinates encodes position (xmin,ymax) and size (width/height) ...
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates
QgsMapCanvas * mMapCanvas
pointer to map canvas
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
QgsMapCanvasItem(QgsMapCanvas *mapCanvas)
protected constructor: cannot be constructed directly
void updateCanvas()
schedules map canvas for repaint
~QgsMapCanvasItem() override
bool setRenderContextVariables(QPainter *p, QgsRenderContext &context) const
Sets render context parameters.
virtual void updatePosition()
called on changed extent or resize event to update position of the item
QgsPointXY toMapCoordinates(QPoint point) const
transformation from screen coordinates to map coordinates
Map canvas is a class for displaying all GIS data types on a canvas.
bool antiAliasingEnabled() const
true if antialiasing is enabled
double scale() const
Returns the last reported scale of the canvas.
double rotation() const
Gets the current map canvas rotation in clockwise degrees.
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
The QgsMapSettings class contains configuration for rendering of the map.
double outputDpi() const
Returns the DPI (dots per inch) used for conversion between real world units (e.g.
Perform transforms between map coordinates and device coordinates.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
void transformInPlace(double &x, double &y) const
Transforms device coordinates to map coordinates.
A class to represent a 2D point.
A rectangle specified with double values.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double width() const
Returns the width of the rectangle.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
bool isEmpty() const
Returns true if the rectangle has no area.
double height() const
Returns the height of the rectangle.
Contains information about the context of a rendering operation.
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
void setRendererScale(double scale)
Sets the renderer map scale.