From 77c3be97e33e100637537f0167b5fd784639c20c Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 25 Aug 2017 02:12:54 +1000 Subject: [PATCH] Make sure (f)abs are prefixed with std:: --- src/analysis/interpolation/MathUtils.cc | 4 +-- src/analysis/raster/qgsalignraster.cpp | 8 ++--- src/analysis/raster/qgsrelief.cpp | 2 +- src/analysis/vector/qgsgeometrysnapper.cpp | 4 +-- src/app/dwg/libdxfrw/drw_entities.cpp | 10 +++--- src/app/dwg/libdxfrw/drw_objects.cpp | 2 +- src/app/qgsdecorationgrid.cpp | 8 ++--- src/app/qgsdecorationscalebar.cpp | 2 +- src/app/qgslabelinggui.cpp | 2 +- src/app/qgsmaptoolmeasureangle.cpp | 8 ++--- src/app/qgsundowidget.cpp | 2 +- src/core/composer/qgscomposerarrow.cpp | 2 +- src/core/composer/qgscomposermapgrid.cpp | 4 +-- src/core/composer/qgscomposermousehandles.cpp | 12 +++---- src/core/composer/qgscomposernodesitem.cpp | 6 ++-- src/core/composer/qgscomposerpicture.cpp | 4 +-- src/core/composer/qgscomposerutils.cpp | 8 ++--- src/core/composer/qgscomposition.cpp | 4 +-- src/core/dxf/qgsdxfpaintengine.cpp | 2 +- src/core/effects/qgsimageoperation.cpp | 4 +-- src/core/expression/qgsexpressionfunction.cpp | 14 ++++---- src/core/geometry/qgscircle.cpp | 18 +++++------ src/core/geometry/qgscircle.h | 6 ++-- src/core/geometry/qgscurvepolygon.cpp | 4 +-- src/core/geometry/qgsellipse.cpp | 12 +++---- src/core/geometry/qgsgeometry.cpp | 2 +- src/core/geometry/qgsgeometryutils.cpp | 2 +- src/core/geometry/qgsgeos.cpp | 4 +-- .../geometry/qgsinternalgeometryengine.cpp | 4 +-- src/core/geometry/qgsregularpolygon.cpp | 8 ++--- src/core/layout/qgslayoutsnapper.cpp | 6 ++-- src/core/pal/feature.cpp | 12 +++---- src/core/pal/pointset.cpp | 8 ++--- src/core/qgsclipper.h | 4 +-- src/core/qgscoordinatereferencesystem.cpp | 2 +- src/core/qgsdistancearea.cpp | 6 ++-- src/core/qgsmaprendererjob.cpp | 8 ++--- src/core/qgsmapsettings.cpp | 4 +-- src/core/qgspallabeling.cpp | 10 +++--- src/core/qgspointxy.cpp | 16 +++++----- src/core/qgsrenderchecker.cpp | 12 +++---- src/core/qgstestutils.h | 4 +-- src/core/qgstracer.cpp | 2 +- src/core/qgsunittypes.cpp | 26 +++++++-------- src/core/qgsvectorfilewriter.cpp | 2 +- src/core/qgsvectorlayerlabeling.cpp | 2 +- src/core/raster/qgscolorrampshader.cpp | 2 +- src/core/raster/qgsrasterchecker.cpp | 4 +-- src/core/raster/qgsrasterminmaxorigin.cpp | 6 ++-- src/core/simplify/effectivearea.cpp | 2 +- src/core/symbology/qgs25drenderer.cpp | 2 +- src/core/symbology/qgsarrowsymbollayer.cpp | 8 ++--- src/core/symbology/qgsfillsymbollayer.cpp | 14 ++++---- src/core/symbology/qgslinesymbollayer.cpp | 6 ++-- src/core/symbology/qgssymbollayerutils.cpp | 2 +- src/gui/layout/qgslayoutruler.cpp | 4 +-- src/gui/layout/qgslayoutview.cpp | 2 +- src/gui/layout/qgslayoutviewrubberband.cpp | 6 ++-- src/gui/layout/qgslayoutviewtool.cpp | 2 +- src/gui/qgsadvanceddigitizingdockwidget.cpp | 12 +++---- src/gui/qgscolorwidgets.cpp | 4 +-- src/gui/qgscomposerview.cpp | 10 +++--- src/gui/qgsgradientstopeditor.cpp | 6 ++-- src/gui/qgsmapcanvas.cpp | 6 ++-- src/gui/qgsmapcanvasannotationitem.cpp | 10 +++--- src/gui/qgsmaptoolextent.cpp | 4 +-- src/gui/qgsscalecombobox.cpp | 2 +- src/gui/raster/qgsrasterhistogramwidget.cpp | 2 +- .../symbology/qgsgraduatedhistogramwidget.cpp | 6 ++-- .../checks/qgsgeometryoverlapcheck.cpp | 2 +- .../checks/qgsgeometryoverlapcheck.h | 2 +- .../utils/qgsgeometrycheckerutils.cpp | 2 +- .../georeferencer/qgsgeorefdelegates.cpp | 2 +- .../georeferencer/qgsgeoreftransform.cpp | 10 +++--- src/plugins/georeferencer/qgsleastsquares.cpp | 4 +-- .../georeferencer/qgsmapcoordsdialog.cpp | 2 +- src/plugins/grass/qgsgrassnewmapset.cpp | 2 +- src/plugins/grass/qtermwidget/ColorScheme.cpp | 6 ++-- .../grass/qtermwidget/TerminalDisplay.cpp | 10 +++--- src/providers/gdal/qgsgdalprovider.cpp | 8 ++--- .../grass/qgsgrassrasterprovider.cpp | 2 +- src/providers/wcs/qgswcsprovider.cpp | 8 ++--- src/providers/wfs/qgswfscapabilities.cpp | 8 ++--- src/providers/wms/qgswmsprovider.cpp | 6 ++-- tests/bench/qgsbench.cpp | 2 +- tests/src/core/testqgscomposermap.cpp | 32 +++++++++---------- tests/src/core/testqgsrasterlayer.cpp | 20 ++++++------ .../providers/grass/testqgsgrassprovider.cpp | 2 +- 88 files changed, 274 insertions(+), 274 deletions(-) diff --git a/src/analysis/interpolation/MathUtils.cc b/src/analysis/interpolation/MathUtils.cc index 8b7b75bbcea..80d3391440b 100644 --- a/src/analysis/interpolation/MathUtils.cc +++ b/src/analysis/interpolation/MathUtils.cc @@ -210,7 +210,7 @@ double MathUtils::distPointFromLine( QgsPoint *thepoint, QgsPoint *p1, QgsPoint double a = normal.getX(); double b = normal.getY(); double c = -( normal.getX() * p2->x() + normal.getY() * p2->y() ); - double distance = fabs( ( a * thepoint->x() + b * thepoint->y() + c ) / ( sqrt( a * a + b * b ) ) ); + double distance = std::fabs( ( a * thepoint->x() + b * thepoint->y() + c ) / ( sqrt( a * a + b * b ) ) ); return distance; } else @@ -471,7 +471,7 @@ double MathUtils::power( double a, int b ) return 1; } double tmp = a; - for ( int i = 2; i <= abs( b ); i++ ) + for ( int i = 2; i <= std::abs( b ); i++ ) { a *= tmp; diff --git a/src/analysis/raster/qgsalignraster.cpp b/src/analysis/raster/qgsalignraster.cpp index 8b451109de4..8d605143404 100644 --- a/src/analysis/raster/qgsalignraster.cpp +++ b/src/analysis/raster/qgsalignraster.cpp @@ -30,7 +30,7 @@ static double ceil_with_tolerance( double value ) { - if ( fabs( value - std::round( value ) ) < 1e-6 ) + if ( std::fabs( value - std::round( value ) ) < 1e-6 ) return std::round( value ); else return qCeil( value ); @@ -38,7 +38,7 @@ static double ceil_with_tolerance( double value ) static double floor_with_tolerance( double value ) { - if ( fabs( value - std::round( value ) ) < 1e-6 ) + if ( std::fabs( value - std::round( value ) ) < 1e-6 ) return std::round( value ); else return qFloor( value ); @@ -538,7 +538,7 @@ bool QgsAlignRaster::suggestedWarpOutput( const QgsAlignRaster::RasterInfo &info if ( eErr != CE_None ) return false; - QSizeF cs( fabs( adfDstGeoTransform[1] ), fabs( adfDstGeoTransform[5] ) ); + QSizeF cs( std::fabs( adfDstGeoTransform[1] ), std::fabs( adfDstGeoTransform[5] ) ); if ( rect ) *rect = QgsRectangle( extents[0], extents[1], extents[2], extents[3] ); @@ -582,7 +582,7 @@ QgsAlignRaster::RasterInfo::~RasterInfo() QSizeF QgsAlignRaster::RasterInfo::cellSize() const { - return QSizeF( fabs( mGeoTransform[1] ), fabs( mGeoTransform[5] ) ); + return QSizeF( std::fabs( mGeoTransform[1] ), std::fabs( mGeoTransform[5] ) ); } QPointF QgsAlignRaster::RasterInfo::gridOffset() const diff --git a/src/analysis/raster/qgsrelief.cpp b/src/analysis/raster/qgsrelief.cpp index b00f7a13ed4..7803e8b89e9 100644 --- a/src/analysis/raster/qgsrelief.cpp +++ b/src/analysis/raster/qgsrelief.cpp @@ -353,7 +353,7 @@ bool QgsRelief::processNineCellWindow( float *x1, float *x2, float *x3, float *x float aspect = mAspectFilter->processNineCellWindow( x1, x2, x3, x4, x5, x6, x7, x8, x9 ); if ( hillShadeValue285 != mOutputNodataValue && aspect != mOutputNodataValue ) { - double angle_diff = fabs( 285 - aspect ); + double angle_diff = std::fabs( 285 - aspect ); if ( angle_diff > 180 ) { angle_diff -= 180; diff --git a/src/analysis/vector/qgsgeometrysnapper.cpp b/src/analysis/vector/qgsgeometrysnapper.cpp index 5ab47eccdd1..e2fb6dbb928 100644 --- a/src/analysis/vector/qgsgeometrysnapper.cpp +++ b/src/analysis/vector/qgsgeometrysnapper.cpp @@ -110,8 +110,8 @@ class Raytracer // See http://playtechs.blogspot.ch/2007/03/raytracing-on-grid.html public: Raytracer( float x0, float y0, float x1, float y1 ) - : m_dx( fabs( x1 - x0 ) ) - , m_dy( fabs( y1 - y0 ) ) + : m_dx( std::fabs( x1 - x0 ) ) + , m_dy( std::fabs( y1 - y0 ) ) , m_x( qFloor( x0 ) ) , m_y( qFloor( y0 ) ) , m_n( 1 ) diff --git a/src/app/dwg/libdxfrw/drw_entities.cpp b/src/app/dwg/libdxfrw/drw_entities.cpp index fbb65138921..9920908774e 100644 --- a/src/app/dwg/libdxfrw/drw_entities.cpp +++ b/src/app/dwg/libdxfrw/drw_entities.cpp @@ -36,7 +36,7 @@ void DRW_Entity::calculateAxis( DRW_Coord extPoint ) { //Follow the arbitrary DXF definitions for extrusion axes. - if ( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 ) + if ( std::fabs( extPoint.x ) < 0.015625 && std::fabs( extPoint.y ) < 0.015625 ) { //If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec. //The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x @@ -797,7 +797,7 @@ void DRW_Arc::applyExtrusion() // Note that the following code only handles the special case where there is a 2D // drawing with the z axis heading into the paper (or rather screen). An arbitrary // extrusion axis (with x and y values greater than 1/64) may still have issues. - if ( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 && extPoint.z < 0.0 ) + if ( std::fabs( extPoint.x ) < 0.015625 && std::fabs( extPoint.y ) < 0.015625 && extPoint.z < 0.0 ) { staangle = M_PI - staangle; endangle = M_PI - endangle; @@ -902,7 +902,7 @@ void DRW_Ellipse::correctAxis() } if ( ratio > 1 ) { - if ( fabs( endparam - staparam - M_PIx2 ) < 1.0e-10 ) + if ( std::fabs( endparam - staparam - M_PIx2 ) < 1.0e-10 ) complete = true; double incX = secPoint.x; secPoint.x = -( secPoint.y * ratio ); @@ -977,7 +977,7 @@ void DRW_Ellipse::toPolyline( DRW_Polyline *pol, int parts ) const curAngle += incAngle; } - if ( fabs( endAngle - staparam - M_PIx2 ) < 1.0e-10 ) + if ( std::fabs( endAngle - staparam - M_PIx2 ) < 1.0e-10 ) { pol->flags = 1; } @@ -2065,7 +2065,7 @@ bool DRW_Vertex::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs, dou stawidth = buf->getBitDouble(); if ( stawidth < 0 ) - endwidth = stawidth = fabs( stawidth ); + endwidth = stawidth = std::fabs( stawidth ); else endwidth = buf->getBitDouble(); bulge = buf->getBitDouble(); diff --git a/src/app/dwg/libdxfrw/drw_objects.cpp b/src/app/dwg/libdxfrw/drw_objects.cpp index 7c4757975c9..217706b30f6 100644 --- a/src/app/dwg/libdxfrw/drw_objects.cpp +++ b/src/app/dwg/libdxfrw/drw_objects.cpp @@ -505,7 +505,7 @@ void DRW_LType::update() size = path.size(); for ( std::vector::size_type i = 0; i < size; i++ ) { - d += fabs( path.at( i ) ); + d += std::fabs( path.at( i ) ); } length = d; } diff --git a/src/app/qgsdecorationgrid.cpp b/src/app/qgsdecorationgrid.cpp index aab776a1a09..1c6f5e852b0 100644 --- a/src/app/qgsdecorationgrid.cpp +++ b/src/app/qgsdecorationgrid.cpp @@ -582,7 +582,7 @@ int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPa QLineF lineWest( mapPolygon[3], mapPolygon[0] ); double len = lineEast.length(); - Q_ASSERT( fabs( len - lineWest.length() ) < 1e-6 ); // no shear + Q_ASSERT( std::fabs( len - lineWest.length() ) < 1e-6 ); // no shear double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0; double dist = static_cast< int >( ( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY; @@ -626,7 +626,7 @@ int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList< QPa QLineF lineNorth( mapPolygon[0], mapPolygon[1] ); double len = lineSouth.length(); - Q_ASSERT( fabs( len - lineNorth.length() ) < 1e-6 ); // no shear + Q_ASSERT( std::fabs( len - lineNorth.length() ) < 1e-6 ); // no shear const QRectF &mapBoundingRect = mapPolygon.boundingRect(); double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0; @@ -836,8 +836,8 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values ) // TODO add a function in QgsRasterLayer to get x/y resolution from provider, // because this might not be 100% accurate QgsRectangle extent = rlayer->extent(); - values[0] = fabs( extent.xMaximum() - extent.xMinimum() ) / rlayer->width(); - values[1] = fabs( extent.yMaximum() - extent.yMinimum() ) / rlayer->height(); + values[0] = std::fabs( extent.xMaximum() - extent.xMinimum() ) / rlayer->width(); + values[1] = std::fabs( extent.yMaximum() - extent.yMinimum() ) / rlayer->height(); // calculate offset - when using very high resolution rasters in geographic CRS // there seems to be a small shift, but this may be due to rendering issues and depends on zoom diff --git a/src/app/qgsdecorationscalebar.cpp b/src/app/qgsdecorationscalebar.cpp index 0804e07fa07..2a927301598 100644 --- a/src/app/qgsdecorationscalebar.cpp +++ b/src/app/qgsdecorationscalebar.cpp @@ -113,7 +113,7 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender //Get map units per pixel. This can be negative at times (to do with //projections) and that just confuses the rest of the code in this //function, so force to a positive number. - double myMapUnitsPerPixelDouble = fabs( context.mapToPixel().mapUnitsPerPixel() ); + double myMapUnitsPerPixelDouble = std::fabs( context.mapToPixel().mapUnitsPerPixel() ); double myActualSize = mPreferredSize; // Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze diff --git a/src/app/qgslabelinggui.cpp b/src/app/qgslabelinggui.cpp index 241ca2bca26..6578738da94 100644 --- a/src/app/qgslabelinggui.cpp +++ b/src/app/qgslabelinggui.cpp @@ -237,7 +237,7 @@ void QgsLabelingGui::setLayer( QgsMapLayer *mapLayer ) // curved label max character angles mMaxCharAngleInDSpinBox->setValue( lyr.maxCurvedCharAngleIn ); // lyr.maxCurvedCharAngleOut must be negative, but it is shown as positive spinbox in GUI - mMaxCharAngleOutDSpinBox->setValue( fabs( lyr.maxCurvedCharAngleOut ) ); + mMaxCharAngleOutDSpinBox->setValue( std::fabs( lyr.maxCurvedCharAngleOut ) ); wrapCharacterEdit->setText( lyr.wrapChar ); mFontMultiLineAlignComboBox->setCurrentIndex( ( unsigned int ) lyr.multilineAlign ); diff --git a/src/app/qgsmaptoolmeasureangle.cpp b/src/app/qgsmaptoolmeasureangle.cpp index d41d19be49a..60acc4bae03 100644 --- a/src/app/qgsmaptoolmeasureangle.cpp +++ b/src/app/qgsmaptoolmeasureangle.cpp @@ -64,9 +64,9 @@ void QgsMapToolMeasureAngle::canvasMoveEvent( QgsMapMouseEvent *e ) double azimuthOne = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) ); double azimuthTwo = mDa.bearing( mAnglePoints.at( 1 ), point ); double resultAngle = azimuthTwo - azimuthOne; - QgsDebugMsg( QString::number( fabs( resultAngle ) ) ); + QgsDebugMsg( QString::number( std::fabs( resultAngle ) ) ); QgsDebugMsg( QString::number( M_PI ) ); - if ( fabs( resultAngle ) > M_PI ) + if ( std::fabs( resultAngle ) > M_PI ) { if ( resultAngle < 0 ) { @@ -163,9 +163,9 @@ void QgsMapToolMeasureAngle::updateSettings() double azimuthOne = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) ); double azimuthTwo = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 2 ) ); double resultAngle = azimuthTwo - azimuthOne; - QgsDebugMsg( QString::number( fabs( resultAngle ) ) ); + QgsDebugMsg( QString::number( std::fabs( resultAngle ) ) ); QgsDebugMsg( QString::number( M_PI ) ); - if ( fabs( resultAngle ) > M_PI ) + if ( std::fabs( resultAngle ) > M_PI ) { if ( resultAngle < 0 ) { diff --git a/src/app/qgsundowidget.cpp b/src/app/qgsundowidget.cpp index 41dd32a0057..3691de36614 100644 --- a/src/app/qgsundowidget.cpp +++ b/src/app/qgsundowidget.cpp @@ -78,7 +78,7 @@ void QgsUndoWidget::indexChanged( int curIndx ) canRedo = mUndoStack->canRedo(); curCount = mUndoStack->count(); } - int offset = abs( mPreviousIndex - curIndx ); + int offset = std::abs( mPreviousIndex - curIndx ); // when individually redoing, differentiate between last redo and a new command added to stack bool lastRedo = ( mPreviousIndex == ( mPreviousCount - 1 ) && mPreviousCount == curCount && !canRedo ); diff --git a/src/core/composer/qgscomposerarrow.cpp b/src/core/composer/qgscomposerarrow.cpp index ed55288360a..e905053d22d 100644 --- a/src/core/composer/qgscomposerarrow.cpp +++ b/src/core/composer/qgscomposerarrow.cpp @@ -409,7 +409,7 @@ void QgsComposerArrow::adaptItemSceneRect() { //rectangle containing start and end point QRectF rect = QRectF( qMin( mStartPoint.x(), mStopPoint.x() ), qMin( mStartPoint.y(), mStopPoint.y() ), - fabs( mStopPoint.x() - mStartPoint.x() ), fabs( mStopPoint.y() - mStartPoint.y() ) ); + std::fabs( mStopPoint.x() - mStartPoint.x() ), std::fabs( mStopPoint.y() - mStartPoint.y() ) ); double enlarge = computeMarkerMargin(); rect.adjust( -enlarge, -enlarge, enlarge, enlarge ); QgsComposerItem::setSceneRect( rect ); diff --git a/src/core/composer/qgscomposermapgrid.cpp b/src/core/composer/qgscomposermapgrid.cpp index 2dfc342b318..bd7a8f9c588 100644 --- a/src/core/composer/qgscomposermapgrid.cpp +++ b/src/core/composer/qgscomposermapgrid.cpp @@ -1465,11 +1465,11 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr if ( geographic ) { //insert degree symbol for geographic coordinates - return QString::number( fabs( value ), 'f', mGridAnnotationPrecision ) + QChar( 176 ) + hemisphere; + return QString::number( std::fabs( value ), 'f', mGridAnnotationPrecision ) + QChar( 176 ) + hemisphere; } else { - return QString::number( fabs( value ), 'f', mGridAnnotationPrecision ) + hemisphere; + return QString::number( std::fabs( value ), 'f', mGridAnnotationPrecision ) + hemisphere; } } else if ( mGridAnnotationFormat == CustomFormat ) diff --git a/src/core/composer/qgscomposermousehandles.cpp b/src/core/composer/qgscomposermousehandles.cpp index 3e01aa20027..87f00616f1c 100644 --- a/src/core/composer/qgscomposermousehandles.cpp +++ b/src/core/composer/qgscomposermousehandles.cpp @@ -593,7 +593,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *event double diffY = mouseMoveStopPoint.y() - mMouseMoveStartPos.y(); //it was only a click - if ( fabs( diffX ) < std::numeric_limits::min() && fabs( diffY ) < std::numeric_limits::min() ) + if ( std::fabs( diffX ) < std::numeric_limits::min() && std::fabs( diffY ) < std::numeric_limits::min() ) { mIsDragging = false; mIsResizing = false; @@ -824,7 +824,7 @@ void QgsComposerMouseHandles::dragMouseMove( QPointF currentPosition, bool lockM { //constrained (shift) moving should lock to horizontal/vertical movement //reset the smaller of the x/y movements - if ( fabs( moveRectX ) <= fabs( moveRectY ) ) + if ( std::fabs( moveRectX ) <= std::fabs( moveRectY ) ) { moveRectX = 0; } @@ -1091,7 +1091,7 @@ void QgsComposerMouseHandles::resizeMouseMove( QPointF currentPosition, bool loc mResizeRect = QRectF( QPointF( -( mBeginHandleWidth + rx ), -( mBeginHandleHeight + ry ) ), QPointF( 0, 0 ) ); } - setRect( 0, 0, fabs( mBeginHandleWidth + rx ), fabs( mBeginHandleHeight + ry ) ); + setRect( 0, 0, std::fabs( mBeginHandleWidth + rx ), std::fabs( mBeginHandleHeight + ry ) ); //show current size of selection in status bar mComposition->setStatusMessage( QString( tr( "width: %1 mm height: %2 mm" ) ).arg( rect().width() ).arg( rect().height() ) ); @@ -1270,7 +1270,7 @@ QPointF QgsComposerMouseHandles::alignPos( QPointF pos, double &alignX, double & double alignThreshold = mComposition->snapTolerance() / viewScaleFactor; QPointF result( pos.x(), pos.y() ); - if ( fabs( nearestX - pos.x() ) < alignThreshold ) + if ( std::fabs( nearestX - pos.x() ) < alignThreshold ) { result.setX( nearestX ); alignX = nearestX; @@ -1280,7 +1280,7 @@ QPointF QgsComposerMouseHandles::alignPos( QPointF pos, double &alignX, double & alignX = -1; } - if ( fabs( nearestY - pos.y() ) < alignThreshold ) + if ( std::fabs( nearestY - pos.y() ) < alignThreshold ) { result.setY( nearestY ); alignY = nearestY; @@ -1359,7 +1359,7 @@ void QgsComposerMouseHandles::checkNearestItem( double checkCoord, const QMap< d return; } - double currentDiff = fabs( checkCoord - currentCoord ); + double currentDiff = std::fabs( checkCoord - currentCoord ); //convert snap tolerance from pixels to mm double viewScaleFactor = graphicsView()->transform().m11(); double alignThreshold = mComposition->snapTolerance() / viewScaleFactor; diff --git a/src/core/composer/qgscomposernodesitem.cpp b/src/core/composer/qgscomposernodesitem.cpp index e71ca769eec..fb2597f4d5a 100644 --- a/src/core/composer/qgscomposernodesitem.cpp +++ b/src/core/composer/qgscomposernodesitem.cpp @@ -77,7 +77,7 @@ bool QgsComposerNodesItem::addNode( QPointF pt, double distance = std::numeric_limits::max(); if ( qIsInf( coef ) ) - distance = fabs( pt1.x() - start.x() ); + distance = std::fabs( pt1.x() - start.x() ); else { const double coef2 = ( -1 / coef ); @@ -86,7 +86,7 @@ bool QgsComposerNodesItem::addNode( QPointF pt, QPointF inter; if ( qIsInf( coef2 ) ) { - distance = fabs( pt1.y() - start.y() ); + distance = std::fabs( pt1.y() - start.y() ); inter.setX( start.x() ); inter.setY( pt1.y() ); } @@ -104,7 +104,7 @@ bool QgsComposerNodesItem::addNode( QPointF pt, const double length3 = computeDistance( pt1, pt2 ); const double length4 = length1 + length2; - if ( fabs( length3 - length4 ) < std::numeric_limits::epsilon() ) + if ( std::fabs( length3 - length4 ) < std::numeric_limits::epsilon() ) distance = computeDistance( inter, start ); } diff --git a/src/core/composer/qgscomposerpicture.cpp b/src/core/composer/qgscomposerpicture.cpp index e7b3be32c45..c18c690063c 100644 --- a/src/core/composer/qgscomposerpicture.cpp +++ b/src/core/composer/qgscomposerpicture.cpp @@ -578,8 +578,8 @@ void QgsComposerPicture::setSceneRect( const QRectF &rectangle ) //if height has changed more than width, then fix width and set height correspondingly //else, do the opposite - if ( fabs( rect().width() - rectangle.width() ) < - fabs( rect().height() - rectangle.height() ) ) + if ( std::fabs( rect().width() - rectangle.width() ) < + std::fabs( rect().height() - rectangle.height() ) ) { newRect.setHeight( targetImageSize.height() * newRect.width() / targetImageSize.width() ); } diff --git a/src/core/composer/qgscomposerutils.cpp b/src/core/composer/qgscomposerutils.cpp index aaf1e2a87e7..737e2749ca8 100644 --- a/src/core/composer/qgscomposerutils.cpp +++ b/src/core/composer/qgscomposerutils.cpp @@ -189,8 +189,8 @@ QRectF QgsComposerUtils::largestRotatedRectWithinBounds( const QRectF &originalR double sinAngle = sin( angleRad ); //calculate size of bounds of rotated rectangle - double widthBoundsRotatedRect = originalWidth * fabs( cosAngle ) + originalHeight * fabs( sinAngle ); - double heightBoundsRotatedRect = originalHeight * fabs( cosAngle ) + originalWidth * fabs( sinAngle ); + double widthBoundsRotatedRect = originalWidth * std::fabs( cosAngle ) + originalHeight * std::fabs( sinAngle ); + double heightBoundsRotatedRect = originalHeight * std::fabs( cosAngle ) + originalWidth * std::fabs( sinAngle ); //compare ratio of rotated rect with bounds rect and calculate scaling of rotated //rect to fit within bounds @@ -221,9 +221,9 @@ QRectF QgsComposerUtils::largestRotatedRectWithinBounds( const QRectF &originalR //now calculate offset position of rotated rectangle double offsetX = ratioBoundsRotatedRect > ratioBoundsRect ? 0 : ( boundsWidth - rectScale * widthBoundsRotatedRect ) / 2.0; - offsetX += fabs( minX ); + offsetX += std::fabs( minX ); double offsetY = ratioBoundsRotatedRect > ratioBoundsRect ? ( boundsHeight - rectScale * heightBoundsRotatedRect ) / 2.0 : 0; - offsetY += fabs( minY ); + offsetY += std::fabs( minY ); return QRectF( offsetX, offsetY, rectScaledWidth, rectScaledHeight ); } diff --git a/src/core/composer/qgscomposition.cpp b/src/core/composer/qgscomposition.cpp index bd28d613518..bff1bfcf158 100644 --- a/src/core/composer/qgscomposition.cpp +++ b/src/core/composer/qgscomposition.cpp @@ -2047,12 +2047,12 @@ QPointF QgsComposition::snapPointToGrid( QPointF scenePoint ) const double viewScaleFactor = graphicsView()->transform().m11(); double alignThreshold = mSnapTolerance / viewScaleFactor; - if ( fabs( xSnapped - scenePoint.x() ) > alignThreshold ) + if ( std::fabs( xSnapped - scenePoint.x() ) > alignThreshold ) { //snap distance is outside of tolerance xSnapped = scenePoint.x(); } - if ( fabs( ySnapped - scenePoint.y() ) > alignThreshold ) + if ( std::fabs( ySnapped - scenePoint.y() ) > alignThreshold ) { //snap distance is outside of tolerance ySnapped = scenePoint.y(); diff --git a/src/core/dxf/qgsdxfpaintengine.cpp b/src/core/dxf/qgsdxfpaintengine.cpp index 68926fbb3a9..e6ea5bbd62d 100644 --- a/src/core/dxf/qgsdxfpaintengine.cpp +++ b/src/core/dxf/qgsdxfpaintengine.cpp @@ -262,7 +262,7 @@ double QgsDxfPaintEngine::power( double a, int b ) return 1; double tmp = a; - for ( int i = 2; i <= abs( b ); i++ ) + for ( int i = 2; i <= std::abs( b ); i++ ) a *= tmp; if ( b > 0 ) diff --git a/src/core/effects/qgsimageoperation.cpp b/src/core/effects/qgsimageoperation.cpp index 846675fe59c..0e229039c97 100644 --- a/src/core/effects/qgsimageoperation.cpp +++ b/src/core/effects/qgsimageoperation.cpp @@ -889,8 +889,8 @@ QRect QgsImageOperation::nonTransparentImageRect( const QImage &image, QSize min if ( center ) { // recompute min and max to center image - const int dx = qMax( abs( xmax - width / 2 ), abs( xmin - width / 2 ) ); - const int dy = qMax( abs( ymax - height / 2 ), abs( ymin - height / 2 ) ); + const int dx = qMax( std::abs( xmax - width / 2 ), std::abs( xmin - width / 2 ) ); + const int dy = qMax( std::abs( ymax - height / 2 ), std::abs( ymin - height / 2 ) ); xmin = qMax( 0, width / 2 - dx ); xmax = qMin( width, width / 2 + dx ); ymin = qMax( 0, height / 2 - dy ); diff --git a/src/core/expression/qgsexpressionfunction.cpp b/src/core/expression/qgsexpressionfunction.cpp index 268ced0c10a..32ea9e8d16d 100644 --- a/src/core/expression/qgsexpressionfunction.cpp +++ b/src/core/expression/qgsexpressionfunction.cpp @@ -241,7 +241,7 @@ static QVariant fcnSqrt( const QVariantList &values, const QgsExpressionContext static QVariant fcnAbs( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent ) { double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ); - return QVariant( fabs( val ) ); + return QVariant( std::fabs( val ) ); } static QVariant fcnRadians( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent ) @@ -1007,13 +1007,13 @@ static QVariant fcnWordwrap( const QVariantList &values, const QgsExpressionCont if ( strhit == lasthit || strhit == -1 ) { //if no new backward delimiter found, try to locate forward - strhit = lines[i].indexOf( rx, strcurrent + labs( wrap ) ); + strhit = lines[i].indexOf( rx, strcurrent + std::labs( wrap ) ); } lasthit = strhit; } else { - strhit = lines[i].indexOf( rx, strcurrent + labs( wrap ) ); + strhit = lines[i].indexOf( rx, strcurrent + std::labs( wrap ) ); } if ( strhit > -1 ) { @@ -2656,11 +2656,11 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte { if ( pt1->y() < pt2->y() ) { - return atan( fabs( pt1->x() - pt2->x() ) / fabs( pt1->y() - pt2->y() ) ); + return atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) ); } else /* ( pt1->y() > pt2->y() ) - equality case handled above */ { - return atan( fabs( pt1->y() - pt2->y() ) / fabs( pt1->x() - pt2->x() ) ) + return atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) ) + ( M_PI / 2 ); } } @@ -2669,12 +2669,12 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte { if ( pt1->y() > pt2->y() ) { - return atan( fabs( pt1->x() - pt2->x() ) / fabs( pt1->y() - pt2->y() ) ) + return atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) ) + M_PI; } else /* ( pt1->y() < pt2->y() ) - equality case handled above */ { - return atan( fabs( pt1->y() - pt2->y() ) / fabs( pt1->x() - pt2->x() ) ) + return atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) ) + ( M_PI + ( M_PI / 2 ) ); } } diff --git a/src/core/geometry/qgscircle.cpp b/src/core/geometry/qgscircle.cpp index d098f6c6a74..c65909d174d 100644 --- a/src/core/geometry/qgscircle.cpp +++ b/src/core/geometry/qgscircle.cpp @@ -52,24 +52,24 @@ static bool isPerpendicular( const QgsPoint &pt1, const QgsPoint &pt2, const Qgs double yDelta_b = pt3.y() - pt2.y(); double xDelta_b = pt3.x() - pt2.x(); - if ( ( fabs( xDelta_a ) <= epsilon ) && ( fabs( yDelta_b ) <= epsilon ) ) + if ( ( std::fabs( xDelta_a ) <= epsilon ) && ( std::fabs( yDelta_b ) <= epsilon ) ) { return false; } - if ( fabs( yDelta_a ) <= epsilon ) + if ( std::fabs( yDelta_a ) <= epsilon ) { return true; } - else if ( fabs( yDelta_b ) <= epsilon ) + else if ( std::fabs( yDelta_b ) <= epsilon ) { return true; } - else if ( fabs( xDelta_a ) <= epsilon ) + else if ( std::fabs( xDelta_a ) <= epsilon ) { return true; } - else if ( fabs( xDelta_b ) <= epsilon ) + else if ( std::fabs( xDelta_b ) <= epsilon ) { return true; } @@ -138,7 +138,7 @@ QgsCircle QgsCircle::from3Points( const QgsPoint &pt1, const QgsPoint &pt2, cons double aSlope = yDelta_a / xDelta_a; double bSlope = yDelta_b / xDelta_b; - if ( ( fabs( xDelta_a ) <= epsilon ) && ( fabs( yDelta_b ) <= epsilon ) ) + if ( ( std::fabs( xDelta_a ) <= epsilon ) && ( std::fabs( yDelta_b ) <= epsilon ) ) { center.setX( 0.5 * ( p2.x() + p3.x() ) ); center.setY( 0.5 * ( p1.y() + p2.y() ) ); @@ -147,7 +147,7 @@ QgsCircle QgsCircle::from3Points( const QgsPoint &pt1, const QgsPoint &pt2, cons return QgsCircle( center, radius ); } - if ( fabs( aSlope - bSlope ) <= epsilon ) + if ( std::fabs( aSlope - bSlope ) <= epsilon ) { return QgsCircle(); } @@ -191,8 +191,8 @@ QgsCircle QgsCircle::from3Tangents( const QgsPoint &pt1_tg1, const QgsPoint &pt2 QgsCircle QgsCircle::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) { - double delta_x = fabs( pt1.x() - pt2.x() ); - double delta_y = fabs( pt1.x() - pt2.y() ); + double delta_x = std::fabs( pt1.x() - pt2.x() ); + double delta_y = std::fabs( pt1.x() - pt2.y() ); if ( !qgsDoubleNear( delta_x, delta_y ) ) { return QgsCircle(); diff --git a/src/core/geometry/qgscircle.h b/src/core/geometry/qgscircle.h index 7a233c5a9a1..b15b9d4572c 100644 --- a/src/core/geometry/qgscircle.h +++ b/src/core/geometry/qgscircle.h @@ -133,7 +133,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse */ void setSemiMajorAxis( const double semiMajorAxis ) override { - mSemiMajorAxis = fabs( semiMajorAxis ); + mSemiMajorAxis = std::fabs( semiMajorAxis ); mSemiMinorAxis = mSemiMajorAxis; } @@ -143,7 +143,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse */ void setSemiMinorAxis( const double semiMinorAxis ) override { - mSemiMajorAxis = fabs( semiMinorAxis ); + mSemiMajorAxis = std::fabs( semiMinorAxis ); mSemiMinorAxis = mSemiMajorAxis; } @@ -152,7 +152,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse //! Set the radius of the circle void setRadius( double radius ) { - mSemiMajorAxis = fabs( radius ); + mSemiMajorAxis = std::fabs( radius ); mSemiMinorAxis = mSemiMajorAxis; } diff --git a/src/core/geometry/qgscurvepolygon.cpp b/src/core/geometry/qgscurvepolygon.cpp index 5e1e6d3a414..aef192cfd8c 100644 --- a/src/core/geometry/qgscurvepolygon.cpp +++ b/src/core/geometry/qgscurvepolygon.cpp @@ -370,7 +370,7 @@ double QgsCurvePolygon::area() const { double area = 0.0; mExteriorRing->sumUpArea( area ); - totalArea += fabs( area ); + totalArea += std::fabs( area ); } QList::const_iterator ringIt = mInteriorRings.constBegin(); @@ -380,7 +380,7 @@ double QgsCurvePolygon::area() const if ( ( *ringIt )->isRing() ) { ( *ringIt )->sumUpArea( area ); - totalArea -= fabs( area ); + totalArea -= std::fabs( area ); } } return totalArea; diff --git a/src/core/geometry/qgsellipse.cpp b/src/core/geometry/qgsellipse.cpp index 3414c6a7969..16e843324a7 100644 --- a/src/core/geometry/qgsellipse.cpp +++ b/src/core/geometry/qgsellipse.cpp @@ -25,8 +25,8 @@ void QgsEllipse::normalizeAxis() { - mSemiMajorAxis = fabs( mSemiMajorAxis ); - mSemiMinorAxis = fabs( mSemiMinorAxis ); + mSemiMajorAxis = std::fabs( mSemiMajorAxis ); + mSemiMinorAxis = std::fabs( mSemiMinorAxis ); if ( mSemiMajorAxis < mSemiMinorAxis ) { std::swap( mSemiMajorAxis, mSemiMinorAxis ); @@ -72,8 +72,8 @@ QgsEllipse QgsEllipse::fromFoci( const QgsPoint &pt1, const QgsPoint &pt2, const QgsEllipse QgsEllipse::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) { QgsPoint center = QgsGeometryUtils::midpoint( pt1, pt2 ); - double axis_a = fabs( pt2.x() - pt1.x() ) / 2.0; - double axis_b = fabs( pt2.y() - pt1.y() ) / 2.0; + double axis_a = std::fabs( pt2.x() - pt1.x() ) / 2.0; + double axis_b = std::fabs( pt2.y() - pt1.y() ) / 2.0; double azimuth = 90.0; return QgsEllipse( center, axis_a, axis_b, azimuth ); @@ -81,8 +81,8 @@ QgsEllipse QgsEllipse::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) QgsEllipse QgsEllipse::fromCenterPoint( const QgsPoint ¢er, const QgsPoint &pt1 ) { - double axis_a = fabs( pt1.x() - center.x() ); - double axis_b = fabs( pt1.y() - center.y() ); + double axis_a = std::fabs( pt1.x() - center.x() ); + double axis_b = std::fabs( pt1.y() - center.y() ); double azimuth = 90.0; return QgsEllipse( center, axis_a, axis_b, azimuth ); diff --git a/src/core/geometry/qgsgeometry.cpp b/src/core/geometry/qgsgeometry.cpp index 920fffed53f..95ed2a5e49e 100644 --- a/src/core/geometry/qgsgeometry.cpp +++ b/src/core/geometry/qgsgeometry.cpp @@ -2558,7 +2558,7 @@ QgsLineString *smoothCurve( const QgsLineString &line, const unsigned int iterat QgsPoint p3 = result->pointN( 1 ); double angle = QgsGeometryUtils::angleBetweenThreePoints( p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y() ); - angle = fabs( M_PI - angle ); + angle = std::fabs( M_PI - angle ); skipFirst = angle > maxAngleRads; } for ( int i = 0; i < result->numPoints() - 1; i++ ) diff --git a/src/core/geometry/qgsgeometryutils.cpp b/src/core/geometry/qgsgeometryutils.cpp index 41f78739346..4adb92da691 100644 --- a/src/core/geometry/qgsgeometryutils.cpp +++ b/src/core/geometry/qgsgeometryutils.cpp @@ -468,7 +468,7 @@ void QgsGeometryUtils::circleCenterRadius( const QgsPoint &pt1, const QgsPoint & d = 2 * ( dx21 * dy31 - dx31 * dy21 ); // Check colinearity, Cross product = 0 - if ( qgsDoubleNear( fabs( d ), 0.0, 0.00000000001 ) ) + if ( qgsDoubleNear( std::fabs( d ), 0.0, 0.00000000001 ) ) { radius = -1.0; return; diff --git a/src/core/geometry/qgsgeos.cpp b/src/core/geometry/qgsgeos.cpp index c610bee2dfd..2893a7c161a 100644 --- a/src/core/geometry/qgsgeos.cpp +++ b/src/core/geometry/qgsgeos.cpp @@ -2705,12 +2705,12 @@ int QgsGeos::geomDigits( const GEOSGeometry *geom ) GEOSCoordSeq_getX_r( geosinit.ctxt, bBoxCoordSeq, i, &t ); int digits; - digits = ceil( log10( fabs( t ) ) ); + digits = ceil( log10( std::fabs( t ) ) ); if ( digits > maxDigits ) maxDigits = digits; GEOSCoordSeq_getY_r( geosinit.ctxt, bBoxCoordSeq, i, &t ); - digits = ceil( log10( fabs( t ) ) ); + digits = ceil( log10( std::fabs( t ) ) ); if ( digits > maxDigits ) maxDigits = digits; } diff --git a/src/core/geometry/qgsinternalgeometryengine.cpp b/src/core/geometry/qgsinternalgeometryengine.cpp index b69991b6e6a..c6b8261d0ec 100644 --- a/src/core/geometry/qgsinternalgeometryengine.cpp +++ b/src/core/geometry/qgsinternalgeometryengine.cpp @@ -290,7 +290,7 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision, bool dotProductWithinAngleTolerance( double dotProduct, double lowerThreshold, double upperThreshold ) { - return lowerThreshold > fabs( dotProduct ) || fabs( dotProduct ) > upperThreshold; + return lowerThreshold > std::fabs( dotProduct ) || std::fabs( dotProduct ) > upperThreshold; } double normalizedDotProduct( const QgsPoint &a, const QgsPoint &b, const QgsPoint &c ) @@ -341,7 +341,7 @@ double squareness( QgsLineString *ring, double lowerThreshold, double upperThres if ( !dotProductWithinAngleTolerance( dotProduct, lowerThreshold, upperThreshold ) ) continue; - sum += 2.0 * qMin( fabs( dotProduct - 1.0 ), qMin( fabs( dotProduct ), fabs( dotProduct + 1 ) ) ); + sum += 2.0 * qMin( std::fabs( dotProduct - 1.0 ), qMin( std::fabs( dotProduct ), std::fabs( dotProduct + 1 ) ) ); } a = b; b = c; diff --git a/src/core/geometry/qgsregularpolygon.cpp b/src/core/geometry/qgsregularpolygon.cpp index ef2db585517..36bc799d8c1 100644 --- a/src/core/geometry/qgsregularpolygon.cpp +++ b/src/core/geometry/qgsregularpolygon.cpp @@ -46,13 +46,13 @@ QgsRegularPolygon::QgsRegularPolygon( const QgsPoint ¢er, const double radiu { case InscribedCircle: { - mRadius = fabs( radius ); + mRadius = std::fabs( radius ); mFirstVertex = mCenter.project( mRadius, azimuth ); break; } case CircumscribedCircle: { - mRadius = apothemToRadius( fabs( radius ), numSides ); + mRadius = apothemToRadius( std::fabs( radius ), numSides ); mFirstVertex = mCenter.project( mRadius, azimuth - centralAngle( numSides ) / 2 ); break; } @@ -118,7 +118,7 @@ QgsRegularPolygon::QgsRegularPolygon( const QgsPoint &pt1, const QgsPoint &pt2, mCenter = pt1.project( hypothenuse, azimuth + angle ); mFirstVertex = pt1; - mRadius = fabs( hypothenuse ); + mRadius = std::fabs( hypothenuse ); } } @@ -152,7 +152,7 @@ void QgsRegularPolygon::setCenter( const QgsPoint ¢er ) void QgsRegularPolygon::setRadius( const double radius ) { - mRadius = fabs( radius ); + mRadius = std::fabs( radius ); double azimuth = mCenter.azimuth( mFirstVertex ); // TODO: double inclination = mCenter.inclination(mFirstVertex); mFirstVertex = mCenter.project( mRadius, azimuth ); diff --git a/src/core/layout/qgslayoutsnapper.cpp b/src/core/layout/qgslayoutsnapper.cpp index 0e307b66a5d..dc1f7425d5a 100644 --- a/src/core/layout/qgslayoutsnapper.cpp +++ b/src/core/layout/qgslayoutsnapper.cpp @@ -89,7 +89,7 @@ QPointF QgsLayoutSnapper::snapPointToGrid( QPointF point, double scaleFactor, bo //convert snap tolerance from pixels to layout units double alignThreshold = mTolerance / scaleFactor; - if ( fabs( xSnapped - point.x() ) > alignThreshold ) + if ( std::fabs( xSnapped - point.x() ) > alignThreshold ) { //snap distance is outside of tolerance xSnapped = point.x(); @@ -98,7 +98,7 @@ QPointF QgsLayoutSnapper::snapPointToGrid( QPointF point, double scaleFactor, bo { snappedX = true; } - if ( fabs( ySnapped - point.y() ) > alignThreshold ) + if ( std::fabs( ySnapped - point.y() ) > alignThreshold ) { //snap distance is outside of tolerance ySnapped = point.y(); @@ -128,7 +128,7 @@ double QgsLayoutSnapper::snapPointToGuides( double original, QgsLayoutGuide::Ori Q_FOREACH ( QgsLayoutGuide *guide, mLayout->guides().guides( orientation ) ) { double guidePos = guide->layoutPosition(); - double diff = fabs( original - guidePos ); + double diff = std::fabs( original - guidePos ); if ( diff < smallestDiff ) { smallestDiff = diff; diff --git a/src/core/pal/feature.cpp b/src/core/pal/feature.cpp index 9c2c70e2962..73f423dd799 100644 --- a/src/core/pal/feature.cpp +++ b/src/core/pal/feature.cpp @@ -720,7 +720,7 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList 1 (lower for longer segments) - double segmentAngleCost = 1 - fabs( fmod( currentSegmentAngle, M_PI ) - M_PI_2 ) / M_PI_2; // 0 -> 1, lower for more horizontal segments + double segmentAngleCost = 1 - std::fabs( fmod( currentSegmentAngle, M_PI ) - M_PI_2 ) / M_PI_2; // 0 -> 1, lower for more horizontal segments while ( currentDistanceAlongLine + labelWidth < distanceToEndOfSegment ) { @@ -745,7 +745,7 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList 1 + double costCenter = 2 * std::fabs( labelCenter - distanceToCenterOfSegment ) / ( distanceToEndOfSegment - distanceToStartOfSegment ); // 0 -> 1 cost += costCenter * 0.0005; // < 0, 0.0005 > if ( !closedLine ) @@ -753,7 +753,7 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList 1 + double costLineCenter = 2 * std::fabs( labelCenter - middleOfLine ) / totalLineLength; // 0 -> 1 cost += costLineCenter * 0.0005; // < 0, 0.0005 > } @@ -901,7 +901,7 @@ int FeaturePart::createCandidatesAlongLineNearMidpoint( QList & } // penalize positions which are further from the line's midpoint - double costCenter = fabs( totalLineLength / 2 - ( currentDistanceAlongLine + labelWidth / 2 ) ) / totalLineLength; // <0, 0.5> + double costCenter = std::fabs( totalLineLength / 2 - ( currentDistanceAlongLine + labelWidth / 2 ) ) / totalLineLength; // <0, 0.5> cost += costCenter / 1000; // < 0, 0.0005 > cost += initialCost; @@ -1223,7 +1223,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos { if ( tmp != slp ) // not first? { - diff = fabs( tmp->getAlpha() - angle_last ); + diff = std::fabs( tmp->getAlpha() - angle_last ); if ( diff > 2 * M_PI ) diff -= 2 * M_PI; diff = qMin( diff, 2 * M_PI - diff ); // difference 350 deg is actually just 10 deg... angle_diff += diff; @@ -1241,7 +1241,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos // penalize positions which are further from the line's midpoint double labelCenter = i + getLabelWidth() / 2; - double costCenter = fabs( total_distance / 2 - labelCenter ) / total_distance; // <0, 0.5> + double costCenter = std::fabs( total_distance / 2 - labelCenter ) / total_distance; // <0, 0.5> cost += costCenter / 1000; // < 0, 0.0005 > slp->setCost( cost ); diff --git a/src/core/pal/pointset.cpp b/src/core/pal/pointset.cpp index 27a640fb5e5..8a0939462e5 100644 --- a/src/core/pal/pointset.cpp +++ b/src/core/pal/pointset.cpp @@ -371,9 +371,9 @@ void PointSet::splitPolygons( QLinkedList &shapes_toProcess, // lookup for the deepest point in the hole for ( i = ips; i != cHull[ihn]; i = ( i + 1 ) % nbp ) { - cp = fabs( GeomFunction::cross_product( x[cHull[ihs]], y[cHull[ihs]], - x[cHull[ihn]], y[cHull[ihn]], - x[i], y[i] ) ); + cp = std::fabs( GeomFunction::cross_product( x[cHull[ihs]], y[cHull[ihs]], + x[cHull[ihn]], y[cHull[ihn]], + x[i], y[i] ) ); if ( cp - bestcp > EPSILON ) { bestcp = cp; @@ -444,7 +444,7 @@ void PointSet::splitPolygons( QLinkedList &shapes_toProcess, fx = cx + dx; fy = cy - dy; - if ( seg_length < EPSILON || fabs( ( b = GeomFunction::cross_product( ex, ey, fx, fy, x[retainedPt], y[retainedPt] ) / ( seg_length ) ) ) > ( seg_length / 2 ) ) // retainedPt is not fronting i->j + if ( seg_length < EPSILON || std::fabs( ( b = GeomFunction::cross_product( ex, ey, fx, fy, x[retainedPt], y[retainedPt] ) / ( seg_length ) ) ) > ( seg_length / 2 ) ) // retainedPt is not fronting i->j { if ( ( ex = GeomFunction::dist_euc2d_sq( x[i], y[i], x[retainedPt], y[retainedPt] ) ) < ( ey = GeomFunction::dist_euc2d_sq( x[j], y[j], x[retainedPt], y[retainedPt] ) ) ) { diff --git a/src/core/qgsclipper.h b/src/core/qgsclipper.h index e967b376a0b..4f7e906293a 100644 --- a/src/core/qgsclipper.h +++ b/src/core/qgsclipper.h @@ -395,7 +395,7 @@ inline QgsPointXY QgsClipper::intersect( const double x1, const double y1, QgsPointXY p; - if ( fabs( r_d ) > SMALL_NUM && fabs( r_n ) > SMALL_NUM ) + if ( std::fabs( r_d ) > SMALL_NUM && std::fabs( r_n ) > SMALL_NUM ) { // they cross double r = r_n / r_d; @@ -405,7 +405,7 @@ inline QgsPointXY QgsClipper::intersect( const double x1, const double y1, { // Should never get here, but if we do for some reason, cause a // clunk because something else is wrong if we do. - Q_ASSERT( fabs( r_d ) > SMALL_NUM && fabs( r_n ) > SMALL_NUM ); + Q_ASSERT( std::fabs( r_d ) > SMALL_NUM && std::fabs( r_n ) > SMALL_NUM ); } return p; diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index 653647a1596..c5da999aaee 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -1164,7 +1164,7 @@ void QgsCoordinateReferenceSystem::setMapUnits() static const double FEET_TO_METER = 0.3048; static const double SMALL_NUM = 1e-3; - if ( fabs( toMeter - FEET_TO_METER ) < SMALL_NUM ) + if ( std::fabs( toMeter - FEET_TO_METER ) < SMALL_NUM ) unit = QStringLiteral( "Foot" ); if ( qgsDoubleNear( toMeter, 1.0 ) ) //Unit name for meters would be "metre" diff --git a/src/core/qgsdistancearea.cpp b/src/core/qgsdistancearea.cpp index 7bcb21b3b07..9c517de33cc 100644 --- a/src/core/qgsdistancearea.cpp +++ b/src/core/qgsdistancearea.cpp @@ -442,7 +442,7 @@ QgsPointXY QgsDistanceArea::computeSpheroidProject( sigma = ( distance / ( b * A ) ) + delta_sigma; i++; } - while ( i < 999 && fabs( ( last_sigma - sigma ) / sigma ) > 1.0e-9 ); + while ( i < 999 && std::fabs( ( last_sigma - sigma ) / sigma ) > 1.0e-9 ); lat2 = atan2( ( sin( u1 ) * cos( sigma ) + cos( u1 ) * sin( sigma ) * cos( azimuth ) ), ( omf * sqrt( POW2( sin_alpha ) + @@ -571,7 +571,7 @@ double QgsDistanceArea::computeDistanceBearing( double tu2 = 0; int iterLimit = 20; - while ( fabs( lambda - lambdaP ) > 1e-12 && --iterLimit > 0 ) + while ( std::fabs( lambda - lambdaP ) > 1e-12 && --iterLimit > 0 ) { sinLambda = sin( lambda ); cosLambda = cos( lambda ); @@ -741,7 +741,7 @@ double QgsDistanceArea::computePolygonArea( const QList &points ) co dx = x2 - x1; dy = y2 - y1; - if ( fabs( dy ) > thresh ) + if ( std::fabs( dy ) > thresh ) { /* account for different latitudes y1, y2 */ area += dx * ( m_Qp - ( Qbar2 - Qbar1 ) / dy ); diff --git a/src/core/qgsmaprendererjob.cpp b/src/core/qgsmaprendererjob.cpp index 7aba351c4c4..8a1dded3106 100644 --- a/src/core/qgsmaprendererjob.cpp +++ b/src/core/qgsmaprendererjob.cpp @@ -134,12 +134,12 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs QgsDebugMsgLevel( QString( "\n0:%1 %2x%3\n1:%4\n2:%5 %6x%7 (w:%8 h:%9)" ) .arg( extent.toString() ).arg( extent.width() ).arg( extent.height() ) .arg( extent1.toString(), extent2.toString() ).arg( extent2.width() ).arg( extent2.height() ) - .arg( fabs( 1.0 - extent2.width() / extent.width() ) ) - .arg( fabs( 1.0 - extent2.height() / extent.height() ) ) + .arg( std::fabs( 1.0 - extent2.width() / extent.width() ) ) + .arg( std::fabs( 1.0 - extent2.height() / extent.height() ) ) , 3 ); - if ( fabs( 1.0 - extent2.width() / extent.width() ) < 0.5 && - fabs( 1.0 - extent2.height() / extent.height() ) < 0.5 ) + if ( std::fabs( 1.0 - extent2.width() / extent.width() ) < 0.5 && + std::fabs( 1.0 - extent2.height() / extent.height() ) < 0.5 ) { extent = extent1; } diff --git a/src/core/qgsmapsettings.cpp b/src/core/qgsmapsettings.cpp index 3919741956a..34ab9638260 100644 --- a/src/core/qgsmapsettings.cpp +++ b/src/core/qgsmapsettings.cpp @@ -143,8 +143,8 @@ void QgsMapSettings::updateDerived() { // Use abs() on the extent to avoid the case where the extent is // symmetrical about 0. - double xMean = ( fabs( extent.xMinimum() ) + fabs( extent.xMaximum() ) ) * 0.5; - double yMean = ( fabs( extent.yMinimum() ) + fabs( extent.yMaximum() ) ) * 0.5; + double xMean = ( std::fabs( extent.xMinimum() ) + std::fabs( extent.xMaximum() ) ) * 0.5; + double yMean = ( std::fabs( extent.yMinimum() ) + std::fabs( extent.yMaximum() ) ) * 0.5; double xRange = extent.width() / xMean; double yRange = extent.height() / yMean; diff --git a/src/core/qgspallabeling.cpp b/src/core/qgspallabeling.cpp index f18b0dad51f..c90695ecfc6 100644 --- a/src/core/qgspallabeling.cpp +++ b/src/core/qgspallabeling.cpp @@ -1171,8 +1171,8 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, QString t #if 0 // XXX strk QgsPointXY ptSize = xform->toMapCoordinatesF( w, h ); - labelX = fabs( ptSize.x() - ptZero.x() ); - labelY = fabs( ptSize.y() - ptZero.y() ); + labelX = std::fabs( ptSize.x() - ptZero.x() ); + labelY = std::fabs( ptSize.y() - ptZero.y() ); #else double uPP = xform->mapUnitsPerPixel(); labelX = w * uPP; @@ -1224,7 +1224,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont // scales closer than 1:1 if ( maxScale < 0 ) { - maxScale = 1 / fabs( maxScale ); + maxScale = 1 / std::fabs( maxScale ); } if ( !qgsDoubleNear( maxScale, 0.0 ) && context.rendererScale() < maxScale ) @@ -1239,7 +1239,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont // scales closer than 1:1 if ( minScale < 0 ) { - minScale = 1 / fabs( minScale ); + minScale = 1 / std::fabs( minScale ); } if ( !qgsDoubleNear( minScale, 0.0 ) && context.rendererScale() > minScale ) @@ -1436,7 +1436,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont } } // make sure maxcharangleout is always negative - maxcharangleout = -( fabs( maxcharangleout ) ); + maxcharangleout = -( std::fabs( maxcharangleout ) ); } // data defined centroid whole or clipped? diff --git a/src/core/qgspointxy.cpp b/src/core/qgspointxy.cpp index 6a85e7a1dd5..d9489f3e9bb 100644 --- a/src/core/qgspointxy.cpp +++ b/src/core/qgspointxy.cpp @@ -84,13 +84,13 @@ QString QgsPointXY::toDegreesMinutesSeconds( int precision, const bool useSuffix myWrappedY = myWrappedY + 180.0; } - int myDegreesX = int( fabs( myWrappedX ) ); - double myFloatMinutesX = double( ( fabs( myWrappedX ) - myDegreesX ) * 60 ); + int myDegreesX = int( std::fabs( myWrappedX ) ); + double myFloatMinutesX = double( ( std::fabs( myWrappedX ) - myDegreesX ) * 60 ); int myIntMinutesX = int( myFloatMinutesX ); double mySecondsX = double( myFloatMinutesX - myIntMinutesX ) * 60; - int myDegreesY = int( fabs( myWrappedY ) ); - double myFloatMinutesY = double( ( fabs( myWrappedY ) - myDegreesY ) * 60 ); + int myDegreesY = int( std::fabs( myWrappedY ) ); + double myFloatMinutesY = double( ( std::fabs( myWrappedY ) - myDegreesY ) * 60 ); int myIntMinutesY = int( myFloatMinutesY ); double mySecondsY = double( myFloatMinutesY - myIntMinutesY ) * 60; @@ -186,11 +186,11 @@ QString QgsPointXY::toDegreesMinutes( int precision, const bool useSuffix, const myWrappedX = myWrappedX + 360.0; } - int myDegreesX = int( fabs( myWrappedX ) ); - double myFloatMinutesX = double( ( fabs( myWrappedX ) - myDegreesX ) * 60 ); + int myDegreesX = int( std::fabs( myWrappedX ) ); + double myFloatMinutesX = double( ( std::fabs( myWrappedX ) - myDegreesX ) * 60 ); - int myDegreesY = int( fabs( mY ) ); - double myFloatMinutesY = double( ( fabs( mY ) - myDegreesY ) * 60 ); + int myDegreesY = int( std::fabs( mY ) ); + double myFloatMinutesY = double( ( std::fabs( mY ) - myDegreesY ) * 60 ); //make sure rounding to specified precision doesn't create minutes >= 60 if ( std::round( myFloatMinutesX * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) ) diff --git a/src/core/qgsrenderchecker.cpp b/src/core/qgsrenderchecker.cpp index 93d2a1b47c0..66f4c29b55f 100644 --- a/src/core/qgsrenderchecker.cpp +++ b/src/core/qgsrenderchecker.cpp @@ -381,8 +381,8 @@ bool QgsRenderChecker::compareImages( const QString &testName, { qDebug( "Test image and result image for %s are different dimensions", testName.toLocal8Bit().constData() ); - if ( abs( myExpectedImage.width() - myResultImage.width() ) > mMaxSizeDifferenceX || - abs( myExpectedImage.height() - myResultImage.height() ) > mMaxSizeDifferenceY ) + if ( std::abs( myExpectedImage.width() - myResultImage.width() ) > mMaxSizeDifferenceX || + std::abs( myExpectedImage.height() - myResultImage.height() ) > mMaxSizeDifferenceY ) { mReport += QLatin1String( "" ); mReport += "Expected image and result image for " + testName + " are different dimensions - FAILING!"; @@ -438,10 +438,10 @@ bool QgsRenderChecker::compareImages( const QString &testName, } else { - if ( abs( qRed( myExpectedPixel ) - qRed( myActualPixel ) ) > pixelTolerance || - abs( qGreen( myExpectedPixel ) - qGreen( myActualPixel ) ) > pixelTolerance || - abs( qBlue( myExpectedPixel ) - qBlue( myActualPixel ) ) > pixelTolerance || - abs( qAlpha( myExpectedPixel ) - qAlpha( myActualPixel ) ) > pixelTolerance ) + if ( std::abs( qRed( myExpectedPixel ) - qRed( myActualPixel ) ) > pixelTolerance || + std::abs( qGreen( myExpectedPixel ) - qGreen( myActualPixel ) ) > pixelTolerance || + std::abs( qBlue( myExpectedPixel ) - qBlue( myActualPixel ) ) > pixelTolerance || + std::abs( qAlpha( myExpectedPixel ) - qAlpha( myActualPixel ) ) > pixelTolerance ) { ++mMismatchCount; diffScanline[ x ] = qRgb( 255, 0, 0 ); diff --git a/src/core/qgstestutils.h b/src/core/qgstestutils.h index 1d38a7c576c..c81ccd4d23f 100644 --- a/src/core/qgstestutils.h +++ b/src/core/qgstestutils.h @@ -29,7 +29,7 @@ bool _xxxresult = qgsDoubleNear( value, expected, epsilon ); \ if ( !_xxxresult ) \ { \ - qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( expected ), static_cast< double >( value ), fabs( static_cast< double >( expected ) - value ), static_cast< double >( epsilon ) ); \ + qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( expected ), static_cast< double >( value ), std::fabs( static_cast< double >( expected ) - value ), static_cast< double >( epsilon ) ); \ } \ QVERIFY( qgsDoubleNear( value, expected, epsilon ) ); \ } @@ -38,7 +38,7 @@ bool _xxxresult = qgsDoubleNear( value, not_expected, epsilon ); \ if ( _xxxresult ) \ { \ - qDebug( "Expecting %f to be differerent from %f (diff %f > %f)", static_cast< double >( value ), static_cast< double >( not_expected ), fabs( static_cast< double >( not_expected ) - value ), static_cast< double >( epsilon ) ); \ + qDebug( "Expecting %f to be differerent from %f (diff %f > %f)", static_cast< double >( value ), static_cast< double >( not_expected ), std::fabs( static_cast< double >( not_expected ) - value ), static_cast< double >( epsilon ) ); \ } \ QVERIFY( !qgsDoubleNear( value, not_expected, epsilon ) ); \ } diff --git a/src/core/qgstracer.cpp b/src/core/qgstracer.cpp index 1c6e54f2f6a..16ce217e1af 100644 --- a/src/core/qgstracer.cpp +++ b/src/core/qgstracer.cpp @@ -264,7 +264,7 @@ int point2vertex( const QgsTracerGraph &g, const QgsPointXY &pt, double epsilon for ( int i = 0; i < g.v.count(); ++i ) { const QgsTracerGraph::V &v = g.v.at( i ); - if ( v.pt == pt || ( fabs( v.pt.x() - pt.x() ) < epsilon && fabs( v.pt.y() - pt.y() ) < epsilon ) ) + if ( v.pt == pt || ( std::fabs( v.pt.x() - pt.x() ) < epsilon && std::fabs( v.pt.y() - pt.y() ) < epsilon ) ) return i; } diff --git a/src/core/qgsunittypes.cpp b/src/core/qgsunittypes.cpp index 471d2f51619..9e4ae8e7a63 100644 --- a/src/core/qgsunittypes.cpp +++ b/src/core/qgsunittypes.cpp @@ -1383,17 +1383,17 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn result.value = qgsRound( distance, decimals ); result.unit = QgsUnitTypes::DistanceMeters; } - else if ( fabs( distance ) > 1000.0 ) + else if ( std::fabs( distance ) > 1000.0 ) { result.value = qgsRound( distance / 1000, decimals ); result.unit = QgsUnitTypes::DistanceKilometers; } - else if ( fabs( distance ) < 0.01 ) + else if ( std::fabs( distance ) < 0.01 ) { result.value = qgsRound( distance * 1000, decimals ); result.unit = QgsUnitTypes::DistanceMillimeters; } - else if ( fabs( distance ) < 0.1 ) + else if ( std::fabs( distance ) < 0.1 ) { result.value = qgsRound( distance * 100, decimals ); @@ -1407,7 +1407,7 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn break; case DistanceKilometers: - if ( keepBaseUnit || fabs( distance ) >= 1.0 ) + if ( keepBaseUnit || std::fabs( distance ) >= 1.0 ) { result.value = qgsRound( distance, decimals ); result.unit = QgsUnitTypes::DistanceKilometers; @@ -1420,7 +1420,7 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn break; case DistanceFeet: - if ( fabs( distance ) <= 5280.0 || keepBaseUnit ) + if ( std::fabs( distance ) <= 5280.0 || keepBaseUnit ) { result.value = qgsRound( distance, decimals ); result.unit = QgsUnitTypes::DistanceFeet; @@ -1433,7 +1433,7 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn break; case DistanceYards: - if ( fabs( distance ) <= 1760.0 || keepBaseUnit ) + if ( std::fabs( distance ) <= 1760.0 || keepBaseUnit ) { result.value = qgsRound( distance, decimals ); result.unit = QgsUnitTypes::DistanceYards; @@ -1446,7 +1446,7 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn break; case DistanceMiles: - if ( fabs( distance ) >= 1.0 || keepBaseUnit ) + if ( std::fabs( distance ) >= 1.0 || keepBaseUnit ) { result.value = qgsRound( distance, decimals ); result.unit = QgsUnitTypes::DistanceMiles; @@ -1531,12 +1531,12 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are result.value = qgsRound( area, decimals ); result.unit = QgsUnitTypes::AreaSquareMeters; } - else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareKilometers, QgsUnitTypes::AreaSquareMeters ) ) + else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareKilometers, QgsUnitTypes::AreaSquareMeters ) ) { result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMeters, QgsUnitTypes::AreaSquareKilometers ), decimals ); result.unit = QgsUnitTypes::AreaSquareKilometers; } - else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaHectares, QgsUnitTypes::AreaSquareMeters ) ) + else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaHectares, QgsUnitTypes::AreaSquareMeters ) ) { result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMeters, QgsUnitTypes::AreaHectares ), decimals ); result.unit = QgsUnitTypes::AreaHectares; @@ -1563,7 +1563,7 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are result.value = qgsRound( area, decimals ); result.unit = QgsUnitTypes::AreaSquareFeet; } - else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaSquareFeet ) ) + else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaSquareFeet ) ) { result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareFeet, QgsUnitTypes::AreaSquareMiles ), decimals ); result.unit = QgsUnitTypes::AreaSquareMiles; @@ -1583,7 +1583,7 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are result.value = qgsRound( area, decimals ); result.unit = QgsUnitTypes::AreaSquareYards; } - else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaSquareYards ) ) + else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaSquareYards ) ) { result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareYards, QgsUnitTypes::AreaSquareMiles ), decimals ); result.unit = QgsUnitTypes::AreaSquareMiles; @@ -1610,7 +1610,7 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are result.value = qgsRound( area, decimals ); result.unit = QgsUnitTypes::AreaHectares; } - else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareKilometers, QgsUnitTypes::AreaHectares ) ) + else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareKilometers, QgsUnitTypes::AreaHectares ) ) { result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaHectares, QgsUnitTypes::AreaSquareKilometers ), decimals ); result.unit = QgsUnitTypes::AreaSquareKilometers; @@ -1630,7 +1630,7 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are result.value = qgsRound( area, decimals ); result.unit = QgsUnitTypes::AreaAcres; } - else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaAcres ) ) + else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaAcres ) ) { result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaAcres, QgsUnitTypes::AreaSquareMiles ), decimals ); result.unit = QgsUnitTypes::AreaSquareMiles; diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index 1c24ec469e9..7afd65dfea4 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -2472,7 +2472,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer *layer, { QVariant min = layer->minimumValue( i ); QVariant max = layer->maximumValue( i ); - if ( qMax( llabs( min.toLongLong() ), llabs( max.toLongLong() ) ) < INT_MAX ) + if ( qMax( std::llabs( min.toLongLong() ), std::llabs( max.toLongLong() ) ) < INT_MAX ) { fields[i].setType( QVariant::Int ); } diff --git a/src/core/qgsvectorlayerlabeling.cpp b/src/core/qgsvectorlayerlabeling.cpp index 74f2770720f..44b1286b035 100644 --- a/src/core/qgsvectorlayerlabeling.cpp +++ b/src/core/qgsvectorlayerlabeling.cpp @@ -465,7 +465,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap & if ( mSettings->maxCurvedCharAngleIn > 0 || mSettings->maxCurvedCharAngleOut > 0 ) { // SLD has no notion for this, the GeoTools ecosystem can only do a single angle - double angle = qMin( fabs( mSettings->maxCurvedCharAngleIn ), fabs( mSettings->maxCurvedCharAngleOut ) ); + double angle = qMin( std::fabs( mSettings->maxCurvedCharAngleIn ), std::fabs( mSettings->maxCurvedCharAngleOut ) ); QDomElement vo = QgsSymbolLayerUtils::createVendorOptionElement( doc, QStringLiteral( "maxAngleDelta" ), qgsDoubleToString( angle ) ); textSymbolizerElement.appendChild( vo ); } diff --git a/src/core/raster/qgscolorrampshader.cpp b/src/core/raster/qgscolorrampshader.cpp index 99e7a88c213..485728bd816 100644 --- a/src/core/raster/qgscolorrampshader.cpp +++ b/src/core/raster/qgscolorrampshader.cpp @@ -285,7 +285,7 @@ void QgsColorRampShader::classifyColorRamp( const int classes, const int band, c QVector::const_iterator color_it = entryColors.begin(); // calculate a reasonable number of decimals to display - double maxabs = log10( qMax( fabs( max ), fabs( min ) ) ); + double maxabs = log10( qMax( std::fabs( max ), std::fabs( min ) ) ); int nDecimals = std::round( qMax( 3.0 + maxabs - log10( max - min ), maxabs <= 15.0 ? maxabs + 0.49 : 0.0 ) ); QList colorRampItems; diff --git a/src/core/raster/qgsrasterchecker.cpp b/src/core/raster/qgsrasterchecker.cpp index 8d47800bb89..a9806fb8cf4 100644 --- a/src/core/raster/qgsrasterchecker.cpp +++ b/src/core/raster/qgsrasterchecker.cpp @@ -203,7 +203,7 @@ double QgsRasterChecker::tolerance( double val, int places ) { // float precision is about 7 decimal digits, double about 16 // default places = 6 - return 1. * qPow( 10, std::round( log10( fabs( val ) ) - places ) ); + return 1. * qPow( 10, std::round( log10( std::fabs( val ) ) - places ) ); } QString QgsRasterChecker::compareHead() @@ -224,7 +224,7 @@ void QgsRasterChecker::compare( const QString ¶mName, int verifiedVal, int e bool QgsRasterChecker::compare( double verifiedVal, double expectedVal, double tolerance ) { // values may be nan - return ( qIsNaN( verifiedVal ) && qIsNaN( expectedVal ) ) || ( fabs( verifiedVal - expectedVal ) <= tolerance ); + return ( qIsNaN( verifiedVal ) && qIsNaN( expectedVal ) ) || ( std::fabs( verifiedVal - expectedVal ) <= tolerance ); } void QgsRasterChecker::compare( const QString ¶mName, double verifiedVal, double expectedVal, QString &report, bool &ok, double tolerance ) diff --git a/src/core/raster/qgsrasterminmaxorigin.cpp b/src/core/raster/qgsrasterminmaxorigin.cpp index 8d476a73dc4..5a126d37378 100644 --- a/src/core/raster/qgsrasterminmaxorigin.cpp +++ b/src/core/raster/qgsrasterminmaxorigin.cpp @@ -40,9 +40,9 @@ bool QgsRasterMinMaxOrigin::operator ==( const QgsRasterMinMaxOrigin &other ) co return mLimits == other.mLimits && mExtent == other.mExtent && mAccuracy == other.mAccuracy && - fabs( mCumulativeCutLower - other.mCumulativeCutLower ) < 1e-5 && - fabs( mCumulativeCutUpper - other.mCumulativeCutUpper ) < 1e-5 && - fabs( mStdDevFactor - other.mStdDevFactor ) < 1e-5; + std::fabs( mCumulativeCutLower - other.mCumulativeCutLower ) < 1e-5 && + std::fabs( mCumulativeCutUpper - other.mCumulativeCutUpper ) < 1e-5 && + std::fabs( mStdDevFactor - other.mStdDevFactor ) < 1e-5; } QString QgsRasterMinMaxOrigin::limitsString( Limits limits ) diff --git a/src/core/simplify/effectivearea.cpp b/src/core/simplify/effectivearea.cpp index 4863b96ded2..0dbc9df1d9a 100644 --- a/src/core/simplify/effectivearea.cpp +++ b/src/core/simplify/effectivearea.cpp @@ -65,7 +65,7 @@ static double triarea3d( const QgsPoint &P1, const QgsPoint &P2, const QgsPoint cy = az * bx - ax * bz; cz = ax * by - ay * bx; - area = fabs( 0.5 * ( sqrt( cx * cx + cy * cy + cz * cz ) ) ); + area = std::fabs( 0.5 * ( sqrt( cx * cx + cy * cy + cz * cz ) ) ); return area; } diff --git a/src/core/symbology/qgs25drenderer.cpp b/src/core/symbology/qgs25drenderer.cpp index cca1b31628d..726b72119fb 100644 --- a/src/core/symbology/qgs25drenderer.cpp +++ b/src/core/symbology/qgs25drenderer.cpp @@ -53,7 +53,7 @@ "set_color_part( " \ " @symbol_color," \ " 'value'," \ - " 40 + 19 * abs( $pi - azimuth( " \ + " 40 + 19 * std::abs( $pi - azimuth( " \ " point_n( geometry_n($geometry, @geometry_part_num) , 1 ), " \ " point_n( geometry_n($geometry, @geometry_part_num) , 2 )" \ " ) ) " \ diff --git a/src/core/symbology/qgsarrowsymbollayer.cpp b/src/core/symbology/qgsarrowsymbollayer.cpp index caaf48950c1..c11bcab8653 100644 --- a/src/core/symbology/qgsarrowsymbollayer.cpp +++ b/src/core/symbology/qgsarrowsymbollayer.cpp @@ -355,7 +355,7 @@ bool pointsToCircle( QPointF a, QPointF b, QPointF c, QPointF ¢er, qreal &ra QPointF bc2 = ( b + c ) / 2.0; // Aligned points - if ( fabs( ab.x() * bc.y() - ab.y() * bc.x() ) < 0.001 ) // Empirical threshold for nearly aligned points + if ( std::fabs( ab.x() * bc.y() - ab.y() * bc.x() ) < 0.001 ) // Empirical threshold for nearly aligned points return false; // in case AB is horizontal @@ -493,9 +493,9 @@ QPolygonF curvedArrow( QPointF po, QPointF pm, QPointF pd, qreal length = euclidian_distance( po, pd ); // for close points and deltaAngle < 180, draw a straight line - if ( fabs( deltaAngle ) < M_PI && ( ( ( headType == QgsArrowSymbolLayer::HeadSingle ) && ( length < headWidth ) ) || - ( ( headType == QgsArrowSymbolLayer::HeadReversed ) && ( length < headWidth ) ) || - ( ( headType == QgsArrowSymbolLayer::HeadDouble ) && ( length < 2 * headWidth ) ) ) ) + if ( std::fabs( deltaAngle ) < M_PI && ( ( ( headType == QgsArrowSymbolLayer::HeadSingle ) && ( length < headWidth ) ) || + ( ( headType == QgsArrowSymbolLayer::HeadReversed ) && ( length < headWidth ) ) || + ( ( headType == QgsArrowSymbolLayer::HeadDouble ) && ( length < 2 * headWidth ) ) ) ) { return straightArrow( po, pd, startWidth, width, headWidth, headHeight, headType, arrowType, offset ); } diff --git a/src/core/symbology/qgsfillsymbollayer.cpp b/src/core/symbology/qgsfillsymbollayer.cpp index 01e1539a321..8a7365ccb2a 100644 --- a/src/core/symbology/qgsfillsymbollayer.cpp +++ b/src/core/symbology/qgsfillsymbollayer.cpp @@ -395,7 +395,7 @@ QgsSymbolLayer *QgsSimpleFillSymbolLayer::createFromSld( QDomElement &element ) double QgsSimpleFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const { double penBleed = context.convertToPainterUnits( mStrokeStyle == Qt::NoPen ? 0 : ( mStrokeWidth / 2.0 ), mStrokeWidthUnit, mStrokeWidthMapUnitScale ); - double offsetBleed = context.convertToPainterUnits( qMax( fabs( mOffset.x() ), fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale ); + double offsetBleed = context.convertToPainterUnits( qMax( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale ); return penBleed + offsetBleed; } @@ -916,7 +916,7 @@ QgsGradientFillSymbolLayer *QgsGradientFillSymbolLayer::clone() const double QgsGradientFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const { - double offsetBleed = context.convertToPainterUnits( qMax( fabs( mOffset.x() ), fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale ); + double offsetBleed = context.convertToPainterUnits( qMax( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale ); return offsetBleed; } @@ -1512,7 +1512,7 @@ QgsShapeburstFillSymbolLayer *QgsShapeburstFillSymbolLayer::clone() const double QgsShapeburstFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const { - double offsetBleed = context.convertToPainterUnits( qMax( fabs( mOffset.x() ), fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale ); + double offsetBleed = context.convertToPainterUnits( qMax( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale ); return offsetBleed; } @@ -2600,14 +2600,14 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext & lineAngle += 360.; } - height = abs( height ); - width = abs( width ); + height = std::abs( height ); + width = std::abs( width ); outputPixelDist = height * cos( lineAngle * M_PI / 180 ); // Round offset to correspond to one pixel height, otherwise lines may // be shifted on tile border if offset falls close to pixel center - int offsetHeight = std::round( fabs( outputPixelOffset / cos( lineAngle * M_PI / 180 ) ) ); + int offsetHeight = std::round( std::fabs( outputPixelOffset / cos( lineAngle * M_PI / 180 ) ) ); outputPixelOffset = offsetHeight * cos( lineAngle * M_PI / 180 ); } @@ -3749,7 +3749,7 @@ QgsRasterFillSymbolLayer *QgsRasterFillSymbolLayer::clone() const double QgsRasterFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const { - return context.convertToPainterUnits( qMax( fabs( mOffset.x() ), fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale ); + return context.convertToPainterUnits( qMax( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale ); } void QgsRasterFillSymbolLayer::setImageFilePath( const QString &imagePath ) diff --git a/src/core/symbology/qgslinesymbollayer.cpp b/src/core/symbology/qgslinesymbollayer.cpp index 1efbac4a39d..58b05f4a8b8 100644 --- a/src/core/symbology/qgslinesymbollayer.cpp +++ b/src/core/symbology/qgslinesymbollayer.cpp @@ -581,7 +581,7 @@ double QgsSimpleLineSymbolLayer::estimateMaxBleed( const QgsRenderContext &conte else { return context.convertToPainterUnits( ( mWidth / 2.0 ), mWidthUnit, mWidthMapUnitScale ) + - context.convertToPainterUnits( fabs( mOffset ), mOffsetUnit, mOffsetMapUnitScale ); + context.convertToPainterUnits( std::fabs( mOffset ), mOffsetUnit, mOffsetMapUnitScale ); } } @@ -1236,7 +1236,7 @@ void QgsMarkerLineSymbolLayer::renderOffsetVertexAlongLine( const QPolygonF &poi QPointF previousPoint = points[vertex]; int startPoint = distance > 0 ? qMin( vertex + 1, points.count() - 1 ) : qMax( vertex - 1, 0 ); int endPoint = distance > 0 ? points.count() - 1 : 0; - double distanceLeft = fabs( distance ); + double distanceLeft = std::fabs( distance ); for ( int i = startPoint; pointIncrement > 0 ? i <= endPoint : i >= endPoint; i += pointIncrement ) { @@ -1604,7 +1604,7 @@ QSet QgsMarkerLineSymbolLayer::usedAttributes( const QgsRenderContext & double QgsMarkerLineSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const { return context.convertToPainterUnits( ( mMarker->size() / 2.0 ), mMarker->sizeUnit(), mMarker->sizeMapUnitScale() ) + - context.convertToPainterUnits( fabs( mOffset ), mOffsetUnit, mOffsetMapUnitScale ); + context.convertToPainterUnits( std::fabs( mOffset ), mOffsetUnit, mOffsetMapUnitScale ); } diff --git a/src/core/symbology/qgssymbollayerutils.cpp b/src/core/symbology/qgssymbollayerutils.cpp index a2fb2792ca3..a30465e1cb4 100644 --- a/src/core/symbology/qgssymbollayerutils.cpp +++ b/src/core/symbology/qgssymbollayerutils.cpp @@ -3895,7 +3895,7 @@ QList QgsSymbolLayerUtils::prettyBreaks( double minimum, double maximum, else { int U = 1; - cell = qMax( fabs( minimum ), fabs( maximum ) ); + cell = qMax( std::fabs( minimum ), std::fabs( maximum ) ); if ( adjustBias >= 1.5 * h + 0.5 ) { U = 1 + ( 1.0 / ( 1 + h ) ); diff --git a/src/gui/layout/qgslayoutruler.cpp b/src/gui/layout/qgslayoutruler.cpp index a74ff53da44..3cc239ec009 100644 --- a/src/gui/layout/qgslayoutruler.cpp +++ b/src/gui/layout/qgslayoutruler.cpp @@ -376,11 +376,11 @@ QgsLayoutGuide *QgsLayoutRuler::guideAtPoint( QPoint localPoint ) const switch ( mOrientation ) { case Qt::Horizontal: - currentDelta = fabs( layoutPoint.x() - guide->layoutPosition() ); + currentDelta = std::fabs( layoutPoint.x() - guide->layoutPosition() ); break; case Qt::Vertical: - currentDelta = fabs( layoutPoint.y() - guide->layoutPosition() ); + currentDelta = std::fabs( layoutPoint.y() - guide->layoutPosition() ); break; } if ( currentDelta < minDelta ) diff --git a/src/gui/layout/qgslayoutview.cpp b/src/gui/layout/qgslayoutview.cpp index 2eca4704392..785ec47f152 100644 --- a/src/gui/layout/qgslayoutview.cpp +++ b/src/gui/layout/qgslayoutview.cpp @@ -456,7 +456,7 @@ void QgsLayoutView::wheelZoom( QWheelEvent *event ) double zoomFactor = settings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble(); // "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps - zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * fabs( event->angleDelta().y() ); + zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() ); if ( event->modifiers() & Qt::ControlModifier ) { diff --git a/src/gui/layout/qgslayoutviewrubberband.cpp b/src/gui/layout/qgslayoutviewrubberband.cpp index 7dc65655160..f4a8a0fcd21 100644 --- a/src/gui/layout/qgslayoutviewrubberband.cpp +++ b/src/gui/layout/qgslayoutviewrubberband.cpp @@ -49,14 +49,14 @@ QRectF QgsLayoutViewRubberBand::updateRect( QPointF start, QPointF position, boo if ( constrainSquare ) { - if ( fabs( dx ) > fabs( dy ) ) + if ( std::fabs( dx ) > std::fabs( dy ) ) { - width = fabs( dx ); + width = std::fabs( dx ); height = width; } else { - height = fabs( dy ); + height = std::fabs( dy ); width = height; } diff --git a/src/gui/layout/qgslayoutviewtool.cpp b/src/gui/layout/qgslayoutviewtool.cpp index 2d981d80c61..76ef9f125f8 100644 --- a/src/gui/layout/qgslayoutviewtool.cpp +++ b/src/gui/layout/qgslayoutviewtool.cpp @@ -31,7 +31,7 @@ bool QgsLayoutViewTool::isClickAndDrag( QPoint startViewPoint, QPoint endViewPoi { int diffX = endViewPoint.x() - startViewPoint.x(); int diffY = endViewPoint.y() - startViewPoint.y(); - if ( abs( diffX ) >= 2 || abs( diffY ) >= 2 ) + if ( std::abs( diffX ) >= 2 || std::abs( diffY ) >= 2 ) { return true; } diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 06b51e5a448..e0dd9b0089d 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -66,11 +66,11 @@ bool QgsAdvancedDigitizingDockWidget::lineCircleIntersection( const QgsPointXY & const int sgnDy = dy < 0 ? -1 : 1; const double ax = center.x() + ( d * dy + sgnDy * dx * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) ); - const double ay = center.y() + ( -d * dx + fabs( dy ) * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) ); + const double ay = center.y() + ( -d * dx + std::fabs( dy ) * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) ); const QgsPointXY p1( ax, ay ); const double bx = center.x() + ( d * dy - sgnDy * dx * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) ); - const double by = center.y() + ( -d * dx - fabs( dy ) * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) ); + const double by = center.y() + ( -d * dx - std::fabs( dy ) * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) ); const QgsPointXY p2( bx, by ); // snap to nearest intersection @@ -656,14 +656,14 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e ) softAngle -= deltaAngle; } int quo = std::round( softAngle / commonAngle ); - if ( fabs( softAngle - quo * commonAngle ) * 180.0 * M_1_PI <= SOFT_CONSTRAINT_TOLERANCE_DEGREES ) + if ( std::fabs( softAngle - quo * commonAngle ) * 180.0 * M_1_PI <= SOFT_CONSTRAINT_TOLERANCE_DEGREES ) { // also check the distance in pixel to the line, otherwise it's too sticky at long ranges softAngle = quo * commonAngle ; // http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html // use the direction vector (cos(a),sin(a)) from previous point. |x2-x1|=1 since sin2+cos2=1 - const double dist = fabs( qCos( softAngle + deltaAngle ) * ( previousPt.y() - point.y() ) - - qSin( softAngle + deltaAngle ) * ( previousPt.x() - point.x() ) ); + const double dist = std::fabs( qCos( softAngle + deltaAngle ) * ( previousPt.y() - point.y() ) + - qSin( softAngle + deltaAngle ) * ( previousPt.x() - point.x() ) ); if ( dist / mMapCanvas->mapSettings().mapUnitsPerPixel() < SOFT_CONSTRAINT_TOLERANCE_PIXEL ) { mAngleConstraint->setLockMode( CadConstraint::SoftLock ); @@ -745,7 +745,7 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e ) // do not compute intersection if lines are almost parallel // this threshold might be adapted - if ( fabs( d ) > 0.01 ) + if ( std::fabs( d ) > 0.01 ) { point.setX( ( ( x3 - x4 ) * ( x1 * y2 - y1 * x2 ) - ( x1 - x2 ) * ( x3 * y4 - y3 * x4 ) ) / d ); point.setY( ( ( y3 - y4 ) * ( x1 * y2 - y1 * x2 ) - ( y1 - y2 ) * ( x3 * y4 - y3 * x4 ) ) / d ); diff --git a/src/gui/qgscolorwidgets.cpp b/src/gui/qgscolorwidgets.cpp index be041c56bda..b5f624a4b35 100644 --- a/src/gui/qgscolorwidgets.cpp +++ b/src/gui/qgscolorwidgets.cpp @@ -464,7 +464,7 @@ void QgsColorWheel::paintEvent( QPaintEvent *event ) double mx = ( sx + vx ) / 2.0; double my = ( sy + vy ) / 2.0; - double a = ( 1 - 2.0 * fabs( lightness - 0.5 ) ) * mCurrentColor.hslSaturationF(); + double a = ( 1 - 2.0 * std::fabs( lightness - 0.5 ) ) * mCurrentColor.hslSaturationF(); double x = sx + ( vx - sx ) * lightness + ( hx - mx ) * a; double y = sy + ( vy - sy ) * lightness + ( hy - my ) * a; @@ -564,7 +564,7 @@ void QgsColorWheel::setColorFromPos( const QPointF pos ) double triangleSideLength = sqrt( 3.0 ) * triangleLength; double newL = ( ( -sin( rad0 ) * r ) / triangleSideLength ) + 0.5; - double widthShare = 1.0 - ( fabs( newL - 0.5 ) * 2.0 ); + double widthShare = 1.0 - ( std::fabs( newL - 0.5 ) * 2.0 ); double newS = ( ( ( cos( rad0 ) * r ) + ( triangleLength / 2.0 ) ) / ( 1.5 * triangleLength ) ) / widthShare; s = qMin( static_cast< int >( std::round( qMax( 0.0, newS ) * 255.0 ) ), 255 ); l = qMin( static_cast< int >( std::round( qMax( 0.0, newL ) * 255.0 ) ), 255 ); diff --git a/src/gui/qgscomposerview.cpp b/src/gui/qgscomposerview.cpp index a7e10e9df9c..93933fbf9e9 100644 --- a/src/gui/qgscomposerview.cpp +++ b/src/gui/qgscomposerview.cpp @@ -753,7 +753,7 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent *e ) //was this just a click? or a click and drag? bool clickOnly = false; - if ( fabs( diffX ) < 2 && fabs( diffY ) < 2 ) + if ( std::fabs( diffX ) < 2 && std::fabs( diffY ) < 2 ) { clickOnly = true; } @@ -1315,14 +1315,14 @@ void QgsComposerView::updateRubberBandRect( QPointF &pos, const bool constrainSq if ( constrainSquare ) { - if ( fabs( dx ) > fabs( dy ) ) + if ( std::fabs( dx ) > std::fabs( dy ) ) { - width = fabs( dx ); + width = std::fabs( dx ); height = width; } else { - height = fabs( dy ); + height = std::fabs( dy ); width = height; } @@ -2015,7 +2015,7 @@ void QgsComposerView::wheelZoom( QWheelEvent *event ) double zoomFactor = mySettings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble(); // "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps - zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * fabs( event->angleDelta().y() ); + zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() ); if ( event->modifiers() & Qt::ControlModifier ) { diff --git a/src/gui/qgsgradientstopeditor.cpp b/src/gui/qgsgradientstopeditor.cpp index b81692957b5..1a4f15d14dd 100644 --- a/src/gui/qgsgradientstopeditor.cpp +++ b/src/gui/qgsgradientstopeditor.cpp @@ -285,7 +285,7 @@ int QgsGradientStopEditor::findClosestStop( int x, int threshold ) const int i = 1; Q_FOREACH ( const QgsGradientStop &stop, mGradient.stops() ) { - currentDiff = abs( relativePositionToPoint( stop.offset ) + 1 - x ); + currentDiff = std::abs( relativePositionToPoint( stop.offset ) + 1 - x ); if ( ( threshold < 0 || currentDiff < threshold ) && currentDiff < closestDiff ) { closestStop = i; @@ -295,7 +295,7 @@ int QgsGradientStopEditor::findClosestStop( int x, int threshold ) const } //first stop - currentDiff = abs( relativePositionToPoint( 0.0 ) + 1 - x ); + currentDiff = std::abs( relativePositionToPoint( 0.0 ) + 1 - x ); if ( ( threshold < 0 || currentDiff < threshold ) && currentDiff < closestDiff ) { closestStop = 0; @@ -303,7 +303,7 @@ int QgsGradientStopEditor::findClosestStop( int x, int threshold ) const } //last stop - currentDiff = abs( relativePositionToPoint( 1.0 ) + 1 - x ); + currentDiff = std::abs( relativePositionToPoint( 1.0 ) + 1 - x ); if ( ( threshold < 0 || currentDiff < threshold ) && currentDiff < closestDiff ) { closestStop = mGradient.count() - 1; diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index fe828b8a55f..8ff4e666957 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -1091,8 +1091,8 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent *e ) // Don't want to interfer with mouse events QgsRectangle currentExtent = mapSettings().visibleExtent(); - double dx = fabs( currentExtent.width() / 4 ); - double dy = fabs( currentExtent.height() / 4 ); + double dx = std::fabs( currentExtent.width() / 4 ); + double dy = std::fabs( currentExtent.height() / 4 ); switch ( e->key() ) { @@ -1420,7 +1420,7 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e ) double zoomFactor = mWheelZoomFactor; // "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps - zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * fabs( e->angleDelta().y() ); + zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( e->angleDelta().y() ); if ( e->modifiers() & Qt::ControlModifier ) { diff --git a/src/gui/qgsmapcanvasannotationitem.cpp b/src/gui/qgsmapcanvasannotationitem.cpp index 6a7e51ba0e6..ca0ce5f9bd1 100644 --- a/src/gui/qgsmapcanvasannotationitem.cpp +++ b/src/gui/qgsmapcanvasannotationitem.cpp @@ -187,7 +187,7 @@ QgsMapCanvasAnnotationItem::MouseMoveAction QgsMapCanvasAnnotationItem::moveActi int cursorSensitivity = 7; if ( mAnnotation && mAnnotation->hasFixedMapPosition() && - fabs( itemPos.x() ) < cursorSensitivity && fabs( itemPos.y() ) < cursorSensitivity ) //move map point if position is close to the origin + std::fabs( itemPos.x() ) < cursorSensitivity && std::fabs( itemPos.y() ) < cursorSensitivity ) //move map point if position is close to the origin { return MoveMapPosition; } @@ -196,10 +196,10 @@ QgsMapCanvasAnnotationItem::MouseMoveAction QgsMapCanvasAnnotationItem::moveActi QSizeF frameSize = mAnnotation ? mAnnotation->frameSize() : QSizeF( 0, 0 ); bool left, right, up, down; - left = fabs( itemPos.x() - offset.x() ) < cursorSensitivity; - right = fabs( itemPos.x() - ( offset.x() + frameSize.width() ) ) < cursorSensitivity; - up = fabs( itemPos.y() - offset.y() ) < cursorSensitivity; - down = fabs( itemPos.y() - ( offset.y() + frameSize.height() ) ) < cursorSensitivity; + left = std::fabs( itemPos.x() - offset.x() ) < cursorSensitivity; + right = std::fabs( itemPos.x() - ( offset.x() + frameSize.width() ) ) < cursorSensitivity; + up = std::fabs( itemPos.y() - offset.y() ) < cursorSensitivity; + down = std::fabs( itemPos.y() - ( offset.y() + frameSize.height() ) ) < cursorSensitivity; if ( left && up ) { diff --git a/src/gui/qgsmaptoolextent.cpp b/src/gui/qgsmaptoolextent.cpp index d895883f4aa..d3b41e3de91 100644 --- a/src/gui/qgsmaptoolextent.cpp +++ b/src/gui/qgsmaptoolextent.cpp @@ -47,7 +47,7 @@ void QgsMapToolExtent::canvasMoveEvent( QgsMapMouseEvent *e ) QgsPointXY p = toMapCoordinates( e->pos() ); if ( mRatio.width() > 0 && mRatio.height() > 0 ) { - double width = fabs( p.x() - mStartPoint.x() ); + double width = std::fabs( p.x() - mStartPoint.x() ); double height = width * ( mRatio.width() / mRatio.height() ); if ( p.y() - mStartPoint.y() < 0 ) height *= -1; @@ -98,7 +98,7 @@ void QgsMapToolExtent::calculateEndPoint( QgsPointXY &point ) { if ( mRatio.width() > 0 && mRatio.height() > 0 ) { - double width = fabs( point.x() - mStartPoint.x() ); + double width = std::fabs( point.x() - mStartPoint.x() ); double height = width * mRatio.height() / mRatio.width(); if ( point.y() - mStartPoint.y() < 0 ) height *= -1; diff --git a/src/gui/qgsscalecombobox.cpp b/src/gui/qgsscalecombobox.cpp index 3bd1145ca5c..6ff6afb1b85 100644 --- a/src/gui/qgsscalecombobox.cpp +++ b/src/gui/qgsscalecombobox.cpp @@ -98,7 +98,7 @@ void QgsScaleComboBox::showPopup() { parts = itemText( i ).split( ':' ); nextScale = parts.at( 1 ).toLong( &ok ); - delta = labs( currScale - nextScale ); + delta = std::labs( currScale - nextScale ); if ( delta < min ) { min = delta; diff --git a/src/gui/raster/qgsrasterhistogramwidget.cpp b/src/gui/raster/qgsrasterhistogramwidget.cpp index e63e9c0ecdf..50a31768ee6 100644 --- a/src/gui/raster/qgsrasterhistogramwidget.cpp +++ b/src/gui/raster/qgsrasterhistogramwidget.cpp @@ -1005,7 +1005,7 @@ QString findClosestTickVal( double target, const QwtScaleDiv *scale, int div = 1 current += diff; if ( current > target ) { - closest = ( fabs( target - current + diff ) < fabs( target - current ) ) ? current - diff : current; + closest = ( std::fabs( target - current + diff ) < std::fabs( target - current ) ) ? current - diff : current; break; } } diff --git a/src/gui/symbology/qgsgraduatedhistogramwidget.cpp b/src/gui/symbology/qgsgraduatedhistogramwidget.cpp index bef17e88ab0..e316e57be6e 100644 --- a/src/gui/symbology/qgsgraduatedhistogramwidget.cpp +++ b/src/gui/symbology/qgsgraduatedhistogramwidget.cpp @@ -158,11 +158,11 @@ void QgsGraduatedHistogramWidget::findClosestRange( double value, int &closestRa int pressedPixel = mPlot->canvasMap( QwtPlot::xBottom ).transform( value ); for ( int i = 0; i < ranges.count() - 1; ++i ) { - if ( fabs( mPressedValue - ranges.at( i ).upperValue() ) < minDistance ) + if ( std::fabs( mPressedValue - ranges.at( i ).upperValue() ) < minDistance ) { closestRangeIndex = i; - minDistance = fabs( mPressedValue - ranges.at( i ).upperValue() ); - pixelDistance = fabs( pressedPixel - mPlot->canvasMap( QwtPlot::xBottom ).transform( ranges.at( i ).upperValue() ) ); + minDistance = std::fabs( mPressedValue - ranges.at( i ).upperValue() ); + pixelDistance = std::fabs( pressedPixel - mPlot->canvasMap( QwtPlot::xBottom ).transform( ranges.at( i ).upperValue() ) ); } } } diff --git a/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp b/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp index a458195fc0f..0ac17d81f07 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp +++ b/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp @@ -111,7 +111,7 @@ void QgsGeometryOverlapCheck::fixError( QgsGeometryCheckError *error, int method for ( int iPart = 0, nParts = interGeom->partCount(); iPart < nParts; ++iPart ) { QgsAbstractGeometry *part = QgsGeometryCheckerUtils::getGeomPart( interGeom, iPart ); - if ( fabs( part->area() - overlapError->value().toDouble() ) < QgsGeometryCheckPrecision::reducedTolerance() && + if ( std::fabs( part->area() - overlapError->value().toDouble() ) < QgsGeometryCheckPrecision::reducedTolerance() && QgsGeometryCheckerUtils::pointsFuzzyEqual( part->centroid(), overlapError->location(), QgsGeometryCheckPrecision::reducedTolerance() ) ) { interPart = part; diff --git a/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.h b/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.h index 34cbb40fe95..79508a35043 100644 --- a/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.h +++ b/src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.h @@ -38,7 +38,7 @@ class QgsGeometryOverlapCheckError : public QgsGeometryCheckError other->featureId() == featureId() && err->otherId() == otherId() && QgsGeometryCheckerUtils::pointsFuzzyEqual( location(), other->location(), QgsGeometryCheckPrecision::reducedTolerance() ) && - fabs( value().toDouble() - other->value().toDouble() ) < QgsGeometryCheckPrecision::reducedTolerance(); + std::fabs( value().toDouble() - other->value().toDouble() ) < QgsGeometryCheckPrecision::reducedTolerance(); } bool closeMatch( QgsGeometryCheckError *other ) const override diff --git a/src/plugins/geometry_checker/utils/qgsgeometrycheckerutils.cpp b/src/plugins/geometry_checker/utils/qgsgeometrycheckerutils.cpp index 29a9f73a1f5..64a7f70deb0 100644 --- a/src/plugins/geometry_checker/utils/qgsgeometrycheckerutils.cpp +++ b/src/plugins/geometry_checker/utils/qgsgeometrycheckerutils.cpp @@ -54,7 +54,7 @@ namespace QgsGeometryCheckerUtils static inline double pointLineDist( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q ) { - double nom = fabs( ( p2.y() - p1.y() ) * q.x() - ( p2.x() - p1.x() ) * q.y() + p2.x() * p1.y() - p2.y() * p1.x() ); + double nom = std::fabs( ( p2.y() - p1.y() ) * q.x() - ( p2.x() - p1.x() ) * q.y() + p2.x() * p1.y() - p2.y() * p1.x() ); double dx = p2.x() - p1.x(); double dy = p2.y() - p1.y(); return nom / qSqrt( dx * dx + dy * dy ); diff --git a/src/plugins/georeferencer/qgsgeorefdelegates.cpp b/src/plugins/georeferencer/qgsgeorefdelegates.cpp index 3004dc3d9d0..fa3f36113d0 100644 --- a/src/plugins/georeferencer/qgsgeorefdelegates.cpp +++ b/src/plugins/georeferencer/qgsgeorefdelegates.cpp @@ -77,7 +77,7 @@ double QgsDmsAndDdDelegate::dmsToDD( const QString &dms ) const { QStringList list = dms.split( ' ' ); QString tmpStr = list.at( 0 ); - double res = fabs( tmpStr.toDouble() ); + double res = std::fabs( tmpStr.toDouble() ); tmpStr = list.value( 1 ); if ( !tmpStr.isEmpty() ) diff --git a/src/plugins/georeferencer/qgsgeoreftransform.cpp b/src/plugins/georeferencer/qgsgeoreftransform.cpp index 84dbb40d6e9..f44b9ba2859 100644 --- a/src/plugins/georeferencer/qgsgeoreftransform.cpp +++ b/src/plugins/georeferencer/qgsgeoreftransform.cpp @@ -379,8 +379,8 @@ int QgsLinearGeorefTransform::linear_transform( void *pTransformerArg, int bDstT else { // Guard against division by zero - if ( fabs( t->scaleX ) < std::numeric_limits::epsilon() || - fabs( t->scaleY ) < std::numeric_limits::epsilon() ) + if ( std::fabs( t->scaleX ) < std::numeric_limits::epsilon() || + std::fabs( t->scaleY ) < std::numeric_limits::epsilon() ) { for ( int i = 0; i < nPointCount; ++i ) { @@ -460,7 +460,7 @@ int QgsHelmertGeorefTransform::helmert_transform( void *pTransformerArg, int bDs else { // Guard against division by zero - if ( fabs( s ) < std::numeric_limits::epsilon() ) + if ( std::fabs( s ) < std::numeric_limits::epsilon() ) { for ( int i = 0; i < nPointCount; ++i ) { @@ -602,7 +602,7 @@ bool QgsProjectiveGeorefTransform::updateParametersFromGCPs( const QVector::epsilon() ) + if ( std::fabs( det ) < 1024.0 * std::numeric_limits::epsilon() ) { mParameters.hasInverse = false; } @@ -654,7 +654,7 @@ int QgsProjectiveGeorefTransform::projective_transform( void *pTransformerArg, i { double Z = x[i] * H[6] + y[i] * H[7] + H[8]; // Projects to infinity? - if ( fabs( Z ) < 1024.0 * std::numeric_limits::epsilon() ) + if ( std::fabs( Z ) < 1024.0 * std::numeric_limits::epsilon() ) { panSuccess[i] = false; continue; diff --git a/src/plugins/georeferencer/qgsleastsquares.cpp b/src/plugins/georeferencer/qgsleastsquares.cpp index ac218fdcd36..6d1ee228e23 100644 --- a/src/plugins/georeferencer/qgsleastsquares.cpp +++ b/src/plugins/georeferencer/qgsleastsquares.cpp @@ -57,8 +57,8 @@ void QgsLeastSquares::linear( const QVector &mapCoords, origin.setX( aX ); origin.setY( aY ); - pixelXSize = fabs( bX ); - pixelYSize = fabs( bY ); + pixelXSize = std::fabs( bX ); + pixelYSize = std::fabs( bY ); } diff --git a/src/plugins/georeferencer/qgsmapcoordsdialog.cpp b/src/plugins/georeferencer/qgsmapcoordsdialog.cpp index 5ab6af74d98..a23f5a9ef1f 100644 --- a/src/plugins/georeferencer/qgsmapcoordsdialog.cpp +++ b/src/plugins/georeferencer/qgsmapcoordsdialog.cpp @@ -137,7 +137,7 @@ double QgsMapCoordsDialog::dmsToDD( const QString &dms ) { QStringList list = dms.split( ' ' ); QString tmpStr = list.at( 0 ); - double res = fabs( tmpStr.toDouble() ); + double res = std::fabs( tmpStr.toDouble() ); tmpStr = list.value( 1 ); if ( !tmpStr.isEmpty() ) diff --git a/src/plugins/grass/qgsgrassnewmapset.cpp b/src/plugins/grass/qgsgrassnewmapset.cpp index f336a69db5d..dd096f1f601 100644 --- a/src/plugins/grass/qgsgrassnewmapset.cpp +++ b/src/plugins/grass/qgsgrassnewmapset.cpp @@ -1087,7 +1087,7 @@ void QgsGrassNewMapset::drawRegion() double x1 = points[i].x(); double x2 = points[i + 1].x(); - if ( fabs( x2 - x1 ) > 150 ) + if ( std::fabs( x2 - x1 ) > 150 ) { if ( x2 < x1 ) { diff --git a/src/plugins/grass/qtermwidget/ColorScheme.cpp b/src/plugins/grass/qtermwidget/ColorScheme.cpp index 008399b94fc..563ce71d3a9 100644 --- a/src/plugins/grass/qtermwidget/ColorScheme.cpp +++ b/src/plugins/grass/qtermwidget/ColorScheme.cpp @@ -196,9 +196,9 @@ ColorEntry ColorScheme::colorEntry( int index, uint randomSeed ) const QColor &color = entry.color; - int newHue = abs( ( color.hue() + hueDifference ) % MAX_HUE ); - int newValue = qMin( abs( color.value() + valueDifference ), 255 ); - int newSaturation = qMin( abs( color.saturation() + saturationDifference ), 255 ); + int newHue = std::abs( ( color.hue() + hueDifference ) % MAX_HUE ); + int newValue = qMin( std::abs( color.value() + valueDifference ), 255 ); + int newSaturation = qMin( std::abs( color.saturation() + saturationDifference ), 255 ); color.setHsv( newHue, newSaturation, newValue ); } diff --git a/src/plugins/grass/qtermwidget/TerminalDisplay.cpp b/src/plugins/grass/qtermwidget/TerminalDisplay.cpp index 73fcab70119..320c3278b04 100644 --- a/src/plugins/grass/qtermwidget/TerminalDisplay.cpp +++ b/src/plugins/grass/qtermwidget/TerminalDisplay.cpp @@ -817,7 +817,7 @@ void TerminalDisplay::scrollImage( int lines, const QRect &screenWindowRegion ) if ( lines == 0 || _image == 0 || !region.isValid() - || ( region.top() + abs( lines ) ) >= region.bottom() + || ( region.top() + std::abs( lines ) ) >= region.bottom() || this->_lines <= region.height() ) return; // hide terminal size label to prevent it being scrolled @@ -848,10 +848,10 @@ void TerminalDisplay::scrollImage( int lines, const QRect &screenWindowRegion ) scrollRect.setRight( width() - scrollBarWidth - SCROLLBAR_CONTENT_GAP ); } void *firstCharPos = &_image[ region.top() * this->_columns ]; - void *lastCharPos = &_image[( region.top() + abs( lines ) ) * this->_columns ]; + void *lastCharPos = &_image[( region.top() + std::abs( lines ) ) * this->_columns ]; int top = _topMargin + ( region.top() * _fontHeight ); - int linesToMove = region.height() - abs( lines ); + int linesToMove = region.height() - std::abs( lines ); int bytesToMove = linesToMove * this->_columns * sizeof( Character ); @@ -884,7 +884,7 @@ void TerminalDisplay::scrollImage( int lines, const QRect &screenWindowRegion ) memmove( lastCharPos, firstCharPos, bytesToMove ); //set region of the display to scroll - scrollRect.setTop( top + abs( lines ) * _fontHeight ); + scrollRect.setTop( top + std::abs( lines ) * _fontHeight ); } scrollRect.setHeight( linesToMove * _fontHeight ); @@ -2392,7 +2392,7 @@ void TerminalDisplay::wheelEvent( QWheelEvent *ev ) // QWheelEvent::delta() gives rotation in eighths of a degree int wheelDegrees = ev->delta() / 8; - int linesToScroll = abs( wheelDegrees ) / 5; + int linesToScroll = std::abs( wheelDegrees ) / 5; QKeyEvent keyScrollEvent( QEvent::KeyPress, key, Qt::NoModifier ); diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index 03d9fee4ad2..11ce0732fb9 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -528,7 +528,7 @@ void QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi int srcBottom = ySize() - 1; int srcRight = xSize() - 1; - // Note: original approach for xRes < srcXRes || yRes < fabs( srcYRes ) was to avoid + // Note: original approach for xRes < srcXRes || yRes < std::fabs( srcYRes ) was to avoid // second resampling and read with GDALRasterIO to another temporary data block // extended to fit src grid. The problem was that with src resolution much bigger // than dst res, the target could become very large @@ -587,7 +587,7 @@ void QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi { tmpWidth = static_cast( std::round( srcWidth * srcXRes / xRes ) ); } - if ( yRes > fabs( srcYRes ) ) + if ( yRes > std::fabs( srcYRes ) ) { tmpHeight = static_cast( std::round( -1.*srcHeight * srcYRes / yRes ) ); } @@ -1291,8 +1291,8 @@ bool QgsGdalProvider::hasHistogram( int bandNo, // min/max are stored as text in aux file => use threshold if ( myBinCount != myHistogram.binCount || - fabs( myMinVal - myExpectedMinVal ) > fabs( myExpectedMinVal ) / 10e6 || - fabs( myMaxVal - myExpectedMaxVal ) > fabs( myExpectedMaxVal ) / 10e6 ) + std::fabs( myMinVal - myExpectedMinVal ) > std::fabs( myExpectedMinVal ) / 10e6 || + std::fabs( myMaxVal - myExpectedMaxVal ) > std::fabs( myExpectedMaxVal ) / 10e6 ) { QgsDebugMsg( QString( "Params do not match binCount: %1 x %2, minVal: %3 x %4, maxVal: %5 x %6" ).arg( myBinCount ).arg( myHistogram.binCount ).arg( myMinVal ).arg( myExpectedMinVal ).arg( myMaxVal ).arg( myExpectedMaxVal ) ); return false; diff --git a/src/providers/grass/qgsgrassrasterprovider.cpp b/src/providers/grass/qgsgrassrasterprovider.cpp index 370acbd8f2b..3e95e76530d 100644 --- a/src/providers/grass/qgsgrassrasterprovider.cpp +++ b/src/providers/grass/qgsgrassrasterprovider.cpp @@ -123,7 +123,7 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const &uri ) else if ( mGrassDataType == DCELL_TYPE ) { // Don't use numeric limits, raster layer is using - // fabs( myValue - mNoDataValue ) <= TINY_VALUE + // std::fabs( myValue - mNoDataValue ) <= TINY_VALUE // if the mNoDataValue would be a limit, the subtraction could overflow. // No data value is shown in GUI, use some nice number. // Choose values with small representation error. diff --git a/src/providers/wcs/qgswcsprovider.cpp b/src/providers/wcs/qgswcsprovider.cpp index 527c8441319..b3e23e5593d 100644 --- a/src/providers/wcs/qgswcsprovider.cpp +++ b/src/providers/wcs/qgswcsprovider.cpp @@ -1413,8 +1413,8 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, QgsRa point.x() + xRes * width / 2, point.y() + yRes * height / 2 ); - double xResDiff = fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes ); - double yResDiff = fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes ); + double xResDiff = std::fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes ); + double yResDiff = std::fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes ); if ( !mCachedGdalDataset || !mCachedViewExtent.contains( point ) || @@ -1434,8 +1434,8 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, QgsRa double xRes = finalExtent.width() / width; double yRes = finalExtent.height() / height; QgsDebugMsg( QString( "width = %1 height = %2 xRes = %3 yRes = %4" ).arg( finalExtent.width() ).arg( finalExtent.height() ).arg( xRes ).arg( yRes ) ); - double xResDiff = fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes ); - double yResDiff = fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes ); + double xResDiff = std::fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes ); + double yResDiff = std::fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes ); QgsDebugMsg( QString( "xRes diff = %1 yRes diff = %2 relative xResDiff = %3 relative yResDiff = %4" ).arg( xResDiff ).arg( yResDiff ).arg( xResDiff / xRes ).arg( yResDiff / yRes ) ); if ( !mCachedGdalDataset || !mCachedViewExtent.contains( point ) || diff --git a/src/providers/wfs/qgswfscapabilities.cpp b/src/providers/wfs/qgswfscapabilities.cpp index fc20e4911a0..89e317be8d4 100644 --- a/src/providers/wfs/qgswfscapabilities.cpp +++ b/src/providers/wfs/qgswfscapabilities.cpp @@ -403,10 +403,10 @@ void QgsWfsCapabilities::capabilitiesReplyFinished() QgsDebugMsg( ptMinBack.toString() ); QgsDebugMsg( ptMaxBack.toString() ); - if ( fabs( featureType.bbox.xMinimum() - ptMinBack.x() ) < 1e-5 && - fabs( featureType.bbox.yMinimum() - ptMinBack.y() ) < 1e-5 && - fabs( featureType.bbox.xMaximum() - ptMaxBack.x() ) < 1e-5 && - fabs( featureType.bbox.yMaximum() - ptMaxBack.y() ) < 1e-5 ) + if ( std::fabs( featureType.bbox.xMinimum() - ptMinBack.x() ) < 1e-5 && + std::fabs( featureType.bbox.yMinimum() - ptMinBack.y() ) < 1e-5 && + std::fabs( featureType.bbox.xMaximum() - ptMaxBack.x() ) < 1e-5 && + std::fabs( featureType.bbox.yMaximum() - ptMaxBack.y() ) < 1e-5 ) { QgsDebugMsg( "Values of LatLongBoundingBox are consistent with WGS84 long/lat bounds, so as the CRS is projected, assume they are indeed in WGS84 and not in the CRS units" ); featureType.bboxSRSIsWGS84 = true; diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index a98c38d95ab..c4236fc7dc4 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -89,8 +89,8 @@ struct LessThanTileRequest QPointF p1 = req1.rect.center(); QPointF p2 = req2.rect.center(); // using chessboard distance (loading order more natural than euclidean/manhattan distance) - double d1 = qMax( fabs( center.x() - p1.x() ), fabs( center.y() - p1.y() ) ); - double d2 = qMax( fabs( center.x() - p2.x() ), fabs( center.y() - p2.y() ) ); + double d1 = qMax( std::fabs( center.x() - p1.x() ), std::fabs( center.y() - p1.y() ) ); + double d2 = qMax( std::fabs( center.x() - p2.x() ), std::fabs( center.y() - p2.y() ) ); return d1 < d2; } }; @@ -4044,7 +4044,7 @@ static QString formatDouble( double x ) { if ( x == 0.0 ) return QStringLiteral( "0" ); - const int numberOfDecimals = qMax( 0, 19 - static_cast( ceil( log10( fabs( x ) ) ) ) ); + const int numberOfDecimals = qMax( 0, 19 - static_cast( ceil( log10( std::fabs( x ) ) ) ) ); return qgsDoubleToString( x, numberOfDecimals ); } diff --git a/tests/bench/qgsbench.cpp b/tests/bench/qgsbench.cpp index 79fc1043c6f..50f2e0b709f 100644 --- a/tests/bench/qgsbench.cpp +++ b/tests/bench/qgsbench.cpp @@ -243,7 +243,7 @@ void QgsBench::render() { for ( int i = 0; i < mTimes.size(); i++ ) { - double d = fabs( avg[t] - mTimes.at( i )[t] ); + double d = std::fabs( avg[t] - mTimes.at( i )[t] ); stdev[t] += pow( d, 2 ); if ( i == 0 || d > maxdev[t] ) maxdev[t] = d; } diff --git a/tests/src/core/testqgscomposermap.cpp b/tests/src/core/testqgscomposermap.cpp index 2bfb11a17bc..98b4c13cce5 100644 --- a/tests/src/core/testqgscomposermap.cpp +++ b/tests/src/core/testqgscomposermap.cpp @@ -216,14 +216,14 @@ void TestQgsComposerMap::mapPolygonVertices() QPolygonF visibleExtent = mComposerMap->visibleExtentPolygon(); //vertices should be returned in clockwise order starting at the top-left point - QVERIFY( fabs( visibleExtent[0].x() - 781662.375 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[0].y() - 3345223.125 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[1].x() - 793062.375 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[1].y() - 3345223.125 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[2].x() - 793062.375 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[2].y() - 3339523.125 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[3].x() - 781662.375 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[3].y() - 3339523.125 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[0].x() - 781662.375 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[0].y() - 3345223.125 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[1].x() - 793062.375 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[1].y() - 3345223.125 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[2].x() - 793062.375 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[2].y() - 3339523.125 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[3].x() - 781662.375 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[3].y() - 3339523.125 ) < 0.001 ); //polygon should be closed QVERIFY( visibleExtent.isClosed() ); @@ -233,14 +233,14 @@ void TestQgsComposerMap::mapPolygonVertices() visibleExtent = mComposerMap->visibleExtentPolygon(); //vertices should be returned in clockwise order starting at the top-left point - QVERIFY( fabs( visibleExtent[0].x() - 781254.0735015 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[0].y() - 3344190.0324834 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[1].x() - 792480.881886 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[1].y() - 3346169.62171 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[2].x() - 793470.676499 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[2].y() - 3340556.21752 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[3].x() - 782243.868114 ) < 0.001 ); - QVERIFY( fabs( visibleExtent[3].y() - 3338576.62829 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[0].x() - 781254.0735015 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[0].y() - 3344190.0324834 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[1].x() - 792480.881886 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[1].y() - 3346169.62171 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[2].x() - 793470.676499 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[2].y() - 3340556.21752 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[3].x() - 782243.868114 ) < 0.001 ); + QVERIFY( std::fabs( visibleExtent[3].y() - 3338576.62829 ) < 0.001 ); //polygon should be closed QVERIFY( visibleExtent.isClosed() ); diff --git a/tests/src/core/testqgsrasterlayer.cpp b/tests/src/core/testqgsrasterlayer.cpp index 42ce3b6daf9..e93c7607f2f 100644 --- a/tests/src/core/testqgsrasterlayer.cpp +++ b/tests/src/core/testqgsrasterlayer.cpp @@ -435,19 +435,19 @@ void TestQgsRasterLayer::checkScaleOffset() QVERIFY( myRasterLayer->height() == 10 ); //QVERIFY( myStatistics.elementCount == 100 ); double minVal = 0.0; - mReport += QStringLiteral( "min = %1 expected = %2 diff = %3
\n" ).arg( myStatistics.minimumValue ).arg( minVal ).arg( fabs( myStatistics.minimumValue - minVal ) ); + mReport += QStringLiteral( "min = %1 expected = %2 diff = %3
\n" ).arg( myStatistics.minimumValue ).arg( minVal ).arg( std::fabs( myStatistics.minimumValue - minVal ) ); double maxVal = 9.0; - mReport += QStringLiteral( "max = %1 expected = %2 diff = %3
\n" ).arg( myStatistics.maximumValue ).arg( maxVal ).arg( fabs( myStatistics.maximumValue - maxVal ) ); + mReport += QStringLiteral( "max = %1 expected = %2 diff = %3
\n" ).arg( myStatistics.maximumValue ).arg( maxVal ).arg( std::fabs( myStatistics.maximumValue - maxVal ) ); double meanVal = 4.5; - mReport += QStringLiteral( "min = %1 expected = %2 diff = %3
\n" ).arg( myStatistics.mean ).arg( meanVal ).arg( fabs( myStatistics.mean - meanVal ) ); - QVERIFY( fabs( myStatistics.minimumValue - minVal ) < 0.0000001 ); - QVERIFY( fabs( myStatistics.maximumValue - maxVal ) < 0.0000001 ); - QVERIFY( fabs( myStatistics.mean - meanVal ) < 0.0000001 ); + mReport += QStringLiteral( "min = %1 expected = %2 diff = %3
\n" ).arg( myStatistics.mean ).arg( meanVal ).arg( std::fabs( myStatistics.mean - meanVal ) ); + QVERIFY( std::fabs( myStatistics.minimumValue - minVal ) < 0.0000001 ); + QVERIFY( std::fabs( myStatistics.maximumValue - maxVal ) < 0.0000001 ); + QVERIFY( std::fabs( myStatistics.mean - meanVal ) < 0.0000001 ); double stdDev = 2.87228615; // TODO: verify why GDAL stdDev is so different from generic (2.88675) - mReport += QStringLiteral( "stdDev = %1 expected = %2 diff = %3
\n" ).arg( myStatistics.stdDev ).arg( stdDev ).arg( fabs( myStatistics.stdDev - stdDev ) ); - QVERIFY( fabs( myStatistics.stdDev - stdDev ) < 0.0000001 ); + mReport += QStringLiteral( "stdDev = %1 expected = %2 diff = %3
\n" ).arg( myStatistics.stdDev ).arg( stdDev ).arg( std::fabs( myStatistics.stdDev - stdDev ) ); + QVERIFY( std::fabs( myStatistics.stdDev - stdDev ) < 0.0000001 ); QgsRasterDataProvider *myProvider = myRasterLayer->dataProvider(); QgsPointXY myPoint( 1535030, 5083350 ); @@ -474,8 +474,8 @@ void TestQgsRasterLayer::checkScaleOffset() double value = values.value( bandNo ).toDouble(); valueString = QgsRasterBlock::printValue( value ); mReport += QStringLiteral( " %1 = %2
\n" ).arg( myProvider->generateBandName( bandNo ), valueString ); - mReport += QStringLiteral( " value = %1 expected = %2 diff = %3
\n" ).arg( value ).arg( expected ).arg( fabs( value - expected ) ); - QVERIFY( fabs( value - expected ) < 0.0000001 ); + mReport += QStringLiteral( " value = %1 expected = %2 diff = %3
\n" ).arg( value ).arg( expected ).arg( std::fabs( value - expected ) ); + QVERIFY( std::fabs( value - expected ) < 0.0000001 ); } } } diff --git a/tests/src/providers/grass/testqgsgrassprovider.cpp b/tests/src/providers/grass/testqgsgrassprovider.cpp index 0047d9a66b6..9296933e0a5 100644 --- a/tests/src/providers/grass/testqgsgrassprovider.cpp +++ b/tests/src/providers/grass/testqgsgrassprovider.cpp @@ -340,7 +340,7 @@ bool TestQgsGrassProvider::compare( const QStringList &expected, const QStringLi bool TestQgsGrassProvider::compare( double expected, double got, bool &ok ) { - if ( fabs( got - expected ) > TINY_VALUE ) + if ( std::fabs( got - expected ) > TINY_VALUE ) { ok = false; return false;