Skip to content
Permalink
Browse files

Fix distorted line pattern fill when line offset is large compared

with pattern distance

(cherry picked from commit e277b91)
  • Loading branch information
nyalldawson committed Oct 15, 2018
1 parent 34f2e95 commit 968948a73eb4f4f8f0063bc8385dae77252c8ae7
Showing with 21 additions and 0 deletions.
  1. +9 −0 src/core/symbology-ng/qgsfillsymbollayerv2.cpp
  2. +12 −0 tests/src/core/testqgslinefillsymbol.cpp
@@ -2569,6 +2569,15 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolV2RenderContext
double outputPixelDist = distance * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( ctx, mDistanceUnit, mDistanceMapUnitScale );
double outputPixelOffset = mOffset * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( ctx, mOffsetUnit, mOffsetMapUnitScale );

// NOTE: this may need to be modified if we ever change from a forced rasterized/brush approach,
// because potentially we may want to allow vector based line pattern fills where the first line
// is offset by a large distance

// fix truncated pattern with larger offsets
outputPixelOffset = fmod( outputPixelOffset, outputPixelDist );
if ( outputPixelOffset > outputPixelDist / 2.0 )
outputPixelOffset -= outputPixelDist;

// To get all patterns into image, we have to consider symbols size (estimateMaxBleed()).
// For marker lines we have to get markers interval.
double outputPixelBleed = 0;
@@ -61,6 +61,7 @@ class TestQgsLineFillSymbol : public QObject

void lineFillSymbol();
void lineFillSymbolOffset();
void lineFillLargeOffset();

void dataDefinedSubSymbol();

@@ -161,6 +162,17 @@ void TestQgsLineFillSymbol::lineFillSymbolOffset()
mLineFill->setOffset( 0 );
}

void TestQgsLineFillSymbol::lineFillLargeOffset()
{
// test line fill with large offset compared to line distance
mLineFill->setOffset( 8 );
QVERIFY( imageCheck( "symbol_linefill_large_posoffset" ) );

mLineFill->setOffset( -8 );
QVERIFY( imageCheck( "symbol_linefill_large_negoffset" ) );
mLineFill->setOffset( 0 );
}

void TestQgsLineFillSymbol::dataDefinedSubSymbol()
{
mReport += "<h2>Line fill symbol data defined sub symbol test</h2>\n";

0 comments on commit 968948a

Please sign in to comment.
You can’t perform that action at this time.