Skip to content
Permalink
Browse files

Use std::round instead of qRound

Now that our minimum VS studio version allowed supports std::round,
we should use that in place of Qt's qRound method.

Because:
- it doesn't truncate to int, resulting in unpredictable
behaviour (refs #16925)
- better to stick to standard c++ methods wherever possible,
since they're likely better supported and optimised by the
compilers
- it's a tiny reduction to the barrier for entry to QGIS
development (I'm sick of pointing out the need to use
qRound during PR reviews!)
  • Loading branch information
nyalldawson committed Aug 24, 2017
1 parent 50e8e1c commit 4b009f96ecb92db0056c18285cb1b8375c239ed1
Showing with 1,800 additions and 1,798 deletions.
  1. +0 −6 python/core/qgis.sip
  2. +4 −4 src/analysis/raster/qgsalignraster.cpp
  3. +1 −1 src/app/composer/qgscomposermapwidget.cpp
  4. +2 −2 src/app/pluginmanager/qgspluginmanager.cpp
  5. +1 −1 src/app/qgsalignrasterdialog.cpp
  6. +1 −1 src/app/qgsdecorationgrid.cpp
  7. +1 −1 src/app/qgsdecorationscalebar.cpp
  8. +1 −1 src/app/qgsmaptoolrotatefeature.cpp
  9. +1 −1 src/app/qgsmeasuredialog.cpp
  10. +1 −1 src/core/composer/qgscomposermapgrid.cpp
  11. +1 −1 src/core/effects/qgsimageoperation.cpp
  12. +2 −2 src/core/expression/qgsexpressionfunction.cpp
  13. +6 −6 src/core/geometry/qgsgeos.cpp
  14. +2 −2 src/core/processing/qgsprocessingparameters.cpp
  15. +1 −7 src/core/qgis.h
  16. +2 −2 src/core/qgscolorramp.cpp
  17. +8 −8 src/core/qgsdatadefinedsizelegend.cpp
  18. +2 −2 src/core/qgsfield.cpp
  19. +4 −4 src/core/qgsmaptopixelgeometrysimplifier.cpp
  20. +10 −10 src/core/qgspointxy.cpp
  21. +1 −1 src/core/qgsproperty.cpp
  22. +1 −1 src/core/qgsvectorlayerlabeling.cpp
  23. +1 −1 src/core/raster/qgscolorrampshader.cpp
  24. +4 −4 src/core/raster/qgsrasterblock.cpp
  25. +1 −1 src/core/raster/qgsrasterchecker.cpp
  26. +6 −6 src/core/raster/qgsrasterdataprovider.cpp
  27. +2 −2 src/core/raster/qgsrasterinterface.cpp
  28. +2 −2 src/core/raster/qgsrasterprojector.cpp
  29. +3 −3 src/core/symbology/qgsfillsymbollayer.cpp
  30. +1 −1 src/core/symbology/qgsheatmaprenderer.cpp
  31. +1 −1 src/core/symbology/qgsmarkersymbollayer.cpp
  32. +9 −9 src/core/symbology/qgssymbollayerutils.cpp
  33. +1 −1 src/gui/editorwidgets/qgsspinbox.cpp
  34. +1 −1 src/gui/qgsadvanceddigitizingdockwidget.cpp
  35. +7 −7 src/gui/qgscolorwidgets.cpp
  36. +1 −1 src/gui/qgsgradientstopeditor.cpp
  37. +1 −1 src/gui/qgsmapcanvasmap.cpp
  38. +1 −1 src/gui/qgsmapmouseevent.cpp
  39. +1 −1 src/gui/qgsmaptool.cpp
  40. +2 −2 src/gui/qgsmaptoolidentify.cpp
  41. +2 −2 src/gui/qgsrasterlayersaveasdialog.cpp
  42. +2 −2 src/gui/qgsscalecombobox.cpp
  43. +1 −1 src/gui/symbology/qgsellipsesymbollayerwidget.cpp
  44. +1 −1 src/gui/symbology/qgssvgselectorwidget.cpp
  45. +2 −2 src/gui/symbology/qgssymbollayerwidget.cpp
  46. +1,669 −1,641 src/plugins/grass/qtermwidget/TerminalDisplay.cpp
  47. +6 −6 src/providers/gdal/qgsgdalprovider.cpp
  48. +6 −5 tests/src/analysis/testqgsalignraster.cpp
  49. +2 −2 tests/src/app/testqgisappclipboard.cpp
  50. +1 −1 tests/src/app/testqgsnodetool.cpp
  51. +0 −15 tests/src/core/testqgis.cpp
  52. +8 −8 tests/src/core/testqgstaskmanager.cpp
  53. +1 −1 tests/src/core/testqgsvectordataprovider.cpp
  54. +1 −1 tests/src/providers/testqgswcspublicservers.cpp
@@ -153,12 +153,6 @@ Compare two doubles using specified number of significant digits
:rtype: bool
%End

double qgsRound( double x );
%Docstring
A round function which returns a double to guard against overflows
:rtype: float
%End

double qgsRound( double number, double places );
%Docstring
Returns a double ``number``, rounded (as close as possible) to the specified number of ``places``.
@@ -30,16 +30,16 @@

static double ceil_with_tolerance( double value )
{
if ( qAbs( value - qRound( value ) ) < 1e-6 )
return qRound( value );
if ( qAbs( value - std::round( value ) ) < 1e-6 )
return std::round( value );
else
return qCeil( value );
}

static double floor_with_tolerance( double value )
{
if ( qAbs( value - qRound( value ) ) < 1e-6 )
return qRound( value );
if ( qAbs( value - std::round( value ) ) < 1e-6 )
return std::round( value );
else
return qFloor( value );
}
@@ -444,7 +444,7 @@ void QgsComposerMapWidget::on_mScaleLineEdit_editingFinished()
return;
}

