QGIS API Documentation  3.6.0-Noosa (5873452)
qgsquickidentifykit.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsquickidentifykit.h
3  ---------------------
4  Date : 30.8.2016
5  Copyright : (C) 2016 by Matthias Kuhn
6  Email : matthias (at) 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 QGSQUICKIDENTIFYKIT_H
17 #define QGSQUICKIDENTIFYKIT_H
18 
19 #include <QObject>
20 #include <QPair>
21 
22 #include "qgsfeature.h"
23 #include "qgsmapsettings.h"
24 #include "qgspoint.h"
25 #include "qgsrendercontext.h"
26 
27 #include "qgis_quick.h"
29 
30 class QgsMapLayer;
32 class QgsVectorLayer;
33 
46 class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
47 {
48  Q_OBJECT
49 
53  Q_PROPERTY( QgsQuickMapSettings *mapSettings READ mapSettings WRITE setMapSettings NOTIFY mapSettingsChanged )
54 
55 
60  Q_PROPERTY( double searchRadiusMm READ searchRadiusMm WRITE setSearchRadiusMm NOTIFY searchRadiusMmChanged )
61 
67  Q_PROPERTY( int featuresLimit READ featuresLimit WRITE setFeaturesLimit NOTIFY featuresLimitChanged )
68 
74  Q_PROPERTY( IdentifyMode identifyMode MEMBER mIdentifyMode NOTIFY identifyModeChanged )
75 
76  public:
77 
82  {
83 
88  TopDownAll = 0,
89 
94  TopDownStopAtFirst
95  };
96  Q_ENUM( IdentifyMode )
97 
98 
99  explicit QgsQuickIdentifyKit( QObject *parent = nullptr );
100 
102  QgsQuickMapSettings *mapSettings() const;
103 
105  void setMapSettings( QgsQuickMapSettings *mapSettings );
106 
108  double searchRadiusMm() const;
109 
111  void setSearchRadiusMm( double searchRadiusMm );
112 
114  int featuresLimit() const;
115 
117  void setFeaturesLimit( int limit );
118 
132  Q_INVOKABLE QgsQuickFeatureLayerPair identifyOne( const QPointF &point, QgsVectorLayer *layer = nullptr );
133 
148  Q_INVOKABLE QgsQuickFeatureLayerPairs identify( const QPointF &point, QgsVectorLayer *layer = nullptr );
149 
150  signals:
152  void mapSettingsChanged();
154  void searchRadiusMmChanged();
156  void featuresLimitChanged();
158  void identifyModeChanged();
159 
160  private:
161  QgsQuickMapSettings *mMapSettings = nullptr; // not owned
162 
163  double searchRadiusMU( const QgsRenderContext &context ) const;
164  double searchRadiusMU() const;
165 
166  QgsRectangle toLayerCoordinates( QgsMapLayer *layer, const QgsRectangle &rect ) const;
167  QgsFeatureList identifyVectorLayer( QgsVectorLayer *layer, const QgsPointXY &point ) const;
168 
169  double mSearchRadiusMm = 5;
170  int mFeaturesLimit = 100;
171  IdentifyMode mIdentifyMode = IdentifyMode::TopDownAll;
172 };
173 
174 #endif // QGSQUICKIDENTIFYKIT_H
Convenient set of tools to identify features.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Base class for all map layer types.
Definition: qgsmaplayer.h:64
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:571
A class to represent a 2D point.
Definition: qgspointxy.h:43
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
Contains information about the context of a rendering operation.
QList< QgsQuickFeatureLayerPair > QgsQuickFeatureLayerPairs
IdentifyMode
IdentifyMode enums used to define identify tool behavior on identifiable layers.
Pair of QgsFeature and QgsVectorLayer.
Represents a vector layer which manages a vector based data sets.