Skip to content

Commit

Permalink
use qRound() fro round() (followup ad437bf)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Aug 29, 2012
1 parent b3a6172 commit 88bc309
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 32 deletions.
6 changes: 1 addition & 5 deletions src/app/qgsdecorationgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
#include <cmath>


#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif

#define FONT_WORKAROUND_SCALE 10 //scale factor for upscaling fontsize and downscaling painter


Expand Down Expand Up @@ -808,7 +804,7 @@ bool QgsDecorationGrid::getIntervalFromExtent( double* values, bool useXAxis )
int factor = pow( 10, floor( log10( interval ) ) );
if ( factor != 0 )
{
interval2 = round( interval / factor ) * factor;
interval2 = qRound( interval / factor ) * factor;
QgsDebugMsg( QString( "interval2: %1" ).arg( interval2 ) );
if ( interval2 != 0 )
interval = interval2;
Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsdecorationnortharrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ email : tim@linfiniti.com
#include <cassert>


#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif

const double QgsDecorationNorthArrow::PI = 3.14159265358979323846;
// const double QgsNorthArrowPlugin::DEG2RAD = 0.0174532925199433;
const double QgsDecorationNorthArrow::TOL = 1e-8;
Expand Down Expand Up @@ -298,7 +294,7 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
}
// And set the angle of the north arrow. Perhaps do something
// different if goodDirn = false.
mRotationInt = static_cast<int>( round( fmod( 360.0 - angle * 180.0 / PI, 360.0 ) ) );
mRotationInt = qRound( fmod( 360.0 - angle * 180.0 / PI, 360.0 ) );
}
else
{
Expand Down
7 changes: 1 addition & 6 deletions src/app/qgsdecorationscalebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ email : sbr00pwb@users.sourceforge.net
#include <cmath>


#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif


QgsDecorationScaleBar::QgsDecorationScaleBar( QObject* parent )
: QgsDecorationItem( parent )
{
Expand Down Expand Up @@ -164,7 +159,7 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
if ( mSnapping )
{
double scaler = pow( 10.0, myPowerOf10 );
myActualSize = round( myActualSize / scaler ) * scaler;
myActualSize = qRound( myActualSize / scaler ) * scaler;
myScaleBarWidth = myActualSize / myMapUnitsPerPixelDouble;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ int QgsComposition::pixelFontSize( double pointSize ) const
{
//in QgsComposition, one unit = one mm
double sizeMillimeters = pointSize * 0.3527;
return ( sizeMillimeters + 0.5 ); //round to nearest mm
return qRound( sizeMillimeters ); //round to nearest mm
}

double QgsComposition::pointFontSize( int pixelSize ) const
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmaptool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ QPoint QgsMapTool::toCanvasCoordinates( const QgsPoint& point )
{
double x = point.x(), y = point.y();
mCanvas->getCoordinateTransform()->transformInPlace( x, y );
return QPoint(( int )( x + 0.5 ), ( int )( y + 0.5 ) ); // round the values
return QPoint( qRound( x ), qRound( y ) );
}


Expand Down
6 changes: 1 addition & 5 deletions src/gui/qgsquickprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@
//other includes
#include <cmath>

#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif

QgsQuickPrint::QgsQuickPrint()
{
mPageSize = QPrinter::A4;
Expand Down Expand Up @@ -813,7 +809,7 @@ void QgsQuickPrint::renderPrintScaleBar( QPainter * thepPainter,
if ( mySnappingFlag )
{
double scaler = pow( 10.0, myPowerOf10 );
myActualSize = round( myActualSize / scaler ) * scaler;
myActualSize = qRound( myActualSize / scaler ) * scaler;
myScaleBarWidth = myActualSize / myMapUnitsPerPixelDouble;
}

Expand Down
12 changes: 3 additions & 9 deletions src/plugins/grass/qgsgrassedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ extern "C"
#include <grass/Vect.h>
}

#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif


class QgsGrassEditLayer : public QgsMapCanvasItem
{
public:
Expand Down Expand Up @@ -1718,8 +1713,7 @@ void QgsGrassEdit::displayElement( int line, const QPen & pen, int size, QPainte
point.setX( mPoints->x[i] );
point.setY( mPoints->y[i] );
point = transformLayerToCanvas( point );
pointArray.setPoint( i, static_cast<int>( round( point.x() ) ),
static_cast<int>( round( point.y() ) ) );
pointArray.setPoint( i, qRound( point.x() ), qRound( point.y() ) );
}

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

point = transformLayerToCanvas( point );

int px = static_cast<int>( round( point.x() ) );
int py = static_cast<int>( round( point.y() ) );
int px = qRound( point.x() );
int py = qRound( point.y() );
int m = ( size - 1 ) / 2;

QPainter *myPainter;
Expand Down

0 comments on commit 88bc309

Please sign in to comment.