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 );
void setForceVectorOutput(bool force)
A rectangle specified with double values.
QgsRectangle rect() const
returns canvas item rectangle in map units
QgsPointXY toMapCoordinates(QPoint point) const
transformation from screen coordinates to map coordinates
A class to represent a 2D point.
double rotation() const
Gets the current map canvas rotation in clockwise degrees.
void setRendererScale(double scale)
Sets the renderer map scale.
Map canvas is a class for displaying all GIS data types on a canvas.
The QgsMapSettings class contains configuration for rendering of the map.
void transformInPlace(double &x, double &y) const
Transform device coordinates to map coordinates.
~QgsMapCanvasItem() override
QSizeF mItemSize
cached size of the item (to return in boundingRect())
Perform transforms between map coordinates and device coordinates.
QRectF boundingRect() const override
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
bool isEmpty() const
Returns true if the rectangle is empty.
double width() const
Returns the width of the rectangle.
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
QgsRectangle mRect
cached canvas item rectangle in map coordinates encodes position (xmin,ymax) and size (width/height) ...
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
double mapUnitsPerPixel() const
Returns current map units per pixel.
QgsMapCanvasItem(QgsMapCanvas *mapCanvas)
protected constructor: cannot be constructed directly
void updateCanvas()
schedules map canvas for repaint
double scale() const
Returns the last reported scale of the canvas.
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
Contains information about the context of a rendering operation.
bool antiAliasingEnabled() const
true if antialising is enabled
QgsMapCanvas * mMapCanvas
pointer to map canvas
double xMinimum() const
Returns the x minimum value (left side of rectangle).
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates
virtual void updatePosition()
called on changed extent or resize event to update position of the item
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
double height() const
Returns the height of the rectangle.
bool setRenderContextVariables(QPainter *p, QgsRenderContext &context) const
Sets render context parameters.