QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
26 #ifdef SIP_RUN
27 % ModuleHeaderCode
28 // For ConvertToSubClassCode.
30 % End
31 #endif
32 
40 class GUI_EXPORT QgsSnapToGridCanvasItem : public QObject, public QgsMapCanvasItem
41 {
42  Q_OBJECT
43 
44 #ifdef SIP_RUN
46  if ( dynamic_cast<QgsSnapToGridCanvasItem *>( sipCpp ) )
47  sipType = sipType_QgsSnapToGridCanvasItem;
48  else
49  sipType = nullptr;
50  SIP_END
51 #endif
52 
53  public:
54 
59 
60  void paint( QPainter *painter ) override;
61 
67  QgsPointXY point() const;
68 
74  void setPoint( const QgsPointXY &point );
75 
80  double precision() const;
81 
86  void setPrecision( double precision );
87 
94 
100  void setCrs( const QgsCoordinateReferenceSystem &crs );
101 
105  bool enabled() const;
106 
110  void setEnabled( bool enabled );
111 
112  private slots:
113  void updateMapCanvasCrs();
114 
115  void updateZoomFactor();
116 
117  private:
118  QPen mGridPen = QPen( QColor( 127, 127, 127, 150 ) );
119  QPen mCurrentPointPen = QPen( QColor( 200, 200, 200, 150 ) );
120 
121  bool mEnabled = true;
122  bool mAvailableByZoomFactor = false;
123 
124  double mPrecision = 0.0;
125  QgsCoordinateTransform mTransform;
126  QgsPointXY mPoint;
127 };
128 
129 #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:74
Shows a grid on the map canvas given a spatial resolution.
#define SIP_END
Definition: qgis_sip.h:182
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
This class represents a coordinate reference system (CRS).
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:165
Class for doing transforms between two map coordinate systems.