From c527bed8898fe5fa9097ca19bd3a8f3cb3060871 Mon Sep 17 00:00:00 2001 From: Julien Cabieces Date: Tue, 4 Feb 2025 09:21:04 +0100 Subject: [PATCH] design(MaskSymbolLayer): add clearMasks only in mask symbol layer --- .../auto_generated/symbology/qgsmasksymbollayer.sip.in | 8 +++++++- .../core/auto_generated/symbology/qgssymbollayer.sip.in | 9 --------- .../auto_generated/symbology/qgsmasksymbollayer.sip.in | 8 +++++++- .../core/auto_generated/symbology/qgssymbollayer.sip.in | 9 --------- src/core/symbology/qgsmasksymbollayer.h | 7 ++++++- src/core/symbology/qgssymbollayer.cpp | 4 ---- src/core/symbology/qgssymbollayer.h | 7 ------- src/core/symbology/qgssymbollayerutils.cpp | 7 ++++--- 8 files changed, 24 insertions(+), 35 deletions(-) diff --git a/python/PyQt6/core/auto_generated/symbology/qgsmasksymbollayer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgsmasksymbollayer.sip.in index ebf042501778..1ee80706775d 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgsmasksymbollayer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgsmasksymbollayer.sip.in @@ -87,8 +87,14 @@ Returns a list of references to symbol layers that are masked by the sub symbol' .. seealso:: :py:func:`setMasks` %End - virtual void clearMasks(); + void clearMasks(); +%Docstring +Remove masks defined by this symbol layer. + +.. seealso:: :py:func:`masks` +.. versionadded:: 3.42 +%End void setMasks( const QList &maskedLayers ); %Docstring diff --git a/python/PyQt6/core/auto_generated/symbology/qgssymbollayer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgssymbollayer.sip.in index 8637c07dbe7f..1ec9b1adc27d 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgssymbollayer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgssymbollayer.sip.in @@ -639,15 +639,6 @@ Returns masks defined by this symbol layer. This is a list of symbol layers of other layers that should be occluded. .. versionadded:: 3.12 -%End - - virtual void clearMasks(); -%Docstring -Remove masks defined by this symbol layer. - -.. seealso:: :py:func:`masks` - -.. versionadded:: 3.42 %End virtual void prepareMasks( const QgsSymbolRenderContext &context ); diff --git a/python/core/auto_generated/symbology/qgsmasksymbollayer.sip.in b/python/core/auto_generated/symbology/qgsmasksymbollayer.sip.in index ebf042501778..1ee80706775d 100644 --- a/python/core/auto_generated/symbology/qgsmasksymbollayer.sip.in +++ b/python/core/auto_generated/symbology/qgsmasksymbollayer.sip.in @@ -87,8 +87,14 @@ Returns a list of references to symbol layers that are masked by the sub symbol' .. seealso:: :py:func:`setMasks` %End - virtual void clearMasks(); + void clearMasks(); +%Docstring +Remove masks defined by this symbol layer. + +.. seealso:: :py:func:`masks` +.. versionadded:: 3.42 +%End void setMasks( const QList &maskedLayers ); %Docstring diff --git a/python/core/auto_generated/symbology/qgssymbollayer.sip.in b/python/core/auto_generated/symbology/qgssymbollayer.sip.in index 033835f3cb8a..7b2ef5f0e8c7 100644 --- a/python/core/auto_generated/symbology/qgssymbollayer.sip.in +++ b/python/core/auto_generated/symbology/qgssymbollayer.sip.in @@ -639,15 +639,6 @@ Returns masks defined by this symbol layer. This is a list of symbol layers of other layers that should be occluded. .. versionadded:: 3.12 -%End - - virtual void clearMasks(); -%Docstring -Remove masks defined by this symbol layer. - -.. seealso:: :py:func:`masks` - -.. versionadded:: 3.42 %End virtual void prepareMasks( const QgsSymbolRenderContext &context ); diff --git a/src/core/symbology/qgsmasksymbollayer.h b/src/core/symbology/qgsmasksymbollayer.h index a1ecbe1b5e7c..1c52d14a92e8 100644 --- a/src/core/symbology/qgsmasksymbollayer.h +++ b/src/core/symbology/qgsmasksymbollayer.h @@ -79,7 +79,12 @@ class CORE_EXPORT QgsMaskMarkerSymbolLayer : public QgsMarkerSymbolLayer */ QList masks() const override; - void clearMasks() override; + /** + * Remove masks defined by this symbol layer. + * \see masks() + * \since QGIS 3.42 + */ + void clearMasks(); /** * Sets the symbol layers that will be masked by the sub symbol's shape. diff --git a/src/core/symbology/qgssymbollayer.cpp b/src/core/symbology/qgssymbollayer.cpp index 307982ed5377..b0a9cc928e32 100644 --- a/src/core/symbology/qgssymbollayer.cpp +++ b/src/core/symbology/qgssymbollayer.cpp @@ -921,10 +921,6 @@ QList QgsSymbolLayer::masks() const return {}; } -void QgsSymbolLayer::clearMasks() -{ -} - double QgsMarkerSymbolLayer::dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const { double size = mSize; diff --git a/src/core/symbology/qgssymbollayer.h b/src/core/symbology/qgssymbollayer.h index f9f68821c2ee..f5e3618c99e3 100644 --- a/src/core/symbology/qgssymbollayer.h +++ b/src/core/symbology/qgssymbollayer.h @@ -631,13 +631,6 @@ class CORE_EXPORT QgsSymbolLayer */ virtual QList masks() const; - /** - * Remove masks defined by this symbol layer. - * \see masks() - * \since QGIS 3.42 - */ - virtual void clearMasks(); - /** * Prepares all mask internal objects according to what is defined in \a context * This should be called prior to calling startRender() method. diff --git a/src/core/symbology/qgssymbollayerutils.cpp b/src/core/symbology/qgssymbollayerutils.cpp index 27ab744524c6..96c38de928e3 100644 --- a/src/core/symbology/qgssymbollayerutils.cpp +++ b/src/core/symbology/qgssymbollayerutils.cpp @@ -44,6 +44,7 @@ #include "qgssymbollayerreference.h" #include "qgsmarkersymbollayer.h" #include "qgscurvepolygon.h" +#include "qgsmasksymbollayer.h" #include "qmath.h" #include @@ -5605,12 +5606,12 @@ void QgsSymbolLayerUtils::clearSymbolLayerMasks( QgsSymbol *symbol ) for ( int idx = 0; idx < symbol->symbolLayerCount(); idx++ ) { - if ( QgsSymbolLayer *sl = symbol->symbolLayer( idx ) ) + if ( QgsMaskMarkerSymbolLayer *maskSl = dynamic_cast( symbol->symbolLayer( idx ) ) ) { - sl->clearMasks(); + maskSl->clearMasks(); // recurse over sub symbols - if ( QgsSymbol *subSymbol = sl->subSymbol() ) + if ( QgsSymbol *subSymbol = maskSl->subSymbol() ) { clearSymbolLayerMasks( subSymbol ); }