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