Skip to content

Commit

Permalink
design(MaskSymbolLayer): add clearMasks only in mask symbol layer
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 committed Feb 5, 2025
1 parent 3ff1b82 commit c527bed
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<QgsSymbolLayerReference> &maskedLayers );
%Docstring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<QgsSymbolLayerReference> &maskedLayers );
%Docstring
Expand Down
9 changes: 0 additions & 9 deletions python/core/auto_generated/symbology/qgssymbollayer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
7 changes: 6 additions & 1 deletion src/core/symbology/qgsmasksymbollayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ class CORE_EXPORT QgsMaskMarkerSymbolLayer : public QgsMarkerSymbolLayer
*/
QList<QgsSymbolLayerReference> 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.
Expand Down
4 changes: 0 additions & 4 deletions src/core/symbology/qgssymbollayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,6 @@ QList<QgsSymbolLayerReference> QgsSymbolLayer::masks() const
return {};
}

void QgsSymbolLayer::clearMasks()
{
}

double QgsMarkerSymbolLayer::dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const
{
double size = mSize;
Expand Down
7 changes: 0 additions & 7 deletions src/core/symbology/qgssymbollayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,6 @@ class CORE_EXPORT QgsSymbolLayer
*/
virtual QList<QgsSymbolLayerReference> 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.
Expand Down
7 changes: 4 additions & 3 deletions src/core/symbology/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "qgssymbollayerreference.h"
#include "qgsmarkersymbollayer.h"
#include "qgscurvepolygon.h"
#include "qgsmasksymbollayer.h"

#include "qmath.h"
#include <QColor>
Expand Down Expand Up @@ -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<QgsMaskMarkerSymbolLayer *>( symbol->symbolLayer( idx ) ) )
{
sl->clearMasks();
maskSl->clearMasks();

// recurse over sub symbols
if ( QgsSymbol *subSymbol = sl->subSymbol() )
if ( QgsSymbol *subSymbol = maskSl->subSymbol() )
{
clearSymbolLayerMasks( subSymbol );
}
Expand Down

0 comments on commit c527bed

Please sign in to comment.