Skip to content
Permalink
Browse files
Retain more renderer properties when switching between vector
renderer types
  • Loading branch information
nyalldawson committed Jun 28, 2021
1 parent ed75524 commit 0565c3ffb8e815a80f30a31d0244944f1b03ee77
@@ -538,6 +538,17 @@ Returns ``True`` if the visitor should continue visiting other objects, or ``Fal
should be canceled.

.. versionadded:: 3.10
%End

void copyRendererData( QgsFeatureRenderer *destRenderer ) const;
%Docstring
Clones generic renderer data to another renderer.
Currently clones

- Order By
- Paint Effect

:param destRenderer: destination renderer for copied effect
%End

protected:
@@ -568,17 +579,6 @@ render editing vertex marker for a polygon
%Docstring
Creates a point in screen coordinates from a wkb string in map
coordinates
%End

void copyRendererData( QgsFeatureRenderer *destRenderer ) const;
%Docstring
Clones generic renderer data to another renderer.
Currently clones

- Order By
- Paint Effect

:param destRenderer: destination renderer for copied effect
%End

void saveRendererData( QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context );
@@ -279,7 +279,9 @@ Qgs25DRenderer *Qgs25DRenderer::convertFromRenderer( QgsFeatureRenderer *rendere
}
else
{
return new Qgs25DRenderer();
std::unique_ptr< Qgs25DRenderer > res = std::make_unique< Qgs25DRenderer >();
renderer->copyRendererData( res.get() );
return res.release();
}
}

@@ -1107,8 +1107,7 @@ QgsCategorizedSymbolRenderer *QgsCategorizedSymbolRenderer::convertFromRenderer(
}
}

r->setOrderBy( renderer->orderBy() );
r->setOrderByEnabled( renderer->orderByEnabled() );
renderer->copyRendererData( r.get() );

return r.release();
}
@@ -125,6 +125,7 @@ QgsEmbeddedSymbolRenderer *QgsEmbeddedSymbolRenderer::convertFromRenderer( const
else if ( renderer->type() == QLatin1String( "singleSymbol" ) )
{
std::unique_ptr< QgsEmbeddedSymbolRenderer > symbolRenderer = std::make_unique< QgsEmbeddedSymbolRenderer >( static_cast< const QgsSingleSymbolRenderer * >( renderer )->symbol()->clone() );
renderer->copyRendererData( symbolRenderer.get() );
return symbolRenderer.release();
}
else
@@ -1278,8 +1278,7 @@ QgsGraduatedSymbolRenderer *QgsGraduatedSymbolRenderer::convertFromRenderer( con
}
}

r->setOrderBy( renderer->orderBy() );
r->setOrderByEnabled( renderer->orderByEnabled() );
renderer->copyRendererData( r.get() );

return r.release();
}
@@ -383,7 +383,9 @@ QgsHeatmapRenderer *QgsHeatmapRenderer::convertFromRenderer( const QgsFeatureRen
}
else
{
return new QgsHeatmapRenderer();
std::unique_ptr< QgsHeatmapRenderer > res = std::make_unique< QgsHeatmapRenderer >();
renderer->copyRendererData( res.get() );
return res.release();
}
}

