use qRound() fro round() (followup ad437bfdffd)

This commit is contained in:
Juergen E. Fischer 2012-08-29 14:32:04 +02:00
parent b3a6172ff7
commit 88bc309c63
7 changed files with 9 additions and 32 deletions

View File

@ -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
@ -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;

View File

@ -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;
@ -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
{

View File

@ -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 )
{
@ -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;
}

View File

@ -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

View File

@ -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 ) );
}

View File

@ -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;
@ -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;
}

View File

@ -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:
@ -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 );
@ -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;