Skip to content

Commit 1a1dde1

Browse files
committed
Fix calculation of ruler y-coordinates
1 parent 7e03e56 commit 1a1dde1

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/gui/qgscomposerruler.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ void QgsComposerRuler::paintEvent( QPaintEvent* event )
2727

2828
if ( mDirection == Horizontal )
2929
{
30-
if( doubleNear( width(), 0 ) )
31-
{
32-
return;
33-
}
30+
if ( doubleNear( width(), 0 ) )
31+
{
32+
return;
33+
}
3434

3535
//start x-coordinate
3636
double startX = t.map( QPointF( 0, 0 ) ).x();
@@ -43,7 +43,7 @@ void QgsComposerRuler::paintEvent( QPaintEvent* event )
4343
{
4444
double pixelCoord = mTransform.map( QPointF( markerPos, 0 ) ).x();
4545
p.drawLine( pixelCoord, 0, pixelCoord, RULER_MIN_SIZE );
46-
p.drawText( QPointF( pixelCoord + 2, RULER_MIN_SIZE / 2.0 ), QString::number( (int)( markerPos ) ) );
46+
p.drawText( QPointF( pixelCoord + 2, RULER_MIN_SIZE / 2.0 ), QString::number(( int )( markerPos ) ) );
4747
}
4848
markerPos += 10.0;
4949
}
@@ -53,25 +53,25 @@ void QgsComposerRuler::paintEvent( QPaintEvent* event )
5353
}
5454
else //vertical
5555
{
56-
if( doubleNear( height(), 0 ) )
57-
{
58-
return;
59-
}
56+
if ( doubleNear( height(), 0 ) )
57+
{
58+
return;
59+
}
6060

61-
double startY = t.map( QPointF( 0, 0 ) ).y();
62-
double endY = t.map( QPointF( 0, height() ) ).y();
61+
double startY = t.map( QPointF( 0, 0 ) ).y();
62+
double endY = t.map( QPointF( 0, height() ) ).y();
6363

64-
double markerPos = ( floor( startY / 10.0 ) + 1 ) + 10.0; //marker position in mm
65-
while( markerPos <= endY )
64+
double markerPos = ( floor( startY / 10.0 ) + 1 ) * 10.0; //marker position in mm
65+
while ( markerPos <= endY )
66+
{
67+
if ( markerPos >= 0 && markerPos <= 210 )
6668
{
67-
if( markerPos >= 0 && markerPos <= 210 )
68-
{
69-
double pixelCoord = mTransform.map( QPointF( 0, markerPos ) ).y();
70-
p.drawLine( 0, pixelCoord, RULER_MIN_SIZE, pixelCoord );
71-
p.drawText( QPointF( RULER_MIN_SIZE / 2.0, pixelCoord + 2.0 ), QString::number( markerPos ) );
72-
}
73-
markerPos += 10.0;
69+
double pixelCoord = mTransform.map( QPointF( 0, markerPos ) ).y();
70+
p.drawLine( 0, pixelCoord, RULER_MIN_SIZE, pixelCoord );
71+
p.drawText( QPointF( RULER_MIN_SIZE / 2.0, pixelCoord + 2.0 ), QString::number( markerPos ) );
7472
}
73+
markerPos += 10.0;
74+
}
7575
}
7676
}
7777

0 commit comments

Comments
 (0)