QGIS API Documentation
2.8.2-Wien
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
gui
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
#include <QMouseEvent>
17
18
#include "
qgscursors.h
"
19
#include "
qgsmaptoolidentifyfeature.h
"
20
#include "
qgsmapcanvas.h
"
21
22
QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature
(
QgsMapCanvas
* canvas,
QgsVectorLayer
* vl )
23
:
QgsMapToolIdentify
( canvas )
24
, mCanvas( canvas )
25
, mLayer( vl )
26
{
27
mToolName
=
tr
(
"Identify feature"
);
28
29
// set cursor
30
QPixmap cursorPixmap = QPixmap((
const
char
** )
cross_hair_cursor
);
31
mCursor
= QCursor( cursorPixmap, 1, 1 );
32
}
33
34
QgsMapToolIdentifyFeature::~QgsMapToolIdentifyFeature
()
35
{
36
}
37
38
void
QgsMapToolIdentifyFeature::canvasReleaseEvent
( QMouseEvent* e )
39
{
40
41
QgsPoint
point = mCanvas->
getCoordinateTransform
()->
toMapCoordinates
( e->x(), e->y() );
42
43
QList<IdentifyResult> results;
44
if
( !
identifyVectorLayer
( &results, mLayer, point ) )
45
return
;
46
47
// TODO: display a menu when several features identified
48
49
emit
featureIdentified
( results[0].mFeature );
50
emit
featureIdentified
( results[0].mFeature.id() );
51
}
52
53
void
QgsMapToolIdentifyFeature::keyPressEvent
( QKeyEvent* e )
54
{
55
if
( e->key() == Qt::Key_Escape )
56
{
57
mCanvas->
unsetMapTool
(
this
);
58
}
59
}
Generated on Sun May 10 2015 16:33:26 for QGIS API Documentation by
1.8.1.2