QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
maptools
qgsmaptoolidentifyfeature.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsmaptoolidentifyfeature.cpp
3
--------------------------------------
4
Date : 22.5.2014
5
Copyright : (C) 2014 Denis Rouzaud
6
Email : denis.rouzaud@gmail.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
17
#include "
qgsmaptoolidentifyfeature.h
"
18
19
#include "
qgsmapcanvas.h
"
20
#include "
qgsmapmouseevent.h
"
21
22
#include "moc_qgsmaptoolidentifyfeature.cpp"
23
24
QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature
(
QgsMapCanvas
*
canvas
,
QgsVectorLayer
*vl )
25
:
QgsMapToolIdentify
(
canvas
)
26
, mLayer( vl )
27
{
28
mToolName
= tr(
"Identify feature"
);
29
30
// set cursor
31
mCursor
= QCursor( Qt::CrossCursor );
32
}
33
34
void
QgsMapToolIdentifyFeature::canvasReleaseEvent
(
QgsMapMouseEvent
*e )
35
{
36
const
QgsPointXY
point =
mCanvas
->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() );
37
38
QList<IdentifyResult> results;
39
if
( !
identifyVectorLayer
( &results, mLayer, point ) )
40
return
;
41
42
// TODO: display a menu when several features identified
43
44
emit
featureIdentified
( results[0].mFeature );
45
Q_NOWARN_DEPRECATED_PUSH
46
emit
featureIdentified
( results[0].mFeature.id() );
47
Q_NOWARN_DEPRECATED_POP
48
}
49
50
void
QgsMapToolIdentifyFeature::keyPressEvent
( QKeyEvent *e )
51
{
52
if
( e->key() == Qt::Key_Escape )
53
{
54
mCanvas
->unsetMapTool(
this
);
55
}
56
}
QgsMapMouseEvent
A mouse event which is the result of a user interaction with a QgsMapCanvas.
Definition
qgsmapmouseevent.h:38
QgsMapToolIdentifyFeature::featureIdentified
void featureIdentified(const QgsFeature &feature)
Emitted when a feature has been identified.
QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature
QgsMapToolIdentifyFeature(QgsMapCanvas *canvas, QgsVectorLayer *vl=nullptr)
QgsMapToolIdentifyFeature is a map tool to identify a feature on a chosen layer.
Definition
qgsmaptoolidentifyfeature.cpp:24
QgsMapToolIdentifyFeature::keyPressEvent
void keyPressEvent(QKeyEvent *e) override
Key event for overriding. Default implementation does nothing.
Definition
qgsmaptoolidentifyfeature.cpp:50
QgsMapToolIdentifyFeature::canvasReleaseEvent
void canvasReleaseEvent(QgsMapMouseEvent *e) override
Mouse release event for overriding. Default implementation does nothing.
Definition
qgsmaptoolidentifyfeature.cpp:34
QgsMapToolIdentify::QgsMapToolIdentify
QgsMapToolIdentify(QgsMapCanvas *canvas)
constructor
Definition
qgsmaptoolidentify.cpp:77
QgsMapToolIdentify::identifyVectorLayer
bool identifyVectorLayer(QList< QgsMapToolIdentify::IdentifyResult > *results, QgsVectorLayer *layer, const QgsPointXY &point, const QgsIdentifyContext &identifyContext=QgsIdentifyContext())
Performs the identification against a given vector layer.
Definition
qgsmaptoolidentify.cpp:301
QgsMapTool::canvas
QgsMapCanvas * canvas() const
returns pointer to the tool's map canvas
Definition
qgsmaptool.cpp:236
QgsMapTool::mCanvas
QPointer< QgsMapCanvas > mCanvas
The pointer to the map canvas.
Definition
qgsmaptool.h:403
QgsMapTool::mToolName
QString mToolName
The translated name of the map tool.
Definition
qgsmaptool.h:421
QgsMapTool::QgsMapCanvas
friend class QgsMapCanvas
Definition
qgsmaptool.h:423
QgsMapTool::mCursor
QCursor mCursor
The cursor used in the map tool.
Definition
qgsmaptool.h:406
QgsPointXY
Represents a 2D point.
Definition
qgspointxy.h:62
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_POP
Definition
qgis.h:8379
Q_NOWARN_DEPRECATED_PUSH
#define Q_NOWARN_DEPRECATED_PUSH
Definition
qgis.h:8378
qgsmapcanvas.h
qgsmapmouseevent.h
qgsmaptoolidentifyfeature.h
Generated on
for QGIS API Documentation by
1.17.0