Skip to content

Commit 5f5499d

Browse files
viktor.sklencar@lutraconsulting.co.ukwonder-sk
authored andcommittedAug 20, 2018
Added identify mode for identify tool
Identification all features on all layers from Top to bottom down layers (TopDownAll) or only first non-empty list going from top to down layers.
1 parent 683df59 commit 5f5499d

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed
 

‎src/quickgui/qgsquickidentifykit.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ QgsQuickFeatureLayerPairs QgsQuickIdentifyKit::identify( const QPointF &point, Q
8686
results.append( QgsQuickFeatureLayerPair( feature, vl ) );
8787
}
8888
}
89+
if ( mIdentifyMode == IdentifyMode::TopDownStopAtFirst && !results.isEmpty() )
90+
{
91+
QgsDebugMsg( QStringLiteral( "IdentifyKit identified %1 results with TopDownStopAtFirst mode." ).arg( results.count() ) );
92+
return results;
93+
}
94+
8995
}
9096

9197
QgsDebugMsg( QStringLiteral( "IdentifyKit identified %1 results" ).arg( results.count() ) );

‎src/quickgui/qgsquickidentifykit.h

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,35 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
6666
*/
6767
Q_PROPERTY( int featuresLimit READ featuresLimit WRITE setFeaturesLimit NOTIFY featuresLimitChanged )
6868

69+
/**
70+
* Defines behavior of the identify tool (See description of IdentifyMode enum).
71+
*
72+
* Default is TopDownAll.
73+
*/
74+
Q_PROPERTY( IdentifyMode identifyMode MEMBER mIdentifyMode NOTIFY identifyModeChanged )
75+
6976
public:
77+
78+
/**
79+
* IdentifyMode enums used to define identify tool behavior on identifiable layers.
80+
*/
81+
enum IdentifyMode
82+
{
83+
84+
/**
85+
* Identification is performed from top to bottom down layers returning all
86+
* identified features;
87+
*/
88+
TopDownAll = 0,
89+
90+
/**
91+
* Identification is performed from top to bottom down layers and stops on the first layer
92+
* returning non-empty list of identified features. Identification on rest layers is skipped.
93+
*/
94+
TopDownStopAtFirst
95+
};
96+
Q_ENUM( IdentifyMode )
97+
7098
//! Constructor of new identify kit.
7199
explicit QgsQuickIdentifyKit( QObject *parent = nullptr );
72100

@@ -91,8 +119,10 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
91119
/**
92120
* Gets the closest feature to the point within the search radius
93121
*
94-
* If layer is nullptr, identifies the closest feature from all identifiable layers
95-
* If layer is not nullptr, identifies the closest feature from given layer
122+
* If layer is nullptr, identifies the closest feature from either
123+
* all identifiable layers (IdentifyMode::TopDownAll) or the first layer from top to bottom layers
124+
* with non-empty identified feature list (IdentifyMode::TopDownStopAtFirst)
125+
* If layer is not nullptr, identifies the closest feature from given layer regardless identify mode.
96126
*
97127
* To modify search radius, use QgsQuickIdentifyKit::searchRadiusMm
98128
*
@@ -104,8 +134,10 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
104134
/**
105135
* Gets all features in the search radius
106136
*
107-
* If layer is nullptr, identifies features from all identifiable layers
108-
* If layer is not nullptr, identifies only features from given layer
137+
* If layer is nullptr, identifies features from either
138+
* all identifiable layers (IdentifyMode::TopDownAll) or the first layer from top to bottom layers
139+
* with non-empty identified feature list (IdentifyMode::TopDownStopAtFirst)
140+
* If layer is not nullptr, identifies only features from given layer regardless identify mode.
109141
*
110142
* To limit number of results, use QgsQuickIdentifyKit::featuresLimit
111143
* To modify search radius, use QgsQuickIdentifyKit::searchRadiusMm
@@ -122,6 +154,8 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
122154
void searchRadiusMmChanged();
123155
//! \copydoc QgsQuickIdentifyKit::featuresLimit
124156
void featuresLimitChanged();
157+
//! \copydoc QgsQuickIdentifyKit::identifyMode
158+
void identifyModeChanged();
125159

126160
private:
127161
QgsQuickMapSettings *mMapSettings = nullptr; // not owned
@@ -134,6 +168,7 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
134168

135169
double mSearchRadiusMm = 8;
136170
int mFeaturesLimit = 100;
171+
IdentifyMode mIdentifyMode = IdentifyMode::TopDownAll;
137172
};
138173

139174
#endif // QGSQUICKIDENTIFYKIT_H

0 commit comments

Comments
 (0)
Please sign in to comment.