Skip to content
Permalink
Browse files

Fix line pattern fill offsets are always treated as positive,

even when offset is negative

(cherry picked from commit 5b4ed16)
  • Loading branch information
nyalldawson committed Oct 12, 2018
1 parent 4f76722 commit 34f2e959dac40875b0166ac37600068eb54b8655
@@ -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 );
}

@@ -60,6 +60,8 @@ class TestQgsLineFillSymbol : public QObject
void cleanup() {} // will be called after every testfunction.

void lineFillSymbol();
void lineFillSymbolOffset();

void dataDefinedSubSymbol();

private:
@@ -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";
Binary file not shown.
Binary file not shown.

0 comments on commit 34f2e95

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