Skip to content
Permalink
Browse files

[composer] Correct placement of cross grids (fix #10626)

  • Loading branch information
nyalldawson committed Jun 18, 2014
1 parent b5b864e commit 7af7b88c990b1ec6fed9e3de58f2c4e3bdfa305e
@@ -1480,7 +1480,7 @@ void QgsComposerMap::drawGrid( QPainter* p )
{
//start mark
crossEnd1 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( vIt->second.p1(), vIt->second.p2(), mCrossLength );
drawGridLine( QLineF( vIt->second.p1(), crossEnd1 ), context );
drawGridLine( QLineF( vIt->second.p1() * dotsPerMM, crossEnd1 * dotsPerMM ), context );

//test for intersection with every horizontal line
hIt = horizontalLines.constBegin();
@@ -1490,20 +1490,20 @@ void QgsComposerMap::drawGrid( QPainter* p )
{
crossEnd1 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( intersectionPoint, vIt->second.p1(), mCrossLength );
crossEnd2 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( intersectionPoint, vIt->second.p2(), mCrossLength );
drawGridLine( QLineF( crossEnd1, crossEnd2 ), context );
drawGridLine( QLineF( crossEnd1 * dotsPerMM, crossEnd2 * dotsPerMM ), context );
}
}
//end mark
QPointF crossEnd2 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( vIt->second.p2(), vIt->second.p1(), mCrossLength );
drawGridLine( QLineF( vIt->second.p2(), crossEnd2 ), context );
drawGridLine( QLineF( vIt->second.p2() * dotsPerMM, crossEnd2 * dotsPerMM ), context );
}

hIt = horizontalLines.constBegin();
for ( ; hIt != horizontalLines.constEnd(); ++hIt )
{
//start mark
crossEnd1 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( hIt->second.p1(), hIt->second.p2(), mCrossLength );
drawGridLine( QLineF( hIt->second.p1(), crossEnd1 ), context );
drawGridLine( QLineF( hIt->second.p1() * dotsPerMM, crossEnd1 * dotsPerMM ), context );

vIt = verticalLines.constBegin();
for ( ; vIt != verticalLines.constEnd(); ++vIt )
@@ -1512,12 +1512,12 @@ void QgsComposerMap::drawGrid( QPainter* p )
{
crossEnd1 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( intersectionPoint, hIt->second.p1(), mCrossLength );
crossEnd2 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( intersectionPoint, hIt->second.p2(), mCrossLength );
drawGridLine( QLineF( crossEnd1, crossEnd2 ), context );
drawGridLine( QLineF( crossEnd1 * dotsPerMM, crossEnd2 * dotsPerMM ), context );
}
}
//end mark
crossEnd1 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( hIt->second.p2(), hIt->second.p1(), mCrossLength );
drawGridLine( QLineF( hIt->second.p2(), crossEnd1 ), context );
drawGridLine( QLineF( hIt->second.p2() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
}
}
// reset composition mode
@@ -37,6 +37,7 @@ class TestQgsComposerMap: public QObject
void cleanup();// will be called after every testfunction.
void render(); //test if rendering of the composition with composr map is correct
void grid(); //test if grid and grid annotation works
void crossGrid(); //test if grid "cross" mode works
void overviewMap(); //test if overview map frame works
void overviewMapBlending(); //test if blend modes with overview map frame works
void overviewMapInvert(); //test if invert of overview map frame works
@@ -139,6 +140,26 @@ void TestQgsComposerMap::grid()
QVERIFY( testResult );
}

void TestQgsComposerMap::crossGrid()
{
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
mComposerMap->setGridEnabled( true );
mComposerMap->setGridStyle( QgsComposerMap::Cross );
mComposerMap->setCrossLength( 2.0 );
mComposerMap->setGridIntervalX( 2000 );
mComposerMap->setGridIntervalY( 2000 );
mComposerMap->setShowGridAnnotation( false );
mComposerMap->setGridPenWidth( 0.5 );
mComposerMap->setGridPenColor( QColor( 0, 255, 0 ) );
mComposerMap->setGridBlendMode( QPainter::CompositionMode_SourceOver );
QgsCompositionChecker checker( "composermap_crossgrid", mComposition );

bool testResult = checker.testComposition( mReport, 0, 100 );
mComposerMap->setGridEnabled( false );
mComposerMap->setShowGridAnnotation( false );
QVERIFY( testResult );
}

void TestQgsComposerMap::overviewMap()
{
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
Binary file not shown.

0 comments on commit 7af7b88

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