Skip to content

Commit

Permalink
Correctly handle offset when calculating symbol bleed
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 30, 2017
1 parent 219a45a commit 7594774
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/core/symbology-ng/qgsfillsymbollayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ QgsSymbolLayer* QgsSimpleFillSymbolLayer::createFromSld( QDomElement &element )
double QgsSimpleFillSymbolLayer::estimateMaxBleed( const QgsRenderContext& context ) const
{
double penBleed = context.convertToPainterUnits( mBorderStyle == Qt::NoPen ? 0 : ( mBorderWidth / 2.0 ), mBorderWidthUnit, mBorderWidthMapUnitScale );
double offsetBleed = context.convertToPainterUnits( mOffset.x() > mOffset.y() ? mOffset.x() : mOffset.y(), mOffsetUnit, mOffsetMapUnitScale );
double offsetBleed = context.convertToPainterUnits( qMax( qAbs( mOffset.x() ), qAbs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
return penBleed + offsetBleed;
}

Expand Down Expand Up @@ -909,7 +909,7 @@ QgsGradientFillSymbolLayer* QgsGradientFillSymbolLayer::clone() const

double QgsGradientFillSymbolLayer::estimateMaxBleed( const QgsRenderContext& context ) const
{
double offsetBleed = context.convertToPainterUnits( mOffset.x() > mOffset.y() ? mOffset.x() : mOffset.y(), mOffsetUnit, mOffsetMapUnitScale );
double offsetBleed = context.convertToPainterUnits( qMax( qAbs( mOffset.x() ), qAbs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
return offsetBleed;
}

Expand Down Expand Up @@ -1504,7 +1504,7 @@ QgsShapeburstFillSymbolLayer* QgsShapeburstFillSymbolLayer::clone() const

double QgsShapeburstFillSymbolLayer::estimateMaxBleed( const QgsRenderContext& context ) const
{
double offsetBleed = context.convertToPainterUnits( qMax( mOffset.x(), mOffset.y() ), mOffsetUnit, mOffsetMapUnitScale );
double offsetBleed = context.convertToPainterUnits( qMax( qAbs( mOffset.x() ), qAbs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
return offsetBleed;
}

Expand Down Expand Up @@ -3727,7 +3727,7 @@ QgsRasterFillSymbolLayer* QgsRasterFillSymbolLayer::clone() const

double QgsRasterFillSymbolLayer::estimateMaxBleed( const QgsRenderContext& context ) const
{
return context.convertToPainterUnits( mOffset.x() > mOffset.y() ? mOffset.x() : mOffset.y(), mOffsetUnit, mOffsetMapUnitScale );
return context.convertToPainterUnits( qMax( qAbs( mOffset.x() ), qAbs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
}

void QgsRasterFillSymbolLayer::setImageFilePath( const QString &imagePath )
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgslinesymbollayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ double QgsSimpleLineSymbolLayer::estimateMaxBleed( const QgsRenderContext& conte
else
{
return context.convertToPainterUnits(( mWidth / 2.0 ), mWidthUnit, mWidthMapUnitScale ) +
context.convertToPainterUnits( mOffset, mOffsetUnit, mOffsetMapUnitScale );
context.convertToPainterUnits( qAbs( mOffset ), mOffsetUnit, mOffsetMapUnitScale );
}
}

Expand Down Expand Up @@ -1597,7 +1597,7 @@ QSet<QString> QgsMarkerLineSymbolLayer::usedAttributes( const QgsRenderContext&
double QgsMarkerLineSymbolLayer::estimateMaxBleed( const QgsRenderContext& context ) const
{
return context.convertToPainterUnits(( mMarker->size() / 2.0 ), mMarker->sizeUnit(), mMarker->sizeMapUnitScale() ) +
context.convertToPainterUnits( mOffset, mOffsetUnit, mOffsetMapUnitScale );
context.convertToPainterUnits( qAbs( mOffset ), mOffsetUnit, mOffsetMapUnitScale );
}


Expand Down

0 comments on commit 7594774

Please sign in to comment.