Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix simple and ellipse marker bound calculation ignores stroke width
  • Loading branch information
nyalldawson committed Apr 4, 2020
1 parent 4cdeafe commit 596dbdb
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/core/symbology/qgsellipsesymbollayer.cpp
Expand Up @@ -674,7 +674,7 @@ QRectF QgsEllipseSymbolLayer::bounds( QPointF point, QgsSymbolRenderContext &con
if ( !qgsDoubleNear( angle, 0.0 ) )
transform.rotate( angle );

double penWidth = 0.0;
double penWidth = mStrokeWidth;
if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyStrokeWidth ) )
{
context.setOriginalValueVariable( mStrokeWidth );
Expand All @@ -686,10 +686,12 @@ QRectF QgsEllipseSymbolLayer::bounds( QPointF point, QgsSymbolRenderContext &con
double strokeWidth = exprVal.toDouble( &ok );
if ( ok )
{
penWidth = context.renderContext().convertToPainterUnits( strokeWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale );
penWidth = strokeWidth;
}
}
}
penWidth = context.renderContext().convertToPainterUnits( penWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale );

if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyStrokeStyle ) )
{
context.setOriginalValueVariable( QgsSymbolLayerUtils::encodePenStyle( mStrokeStyle ) );
Expand All @@ -699,6 +701,8 @@ QRectF QgsEllipseSymbolLayer::bounds( QPointF point, QgsSymbolRenderContext &con
penWidth = 0.0;
}
}
else if ( mStrokeStyle == Qt::NoPen )
penWidth = 0;

//antialiasing, add 1 pixel
penWidth += 1;
Expand Down
8 changes: 6 additions & 2 deletions src/core/symbology/qgsmarkersymbollayer.cpp
Expand Up @@ -1459,17 +1459,18 @@ QRectF QgsSimpleMarkerSymbolLayer::bounds( QPointF point, QgsSymbolRenderContext
QRectF symbolBounds = QgsSimpleMarkerSymbolLayerBase::bounds( point, context );

// need to account for stroke width
double penWidth = 0.0;
double penWidth = mStrokeWidth;
bool ok = true;
if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyStrokeWidth ) )
{
context.setOriginalValueVariable( mStrokeWidth );
double strokeWidth = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyStrokeWidth, context.renderContext().expressionContext(), mStrokeWidth, &ok );
if ( ok )
{
penWidth = context.renderContext().convertToPainterUnits( strokeWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale );
penWidth = strokeWidth;
}
}
penWidth = context.renderContext().convertToPainterUnits( penWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale );
if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyStrokeStyle ) )
{
context.setOriginalValueVariable( QgsSymbolLayerUtils::encodePenStyle( mStrokeStyle ) );
Expand All @@ -1479,6 +1480,9 @@ QRectF QgsSimpleMarkerSymbolLayer::bounds( QPointF point, QgsSymbolRenderContext
penWidth = 0.0;
}
}
else if ( mStrokeStyle == Qt::NoPen )
penWidth = 0;

//antialiasing, add 1 pixel
penWidth += 1;

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit 596dbdb

Please sign in to comment.