QGIS API Documentation  3.6.0-Noosa (5873452)
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. 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
 
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...
 
QgsMapCanvasmMapCanvas = 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
 

Detailed Description

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

Since
QGIS 3.4

Definition at line 33 of file qgssnaptogridcanvasitem.h.

Constructor & Destructor Documentation

◆ QgsSnapToGridCanvasItem()

QgsSnapToGridCanvasItem::QgsSnapToGridCanvasItem ( QgsMapCanvas mapCanvas)

Will automatically be added to the mapCanvas.

Definition at line 19 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 106 of file qgssnaptogridcanvasitem.cpp.

◆ enabled()

bool QgsSnapToGridCanvasItem::enabled ( ) const

Enable this item.

It will be hidden if disabled.

Definition at line 117 of file qgssnaptogridcanvasitem.cpp.

◆ paint()

void QgsSnapToGridCanvasItem::paint ( QPainter *  painter)
overridevirtual

function to be implemented by derived classes

Implements QgsMapCanvasItem.

Definition at line 27 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 84 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 95 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 111 of file qgssnaptogridcanvasitem.cpp.

◆ setEnabled()

void QgsSnapToGridCanvasItem::setEnabled ( bool  enabled)

Enable this item.

It will be hidden if disabled.

Definition at line 122 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 89 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 100 of file qgssnaptogridcanvasitem.cpp.


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