Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
new map tool to select single feature
- Loading branch information
Showing
9 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class QgsMapToolIdentifyFeature : QgsMapToolIdentify | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsmaptoolidentifyfeature.h> | ||
%End | ||
|
||
public: | ||
QgsMapToolIdentifyFeature( QgsVectorLayer* vl, QgsMapCanvas* canvas ); | ||
|
||
void canvasReleaseEvent( QMouseEvent* e ); | ||
|
||
signals: | ||
void featureIdentified( QgsFeature ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*************************************************************************** | ||
qgsmaptoolidentifyfeature.cpp | ||
-------------------------------------- | ||
Date : 22.5.2014 | ||
Copyright : (C) 2014 Denis Rouzaud | ||
Email : denis.rouzaud@gmail.com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include <QMouseEvent> | ||
|
||
#include "qgsmaptoolidentifyfeature.h" | ||
#include "qgsmapcanvas.h" | ||
|
||
QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature( QgsVectorLayer* vl, QgsMapCanvas* canvas ) | ||
: QgsMapToolIdentify( canvas ) | ||
, mLayer( vl ) | ||
, mCanvas( canvas ) | ||
{ | ||
} | ||
|
||
void QgsMapToolIdentifyFeature::canvasReleaseEvent( QMouseEvent* e ) | ||
{ | ||
|
||
QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() ); | ||
|
||
QList<IdentifyResult> results; | ||
if ( !identifyVectorLayer( &results, mLayer, point ) ) | ||
return; | ||
|
||
// TODO: display a menu when several features identified | ||
|
||
emit featureIdentified( results[0].mFeature ); | ||
emit featureIdentified( results[0].mFeature.id() ); | ||
} | ||
|
||
void QgsMapToolIdentifyFeature::keyPressEvent( QKeyEvent* e ) | ||
{ | ||
if ( e->key() == Qt::Key_Escape ) | ||
{ | ||
deactivate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*************************************************************************** | ||
qgsmaptoolidentifyfeature.h | ||
-------------------------------------- | ||
Date : 22.5.2014 | ||
Copyright : (C) 2014 Denis Rouzaud | ||
Email : denis.rouzaud@gmail.com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSMAPTOOLIDENTIFYFEATURE_H | ||
#define QGSMAPTOOLIDENTIFYFEATURE_H | ||
|
||
#include "qgsmaptoolidentify.h" | ||
|
||
/** | ||
* @brief The QgsMapToolIdentifyFeature class is a map tool to be used to identify a feature on a chosen layer. | ||
* Once the map tool is enable, user can click on the map canvas to identify a feature. | ||
* A signal will then be emitted. | ||
*/ | ||
class GUI_EXPORT QgsMapToolIdentifyFeature : public QgsMapToolIdentify | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsMapToolIdentifyFeature( QgsVectorLayer* vl, QgsMapCanvas* canvas ); | ||
|
||
virtual void canvasReleaseEvent( QMouseEvent* e ); | ||
|
||
signals: | ||
void featureIdentified( const QgsFeature& ); | ||
void featureIdentified( QgsFeatureId ); | ||
|
||
protected: | ||
virtual void keyPressEvent( QKeyEvent* e ); | ||
|
||
private: | ||
QgsVectorLayer* mLayer; | ||
QgsMapCanvas* mCanvas; | ||
}; | ||
|
||
#endif // QGSMAPTOOLIDENTIFYFEATURE_H |