QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsSnapToGridCanvasItem Class Reference

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

#include <qgssnaptogridcanvasitem.h>

Inheritance diagram for QgsSnapToGridCanvasItem:
Inheritance graph
[legend]

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
 

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

◆ enabled()

bool QgsSnapToGridCanvasItem::enabled ( ) const

Enable this item.

It will be hidden if disabled.

Definition at line 119 of file qgssnaptogridcanvasitem.cpp.

◆ paint()

void QgsSnapToGridCanvasItem::paint ( QPainter *  painter)
overridevirtual

function to be implemented by derived classes

Implements QgsMapCanvasItem.

Definition at line 29 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 86 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 97 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 113 of file qgssnaptogridcanvasitem.cpp.

◆ setEnabled()

void QgsSnapToGridCanvasItem::setEnabled ( bool  enabled)

Enable this item.

It will be hidden if disabled.

Definition at line 124 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 91 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 102 of file qgssnaptogridcanvasitem.cpp.


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