QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 #ifndef SIP_RUN
41 class GUI_EXPORT QgsSnapToGridCanvasItem : public QObject, public QgsMapCanvasItem
42 {
43 #else
44 class GUI_EXPORT QgsSnapToGridCanvasItem : public QgsMapCanvasItem
45 {
46 #endif
47 
48  Q_OBJECT
49 
50 #ifdef SIP_RUN
52  if ( dynamic_cast<QgsSnapToGridCanvasItem *>( sipCpp ) )
53  sipType = sipType_QgsSnapToGridCanvasItem;
54  else
55  sipType = nullptr;
56  SIP_END
57 #endif
58 
59  public:
60 
65 
66  void paint( QPainter *painter ) override;
67 
73  QgsPointXY point() const;
74 
80  void setPoint( const QgsPointXY &point );
81 
86  double precision() const;
87 
92  void setPrecision( double precision );
93 
100 
106  void setCrs( const QgsCoordinateReferenceSystem &crs );
107 
111  bool enabled() const;
112 
116  void setEnabled( bool enabled );
117 
118  private slots:
119  void updateMapCanvasCrs();
120 
121  void updateZoomFactor();
122 
123  private:
124  QPen mGridPen = QPen( QColor( 127, 127, 127, 150 ) );
125  QPen mCurrentPointPen = QPen( QColor( 200, 200, 200, 150 ) );
126 
127  bool mEnabled = true;
128  bool mAvailableByZoomFactor = false;
129 
130  double mPrecision = 0.0;
131  QgsCoordinateTransform mTransform;
132  QgsPointXY mPoint;
133 };
134 
135 #endif // QGSSNAPTOGRIDCANVASITEM_H
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsMapCanvas
Definition: qgsmapcanvas.h:83
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
precision
int precision
Definition: qgswfsgetfeature.cpp:103
QgsMapCanvasItem::paint
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
qgssnaptogridcanvasitem.h
qgsmapcanvasitem.h
QgsMapCanvasItem
Definition: qgsmapcanvasitem.h:33
qgscoordinatetransform.h
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsPointXY
Definition: qgspointxy.h:43
QgsSnapToGridCanvasItem
Definition: qgssnaptogridcanvasitem.h:41
QgsCoordinateTransform
Definition: qgscoordinatetransform.h:52
SIP_END
#define SIP_END
Definition: qgis_sip.h:189
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgscoordinatereferencesystem.h