Skip to content

Commit

Permalink
restrictedSymbolSizeOK must be false only with geometrygenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and nyalldawson committed May 25, 2023
1 parent 453abdd commit 0be08cd
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions src/core/symbology/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5045,49 +5045,36 @@ QgsSymbol *QgsSymbolLayerUtils::restrictedSizeSymbol( const QgsSymbol *s, double
if ( ok )
*ok = true;

double size;
const QgsMarkerSymbol *markerSymbol = dynamic_cast<const QgsMarkerSymbol *>( s );
const QgsLineSymbol *lineSymbol = dynamic_cast<const QgsLineSymbol *>( s );
if ( markerSymbol )
const QgsSymbolLayerList sls = s->symbolLayers();
for ( const QgsSymbolLayer *sl : std::as_const( sls ) )
{
const QgsSymbolLayerList sls = s->symbolLayers();
for ( const QgsSymbolLayer *sl : std::as_const( sls ) )
// geometry generators involved, there is no way to get a restricted size symbol
if ( sl->type() == Qgis::SymbolType::Hybrid )
{
// geometry generators involved, there is no way to get a restricted size symbol
if ( sl->type() != Qgis::SymbolType::Marker )
{
if ( ok )
*ok = false;
if ( ok )
*ok = false;

return nullptr;
}
return nullptr;
}
}

double size;
const QgsMarkerSymbol *markerSymbol = dynamic_cast<const QgsMarkerSymbol *>( s );
const QgsLineSymbol *lineSymbol = dynamic_cast<const QgsLineSymbol *>( s );
if ( markerSymbol )
{
size = markerSymbol->size( *context );
}
else if ( lineSymbol )
{
const QgsSymbolLayerList sls = s->symbolLayers();
for ( const QgsSymbolLayer *sl : std::as_const( sls ) )
{
// geometry generators involved, there is no way to get a restricted size symbol
if ( sl->type() != Qgis::SymbolType::Line )
{
if ( ok )
*ok = false;

return nullptr;
}
}

size = lineSymbol->width( *context );
}
else
{
if ( ok )
*ok = false;

return nullptr; //not size restriction implemented for other symbol types
// cannot return a size restricted symbol but we assume there is no need
// for one as the rendering will be done in the given size (different from geometry
// generator where rendering will bleed outside the given area
return nullptr;
}

size /= context->scaleFactor();
Expand Down

0 comments on commit 0be08cd

Please sign in to comment.