QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgssnaptogridcanvasitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssnaptogridcanvasitem.h
3  ----------------------
4  begin : August 2018
5  copyright : (C) Matthias Kuhn
6  email : [email protected]
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSSNAPTOGRIDCANVASITEM_H
17 #define QGSSNAPTOGRIDCANVASITEM_H
18 
19 #include <QObject>
20 #include <QPen>
21 
23 #include "qgsmapcanvasitem.h"
24 #include "qgscoordinatetransform.h"
25 
33 class GUI_EXPORT QgsSnapToGridCanvasItem : public QObject, public QgsMapCanvasItem
34 {
35  Q_OBJECT
36 
37  public:
38 
43 
44  void paint( QPainter *painter ) override;
45 
51  QgsPointXY point() const;
52 
58  void setPoint( const QgsPointXY &point );
59 
64  double precision() const;
65 
70  void setPrecision( double precision );
71 
78 
84  void setCrs( const QgsCoordinateReferenceSystem &crs );
85 
89  bool enabled() const;
90 
94  void setEnabled( bool enabled );
95 
96  private slots:
97  void updateMapCanvasCrs();
98 
99  void updateZoomFactor();
100 
101  private:
102  QPen mGridPen = QPen( QColor( 127, 127, 127, 150 ) );
103  QPen mCurrentPointPen = QPen( QColor( 200, 200, 200, 150 ) );
104 
105  bool mEnabled = true;
106  bool mAvailableByZoomFactor = false;
107 
108  double mPrecision = 0.0;
109  QgsCoordinateTransform mTransform;
110  QgsPointXY mPoint;
111 };
112 
113 #endif // QGSSNAPTOGRIDCANVASITEM_H
int precision
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A class to represent a 2D point.
Definition: qgspointxy.h:43
An abstract class for items that can be placed on the map canvas.
const QgsCoordinateReferenceSystem & crs
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
Shows a grid on the map canvas given a spatial resolution.
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
This class represents a coordinate reference system (CRS).
Class for doing transforms between two map coordinate systems.