From 6408267d95839fff99cdded171086868e609d2af Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 18 Dec 2024 14:27:02 +1000 Subject: [PATCH] Address review --- src/core/labeling/qgspallabeling.cpp | 1 - src/core/raster/qgsrasterlabeling.cpp | 30 ++++++++++++---------- src/core/raster/qgsrasterlayerrenderer.cpp | 2 -- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/core/labeling/qgspallabeling.cpp b/src/core/labeling/qgspallabeling.cpp index 9c528507dc29..fed2f7af2d9a 100644 --- a/src/core/labeling/qgspallabeling.cpp +++ b/src/core/labeling/qgspallabeling.cpp @@ -4103,7 +4103,6 @@ bool QgsPalLabeling::staticWillUseLayer( const QgsMapLayer *layer ) } case Qgis::LayerType::Plugin: - case Qgis::LayerType::PointCloud: case Qgis::LayerType::Annotation: case Qgis::LayerType::Group: diff --git a/src/core/raster/qgsrasterlabeling.cpp b/src/core/raster/qgsrasterlabeling.cpp index b94eda8bb2eb..f00887b111d8 100644 --- a/src/core/raster/qgsrasterlabeling.cpp +++ b/src/core/raster/qgsrasterlabeling.cpp @@ -37,10 +37,6 @@ QgsRasterLayerLabelProvider::QgsRasterLayerLabelProvider( QgsRasterLayer *layer { mPlacement = Qgis::LabelPlacement::OverPoint; mFlags |= DrawLabels; - - // always consider these labels highest priority - // TODO possibly expose as a setting - mPriority = 0; } QgsRasterLayerLabelProvider::~QgsRasterLayerLabelProvider() @@ -137,20 +133,20 @@ void QgsRasterLayerLabelProvider::startRender( QgsRenderContext &context ) ///@cond PRIVATE // RAII properties restorer for QgsRasterDataProvider -struct ProviderSettingsRestorer +struct RasterProviderSettingsRestorer { QgsRasterDataProvider *mProvider; const bool mProviderResampling; const Qgis::RasterResamplingMethod mZoomedOutMethod; const double mMaxOversampling; - ProviderSettingsRestorer( QgsRasterDataProvider *provider ) + RasterProviderSettingsRestorer( QgsRasterDataProvider *provider ) : mProvider( provider ) , mProviderResampling( provider->isProviderResamplingEnabled() ) , mZoomedOutMethod( provider->zoomedOutResamplingMethod() ) , mMaxOversampling( provider->maxOversampling() ) {} - ~ProviderSettingsRestorer() + ~RasterProviderSettingsRestorer() { mProvider->enableProviderResampling( mProviderResampling ); mProvider->setZoomedOutResamplingMethod( mZoomedOutMethod ); @@ -255,7 +251,7 @@ void QgsRasterLayerLabelProvider::generateLabels( QgsRenderContext &context, Qgs bool isNoData = false; int numberLabels = 0; - ProviderSettingsRestorer restorer( provider ); + RasterProviderSettingsRestorer restorer( provider ); if ( mResampleOver > 1 ) { provider->enableProviderResampling( true ); @@ -424,13 +420,17 @@ QDomElement QgsRasterLayerSimpleLabeling::save( QDomDocument &doc, const QgsRead } elem.setAttribute( QStringLiteral( "resampleMethod" ), qgsEnumValueToKey( mResampleMethod ) ); - QDomElement textFormatElem = doc.createElement( QStringLiteral( "textFormat" ) ); - textFormatElem.appendChild( mTextFormat.writeXml( doc, context ) ); - elem.appendChild( textFormatElem ); + { + QDomElement textFormatElem = doc.createElement( QStringLiteral( "textFormat" ) ); + textFormatElem.appendChild( mTextFormat.writeXml( doc, context ) ); + elem.appendChild( textFormatElem ); + } - QDomElement numericFormatElem = doc.createElement( QStringLiteral( "numericFormat" ) ); - mNumericFormat->writeXml( numericFormatElem, doc, context ); - elem.appendChild( numericFormatElem ); + { + QDomElement numericFormatElem = doc.createElement( QStringLiteral( "numericFormat" ) ); + mNumericFormat->writeXml( numericFormatElem, doc, context ); + elem.appendChild( numericFormatElem ); + } { QDomElement placementElem = doc.createElement( QStringLiteral( "placement" ) ); @@ -449,6 +449,7 @@ QDomElement QgsRasterLayerSimpleLabeling::save( QDomDocument &doc, const QgsRead { QDomElement renderingElem = doc.createElement( QStringLiteral( "rendering" ) ); renderingElem.setAttribute( QStringLiteral( "scaleVisibility" ), mScaleVisibility ); + // note the element names are "flipped" vs the member -- this is intentional, and done to match vector labeling renderingElem.setAttribute( QStringLiteral( "scaleMin" ), mMaximumScale ); renderingElem.setAttribute( QStringLiteral( "scaleMax" ), mMinimumScale ); elem.appendChild( renderingElem ); @@ -506,6 +507,7 @@ QgsRasterLayerSimpleLabeling *QgsRasterLayerSimpleLabeling::create( const QDomEl res->mThinningSettings.setMinimumFeatureSize( thinningElem.attribute( QStringLiteral( "minFeatureSize" ), QStringLiteral( "8" ) ).toDouble() ); QDomElement renderingElem = element.firstChildElement( QStringLiteral( "rendering" ) ); + // note the element names are "flipped" vs the member -- this is intentional, and done to match vector labeling res->mMaximumScale = renderingElem.attribute( QStringLiteral( "scaleMin" ), QStringLiteral( "0" ) ).toDouble(); res->mMinimumScale = renderingElem.attribute( QStringLiteral( "scaleMax" ), QStringLiteral( "0" ) ).toDouble(); res->mScaleVisibility = renderingElem.attribute( QStringLiteral( "scaleVisibility" ) ).toInt(); diff --git a/src/core/raster/qgsrasterlayerrenderer.cpp b/src/core/raster/qgsrasterlayerrenderer.cpp index 02e016aa5900..46ec85f52d8e 100644 --- a/src/core/raster/qgsrasterlayerrenderer.cpp +++ b/src/core/raster/qgsrasterlayerrenderer.cpp @@ -40,8 +40,6 @@ #include "qgsunittypes.h" #include "qgsrasternuller.h" #include "qgsrenderedlayerstatistics.h" -#include "qgsnumericformat.h" - #include "qgsrasterlabeling.h" #include