QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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 : matthias@opengis.ch
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 "
qgscoordinatereferencesystem.h
"
20
#include "
qgscoordinatetransform.h
"
21
#include "
qgsmapcanvasitem.h
"
22
23
#include <QObject>
24
#include <QPen>
25
26
#ifdef SIP_RUN
27
//%ModuleHeaderCode
28
// For ConvertToSubClassCode.
29
#include <
qgssnaptogridcanvasitem.h
>
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
51
SIP_CONVERT_TO_SUBCLASS_CODE
52
if
(
dynamic_cast<
QgsSnapToGridCanvasItem
*
>
( sipCpp ) )
53
{
54
sipType = sipType_QgsSnapToGridCanvasItem;
55
// We need to tweak the pointer as sip believes it is single inheritance
56
// from QgsMapCanvasItem, but the raw address of QgsSnapToGridCanvasItem (sipCpp)
57
// is actually a QObject
58
*sipCppRet =
dynamic_cast<
QgsSnapToGridCanvasItem
*
>
( sipCpp );
59
}
60
else
61
sipType =
nullptr
;
62
SIP_END
63
#endif
64
65
public
:
69
QgsSnapToGridCanvasItem
(
QgsMapCanvas
*mapCanvas
SIP_TRANSFERTHIS
);
70
71
using
QgsMapCanvasItem::paint
;
72
void
paint
( QPainter *painter )
override
;
73
79
QgsPointXY
point
()
const
;
80
86
void
setPoint
(
const
QgsPointXY
&
point
);
87
92
double
precision
()
const
;
93
98
void
setPrecision
(
double
precision
);
99
105
QgsCoordinateReferenceSystem
crs
()
const
;
106
112
void
setCrs
(
const
QgsCoordinateReferenceSystem
&
crs
);
113
117
bool
enabled
()
const
;
118
122
void
setEnabled
(
bool
enabled
);
123
124
private
slots:
125
void
updateMapCanvasCrs();
126
127
void
updateZoomFactor();
128
129
private
:
130
QPen mGridPen = QPen( QColor( 127, 127, 127, 150 ) );
131
QPen mCurrentPointPen = QPen( QColor( 200, 200, 200, 150 ) );
132
133
bool
mEnabled =
true
;
134
bool
mAvailableByZoomFactor =
false
;
135
136
double
mPrecision = 0.0;
137
QgsCoordinateTransform
mTransform;
138
QgsPointXY
mPoint;
139
};
140
141
#endif
// QGSSNAPTOGRIDCANVASITEM_H
QgsCoordinateReferenceSystem
Represents a coordinate reference system (CRS).
Definition
qgscoordinatereferencesystem.h:216
QgsCoordinateTransform
Handles coordinate transforms between two coordinate systems.
Definition
qgscoordinatetransform.h:63
QgsMapCanvasItem::paint
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
QgsMapCanvasItem::QgsMapCanvasItem
QgsMapCanvasItem(QgsMapCanvas *mapCanvas)
protected constructor: cannot be constructed directly
Definition
qgsmapcanvasitem.cpp:30
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition
qgsmapcanvas.h:96
QgsPointXY
Represents a 2D point.
Definition
qgspointxy.h:62
QgsSnapToGridCanvasItem::enabled
bool enabled() const
Enable this item.
Definition
qgssnaptogridcanvasitem.cpp:121
QgsSnapToGridCanvasItem::precision
double precision() const
The resolution of the grid in map units.
Definition
qgssnaptogridcanvasitem.cpp:99
QgsSnapToGridCanvasItem::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
The CRS in which the grid should be calculated.
Definition
qgssnaptogridcanvasitem.cpp:115
QgsSnapToGridCanvasItem::setPoint
void setPoint(const QgsPointXY &point)
A point that will be highlighted on the map canvas.
Definition
qgssnaptogridcanvasitem.cpp:93
QgsSnapToGridCanvasItem::setEnabled
void setEnabled(bool enabled)
Enable this item.
Definition
qgssnaptogridcanvasitem.cpp:126
QgsSnapToGridCanvasItem::QgsSnapToGridCanvasItem
QgsSnapToGridCanvasItem(QgsMapCanvas *mapCanvas)
Will automatically be added to the mapCanvas.
Definition
qgssnaptogridcanvasitem.cpp:24
QgsSnapToGridCanvasItem::paint
void paint(QPainter *painter) override
function to be implemented by derived classes
Definition
qgssnaptogridcanvasitem.cpp:32
QgsSnapToGridCanvasItem::crs
QgsCoordinateReferenceSystem crs() const
The CRS in which the grid should be calculated.
Definition
qgssnaptogridcanvasitem.cpp:110
QgsSnapToGridCanvasItem::setPrecision
void setPrecision(double precision)
The resolution of the grid in map units.
Definition
qgssnaptogridcanvasitem.cpp:104
QgsSnapToGridCanvasItem::point
QgsPointXY point() const
A point that will be highlighted on the map canvas.
Definition
qgssnaptogridcanvasitem.cpp:88
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition
qgis_sip.h:203
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
SIP_END
#define SIP_END
Definition
qgis_sip.h:220
qgscoordinatereferencesystem.h
qgscoordinatetransform.h
qgsmapcanvasitem.h
qgssnaptogridcanvasitem.h
Generated on
for QGIS API Documentation by
1.17.0