Skip to content
Permalink
Browse files

Add QgsSymbolLayer::canCauseArtifactsBetweenAdjacentTiles()

Returns true if the symbol layer rendering can cause visible
artifacts across a single feature when the feature is rendered
as a series of adjacent map tiles each containing a portion
of the feature's geometry.

This depends on the symbol layer derived class itself - eg
a simple solid color fill won't show any artifacts, but a shapeburst
fill WILL.
  • Loading branch information
nyalldawson committed Feb 12, 2021
1 parent d5e2051 commit bdf5e4fe3b3c02da8060fca80c5f611b67539e23
@@ -245,24 +245,20 @@ Caller takes ownership of the returned symbol layer.

virtual QString layerType() const;


virtual void startRender( QgsSymbolRenderContext &context );


virtual void stopRender( QgsSymbolRenderContext &context );


virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );


virtual QVariantMap properties() const;


virtual QgsGradientFillSymbolLayer *clone() const /Factory/;


virtual double estimateMaxBleed( const QgsRenderContext &context ) const;

virtual bool canCauseArtifactsBetweenAdjacentTiles() const;


GradientType gradientType() const;
%Docstring
@@ -450,24 +446,20 @@ Caller takes ownership of the returned symbol layer.

virtual QString layerType() const;


virtual void startRender( QgsSymbolRenderContext &context );


virtual void stopRender( QgsSymbolRenderContext &context );


virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );


virtual QVariantMap properties() const;


virtual QgsShapeburstFillSymbolLayer *clone() const /Factory/;


virtual double estimateMaxBleed( const QgsRenderContext &context ) const;

virtual bool canCauseArtifactsBetweenAdjacentTiles() const;


void setBlurRadius( int blurRadius );
%Docstring
@@ -2075,6 +2067,8 @@ Caller takes ownership of the returned symbol layer.

virtual QgsRandomMarkerFillSymbolLayer *clone() const /Factory/;

virtual bool canCauseArtifactsBetweenAdjacentTiles() const;


virtual void setColor( const QColor &color );

@@ -2251,51 +2245,42 @@ Caller takes ownership of the returned symbol layer.

virtual QString layerType() const;


virtual void startRender( QgsSymbolRenderContext &context );


virtual void stopRender( QgsSymbolRenderContext &context );


virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );


virtual QVariantMap properties() const;


virtual QgsCentroidFillSymbolLayer *clone() const /Factory/;


virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const;


virtual void setColor( const QColor &color );

virtual QColor color() const;


virtual QgsSymbol *subSymbol();

virtual bool setSubSymbol( QgsSymbol *symbol /Transfer/ );


virtual void setOutputUnit( QgsUnitTypes::RenderUnit unit );

virtual QgsUnitTypes::RenderUnit outputUnit() const;

virtual bool usesMapUnits() const;


virtual void setMapUnitScale( const QgsMapUnitScale &scale );

virtual QgsMapUnitScale mapUnitScale() const;


virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;

virtual bool hasDataDefinedProperties() const;

virtual bool canCauseArtifactsBetweenAdjacentTiles() const;


void setPointOnSurface( bool pointOnSurface );
bool pointOnSurface() const;
@@ -660,6 +660,8 @@ calculating individual symbol angles.

virtual QVariantMap properties() const;

virtual bool canCauseArtifactsBetweenAdjacentTiles() const;


protected:

@@ -336,6 +336,16 @@ Sets layer's subsymbol. takes ownership of the passed symbol
virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;
%Docstring
Returns if the layer can be used below the specified symbol
%End

virtual bool canCauseArtifactsBetweenAdjacentTiles() const;
%Docstring
Returns ``True`` if the symbol layer rendering can cause visible artifacts across a single feature
when the feature is rendered as a series of adjacent map tiles each containing a portion of the feature's geometry.

The default implementation returns ``False``.

.. versionadded:: 3.18
%End

void setLocked( bool locked );
@@ -830,3 +830,8 @@ QColor QgsArrowSymbolLayer::color() const
return mSymbol.get() ? mSymbol->color() : mColor;
}

bool QgsArrowSymbolLayer::canCauseArtifactsBetweenAdjacentTiles() const
{
return true;
}

@@ -145,6 +145,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer
void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
void setColor( const QColor &c ) override;
QColor color() const override;
bool canCauseArtifactsBetweenAdjacentTiles() const override;

private:
#ifdef SIP_RUN
@@ -988,6 +988,11 @@ double QgsGradientFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &con
return offsetBleed;
}

bool QgsGradientFillSymbolLayer::canCauseArtifactsBetweenAdjacentTiles() const
{
return true;
}

void QgsGradientFillSymbolLayer::setOutputUnit( QgsUnitTypes::RenderUnit unit )
{
mOffsetUnit = unit;
@@ -1618,6 +1623,11 @@ double QgsShapeburstFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &c
return offsetBleed;
}

bool QgsShapeburstFillSymbolLayer::canCauseArtifactsBetweenAdjacentTiles() const
{
return true;
}

void QgsShapeburstFillSymbolLayer::setOutputUnit( QgsUnitTypes::RenderUnit unit )
{
mDistanceUnit = unit;
@@ -4049,6 +4059,11 @@ bool QgsCentroidFillSymbolLayer::hasDataDefinedProperties() const
return false;
}

bool QgsCentroidFillSymbolLayer::canCauseArtifactsBetweenAdjacentTiles() const
{
return true;
}

void QgsCentroidFillSymbolLayer::setOutputUnit( QgsUnitTypes::RenderUnit unit )
{
if ( mMarker )
@@ -4616,6 +4631,11 @@ QgsRandomMarkerFillSymbolLayer *QgsRandomMarkerFillSymbolLayer::clone() const
return res.release();
}

