QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
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. | |
QgsCoordinateReferenceSystem | crs () const |
The CRS in which the grid should be calculated. | |
bool | enabled () const |
Enable this item. | |
void | paint (QPainter *painter) override |
function to be implemented by derived classes | |
QgsPointXY | point () const |
A point that will be highlighted on the map canvas. | |
double | precision () const |
The resolution of the grid in map units. | |
void | setCrs (const QgsCoordinateReferenceSystem &crs) |
The CRS in which the grid should be calculated. | |
void | setEnabled (bool enabled) |
Enable this item. | |
void | setPoint (const QgsPointXY &point) |
A point that will be highlighted on the map canvas. | |
void | setPrecision (double precision) |
The resolution of the grid in map units. | |
Public Member Functions inherited from QgsMapCanvasItem | |
QRectF | boundingRect () const override |
QgsRectangle | rect () const |
returns canvas item rectangle in map units | |
void | setRect (const QgsRectangle &r, bool resetRotation=true) |
sets canvas item rectangle in map units | |
QPointF | toCanvasCoordinates (const QgsPointXY &point) const |
transformation from map coordinates to screen coordinates | |
QgsPointXY | toMapCoordinates (QPoint point) const |
transformation from screen coordinates to map coordinates | |
virtual void | updatePosition () |
called on changed extent or resize event to update position of the item | |
Additional Inherited Members | |
Protected Member Functions inherited from QgsMapCanvasItem | |
QgsMapCanvasItem (QgsMapCanvas *mapCanvas) | |
protected constructor: cannot be constructed directly | |
~QgsMapCanvasItem () override | |
void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override |
bool | setRenderContextVariables (QPainter *p, QgsRenderContext &context) const |
Sets render context parameters. | |
void | updateCanvas () |
schedules map canvas for repaint | |
Protected Attributes inherited from QgsMapCanvasItem | |
QSizeF | mItemSize |
cached size of the item (to return in boundingRect()) | |
QgsMapCanvas * | mMapCanvas = nullptr |
pointer to map canvas | |
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. | |
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 21 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 108 of file qgssnaptogridcanvasitem.cpp.
bool QgsSnapToGridCanvasItem::enabled | ( | ) | const |
Enable this item.
It will be hidden if disabled.
Definition at line 119 of file qgssnaptogridcanvasitem.cpp.
|
overridevirtual |
function to be implemented by derived classes
Implements QgsMapCanvasItem.
Definition at line 29 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 86 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 97 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 113 of file qgssnaptogridcanvasitem.cpp.
void QgsSnapToGridCanvasItem::setEnabled | ( | bool | enabled | ) |
Enable this item.
It will be hidden if disabled.
Definition at line 124 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 91 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 102 of file qgssnaptogridcanvasitem.cpp.