do not use hybrid symbol layer type

This commit is contained in:
vcloarec 2021-05-03 17:43:56 -04:00 committed by Martin Dobias
parent 4bb0dcab84
commit 843eebc6ec
9 changed files with 22 additions and 79 deletions

View File

@ -8,7 +8,7 @@
class QgsGeometryGeneratorSymbolLayer : QgsHybridSymbolLayer
class QgsGeometryGeneratorSymbolLayer : QgsSymbolLayer
{
%TypeHeaderCode
@ -89,8 +89,7 @@ This is a hybrid layer, it constructs its own geometry so it does not
care about the geometry of its parents.
%End
virtual void render( QgsSymbolRenderContext &context );
void render( QgsSymbolRenderContext &context );
%Docstring
Will render this symbol layer using the context.
In comparison to other symbols there is no geometry passed in, since

View File

@ -279,7 +279,7 @@ Sets if the rendering must be done as the element is selected
};
class QgsInterpolatedLineSymbolLayer : QgsHybridSymbolLayer
class QgsInterpolatedLineSymbolLayer : QgsLineSymbolLayer
{
%Docstring(signature="appended")
A symbol layer that represents vector layer line feature as interpolated line
@ -320,7 +320,7 @@ Creates the symbol layer
virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
virtual void render( QgsSymbolRenderContext &context );
virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context );
virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;

View File

@ -50,6 +50,8 @@ class QgsSymbolLayer
sipType = sipType_QgsSimpleLineSymbolLayer;
else if ( sipCpp->layerType() == "ArrowLine" )
sipType = sipType_QgsArrowSymbolLayer;
else if ( sipCpp->layerType() == "InterpolatedLine" )
sipType = sipType_QgsInterpolatedLineSymbolLayer;
else
sipType = sipType_QgsLineSymbolLayer;
break;
@ -80,8 +82,6 @@ class QgsSymbolLayer
case QgsSymbol::Hybrid:
sipType = sipType_QgsGeometryGeneratorSymbolLayer;
break;
sipType = sipType_QgsInterpolatedLineSymbolLayer;
break;
}
%End
public:
@ -1217,36 +1217,6 @@ Default method to render polygon
QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
};
class QgsHybridSymbolLayer : QgsSymbolLayer
{
%Docstring(signature="appended")
:py:class:`QgsHybridSymbolLayer`
.. versionadded:: 3.20
%End
%TypeHeaderCode
#include "qgssymbollayer.h"
%End
public:
virtual void render( QgsSymbolRenderContext &context ) = 0;
%Docstring
Will render this symbol layer using the context.
In comparison to other symbols there is no geometry passed in
:param context: The rendering context which will be used to render
%End
protected:
QgsHybridSymbolLayer( bool locked = false );
%Docstring
Constructor
%End
};

View File