bool QgsRandomMarkerFillSymbolLayer::canCauseArtifactsBetweenAdjacentTiles() const
{
return true;
}

QgsSymbol *QgsRandomMarkerFillSymbolLayer::subSymbol()
{
return mMarker.get();
@@ -254,18 +254,13 @@ class CORE_EXPORT QgsGradientFillSymbolLayer : public QgsFillSymbolLayer
// implemented from base classes

QString layerType() const override;

void startRender( QgsSymbolRenderContext &context ) override;

void stopRender( QgsSymbolRenderContext &context ) override;

void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;

QVariantMap properties() const override;

QgsGradientFillSymbolLayer *clone() const override SIP_FACTORY;

double estimateMaxBleed( const QgsRenderContext &context ) const override;
bool canCauseArtifactsBetweenAdjacentTiles() const override;

//! Type of gradient, e.g., linear or radial
GradientType gradientType() const { return mGradientType; }
@@ -454,18 +449,13 @@ class CORE_EXPORT QgsShapeburstFillSymbolLayer : public QgsFillSymbolLayer
// implemented from base classes

QString layerType() const override;

void startRender( QgsSymbolRenderContext &context ) override;

void stopRender( QgsSymbolRenderContext &context ) override;

void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;

QVariantMap properties() const override;

QgsShapeburstFillSymbolLayer *clone() const override SIP_FACTORY;

double estimateMaxBleed( const QgsRenderContext &context ) const override;
bool canCauseArtifactsBetweenAdjacentTiles() const override;

/**
* Sets the blur radius, which controls the amount of blurring applied to the fill.
@@ -1860,6 +1850,7 @@ class CORE_EXPORT QgsRandomMarkerFillSymbolLayer : public QgsFillSymbolLayer
void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
QVariantMap properties() const override;
QgsRandomMarkerFillSymbolLayer *clone() const override SIP_FACTORY;
bool canCauseArtifactsBetweenAdjacentTiles() const override;

void setColor( const QColor &color ) override;
QColor color() const override;
@@ -2037,34 +2028,24 @@ class CORE_EXPORT QgsCentroidFillSymbolLayer : public QgsFillSymbolLayer
// implemented from base classes

QString layerType() const override;

void startRender( QgsSymbolRenderContext &context ) override;

void stopRender( QgsSymbolRenderContext &context ) override;

void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;

QVariantMap properties() const override;

QgsCentroidFillSymbolLayer *clone() const override SIP_FACTORY;

void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;

void setColor( const QColor &color ) override;
QColor color() const override;

QgsSymbol *subSymbol() override;
bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;

void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
QgsUnitTypes::RenderUnit outputUnit() const override;
bool usesMapUnits() const override;

void setMapUnitScale( const QgsMapUnitScale &scale ) override;
QgsMapUnitScale mapUnitScale() const override;

QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
bool hasDataDefinedProperties() const override;
bool canCauseArtifactsBetweenAdjacentTiles() const override;

void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
bool pointOnSurface() const { return mPointOnSurface; }
@@ -1351,6 +1351,24 @@ QVariantMap QgsTemplatedLineSymbolLayerBase::properties() const
return map;
}

bool QgsTemplatedLineSymbolLayerBase::canCauseArtifactsBetweenAdjacentTiles() const
{
switch ( mPlacement )
{
case QgsTemplatedLineSymbolLayerBase::Interval:
case QgsTemplatedLineSymbolLayerBase::CentralPoint:
case QgsTemplatedLineSymbolLayerBase::SegmentCenter:
return true;

case QgsTemplatedLineSymbolLayerBase::Vertex:
case QgsTemplatedLineSymbolLayerBase::CurvePoint:
case QgsTemplatedLineSymbolLayerBase::LastVertex:
case QgsTemplatedLineSymbolLayerBase::FirstVertex:
return false;
}
return false;
}

void QgsTemplatedLineSymbolLayerBase::copyTemplateSymbolProperties( QgsTemplatedLineSymbolLayerBase *destLayer ) const
{
destLayer->setSubSymbol( const_cast< QgsTemplatedLineSymbolLayerBase * >( this )->subSymbol()->clone() );
@@ -599,6 +599,7 @@ class CORE_EXPORT QgsTemplatedLineSymbolLayerBase : public QgsLineSymbolLayer
void setMapUnitScale( const QgsMapUnitScale &scale ) FINAL;
QgsMapUnitScale mapUnitScale() const FINAL;
QVariantMap properties() const override;
bool canCauseArtifactsBetweenAdjacentTiles() const override;

protected:

@@ -234,6 +234,11 @@ bool QgsSymbolLayer::isCompatibleWithSymbol( QgsSymbol *symbol ) const
return symbol->type() == mType;
}

bool QgsSymbolLayer::canCauseArtifactsBetweenAdjacentTiles() const
{
return false;
}

bool QgsSymbolLayer::usesMapUnits() const
{
return false;
@@ -361,6 +361,16 @@ class CORE_EXPORT QgsSymbolLayer
//! Returns if the layer can be used below the specified symbol
virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;

/**
* Returns TRUE if the symbol layer rendering can cause visible artifacts across a single feature
* when the feature is rendered as a series of adjacent map tiles each containing a portion of the feature's geometry.
*
* The default implementation returns FALSE.
*
* \since QGIS 3.18
*/
virtual bool canCauseArtifactsBetweenAdjacentTiles() const;

void setLocked( bool locked ) { mLocked = locked; }
bool isLocked() const { return mLocked; }

0 comments on commit bdf5e4f

Please sign in to comment.