Skip to content

Commit

Permalink
Fix line pattern fill offsets are always treated as positive,
Browse files Browse the repository at this point in the history
even when offset is negative

(cherry picked from commit 5b4ed16)
  • Loading branch information
nyalldawson committed Oct 15, 2018
1 parent 4f76722 commit 34f2e95
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsfillsymbollayerv2.cpp
Expand Up @@ -2650,7 +2650,7 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolV2RenderContext

// Round offset to correspond to one pixel height, otherwise lines may
// be shifted on tile border if offset falls close to pixel center
int offsetHeight = qRound( qAbs( outputPixelOffset / cos( lineAngle * M_PI / 180 ) ) );
int offsetHeight = qRound( outputPixelOffset / cos( lineAngle * M_PI / 180 ) );
outputPixelOffset = offsetHeight * cos( lineAngle * M_PI / 180 );
}

Expand Down
14 changes: 14 additions & 0 deletions tests/src/core/testqgslinefillsymbol.cpp
Expand Up @@ -60,6 +60,8 @@ class TestQgsLineFillSymbol : public QObject
void cleanup() {} // will be called after every testfunction.

void lineFillSymbol();
void lineFillSymbolOffset();

void dataDefinedSubSymbol();

private:
Expand Down Expand Up @@ -147,6 +149,18 @@ void TestQgsLineFillSymbol::lineFillSymbol()
QVERIFY( imageCheck( "symbol_linefill" ) );
}

void TestQgsLineFillSymbol::lineFillSymbolOffset()
{
mReport += QLatin1String( "<h2>Line fill symbol renderer test</h2>\n" );

mLineFill->setOffset( 0.5 );
QVERIFY( imageCheck( "symbol_linefill_posoffset" ) );

mLineFill->setOffset( -0.5 );
QVERIFY( imageCheck( "symbol_linefill_negoffset" ) );
mLineFill->setOffset( 0 );
}

void TestQgsLineFillSymbol::dataDefinedSubSymbol()
{
mReport += "<h2>Line fill symbol data defined sub symbol test</h2>\n";
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 34f2e95

Please sign in to comment.