QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
|
Shows a grid on the map canvas given a spatial resolution. More...
#include <qgssnaptogridcanvasitem.h>
Public Member Functions | |
QgsSnapToGridCanvasItem (QgsMapCanvas *mapCanvas) | |
Will automatically be added to the mapCanvas. More... | |
QgsCoordinateReferenceSystem | crs () const |
The CRS in which the grid should be calculated. More... | |
bool | enabled () const |
Enable this item. More... | |
void | paint (QPainter *painter) override |
function to be implemented by derived classes More... | |
QgsPointXY | point () const |
A point that will be highlighted on the map canvas. More... | |
double | precision () const |
The resolution of the grid in map units. More... | |
void | setCrs (const QgsCoordinateReferenceSystem &crs) |
The CRS in which the grid should be calculated. More... | |
void | setEnabled (bool enabled) |
Enable this item. More... | |
void | setPoint (const QgsPointXY &point) |
A point that will be highlighted on the map canvas. More... | |
void | setPrecision (double precision) |
The resolution of the grid in map units. More... | |
Public Member Functions inherited from QgsMapCanvasItem | |
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... | |
Additional Inherited Members | |
Protected Member Functions inherited from QgsMapCanvasItem | |
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 inherited from QgsMapCanvasItem | |
QSizeF | mItemSize |
cached size of the item (to return in boundingRect()) More... | |
QgsMapCanvas * | mMapCanvas = 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 |
Shows a grid on the map canvas given a spatial resolution.
Definition at line 41 of file qgssnaptogridcanvasitem.h.
QgsSnapToGridCanvasItem::QgsSnapToGridCanvasItem | ( | QgsMapCanvas * | mapCanvas | ) |
Will automatically be added to the mapCanvas.
Definition at line 20 of file qgssnaptogridcanvasitem.cpp.
QgsCoordinateReferenceSystem QgsSnapToGridCanvasItem::crs | ( | ) | const |
The CRS in which the grid should be calculated.
By default will be an invalid QgsCoordinateReferenceSystem and as such equal to the CRS of the map canvas.
Definition at line 107 of file qgssnaptogridcanvasitem.cpp.
bool QgsSnapToGridCanvasItem::enabled | ( | ) | const |
Enable this item.
It will be hidden if disabled.
Definition at line 118 of file qgssnaptogridcanvasitem.cpp.
|
overridevirtual |
function to be implemented by derived classes
Implements QgsMapCanvasItem.
Definition at line 28 of file qgssnaptogridcanvasitem.cpp.
QgsPointXY QgsSnapToGridCanvasItem::point | ( | ) | const |
A point that will be highlighted on the map canvas.
The point needs to be in map coordinates. The closest point on the grid will be highlighted.
Definition at line 85 of file qgssnaptogridcanvasitem.cpp.
double QgsSnapToGridCanvasItem::precision | ( | ) | const |
The resolution of the grid in map units.
If a crs has been specified it will be in CRS units.
Definition at line 96 of file qgssnaptogridcanvasitem.cpp.
void QgsSnapToGridCanvasItem::setCrs | ( | const QgsCoordinateReferenceSystem & | crs | ) |
The CRS in which the grid should be calculated.
By default will be an invalid QgsCoordinateReferenceSystem and as such equal to the CRS of the map canvas.
Definition at line 112 of file qgssnaptogridcanvasitem.cpp.
void QgsSnapToGridCanvasItem::setEnabled | ( | bool | enabled | ) |
Enable this item.
It will be hidden if disabled.
Definition at line 123 of file qgssnaptogridcanvasitem.cpp.
void QgsSnapToGridCanvasItem::setPoint | ( | const QgsPointXY & | point | ) |
A point that will be highlighted on the map canvas.
The point needs to be in map coordinates. The closest point on the grid will be highlighted.
Definition at line 90 of file qgssnaptogridcanvasitem.cpp.
void QgsSnapToGridCanvasItem::setPrecision | ( | double | precision | ) |
The resolution of the grid in map units.
If a crs has been specified it will be in CRS units.
Definition at line 101 of file qgssnaptogridcanvasitem.cpp.