@@ -109,11 +109,15 @@ QgsInvertedPolygonRenderer *QgsInvertedPolygonRenderer::convertFromRenderer( con
renderer->type() == QLatin1String( "graduatedSymbol" ) ||
renderer->type() == QLatin1String( "RuleRenderer" ) )
{
return new QgsInvertedPolygonRenderer( renderer->clone() );
std::unique_ptr< QgsInvertedPolygonRenderer > res = std::make_unique< QgsInvertedPolygonRenderer >( renderer->clone() );
renderer->copyRendererData( res.get() );
return res.release();
}
else if ( renderer->type() == QLatin1String( "mergedFeatureRenderer" ) )
{
return new QgsInvertedPolygonRenderer( renderer->embeddedRenderer() ? renderer->embeddedRenderer()->clone() : nullptr );
std::unique_ptr< QgsInvertedPolygonRenderer > res = std::make_unique< QgsInvertedPolygonRenderer >( renderer->embeddedRenderer() ? renderer->embeddedRenderer()->clone() : nullptr );
renderer->copyRendererData( res.get() );
return res.release();
}
return nullptr;
}
@@ -555,11 +555,15 @@ QgsMergedFeatureRenderer *QgsMergedFeatureRenderer::convertFromRenderer( const Q
renderer->type() == QLatin1String( "graduatedSymbol" ) ||
renderer->type() == QLatin1String( "RuleRenderer" ) )
{
return new QgsMergedFeatureRenderer( renderer->clone() );
std::unique_ptr< QgsMergedFeatureRenderer > res = std::make_unique< QgsMergedFeatureRenderer >( renderer->clone() );
renderer->copyRendererData( res.get() );
return res.release();
}
else if ( renderer->type() == QLatin1String( "invertedPolygonRenderer" ) )
{
return new QgsMergedFeatureRenderer( renderer->embeddedRenderer() ? renderer->embeddedRenderer()->clone() : nullptr );
std::unique_ptr< QgsMergedFeatureRenderer > res = std::make_unique< QgsMergedFeatureRenderer >( renderer->embeddedRenderer() ? renderer->embeddedRenderer()->clone() : nullptr );
renderer->copyRendererData( res.get() );
return res.release();
}
return nullptr;
}
@@ -120,6 +120,7 @@ QDomElement QgsNullSymbolRenderer::save( QDomDocument &doc, const QgsReadWriteCo

QgsNullSymbolRenderer *QgsNullSymbolRenderer::convertFromRenderer( const QgsFeatureRenderer *renderer )
{
Q_UNUSED( renderer )
return new QgsNullSymbolRenderer();
std::unique_ptr< QgsNullSymbolRenderer > res = std::make_unique< QgsNullSymbolRenderer >();
renderer->copyRendererData( res.get() );
return res.release();
}
@@ -189,6 +189,7 @@ QgsPointClusterRenderer *QgsPointClusterRenderer::convertFromRenderer( const Qgs
{
QgsPointClusterRenderer *pointRenderer = new QgsPointClusterRenderer();
pointRenderer->setEmbeddedRenderer( renderer->clone() );
renderer->copyRendererData( pointRenderer );
return pointRenderer;
}
else if ( renderer->type() == QLatin1String( "pointDisplacement" ) )
@@ -202,6 +203,7 @@ QgsPointClusterRenderer *QgsPointClusterRenderer::convertFromRenderer( const Qgs
pointRenderer->setToleranceMapUnitScale( displacementRenderer->toleranceMapUnitScale() );
if ( const_cast< QgsPointDisplacementRenderer * >( displacementRenderer )->centerSymbol() )
pointRenderer->setClusterSymbol( const_cast< QgsPointDisplacementRenderer * >( displacementRenderer )->centerSymbol()->clone() );
renderer->copyRendererData( pointRenderer );
return pointRenderer;
}
else
@@ -476,6 +476,7 @@ QgsPointDisplacementRenderer *QgsPointDisplacementRenderer::convertFromRenderer(
{
QgsPointDisplacementRenderer *pointRenderer = new QgsPointDisplacementRenderer();
pointRenderer->setEmbeddedRenderer( renderer->clone() );
renderer->copyRendererData( pointRenderer );
return pointRenderer;
}
else if ( renderer->type() == QLatin1String( "pointCluster" ) )
@@ -489,6 +490,7 @@ QgsPointDisplacementRenderer *QgsPointDisplacementRenderer::convertFromRenderer(
pointRenderer->setToleranceMapUnitScale( clusterRenderer->toleranceMapUnitScale() );
if ( const_cast< QgsPointClusterRenderer * >( clusterRenderer )->clusterSymbol() )
pointRenderer->setCenterSymbol( const_cast< QgsPointClusterRenderer * >( clusterRenderer )->clusterSymbol()->clone() );
renderer->copyRendererData( pointRenderer );
return pointRenderer;
}
else
@@ -527,6 +527,17 @@ class CORE_EXPORT QgsFeatureRenderer
*/
virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;

/**
* Clones generic renderer data to another renderer.
* Currently clones
*
* - Order By
* - Paint Effect
*
* \param destRenderer destination renderer for copied effect
*/
void copyRendererData( QgsFeatureRenderer *destRenderer ) const;

protected:
QgsFeatureRenderer( const QString &type );

@@ -551,17 +562,6 @@ class CORE_EXPORT QgsFeatureRenderer
*/
static QPointF _getPoint( QgsRenderContext &context, const QgsPoint &point );

/**
* Clones generic renderer data to another renderer.
* Currently clones
*
* - Order By
* - Paint Effect
*
* \param destRenderer destination renderer for copied effect
*/
void copyRendererData( QgsFeatureRenderer *destRenderer ) const;

/**
* Saves generic renderer data into the specified \a element.
*
@@ -1510,8 +1510,7 @@ QgsRuleBasedRenderer *QgsRuleBasedRenderer::convertFromRenderer( const QgsFeatur

if ( r )
{
r->setOrderBy( renderer->orderBy() );
r->setOrderByEnabled( renderer->orderByEnabled() );
renderer->copyRendererData( r.get() );
}

return r.release();
@@ -365,8 +365,7 @@ QgsSingleSymbolRenderer *QgsSingleSymbolRenderer::convertFromRenderer( const Qgs

if ( r )
{
r->setOrderBy( renderer->orderBy() );
r->setOrderByEnabled( renderer->orderByEnabled() );
renderer->copyRendererData( r );
}

return r;

0 comments on commit 0565c3f

Please sign in to comment.