if ( qRound( scaleDenominator ) == qRound( mComposerMap->scale() ) )
if ( std::round( scaleDenominator ) == std::round( mComposerMap->scale() ) )
return;

mComposerMap->beginCommand( tr( "Map scale changed" ) );
@@ -699,8 +699,8 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item )
voteLabel->show();
voteSlider->show();
voteSubmit->show();
QgsDebugMsg( QString( "vote slider:%1" ).arg( qRound( metadata->value( "average_vote" ).toFloat() ) ) );
voteSlider->setValue( qRound( metadata->value( "average_vote" ).toFloat() ) );
QgsDebugMsg( QString( "vote slider:%1" ).arg( std::round( metadata->value( "average_vote" ).toFloat() ) ) );
voteSlider->setValue( std::round( metadata->value( "average_vote" ).toFloat() ) );
mCurrentPluginId = metadata->value( "plugin_id" ).toInt();
}
else
@@ -61,7 +61,7 @@ struct QgsAlignRasterDialogProgress : public QgsAlignRaster::ProgressHandler
explicit QgsAlignRasterDialogProgress( QProgressBar *pb ) : mPb( pb ) {}
virtual bool progress( double complete ) override
{
mPb->setValue( ( int ) qRound( complete * 100 ) );
mPb->setValue( ( int ) std::round( complete * 100 ) );
qApp->processEvents(); // to actually show the progress in GUI
return true;
}
@@ -790,7 +790,7 @@ bool QgsDecorationGrid::getIntervalFromExtent( double *values, bool useXAxis )
int factor = pow( 10, floor( log10( interval ) ) );
if ( factor != 0 )
{
interval2 = qRound( interval / factor ) * factor;
interval2 = std::round( interval / factor ) * factor;
QgsDebugMsg( QString( "interval2: %1" ).arg( interval2 ) );
if ( !qgsDoubleNear( interval2, 0.0 ) )
interval = interval2;
@@ -164,7 +164,7 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender
if ( mSnapping )
{
double scaler = pow( 10.0, myPowerOf10 );
myActualSize = qRound( myActualSize / scaler ) * scaler;
myActualSize = std::round( myActualSize / scaler ) * scaler;
myScaleBarWidth = myActualSize / myMapUnitsPerPixelDouble;
}

@@ -89,7 +89,7 @@ void QgsAngleMagnetWidget::setAngle( double angle )
const int magnet = mMagnetSpinBox->value();
if ( magnet )
{
mAngleSpinBox->setValue( qRound( angle / magnet ) * magnet );
mAngleSpinBox->setValue( std::round( angle / magnet ) * magnet );
}
else
{
@@ -280,7 +280,7 @@ QString QgsMeasureDialog::formatDistance( double distance, bool convertUnits ) c
{
// special handling for degrees - because we can't use smaller units (eg m->mm), we need to make sure there's
// enough decimal places to show a usable measurement value
int minPlaces = qRound( log10( 1.0 / distance ) ) + 1;
int minPlaces = std::round( log10( 1.0 / distance ) ) + 1;
decimals = qMax( decimals, minPlaces );
}
return QgsDistanceArea::formatDistance( distance, decimals, mDistanceUnits, baseUnit );
@@ -1445,7 +1445,7 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr
{
QString hemisphere;

double coordRounded = qRound( value * pow( 10.0, mGridAnnotationPrecision ) ) / pow( 10.0, mGridAnnotationPrecision );
double coordRounded = std::round( value * pow( 10.0, mGridAnnotationPrecision ) ) / pow( 10.0, mGridAnnotationPrecision );
if ( coord == QgsComposerMapGrid::Longitude )
{
//don't use E/W suffixes if ambiguous (e.g., 180 degrees)
@@ -349,7 +349,7 @@ void QgsImageOperation::MultiplyOpacityPixelOperation::operator()( QRgb &rgb, co
{
Q_UNUSED( x );
Q_UNUSED( y );
rgb = qRgba( qRed( rgb ), qGreen( rgb ), qBlue( rgb ), qBound( 0, qRound( mFactor * qAlpha( rgb ) ), 255 ) );
rgb = qRgba( qRed( rgb ), qGreen( rgb ), qBlue( rgb ), qBound( 0.0, std::round( mFactor * qAlpha( rgb ) ), 255.0 ) );
}

// overlay color
@@ -2884,13 +2884,13 @@ static QVariant fcnRound( const QVariantList &values, const QgsExpressionContext
{
double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
double scaler = pow( 10.0, QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
return QVariant( qRound( number * scaler ) / scaler );
return QVariant( std::round( number * scaler ) / scaler );
}

if ( values.length() >= 1 )
{
double number = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
return QVariant( qRound( number ) );
return QVariant( qlonglong( std::round( number ) ) );
}

return QVariant();
@@ -1701,11 +1701,11 @@ GEOSCoordSequence *QgsGeos::createCoordinateSequence( const QgsCurve *curve, dou
{
for ( int i = 0; i < numOutPoints; ++i )
{
GEOSCoordSeq_setX_r( geosinit.ctxt, coordSeq, i, qgsRound( line->xAt( i % numPoints ) / precision ) * precision );
GEOSCoordSeq_setY_r( geosinit.ctxt, coordSeq, i, qgsRound( line->yAt( i % numPoints ) / precision ) * precision );
GEOSCoordSeq_setX_r( geosinit.ctxt, coordSeq, i, std::round( line->xAt( i % numPoints ) / precision ) * precision );
GEOSCoordSeq_setY_r( geosinit.ctxt, coordSeq, i, std::round( line->yAt( i % numPoints ) / precision ) * precision );
if ( hasZ )
{
GEOSCoordSeq_setOrdinate_r( geosinit.ctxt, coordSeq, i, 2, qgsRound( line->zAt( i % numPoints ) / precision ) * precision );
GEOSCoordSeq_setOrdinate_r( geosinit.ctxt, coordSeq, i, 2, std::round( line->zAt( i % numPoints ) / precision ) * precision );
}
if ( hasM )
{
@@ -1765,11 +1765,11 @@ GEOSGeometry *QgsGeos::createGeosPointXY( double x, double y, bool hasZ, double
}
if ( precision > 0. )
{
GEOSCoordSeq_setX_r( geosinit.ctxt, coordSeq, 0, qgsRound( x / precision ) * precision );
GEOSCoordSeq_setY_r( geosinit.ctxt, coordSeq, 0, qgsRound( y / precision ) * precision );
GEOSCoordSeq_setX_r( geosinit.ctxt, coordSeq, 0, std::round( x / precision ) * precision );
GEOSCoordSeq_setY_r( geosinit.ctxt, coordSeq, 0, std::round( y / precision ) * precision );
if ( hasZ )
{
GEOSCoordSeq_setOrdinate_r( geosinit.ctxt, coordSeq, 0, 2, qgsRound( z / precision ) * precision );
GEOSCoordSeq_setOrdinate_r( geosinit.ctxt, coordSeq, 0, 2, std::round( z / precision ) * precision );
}
}
else
@@ -112,13 +112,13 @@ int QgsProcessingParameters::parameterAsInt( const QgsProcessingParameterDefinit
//work around this by first converting to double, and then checking whether the double is convertible to int
if ( ok )
{
double round = qgsRound( dbl );
double round = std::round( dbl );
if ( round > INT_MAX || round < -INT_MAX )
{
//double too large to fit in int
return 0;
}
return qRound( dbl );
return std::round( dbl );
}

return val.toInt();
@@ -236,13 +236,7 @@ inline bool qgsDoubleNearSig( double a, double b, int significantDigits = 10 )
double br = frexp( b, &bexp );

return aexp == bexp &&
qRound( ar * pow( 10.0, significantDigits ) ) == qRound( br * pow( 10.0, significantDigits ) );
}

//! A round function which returns a double to guard against overflows
inline double qgsRound( double x )
{
return x < 0.0 ? std::ceil( x - 0.5 ) : std::floor( x + 0.5 );
std::round( ar * pow( 10.0, significantDigits ) ) == std::round( br * pow( 10.0, significantDigits ) );
}

/**
@@ -396,7 +396,7 @@ QList<QColor> QgsLimitedRandomColorRamp::randomColors( int count,
//see http://basecase.org/env/on-rainbows for more details
currentHueAngle += 137.50776;
//scale hue to between hueMax and hueMin
h = qBound( 0, qRound( ( fmod( currentHueAngle, 360.0 ) / 360.0 ) * ( safeHueMax - safeHueMin ) + safeHueMin ), 359 );
h = qBound( 0.0, std::round( ( fmod( currentHueAngle, 360.0 ) / 360.0 ) * ( safeHueMax - safeHueMin ) + safeHueMin ), 359.0 );
s = qBound( 0, ( qrand() % ( safeSatMax - safeSatMin + 1 ) ) + safeSatMin, 255 );
v = qBound( 0, ( qrand() % ( safeValMax - safeValMin + 1 ) ) + safeValMin, 255 );
colors.append( QColor::fromHsv( h, s, v ) );
@@ -468,7 +468,7 @@ void QgsRandomColorRamp::setTotalColorCount( const int colorCount )
//build up a list of colors
for ( int idx = 0; idx < colorCount; ++ idx )
{
int h = qRound( currentHue ) % 360;
int h = static_cast< int >( std::round( currentHue ) ) % 360;
int s = ( qrand() % ( DEFAULT_RANDOM_SAT_MAX - DEFAULT_RANDOM_SAT_MIN + 1 ) ) + DEFAULT_RANDOM_SAT_MIN;
int v = ( qrand() % ( DEFAULT_RANDOM_VAL_MAX - DEFAULT_RANDOM_VAL_MIN + 1 ) ) + DEFAULT_RANDOM_VAL_MIN;
mPrecalculatedColors << QColor::fromHsv( h, s, v );
@@ -156,9 +156,9 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
// make sure we draw bigger symbols first
std::sort( classes.begin(), classes.end(), []( const SizeClass & a, const SizeClass & b ) { return a.size > b.size; } );

int hLengthLine = qRound( context.convertToPainterUnits( hLengthLineMM, QgsUnitTypes::RenderMillimeters ) );
int hSpaceLineText = qRound( context.convertToPainterUnits( hSpaceLineTextMM, QgsUnitTypes::RenderMillimeters ) );
int dpm = qRound( context.scaleFactor() * 1000 ); // scale factor = dots per millimeter
int hLengthLine = std::round( context.convertToPainterUnits( hLengthLineMM, QgsUnitTypes::RenderMillimeters ) );
int hSpaceLineText = std::round( context.convertToPainterUnits( hSpaceLineTextMM, QgsUnitTypes::RenderMillimeters ) );
int dpm = std::round( context.scaleFactor() * 1000 ); // scale factor = dots per millimeter

// get font metrics - we need a temporary image just to get the metrics right for the given DPI
QImage tmpImg( QSize( 1, 1 ), QImage::Format_ARGB32_Premultiplied );
@@ -194,10 +194,10 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
switch ( mVAlign )
{
case AlignCenter:
symbolTopY << qRound( outputLargestSize / 2 - outputSymbolSize / 2 );
symbolTopY << std::round( outputLargestSize / 2 - outputSymbolSize / 2 );
break;
case AlignBottom:
symbolTopY << qRound( outputLargestSize - outputSymbolSize );
symbolTopY << std::round( outputLargestSize - outputSymbolSize );
break;
}
}
@@ -222,7 +222,7 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
int totalTextHeight = textBottomY - textTopY;

int fullWidth = outputLargestSize + hLengthLine + hSpaceLineText + maxTextWidth;
int fullHeight = qMax( qRound( outputLargestSize ) - textTopY, totalTextHeight );
int fullHeight = qMax( static_cast< int >( std::round( outputLargestSize ) ) - textTopY, totalTextHeight );

if ( outputSize )
*outputSize = QSize( fullWidth, fullHeight );
@@ -292,8 +292,8 @@ QImage QgsDataDefinedSizeLegend::collapsedLegendImage( QgsRenderContext &context
QSize contentSize;
drawCollapsedLegend( context, &contentSize );

int padding = qRound( context.convertToPainterUnits( paddingMM, QgsUnitTypes::RenderMillimeters ) );
int dpm = qRound( context.scaleFactor() * 1000 ); // scale factor = dots per millimeter
int padding = std::round( context.convertToPainterUnits( paddingMM, QgsUnitTypes::RenderMillimeters ) );
int dpm = std::round( context.scaleFactor() * 1000 ); // scale factor = dots per millimeter

QImage img( contentSize.width() + padding * 2, contentSize.height() + padding * 2, QImage::Format_ARGB32_Premultiplied );
img.setDotsPerMeterX( dpm );
@@ -249,14 +249,14 @@ bool QgsField::convertCompatible( QVariant &v ) const
return false;
}

double round = qgsRound( dbl );
double round = std::round( dbl );
if ( round > INT_MAX || round < -INT_MAX )
{
//double too large to fit in int
v = QVariant( d->type );
return false;
}
v = QVariant( qRound( dbl ) );
v = QVariant( static_cast< int >( std::round( dbl ) ) );
return true;
}

@@ -47,12 +47,12 @@ float QgsMapToPixelSimplifier::calculateLengthSquared2D( double x1, double y1, d

bool QgsMapToPixelSimplifier::equalSnapToGrid( double x1, double y1, double x2, double y2, double gridOriginX, double gridOriginY, float gridInverseSizeXY )
{
int grid_x1 = qRound( ( x1 - gridOriginX ) * gridInverseSizeXY );
int grid_x2 = qRound( ( x2 - gridOriginX ) * gridInverseSizeXY );
int grid_x1 = std::round( ( x1 - gridOriginX ) * gridInverseSizeXY );
int grid_x2 = std::round( ( x2 - gridOriginX ) * gridInverseSizeXY );
if ( grid_x1 != grid_x2 ) return false;

int grid_y1 = qRound( ( y1 - gridOriginY ) * gridInverseSizeXY );
int grid_y2 = qRound( ( y2 - gridOriginY ) * gridInverseSizeXY );
int grid_y1 = std::round( ( y1 - gridOriginY ) * gridInverseSizeXY );
int grid_y2 = std::round( ( y2 - gridOriginY ) * gridInverseSizeXY );
if ( grid_y1 != grid_y2 ) return false;

return true;
@@ -95,7 +95,7 @@ QString QgsPointXY::toDegreesMinutesSeconds( int precision, const bool useSuffix
double mySecondsY = double( myFloatMinutesY - myIntMinutesY ) * 60;

//make sure rounding to specified precision doesn't create seconds >= 60
if ( qRound( mySecondsX * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )
if ( std::round( mySecondsX * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )
{
mySecondsX = qMax( mySecondsX - 60, 0.0 );
myIntMinutesX++;
@@ -105,7 +105,7 @@ QString QgsPointXY::toDegreesMinutesSeconds( int precision, const bool useSuffix
myDegreesX++;
}
}
if ( qRound( mySecondsY * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )
if ( std::round( mySecondsY * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )
{
mySecondsY = qMax( mySecondsY - 60, 0.0 );
myIntMinutesY++;
@@ -138,18 +138,18 @@ QString QgsPointXY::toDegreesMinutesSeconds( int precision, const bool useSuffix
}
//check if coordinate is all zeros for the specified precision, and if so,
//remove the sign and hemisphere strings
if ( myDegreesX == 0 && myIntMinutesX == 0 && qRound( mySecondsX * pow( 10.0, precision ) ) == 0 )
if ( myDegreesX == 0 && myIntMinutesX == 0 && std::round( mySecondsX * pow( 10.0, precision ) ) == 0 )
{
myXSign = QString();
myXHemisphere = QString();
}
if ( myDegreesY == 0 && myIntMinutesY == 0 && qRound( mySecondsY * pow( 10.0, precision ) ) == 0 )
if ( myDegreesY == 0 && myIntMinutesY == 0 && std::round( mySecondsY * pow( 10.0, precision ) ) == 0 )
{
myYSign = QString();
myYHemisphere = QString();
}
//also remove directional prefix from 180 degree longitudes
if ( myDegreesX == 180 && myIntMinutesX == 0 && qRound( mySecondsX * pow( 10.0, precision ) ) == 0 )
if ( myDegreesX == 180 && myIntMinutesX == 0 && std::round( mySecondsX * pow( 10.0, precision ) ) == 0 )
{
myXHemisphere = QString();
}
@@ -193,12 +193,12 @@ QString QgsPointXY::toDegreesMinutes( int precision, const bool useSuffix, const
double myFloatMinutesY = double( ( qAbs( mY ) - myDegreesY ) * 60 );

//make sure rounding to specified precision doesn't create minutes >= 60
if ( qRound( myFloatMinutesX * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )
if ( std::round( myFloatMinutesX * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )
{
myFloatMinutesX = qMax( myFloatMinutesX - 60, 0.0 );
myDegreesX++;
}
if ( qRound( myFloatMinutesY * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )
if ( std::round( myFloatMinutesY * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )
{
myFloatMinutesY = qMax( myFloatMinutesY - 60, 0.0 );
myDegreesY++;
@@ -226,18 +226,18 @@ QString QgsPointXY::toDegreesMinutes( int precision, const bool useSuffix, const
}
//check if coordinate is all zeros for the specified precision, and if so,
//remove the sign and hemisphere strings
if ( myDegreesX == 0 && qRound( myFloatMinutesX * pow( 10.0, precision ) ) == 0 )
if ( myDegreesX == 0 && std::round( myFloatMinutesX * pow( 10.0, precision ) ) == 0 )
{
myXSign = QString();
myXHemisphere = QString();
}
if ( myDegreesY == 0 && qRound( myFloatMinutesY * pow( 10.0, precision ) ) == 0 )
if ( myDegreesY == 0 && std::round( myFloatMinutesY * pow( 10.0, precision ) ) == 0 )
{
myYSign = QString();
myYHemisphere = QString();
}
//also remove directional prefix from 180 degree longitudes
if ( myDegreesX == 180 && qRound( myFloatMinutesX * pow( 10.0, precision ) ) == 0 )
if ( myDegreesX == 180 && std::round( myFloatMinutesX * pow( 10.0, precision ) ) == 0 )
{
myXHemisphere = QString();
}
@@ -605,7 +605,7 @@ int QgsProperty::valueAsInt( const QgsExpressionContext &context, int defaultVal
{
if ( ok )
*ok = true;
return qRound( dbl );
return std::round( dbl );
}
else
{
@@ -203,7 +203,7 @@ std::unique_ptr<QgsMarkerSymbolLayer> backgroundToMarkerLayer( const QgsTextBack
QColor strokeColor = settings.strokeColor();
if ( settings.opacity() < 1 )
{
int alpha = qRound( settings.opacity() * 255 );
int alpha = std::round( settings.opacity() * 255 );
fillColor.setAlpha( alpha );
strokeColor.setAlpha( alpha );
}
@@ -286,7 +286,7 @@ void QgsColorRampShader::classifyColorRamp( const int classes, const int band, c

// calculate a reasonable number of decimals to display
double maxabs = log10( qMax( qAbs( max ), qAbs( min ) ) );
int nDecimals = qRound( qMax( 3.0 + maxabs - log10( max - min ), maxabs <= 15.0 ? maxabs + 0.49 : 0.0 ) );
int nDecimals = std::round( qMax( 3.0 + maxabs - log10( max - min ), maxabs <= 15.0 ? maxabs + 0.49 : 0.0 ) );

QList<QgsColorRampShader::ColorRampItem> colorRampItems;
for ( ; value_it != entryValues.end(); ++value_it, ++color_it )

0 comments on commit 4b009f9

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