Skip to content

Commit 88bc309

Browse files
committedAug 29, 2012
use qRound() fro round() (followup ad437bf)
1 parent b3a6172 commit 88bc309

File tree

7 files changed

+9
-32
lines changed

7 files changed

+9
-32
lines changed
 

‎src/app/qgsdecorationgrid.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
#include <cmath>
5252

5353

54-
#ifdef _MSC_VER
55-
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
56-
#endif
57-
5854
#define FONT_WORKAROUND_SCALE 10 //scale factor for upscaling fontsize and downscaling painter
5955

6056

@@ -808,7 +804,7 @@ bool QgsDecorationGrid::getIntervalFromExtent( double* values, bool useXAxis )
808804
int factor = pow( 10, floor( log10( interval ) ) );
809805
if ( factor != 0 )
810806
{
811-
interval2 = round( interval / factor ) * factor;
807+
interval2 = qRound( interval / factor ) * factor;
812808
QgsDebugMsg( QString( "interval2: %1" ).arg( interval2 ) );
813809
if ( interval2 != 0 )
814810
interval = interval2;

‎src/app/qgsdecorationnortharrow.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ email : tim@linfiniti.com
4343
#include <cassert>
4444

4545

46-
#ifdef _MSC_VER
47-
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
48-
#endif
49-
5046
const double QgsDecorationNorthArrow::PI = 3.14159265358979323846;
5147
// const double QgsNorthArrowPlugin::DEG2RAD = 0.0174532925199433;
5248
const double QgsDecorationNorthArrow::TOL = 1e-8;
@@ -298,7 +294,7 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
298294
}
299295
// And set the angle of the north arrow. Perhaps do something
300296
// different if goodDirn = false.
301-
mRotationInt = static_cast<int>( round( fmod( 360.0 - angle * 180.0 / PI, 360.0 ) ) );
297+
mRotationInt = qRound( fmod( 360.0 - angle * 180.0 / PI, 360.0 ) );
302298
}
303299
else
304300
{

‎src/app/qgsdecorationscalebar.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ email : sbr00pwb@users.sourceforge.net
4848
#include <cmath>
4949

5050

51-
#ifdef _MSC_VER
52-
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
53-
#endif
54-
55-
5651
QgsDecorationScaleBar::QgsDecorationScaleBar( QObject* parent )
5752
: QgsDecorationItem( parent )
5853
{
@@ -164,7 +159,7 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
164159
if ( mSnapping )
165160
{
166161
double scaler = pow( 10.0, myPowerOf10 );
167-
myActualSize = round( myActualSize / scaler ) * scaler;
162+
myActualSize = qRound( myActualSize / scaler ) * scaler;
168163
myScaleBarWidth = myActualSize / myMapUnitsPerPixelDouble;
169164
}
170165

‎src/core/composer/qgscomposition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ int QgsComposition::pixelFontSize( double pointSize ) const
214214
{
215215
//in QgsComposition, one unit = one mm
216216
double sizeMillimeters = pointSize * 0.3527;
217-
return ( sizeMillimeters + 0.5 ); //round to nearest mm
217+
return qRound( sizeMillimeters ); //round to nearest mm
218218
}
219219

220220
double QgsComposition::pointFontSize( int pixelSize ) const

‎src/gui/qgsmaptool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ QPoint QgsMapTool::toCanvasCoordinates( const QgsPoint& point )
6464
{
6565
double x = point.x(), y = point.y();
6666
mCanvas->getCoordinateTransform()->transformInPlace( x, y );
67-
return QPoint(( int )( x + 0.5 ), ( int )( y + 0.5 ) ); // round the values
67+
return QPoint( qRound( x ), qRound( y ) );
6868
}
6969

7070

‎src/gui/qgsquickprint.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050
//other includes
5151
#include <cmath>
5252

53-
#ifdef _MSC_VER
54-
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
55-
#endif
56-
5753
QgsQuickPrint::QgsQuickPrint()
5854
{
5955
mPageSize = QPrinter::A4;
@@ -813,7 +809,7 @@ void QgsQuickPrint::renderPrintScaleBar( QPainter * thepPainter,
813809
if ( mySnappingFlag )
814810
{
815811
double scaler = pow( 10.0, myPowerOf10 );
816-
myActualSize = round( myActualSize / scaler ) * scaler;
812+
myActualSize = qRound( myActualSize / scaler ) * scaler;
817813
myScaleBarWidth = myActualSize / myMapUnitsPerPixelDouble;
818814
}
819815

‎src/plugins/grass/qgsgrassedit.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ extern "C"
5050
#include <grass/Vect.h>
5151
}
5252

53-
#ifdef _MSC_VER
54-
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
55-
#endif
56-
57-
5853
class QgsGrassEditLayer : public QgsMapCanvasItem
5954
{
6055
public:
@@ -1718,8 +1713,7 @@ void QgsGrassEdit::displayElement( int line, const QPen & pen, int size, QPainte
17181713
point.setX( mPoints->x[i] );
17191714
point.setY( mPoints->y[i] );
17201715
point = transformLayerToCanvas( point );
1721-
pointArray.setPoint( i, static_cast<int>( round( point.x() ) ),
1722-
static_cast<int>( round( point.y() ) ) );
1716+
pointArray.setPoint( i, qRound( point.x() ), qRound( point.y() ) );
17231717
}
17241718

17251719
myPainter->setPen( pen );
@@ -1846,8 +1840,8 @@ void QgsGrassEdit::displayIcon( double x, double y, const QPen & pen,
18461840

18471841
point = transformLayerToCanvas( point );
18481842

1849-
int px = static_cast<int>( round( point.x() ) );
1850-
int py = static_cast<int>( round( point.y() ) );
1843+
int px = qRound( point.x() );
1844+
int py = qRound( point.y() );
18511845
int m = ( size - 1 ) / 2;
18521846

18531847
QPainter *myPainter;

0 commit comments

Comments
 (0)
Please sign in to comment.