Skip to content

Commit

Permalink
do not use hybrid symbol layer type
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec authored and wonder-sk committed May 5, 2021
1 parent 4bb0dca commit 843eebc
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 79 deletions.
Expand Up @@ -8,7 +8,7 @@



class QgsGeometryGeneratorSymbolLayer : QgsHybridSymbolLayer
class QgsGeometryGeneratorSymbolLayer : QgsSymbolLayer
{

%TypeHeaderCode
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
34 changes: 2 additions & 32 deletions python/core/auto_generated/symbology/qgssymbollayer.sip.in
Expand Up @@ -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;
Expand Down Expand Up @@ -80,8 +82,6 @@ class QgsSymbolLayer
case QgsSymbol::Hybrid:
sipType = sipType_QgsGeometryGeneratorSymbolLayer;
break;
sipType = sipType_QgsInterpolatedLineSymbolLayer;
break;
}
%End
public:
Expand Down Expand Up @@ -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

};




Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology/qgsgeometrygeneratorsymbollayer.cpp
Expand Up @@ -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 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology/qgsgeometrygeneratorsymbollayer.h
Expand Up @@ -23,7 +23,7 @@
* \ingroup core
* \class QgsGeometryGeneratorSymbolLayer
*/
class CORE_EXPORT QgsGeometryGeneratorSymbolLayer : public QgsHybridSymbolLayer
class CORE_EXPORT QgsGeometryGeneratorSymbolLayer : public QgsSymbolLayer
{
public:
~QgsGeometryGeneratorSymbolLayer() override;
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 5 additions & 3 deletions src/core/symbology/qgsinterpolatedlinerenderer.cpp
Expand Up @@ -973,7 +973,7 @@ void QgsInterpolatedLineSymbolLayer::drawPreviewIcon( QgsSymbolRenderContext &co
mLineRender.renderInDeviceCoordinate( v1, v2, v1, v2, p1, p2, context.renderContext() );
}

render( context );
renderPolyline( points, context );
}


Expand Down Expand Up @@ -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 & )
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology/qgsinterpolatedlinerenderer.h
Expand Up @@ -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:

Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -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 );
}
}

Expand Down
32 changes: 2 additions & 30 deletions src/core/symbology/qgssymbollayer.h
Expand Up @@ -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;
Expand Down Expand Up @@ -118,8 +120,6 @@ class CORE_EXPORT QgsSymbolLayer
case QgsSymbol::Hybrid:
sipType = sipType_QgsGeometryGeneratorSymbolLayer;
break;
sipType = sipType_QgsInterpolatedLineSymbolLayer;
break;
}
SIP_END
#endif
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 843eebc

Please sign in to comment.