Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make sure (f)abs are prefixed with std::
  • Loading branch information
nyalldawson committed Aug 24, 2017
1 parent f2b2c6d commit 77c3be9
Show file tree
Hide file tree
Showing 88 changed files with 274 additions and 274 deletions.
4 changes: 2 additions & 2 deletions src/analysis/interpolation/MathUtils.cc
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/raster/qgsalignraster.cpp
Expand Up @@ -30,15 +30,15 @@

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

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 );
Expand Down Expand Up @@ -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] );
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsrelief.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/vector/qgsgeometrysnapper.cpp
Expand Up @@ -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 )
Expand Down
10 changes: 5 additions & 5 deletions src/app/dwg/libdxfrw/drw_entities.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/app/dwg/libdxfrw/drw_objects.cpp
Expand Up @@ -505,7 +505,7 @@ void DRW_LType::update()
size = path.size();
for ( std::vector<double>::size_type i = 0; i < size; i++ )
{
d += fabs( path.at( i ) );
d += std::fabs( path.at( i ) );
}
length = d;
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsdecorationgrid.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdecorationscalebar.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslabelinggui.cpp
Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsmaptoolmeasureangle.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsundowidget.cpp
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerarrow.cpp
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposermapgrid.cpp
Expand Up @@ -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 )
Expand Down
12 changes: 6 additions & 6 deletions src/core/composer/qgscomposermousehandles.cpp
Expand Up @@ -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<double>::min() && fabs( diffY ) < std::numeric_limits<double>::min() )
if ( std::fabs( diffX ) < std::numeric_limits<double>::min() && std::fabs( diffY ) < std::numeric_limits<double>::min() )
{
mIsDragging = false;
mIsResizing = false;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() ) );
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposernodesitem.cpp
Expand Up @@ -77,7 +77,7 @@ bool QgsComposerNodesItem::addNode( QPointF pt,

double distance = std::numeric_limits<double>::max();
if ( qIsInf( coef ) )
distance = fabs( pt1.x() - start.x() );
distance = std::fabs( pt1.x() - start.x() );
else
{
const double coef2 = ( -1 / coef );
Expand All @@ -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() );
}
Expand All @@ -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<float>::epsilon() )
if ( std::fabs( length3 - length4 ) < std::numeric_limits<float>::epsilon() )
distance = computeDistance( inter, start );
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposerpicture.cpp
Expand Up @@ -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() );
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/composer/qgscomposerutils.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 );
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposition.cpp
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfpaintengine.cpp
Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/effects/qgsimageoperation.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 77c3be9

Please sign in to comment.