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