mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-17 00:09:36 -04:00
Make common function for copying QgsSymbol properties
Avoid fragile duplicate code in subclasses
This commit is contained in:
parent
91d5733dc8
commit
bf30f04d0a
@ -731,6 +731,13 @@ clockwise for exterior rings and counter-clockwise for interior rings.
|
||||
%Docstring
|
||||
Retrieve a cloned list of all layers that make up this symbol.
|
||||
Ownership is transferred to the caller.
|
||||
%End
|
||||
|
||||
void copyCommonProperties( const QgsSymbol *other );
|
||||
%Docstring
|
||||
Copies common properties from an ``other`` symbol to this symbol.
|
||||
|
||||
.. versionadded:: 3.40
|
||||
%End
|
||||
|
||||
void renderUsingLayer( QgsSymbolLayer *layer, QgsSymbolRenderContext &context, Qgis::GeometryType geometryType = Qgis::GeometryType::Unknown, const QPolygonF *points = 0, const QVector<QPolygonF> *rings = 0 );
|
||||
|
@ -731,6 +731,13 @@ clockwise for exterior rings and counter-clockwise for interior rings.
|
||||
%Docstring
|
||||
Retrieve a cloned list of all layers that make up this symbol.
|
||||
Ownership is transferred to the caller.
|
||||
%End
|
||||
|
||||
void copyCommonProperties( const QgsSymbol *other );
|
||||
%Docstring
|
||||
Copies common properties from an ``other`` symbol to this symbol.
|
||||
|
||||
.. versionadded:: 3.40
|
||||
%End
|
||||
|
||||
void renderUsingLayer( QgsSymbolLayer *layer, QgsSymbolRenderContext &context, Qgis::GeometryType geometryType = Qgis::GeometryType::Unknown, const QPolygonF *points = 0, const QVector<QPolygonF> *rings = 0 );
|
||||
|
@ -144,15 +144,7 @@ QVector<QPolygonF> *QgsFillSymbol::translateRings( const QVector<QPolygonF> *rin
|
||||
QgsFillSymbol *QgsFillSymbol::clone() const
|
||||
{
|
||||
QgsFillSymbol *cloneSymbol = new QgsFillSymbol( cloneLayers() );
|
||||
cloneSymbol->setOpacity( mOpacity );
|
||||
Q_NOWARN_DEPRECATED_PUSH
|
||||
cloneSymbol->setLayer( mLayer );
|
||||
Q_NOWARN_DEPRECATED_POP
|
||||
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
|
||||
cloneSymbol->setForceRHR( mForceRHR );
|
||||
cloneSymbol->setDataDefinedProperties( dataDefinedProperties() );
|
||||
cloneSymbol->setFlags( mSymbolFlags );
|
||||
cloneSymbol->setAnimationSettings( mAnimationSettings );
|
||||
cloneSymbol->copyCommonProperties( this );
|
||||
return cloneSymbol;
|
||||
}
|
||||
|
||||
@ -170,5 +162,3 @@ void QgsFillSymbol::setAngle( double angle ) const
|
||||
fillLayer->setAngle( angle );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,14 +303,6 @@ void QgsLineSymbol::renderPolylineUsingLayer( QgsLineSymbolLayer *layer, const Q
|
||||
QgsLineSymbol *QgsLineSymbol::clone() const
|
||||
{
|
||||
QgsLineSymbol *cloneSymbol = new QgsLineSymbol( cloneLayers() );
|
||||
cloneSymbol->setOpacity( mOpacity );
|
||||
Q_NOWARN_DEPRECATED_PUSH
|
||||
cloneSymbol->setLayer( mLayer );
|
||||
Q_NOWARN_DEPRECATED_POP
|
||||
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
|
||||
cloneSymbol->setForceRHR( mForceRHR );
|
||||
cloneSymbol->setDataDefinedProperties( dataDefinedProperties() );
|
||||
cloneSymbol->setFlags( mSymbolFlags );
|
||||
cloneSymbol->setAnimationSettings( mAnimationSettings );
|
||||
cloneSymbol->copyCommonProperties( this );
|
||||
return cloneSymbol;
|
||||
}
|
||||
|
@ -523,14 +523,6 @@ QRectF QgsMarkerSymbol::bounds( QPointF point, QgsRenderContext &context, const
|
||||
QgsMarkerSymbol *QgsMarkerSymbol::clone() const
|
||||
{
|
||||
QgsMarkerSymbol *cloneSymbol = new QgsMarkerSymbol( cloneLayers() );
|
||||
cloneSymbol->setOpacity( mOpacity );
|
||||
Q_NOWARN_DEPRECATED_PUSH
|
||||
cloneSymbol->setLayer( mLayer );
|
||||
Q_NOWARN_DEPRECATED_POP
|
||||
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
|
||||
cloneSymbol->setForceRHR( mForceRHR );
|
||||
cloneSymbol->setDataDefinedProperties( dataDefinedProperties() );
|
||||
cloneSymbol->setFlags( mSymbolFlags );
|
||||
cloneSymbol->setAnimationSettings( mAnimationSettings );
|
||||
cloneSymbol->copyCommonProperties( this );
|
||||
return cloneSymbol;
|
||||
}
|
||||
|
@ -1972,3 +1972,17 @@ void QgsSymbol::stopFeatureRender( const QgsFeature &feature, QgsRenderContext &
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSymbol::copyCommonProperties( const QgsSymbol *other )
|
||||
{
|
||||
mOpacity = other->mOpacity;
|
||||
mClipFeaturesToExtent = other->mClipFeaturesToExtent;
|
||||
mForceRHR = other->mForceRHR;
|
||||
mDataDefinedProperties = other->mDataDefinedProperties;
|
||||
mSymbolFlags = other->mSymbolFlags;
|
||||
mAnimationSettings = other->mAnimationSettings;
|
||||
|
||||
Q_NOWARN_DEPRECATED_PUSH
|
||||
mLayer = other->mLayer;
|
||||
Q_NOWARN_DEPRECATED_POP
|
||||
}
|
||||
|
@ -759,6 +759,13 @@ class CORE_EXPORT QgsSymbol
|
||||
*/
|
||||
QgsSymbolLayerList cloneLayers() const SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Copies common properties from an \a other symbol to this symbol.
|
||||
*
|
||||
* \since QGIS 3.40
|
||||
*/
|
||||
void copyCommonProperties( const QgsSymbol *other );
|
||||
|
||||
/**
|
||||
* Renders a context using a particular symbol layer without passing in a
|
||||
* geometry. This is used as fallback, if the symbol being rendered is not
|
||||
|
Loading…
x
Reference in New Issue
Block a user