QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
maptools
qgsmaptoolselectionhandler.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsmaptoolselectionhandler.cpp
3
---------------------
4
begin : March 2018
5
copyright : (C) 2018 by Viktor Sklencar
6
email : vsklencar at gmail dot com
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 QGSMAPTOOLSELECTIONHANDLER_H
17
#define QGSMAPTOOLSELECTIONHANDLER_H
18
19
#include "qgis_gui.h"
20
#include "
qgsgeometry.h
"
21
22
#include <QObject>
23
#include <QTimer>
24
#include <QWidget>
25
26
#define SIP_NO_FILE
27
28
class
QHBoxLayout;
29
class
QKeyEvent;
30
31
class
QgsDoubleSpinBox
;
32
class
QgsMapCanvas
;
33
class
QgsMapMouseEvent
;
34
class
QgsRubberBand
;
35
class
QgsSnapIndicator
;
36
class
QgsIdentifyMenu
;
37
38
40
48
class
QgsDistanceWidget :
public
QWidget
49
{
50
Q_OBJECT
51
52
public
:
54
explicit
QgsDistanceWidget(
const
QString &label = QString(), QWidget *parent =
nullptr
);
55
57
void
setDistance(
double
distance );
59
double
distance();
60
61
signals:
63
void
distanceChanged(
double
distance );
65
void
distanceEditingFinished(
double
distance,
const
Qt::KeyboardModifiers &modifiers );
67
void
distanceEditingCanceled();
68
69
protected
:
70
bool
eventFilter( QObject *obj, QEvent *ev )
override
;
71
72
private
:
73
QHBoxLayout *mLayout =
nullptr
;
74
QgsDoubleSpinBox
*mDistanceSpinBox =
nullptr
;
75
};
76
78
79
85
class
GUI_EXPORT
QgsMapToolSelectionHandler
:
public
QObject
86
{
87
Q_OBJECT
88
89
public
:
91
enum
SelectionMode
92
{
94
SelectSimple
,
96
SelectPolygon
,
98
SelectFreehand
,
100
SelectRadius
,
101
106
SelectOnMouseOver
107
};
108
Q_ENUM( SelectionMode )
109
110
111
QgsMapToolSelectionHandler
(
QgsMapCanvas
*canvas,
QgsMapToolSelectionHandler::SelectionMode
selectionMode =
QgsMapToolSelectionHandler::SelectionMode::SelectSimple
);
112
114
~QgsMapToolSelectionHandler
()
override
;
115
117
QgsGeometry
selectedGeometry()
const
;
118
120
SelectionMode selectionMode()
const
;
122
void
setSelectionMode( SelectionMode mode );
123
125
void
deactivate();
126
128
void
canvasMoveEvent(
QgsMapMouseEvent
*e );
130
void
canvasPressEvent(
QgsMapMouseEvent
*e );
132
void
canvasReleaseEvent(
QgsMapMouseEvent
*e );
134
bool
keyReleaseEvent( QKeyEvent *e );
135
137
void
setSelectedGeometry(
const
QgsGeometry
&geometry, Qt::KeyboardModifiers modifiers = Qt::NoModifier );
138
139
signals:
141
void
geometryChanged
( Qt::KeyboardModifiers modifiers = Qt::NoModifier );
142
143
private
slots:
145
void
updateRadiusRubberband(
double
radius );
146
151
void
radiusValueEntered(
double
radius, Qt::KeyboardModifiers modifiers );
152
154
void
cancel();
155
156
private
:
157
void
selectFeaturesMoveEvent(
QgsMapMouseEvent
*e );
158
void
selectFeaturesReleaseEvent(
QgsMapMouseEvent
*e );
159
void
selectFeaturesPressEvent(
QgsMapMouseEvent
*e );
160
161
void
selectPolygonMoveEvent(
QgsMapMouseEvent
*e );
162
void
selectPolygonPressEvent(
QgsMapMouseEvent
*e );
163
164
void
selectFreehandMoveEvent(
QgsMapMouseEvent
*e );
165
void
selectFreehandReleaseEvent(
QgsMapMouseEvent
*e );
166
167
void
selectRadiusMoveEvent(
QgsMapMouseEvent
*e );
168
void
selectRadiusReleaseEvent(
QgsMapMouseEvent
*e );
169
170
void
initRubberBand();
171
172
QgsPointXY
toMapCoordinates( QPoint point );
173
174
void
createDistanceWidget();
175
void
deleteDistanceWidget();
176
177
void
updateRadiusFromEdge(
QgsPointXY
&radiusEdge );
178
179
private
:
180
QgsMapCanvas
*mCanvas =
nullptr
;
181
183
std::unique_ptr<QgsRubberBand> mSelectionRubberBand;
184
186
QgsGeometry
mSelectionGeometry;
187
189
bool
mSelectionActive =
false
;
190
191
SelectionMode
mSelectionMode =
SelectSimple
;
192
194
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
195
197
QPoint mInitDragPos;
198
200
QgsPointXY
mRadiusCenter;
201
203
QgsDistanceWidget *mDistanceWidget =
nullptr
;
204
205
QColor mFillColor = QColor( 254, 178, 76, 63 );
206
QColor mStrokeColor = QColor( 254, 58, 29, 100 );
207
209
QgsIdentifyMenu
*mIdentifyMenu =
nullptr
;
// owned by canvas
210
212
std::unique_ptr<QTimer> mOnMouseMoveDelayTimer;
213
215
QPoint mMoveLastCursorPos;
216
};
217
218
#endif
QgsDoubleSpinBox
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
Definition
qgsdoublespinbox.h:46
QgsGeometry
A geometry is the spatial representation of a feature.
Definition
qgsgeometry.h:267
QgsIdentifyMenu
Builds a menu to be used with identify results.
Definition
qgsidentifymenu.h:53
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition
qgsmapcanvas.h:96
QgsMapMouseEvent
A mouse event which is the result of a user interaction with a QgsMapCanvas.
Definition
qgsmapmouseevent.h:38
QgsMapToolSelectionHandler
Utility class for handling various methods to create geometry for selection in layers.
Definition
qgsmaptoolselectionhandler.h:86
QgsMapToolSelectionHandler::SelectionMode
SelectionMode
Select features to identify by:
Definition
qgsmaptoolselectionhandler.h:92
QgsMapToolSelectionHandler::SelectSimple
@ SelectSimple
SelectSimple - single click or drawing a rectangle, default option.
Definition
qgsmaptoolselectionhandler.h:94
QgsMapToolSelectionHandler::SelectRadius
@ SelectRadius
SelectRadius - a circle selection.
Definition
qgsmaptoolselectionhandler.h:100
QgsMapToolSelectionHandler::SelectOnMouseOver
@ SelectOnMouseOver
SelectOnMouseMove - selection on mouse over.
Definition
qgsmaptoolselectionhandler.h:106
QgsMapToolSelectionHandler::SelectPolygon
@ SelectPolygon
SelectPolygon - drawing a polygon or right-click on existing polygon feature.
Definition
qgsmaptoolselectionhandler.h:96
QgsMapToolSelectionHandler::SelectFreehand
@ SelectFreehand
SelectFreehand - free hand selection.
Definition
qgsmaptoolselectionhandler.h:98
QgsMapToolSelectionHandler::geometryChanged
void geometryChanged(Qt::KeyboardModifiers modifiers=Qt::NoModifier)
emitted when a new geometry has been picked (selectedGeometry())
QgsMapToolSelectionHandler::QgsMapToolSelectionHandler
QgsMapToolSelectionHandler(QgsMapCanvas *canvas, QgsMapToolSelectionHandler::SelectionMode selectionMode=QgsMapToolSelectionHandler::SelectionMode::SelectSimple)
constructor
Definition
qgsmaptoolselectionhandler.cpp:105
QgsPointXY
Represents a 2D point.
Definition
qgspointxy.h:62
QgsRubberBand
Responsible for drawing transient features (e.g.
Definition
qgsrubberband.h:98
QgsSnapIndicator
Shows a snapping marker on map canvas for the current snapping match.
Definition
qgssnapindicator.h:32
qgsgeometry.h
Generated on
for QGIS API Documentation by
1.17.0