Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create Qgis::SymbolLayerFlags, add flag for symbol layers to prevent
feature clipping to map extent
  • Loading branch information
nyalldawson committed Sep 21, 2021
1 parent 75f735c commit cd2a17f
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/core/auto_additions/qgis.py
Expand Up @@ -150,6 +150,11 @@
Qgis.SymbolPreviewFlag.__doc__ = 'Flags for controlling how symbol preview images are generated.\n\n.. versionadded:: 3.20\n\n' + '* ``FlagIncludeCrosshairsForMarkerSymbols``: ' + Qgis.SymbolPreviewFlag.FlagIncludeCrosshairsForMarkerSymbols.__doc__
# --
Qgis.SymbolPreviewFlag.baseClass = Qgis
# monkey patching scoped based enum
Qgis.SymbolLayerFlag.DisableFeatureClipping.__doc__ = "If present, indicates that features should never be clipped to the map extent during rendering"
Qgis.SymbolLayerFlag.__doc__ = 'Flags controlling behavior of symbol layers\n\n.. versionadded:: 3.22\n\n' + '* ``DisableFeatureClipping``: ' + Qgis.SymbolLayerFlag.DisableFeatureClipping.__doc__
# --
Qgis.SymbolLayerFlag.baseClass = Qgis
QgsDataItem.Type = Qgis.BrowserItemType
# monkey patching scoped based enum
QgsDataItem.Collection = Qgis.BrowserItemType.Collection
Expand Down
9 changes: 9 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Expand Up @@ -153,6 +153,13 @@ The development version
typedef QFlags<Qgis::SymbolPreviewFlag> SymbolPreviewFlags;


enum class SymbolLayerFlag
{
DisableFeatureClipping,
};
typedef QFlags<Qgis::SymbolLayerFlag> SymbolLayerFlags;


enum class BrowserItemType
{
Collection,
Expand Down Expand Up @@ -609,6 +616,8 @@ QFlags<Qgis::SymbolFlag> operator|(Qgis::SymbolFlag f1, QFlags<Qgis::SymbolFlag>

QFlags<Qgis::SymbolPreviewFlag> operator|(Qgis::SymbolPreviewFlag f1, QFlags<Qgis::SymbolPreviewFlag> f2);

QFlags<Qgis::SymbolLayerFlag> operator|(Qgis::SymbolLayerFlag f1, QFlags<Qgis::SymbolLayerFlag> f2);

QFlags<Qgis::BrowserItemCapability> operator|(Qgis::BrowserItemCapability f1, QFlags<Qgis::BrowserItemCapability> f2);

QFlags<Qgis::SublayerQueryFlag> operator|(Qgis::SublayerQueryFlag f1, QFlags<Qgis::SublayerQueryFlag> f2);
Expand Down
Expand Up @@ -303,6 +303,8 @@ Constructor
Creates the symbol layer
%End

virtual Qgis::SymbolLayerFlags flags() const;

virtual QString layerType() const;

virtual void startRender( QgsSymbolRenderContext &context );
Expand Down
7 changes: 7 additions & 0 deletions python/core/auto_generated/symbology/qgssymbollayer.sip.in
Expand Up @@ -165,6 +165,13 @@ Returns the symbol layer property definitions.



virtual Qgis::SymbolLayerFlags flags() const;
%Docstring
Returns flags which control the symbol layer's behavior.

.. versionadded:: 3.22
%End

bool enabled() const;
%Docstring
Returns ``True`` if symbol layer is enabled and will be drawn.
Expand Down
13 changes: 13 additions & 0 deletions src/core/qgis.h
Expand Up @@ -222,6 +222,18 @@ class CORE_EXPORT Qgis
Q_ENUM( SymbolPreviewFlag )
Q_DECLARE_FLAGS( SymbolPreviewFlags, SymbolPreviewFlag )

/**
* \brief Flags controlling behavior of symbol layers
*
* \since QGIS 3.22
*/
enum class SymbolLayerFlag : int
{
DisableFeatureClipping = 1 << 0, //!< If present, indicates that features should never be clipped to the map extent during rendering
};
Q_ENUM( SymbolLayerFlag )
Q_DECLARE_FLAGS( SymbolLayerFlags, SymbolLayerFlag )

/**
* Browser item types.
*
Expand Down Expand Up @@ -975,6 +987,7 @@ class CORE_EXPORT Qgis
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolRenderHints )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolPreviewFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolLayerFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::BrowserItemCapabilities )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SublayerQueryFlags )
Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SublayerFlags )
Expand Down
5 changes: 5 additions & 0 deletions src/core/symbology/qgsinterpolatedlinerenderer.cpp
Expand Up @@ -903,6 +903,11 @@ QgsSymbolLayer *QgsInterpolatedLineSymbolLayer::create( const QVariantMap &prope
return symbolLayer.release();
}

Qgis::SymbolLayerFlags QgsInterpolatedLineSymbolLayer::flags() const
{
return Qgis::SymbolLayerFlag::DisableFeatureClipping;
}

QVariantMap QgsInterpolatedLineSymbolLayer::properties() const
{
QVariantMap props;
Expand Down
1 change: 1 addition & 0 deletions src/core/symbology/qgsinterpolatedlinerenderer.h
Expand Up @@ -283,6 +283,7 @@ class CORE_EXPORT QgsInterpolatedLineSymbolLayer : public QgsLineSymbolLayer
//! Creates the symbol layer
static QgsSymbolLayer *create( const QVariantMap &properties ) SIP_FACTORY;

Qgis::SymbolLayerFlags flags() const override;
QString layerType() const override;
void startRender( QgsSymbolRenderContext &context ) override;
void stopRender( QgsSymbolRenderContext &context ) override;
Expand Down
9 changes: 9 additions & 0 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -931,6 +931,15 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
}

bool clippingEnabled = clipFeaturesToExtent();
// do any symbol layers prevent feature clipping?
for ( QgsSymbolLayer *layer : std::as_const( mLayers ) )
{
if ( layer->flags() & Qgis::SymbolLayerFlag::DisableFeatureClipping )
{
clippingEnabled = false;
break;
}
}
if ( clippingEnabled && context.testFlag( QgsRenderContext::RenderMapTile ) )
{
// If the "avoid artifacts between adjacent tiles" flag is set (RenderMapTile), then we'll force disable
Expand Down
5 changes: 5 additions & 0 deletions src/core/symbology/qgssymbollayer.cpp
Expand Up @@ -220,6 +220,11 @@ QgsSymbolLayer::QgsSymbolLayer( Qgis::SymbolType type, bool locked )
{
}

Qgis::SymbolLayerFlags QgsSymbolLayer::flags() const
{
return Qgis::SymbolLayerFlags();
}

void QgsSymbolLayer::prepareExpressions( const QgsSymbolRenderContext &context )
{
mDataDefinedProperties.prepare( context.renderContext().expressionContext() );
Expand Down
7 changes: 7 additions & 0 deletions src/core/symbology/qgssymbollayer.h
Expand Up @@ -212,6 +212,13 @@ class CORE_EXPORT QgsSymbolLayer
//! QgsSymbolLayer cannot be copied
QgsSymbolLayer &operator=( const QgsSymbolLayer &other ) = delete;

/**
* Returns flags which control the symbol layer's behavior.
*
* \since QGIS 3.22
*/
virtual Qgis::SymbolLayerFlags flags() const;

/**
* Returns TRUE if symbol layer is enabled and will be drawn.
* \see setEnabled()
Expand Down

0 comments on commit cd2a17f

Please sign in to comment.