diff --git a/python/PyQt6/gui/auto_generated/maptools/qgsmaptoolidentify.sip.in b/python/PyQt6/gui/auto_generated/maptools/qgsmaptoolidentify.sip.in index 075cbcaa87b..cb7d9b2dc7b 100644 --- a/python/PyQt6/gui/auto_generated/maptools/qgsmaptoolidentify.sip.in +++ b/python/PyQt6/gui/auto_generated/maptools/qgsmaptoolidentify.sip.in @@ -212,17 +212,19 @@ Works only if layer was already rendered (triangular mesh is created) Returns derived attributes map for a clicked point in map coordinates. May be 2D or 3D point. %End - void setCanvasPropertiesOverrides( double searchRadiusMapUnits ); + void setCanvasPropertiesOverrides( double searchRadiusMapUnits, bool skip3DLayers = true ); %Docstring Overrides some map canvas properties inside the map tool for the upcoming identify requests. This is useful when the identification is triggered by some other piece of GUI like a 3D map view and some properties like search radius need to be adjusted so that identification returns correct -results. Currently only search radius may be overridden. - +results. When the custom identification has finished, :py:func:`~QgsMapToolIdentify.restoreCanvasPropertiesOverrides` should be called to erase any overrides. +:param searchRadiusMapUnits: The overridden search radius in map units +:param skip3DLayers: Optional override to skip identify results from layers that have a 3d renderer set (since QGIS 3.42) + .. seealso:: :py:func:`restoreCanvasPropertiesOverrides` .. versionadded:: 3.4 diff --git a/python/gui/auto_generated/maptools/qgsmaptoolidentify.sip.in b/python/gui/auto_generated/maptools/qgsmaptoolidentify.sip.in index 68c5e37eb45..7043f14fc41 100644 --- a/python/gui/auto_generated/maptools/qgsmaptoolidentify.sip.in +++ b/python/gui/auto_generated/maptools/qgsmaptoolidentify.sip.in @@ -212,17 +212,19 @@ Works only if layer was already rendered (triangular mesh is created) Returns derived attributes map for a clicked point in map coordinates. May be 2D or 3D point. %End - void setCanvasPropertiesOverrides( double searchRadiusMapUnits ); + void setCanvasPropertiesOverrides( double searchRadiusMapUnits, bool skip3DLayers = true ); %Docstring Overrides some map canvas properties inside the map tool for the upcoming identify requests. This is useful when the identification is triggered by some other piece of GUI like a 3D map view and some properties like search radius need to be adjusted so that identification returns correct -results. Currently only search radius may be overridden. - +results. When the custom identification has finished, :py:func:`~QgsMapToolIdentify.restoreCanvasPropertiesOverrides` should be called to erase any overrides. +:param searchRadiusMapUnits: The overridden search radius in map units +:param skip3DLayers: Optional override to skip identify results from layers that have a 3d renderer set (since QGIS 3.42) + .. seealso:: :py:func:`restoreCanvasPropertiesOverrides` .. versionadded:: 3.4 diff --git a/src/app/3d/qgs3dmaptoolidentify.cpp b/src/app/3d/qgs3dmaptoolidentify.cpp index bf3e05f7470..d634c9ca8d4 100644 --- a/src/app/3d/qgs3dmaptoolidentify.cpp +++ b/src/app/3d/qgs3dmaptoolidentify.cpp @@ -172,7 +172,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event ) QgsDebugError( QStringLiteral( "Could not transform identified coordinates to project crs: %1" ).arg( e.what() ) ); } - identifyTool2D->identifyAndShowResults( QgsGeometry::fromPointXY( mapPointCanvas2D ), searchRadiusCanvas2D ); + identifyTool2D->identifyAndShowResults( QgsGeometry::fromPointXY( mapPointCanvas2D ), searchRadiusCanvas2D, true ); } // We need to show other layer type results AFTER terrain results so they don't get overwritten diff --git a/src/app/qgsmaptoolidentifyaction.cpp b/src/app/qgsmaptoolidentifyaction.cpp index 7a9c0c81101..e38b0094fe4 100644 --- a/src/app/qgsmaptoolidentifyaction.cpp +++ b/src/app/qgsmaptoolidentifyaction.cpp @@ -207,9 +207,9 @@ void QgsMapToolIdentifyAction::deactivate() QgsMapToolIdentify::deactivate(); } -void QgsMapToolIdentifyAction::identifyAndShowResults( const QgsGeometry &geom, double searchRadiusMapUnits ) +void QgsMapToolIdentifyAction::identifyAndShowResults( const QgsGeometry &geom, double searchRadiusMapUnits, bool skip3DLayers ) { - setCanvasPropertiesOverrides( searchRadiusMapUnits ); + setCanvasPropertiesOverrides( searchRadiusMapUnits, skip3DLayers ); mSelectionHandler->setSelectedGeometry( geom ); restoreCanvasPropertiesOverrides(); } diff --git a/src/app/qgsmaptoolidentifyaction.h b/src/app/qgsmaptoolidentifyaction.h index 59d37f1e7a3..df6df90e64b 100644 --- a/src/app/qgsmaptoolidentifyaction.h +++ b/src/app/qgsmaptoolidentifyaction.h @@ -58,8 +58,12 @@ class APP_EXPORT QgsMapToolIdentifyAction : public QgsMapToolIdentify void deactivate() override; - //! Triggers map identification of at the given location and outputs results in GUI - void identifyAndShowResults( const QgsGeometry &geom, double searchRadiusMapUnits ); + /** + * Triggers map identification at the given location and outputs results in GUI + * \param searchRadiusMapUnits The search radius to use for identification in map units + * \param skip3DLayers When set to TRUE only layers with no 3d renderer set will be identified + */ + void identifyAndShowResults( const QgsGeometry &geom, double searchRadiusMapUnits, bool skip3DLayers ); //! Clears any previous results from the GUI void clearResults(); //! Looks up feature by its ID and outputs the result in GUI diff --git a/src/gui/maptools/qgsmaptoolidentify.cpp b/src/gui/maptools/qgsmaptoolidentify.cpp index 3aeb14a36b1..43656da3848 100644 --- a/src/gui/maptools/qgsmaptoolidentify.cpp +++ b/src/gui/maptools/qgsmaptoolidentify.cpp @@ -189,14 +189,16 @@ QList QgsMapToolIdentify::identify( const Qg return results; } -void QgsMapToolIdentify::setCanvasPropertiesOverrides( double searchRadiusMapUnits ) +void QgsMapToolIdentify::setCanvasPropertiesOverrides( double searchRadiusMapUnits, bool skip3DLayers ) { mOverrideCanvasSearchRadius = searchRadiusMapUnits; + mSkip3DLayers = skip3DLayers; } void QgsMapToolIdentify::restoreCanvasPropertiesOverrides() { mOverrideCanvasSearchRadius = -1; + mSkip3DLayers = false; } void QgsMapToolIdentify::activate() @@ -280,6 +282,9 @@ bool QgsMapToolIdentify::identifyMeshLayer( QListrenderer3D() ) + return false; + if ( !identifyContext.zRange().isInfinite() ) { if ( !layer->elevationProperties()->isVisibleInZRange( identifyContext.zRange() ) ) @@ -535,6 +540,9 @@ bool QgsMapToolIdentify::identifyVectorTileLayer( QList *results, QgsPointCloudLayer *layer, const QgsGeometry &geometry, const QgsIdentifyContext &identifyContext ) { + if ( mSkip3DLayers && layer->renderer3D() ) + return false; + if ( !identifyContext.zRange().isInfinite() ) { if ( !layer->elevationProperties()->isVisibleInZRange( identifyContext.zRange(), layer ) ) @@ -577,6 +585,9 @@ bool QgsMapToolIdentify::identifyVectorLayer( QListisSpatial() || !layer->dataProvider() ) return false; + if ( mSkip3DLayers && layer->renderer3D() ) + return false; + if ( !layer->isInScaleRange( mCanvas->mapSettings().scale() ) ) { QgsDebugMsgLevel( QStringLiteral( "Out of scale limits" ), 2 ); diff --git a/src/gui/maptools/qgsmaptoolidentify.h b/src/gui/maptools/qgsmaptoolidentify.h index 0c4fea63aa4..dbf1db695af 100644 --- a/src/gui/maptools/qgsmaptoolidentify.h +++ b/src/gui/maptools/qgsmaptoolidentify.h @@ -243,14 +243,16 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool * * This is useful when the identification is triggered by some other piece of GUI like a 3D map view * and some properties like search radius need to be adjusted so that identification returns correct - * results. Currently only search radius may be overridden. - * + * results. * When the custom identification has finished, restoreCanvasPropertiesOverrides() should * be called to erase any overrides. + * + * \param searchRadiusMapUnits The overridden search radius in map units + * \param skip3DLayers Optional override to skip identify results from layers that have a 3d renderer set (since QGIS 3.42) * \see restoreCanvasPropertiesOverrides() * \since QGIS 3.4 */ - void setCanvasPropertiesOverrides( double searchRadiusMapUnits ); + void setCanvasPropertiesOverrides( double searchRadiusMapUnits, bool skip3DLayers = true ); /** * Clears canvas properties overrides previously set with setCanvasPropertiesOverrides() @@ -329,6 +331,7 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool int mCoordinatePrecision; double mOverrideCanvasSearchRadius = -1; + bool mSkip3DLayers = false; }; Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapToolIdentify::LayerType )