@ -45,7 +45,7 @@ QgsSymbolLayer *QgsGeometryGeneratorSymbolLayer::create( const QVariantMap &prop
}
QgsGeometryGeneratorSymbolLayer::QgsGeometryGeneratorSymbolLayer( const QString &expression )
: QgsHybridSymbolLayer()
: QgsSymbolLayer( QgsSymbol::Hybrid )
, mExpression( new QgsExpression( expression ) )
, mSymbolType( QgsSymbol::Marker )
{

View File

@ -23,7 +23,7 @@
* \ingroup core
* \class QgsGeometryGeneratorSymbolLayer
*/
class CORE_EXPORT QgsGeometryGeneratorSymbolLayer : public QgsHybridSymbolLayer
class CORE_EXPORT QgsGeometryGeneratorSymbolLayer : public QgsSymbolLayer
{
public:
~QgsGeometryGeneratorSymbolLayer() override;
@ -95,7 +95,7 @@ class CORE_EXPORT QgsGeometryGeneratorSymbolLayer : public QgsHybridSymbolLayer
* \param context The rendering context which will be used to render and to
* construct a geometry.
*/
void render( QgsSymbolRenderContext &context ) override;
void render( QgsSymbolRenderContext &context );
void setColor( const QColor &color ) override;

View File

@ -973,7 +973,7 @@ void QgsInterpolatedLineSymbolLayer::drawPreviewIcon( QgsSymbolRenderContext &co
mLineRender.renderInDeviceCoordinate( v1, v2, v1, v2, p1, p2, context.renderContext() );
}
render( context );
renderPolyline( points, context );
}
@ -1033,7 +1033,7 @@ QgsInterpolatedLineColor QgsInterpolatedLineSymbolLayer::interpolatedColor() con
return mLineRender.interpolatedColor();
}
QgsInterpolatedLineSymbolLayer::QgsInterpolatedLineSymbolLayer(): QgsHybridSymbolLayer( true ) {}
QgsInterpolatedLineSymbolLayer::QgsInterpolatedLineSymbolLayer(): QgsLineSymbolLayer( true ) {}
void QgsInterpolatedLineSymbolLayer::startFeatureRender( const QgsFeature &feature, QgsRenderContext & )
@ -1046,8 +1046,10 @@ void QgsInterpolatedLineSymbolLayer::stopFeatureRender( const QgsFeature &, QgsR
mFeature = QgsFeature();
}
void QgsInterpolatedLineSymbolLayer::render( QgsSymbolRenderContext &context )
void QgsInterpolatedLineSymbolLayer::renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context )
{
Q_UNUSED( points ); //this symbol layer need to used all the feature geometry, not clipped/simplified geometry
QVector<QgsPolylineXY> lineStrings;
double startValWidth = 0;

View File

@ -273,7 +273,7 @@ class CORE_EXPORT QgsInterpolatedLineRenderer
* The interpolation is done between two values defined at the extremities
* \since QGIS 3.20
*/
class CORE_EXPORT QgsInterpolatedLineSymbolLayer : public QgsHybridSymbolLayer
class CORE_EXPORT QgsInterpolatedLineSymbolLayer : public QgsLineSymbolLayer
{
public:
@ -292,7 +292,7 @@ class CORE_EXPORT QgsInterpolatedLineSymbolLayer : public QgsHybridSymbolLayer
void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
void render( QgsSymbolRenderContext &context ) override;
void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
bool isCompatibleWithSymbol( QgsSymbol *symbol ) const override;
QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
bool canCauseArtifactsBetweenAdjacentTiles() const override;

View File

@ -805,17 +805,17 @@ void QgsSymbol::renderUsingLayer( QgsSymbolLayer *layer, QgsSymbolRenderContext
if ( layer->dataDefinedProperties().hasActiveProperties() && !layer->dataDefinedProperties().valueAsBool( QgsSymbolLayer::PropertyLayerEnabled, context.renderContext().expressionContext(), true ) )
return;
QgsHybridSymbolLayer *hybridLayer = static_cast<QgsGeometryGeneratorSymbolLayer *>( layer );
QgsGeometryGeneratorSymbolLayer *generatorLayer = static_cast<QgsGeometryGeneratorSymbolLayer *>( layer );
QgsPaintEffect *effect = hybridLayer->paintEffect();
QgsPaintEffect *effect = generatorLayer->paintEffect();
if ( effect && effect->enabled() )
{
QgsEffectPainter p( context.renderContext(), effect );
hybridLayer->render( context );
generatorLayer->render( context );
}
else
{
hybridLayer->render( context );
generatorLayer->render( context );
}
}

View File

@ -88,6 +88,8 @@ class CORE_EXPORT QgsSymbolLayer
sipType = sipType_QgsSimpleLineSymbolLayer;
else if ( sipCpp->layerType() == "ArrowLine" )
sipType = sipType_QgsArrowSymbolLayer;
else if ( sipCpp->layerType() == "InterpolatedLine" )
sipType = sipType_QgsInterpolatedLineSymbolLayer;
else
sipType = sipType_QgsLineSymbolLayer;
break;
@ -118,8 +120,6 @@ class CORE_EXPORT QgsSymbolLayer
case QgsSymbol::Hybrid:
sipType = sipType_QgsGeometryGeneratorSymbolLayer;
break;
sipType = sipType_QgsInterpolatedLineSymbolLayer;
break;
}
SIP_END
#endif
@ -1152,34 +1152,6 @@ class CORE_EXPORT QgsFillSymbolLayer : public QgsSymbolLayer
#endif
};
/**
* \ingroup core
* \brief QgsHybridSymbolLayer
* \since QGIS 3.20
*/
class CORE_EXPORT QgsHybridSymbolLayer : public QgsSymbolLayer
{
public:
//! QgsHybridSymbolLayer cannot be copied
QgsHybridSymbolLayer( const QgsHybridSymbolLayer &other ) = delete;
//! QgsHybridSymbolLayer cannot be copied
QgsHybridSymbolLayer &operator=( const QgsHybridSymbolLayer &other ) = delete;
/**
* Will render this symbol layer using the context.
* In comparison to other symbols there is no geometry passed in
*
* \param context The rendering context which will be used to render
*/
virtual void render( QgsSymbolRenderContext &context ) = 0;
protected:
//! Constructor
QgsHybridSymbolLayer( bool locked = false ): QgsSymbolLayer( QgsSymbol::Hybrid, locked ) {}
};
class QgsSymbolLayerWidget; // why does SIP fail, when this isn't here
#endif