Skip to content
Permalink
Browse files

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.
  • Loading branch information
viktor.sklencar@lutraconsulting.co.uk authored and wonder-sk committed Aug 15, 2018
1 parent 683df59 commit 5f5499d977bea3d038b7bef00b6db42dd8cdfe64
Showing with 45 additions and 4 deletions.
  1. +6 −0 src/quickgui/qgsquickidentifykit.cpp
  2. +39 −4 src/quickgui/qgsquickidentifykit.h
@@ -86,6 +86,12 @@ QgsQuickFeatureLayerPairs QgsQuickIdentifyKit::identify( const QPointF &point, Q
results.append( QgsQuickFeatureLayerPair( feature, vl ) );
}
}
if ( mIdentifyMode == IdentifyMode::TopDownStopAtFirst && !results.isEmpty() )
{
QgsDebugMsg( QStringLiteral( "IdentifyKit identified %1 results with TopDownStopAtFirst mode." ).arg( results.count() ) );
return results;
}

}

QgsDebugMsg( QStringLiteral( "IdentifyKit identified %1 results" ).arg( results.count() ) );
@@ -66,7 +66,35 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
*/
Q_PROPERTY( int featuresLimit READ featuresLimit WRITE setFeaturesLimit NOTIFY featuresLimitChanged )

/**
* Defines behavior of the identify tool (See description of IdentifyMode enum).
*
* Default is TopDownAll.
*/
Q_PROPERTY( IdentifyMode identifyMode MEMBER mIdentifyMode NOTIFY identifyModeChanged )

public:

/**
* IdentifyMode enums used to define identify tool behavior on identifiable layers.
*/
enum IdentifyMode
{

/**
* Identification is performed from top to bottom down layers returning all
* identified features;
*/
TopDownAll = 0,

/**
* Identification is performed from top to bottom down layers and stops on the first layer
* returning non-empty list of identified features. Identification on rest layers is skipped.
*/
TopDownStopAtFirst
};
Q_ENUM( IdentifyMode )

//! Constructor of new identify kit.
explicit QgsQuickIdentifyKit( QObject *parent = nullptr );

@@ -91,8 +119,10 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
/**
* Gets the closest feature to the point within the search radius
*
* If layer is nullptr, identifies the closest feature from all identifiable layers
* If layer is not nullptr, identifies the closest feature from given layer
* If layer is nullptr, identifies the closest feature from either
* all identifiable layers (IdentifyMode::TopDownAll) or the first layer from top to bottom layers
* with non-empty identified feature list (IdentifyMode::TopDownStopAtFirst)
* If layer is not nullptr, identifies the closest feature from given layer regardless identify mode.
*
* To modify search radius, use QgsQuickIdentifyKit::searchRadiusMm
*
@@ -104,8 +134,10 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
/**
* Gets all features in the search radius
*
* If layer is nullptr, identifies features from all identifiable layers
* If layer is not nullptr, identifies only features from given layer
* If layer is nullptr, identifies features from either
* all identifiable layers (IdentifyMode::TopDownAll) or the first layer from top to bottom layers
* with non-empty identified feature list (IdentifyMode::TopDownStopAtFirst)
* If layer is not nullptr, identifies only features from given layer regardless identify mode.
*
* To limit number of results, use QgsQuickIdentifyKit::featuresLimit
* To modify search radius, use QgsQuickIdentifyKit::searchRadiusMm
@@ -122,6 +154,8 @@ class QUICK_EXPORT QgsQuickIdentifyKit : public QObject
void searchRadiusMmChanged();
//! \copydoc QgsQuickIdentifyKit::featuresLimit
void featuresLimitChanged();
//! \copydoc QgsQuickIdentifyKit::identifyMode
void identifyModeChanged();

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

double mSearchRadiusMm = 8;
int mFeaturesLimit = 100;
IdentifyMode mIdentifyMode = IdentifyMode::TopDownAll;
};

#endif // QGSQUICKIDENTIFYKIT_H

0 comments on commit 5f5499d

Please sign in to comment.
You can’t perform that action at this time.