QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
QgsSnapToGridCanvasItem Class Reference

Shows a grid on the map canvas given a spatial resolution. More...

#include <qgssnaptogridcanvasitem.h>

Inheritance diagram for QgsSnapToGridCanvasItem:

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())
QgsMapCanvasmMapCanvas = 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 = 0.0

Detailed Description

Shows a grid on the map canvas given a spatial resolution.

Since
QGIS 3.4

Definition at line 41 of file qgssnaptogridcanvasitem.h.

Constructor & Destructor Documentation

◆ QgsSnapToGridCanvasItem()

QgsSnapToGridCanvasItem::QgsSnapToGridCanvasItem ( QgsMapCanvas * mapCanvas)

Will automatically be added to the mapCanvas.

Definition at line 23 of file qgssnaptogridcanvasitem.cpp.

Member Function Documentation

◆ crs()

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 109 of file qgssnaptogridcanvasitem.cpp.

◆ enabled()

bool QgsSnapToGridCanvasItem::enabled ( ) const

Enable this item.

It will be hidden if disabled.

Definition at line 120 of file qgssnaptogridcanvasitem.cpp.

◆ paint()

void QgsSnapToGridCanvasItem::paint ( QPainter * painter)
overridevirtual

function to be implemented by derived classes

Implements QgsMapCanvasItem.

Definition at line 31 of file qgssnaptogridcanvasitem.cpp.

◆ point()

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 87 of file qgssnaptogridcanvasitem.cpp.

◆ precision()

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 98 of file qgssnaptogridcanvasitem.cpp.

◆ setCrs()

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 114 of file qgssnaptogridcanvasitem.cpp.

◆ setEnabled()

void QgsSnapToGridCanvasItem::setEnabled ( bool enabled)

Enable this item.

It will be hidden if disabled.

Definition at line 125 of file qgssnaptogridcanvasitem.cpp.

◆ setPoint()

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 92 of file qgssnaptogridcanvasitem.cpp.

◆ setPrecision()

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 103 of file qgssnaptogridcanvasitem.cpp.


The documentation for this class was generated from the following files: