Skip to content
Permalink
Browse files

Make sure (f)abs are prefixed with std::

  • Loading branch information
nyalldawson committed Aug 24, 2017
1 parent f2b2c6d commit 77c3be97e33e100637537f0167b5fd784639c20c
Showing with 274 additions and 274 deletions.
  1. +2 −2 src/analysis/interpolation/MathUtils.cc
  2. +4 −4 src/analysis/raster/qgsalignraster.cpp
  3. +1 −1 src/analysis/raster/qgsrelief.cpp
  4. +2 −2 src/analysis/vector/qgsgeometrysnapper.cpp
  5. +5 −5 src/app/dwg/libdxfrw/drw_entities.cpp
  6. +1 −1 src/app/dwg/libdxfrw/drw_objects.cpp
  7. +4 −4 src/app/qgsdecorationgrid.cpp
  8. +1 −1 src/app/qgsdecorationscalebar.cpp
  9. +1 −1 src/app/qgslabelinggui.cpp
  10. +4 −4 src/app/qgsmaptoolmeasureangle.cpp
  11. +1 −1 src/app/qgsundowidget.cpp
  12. +1 −1 src/core/composer/qgscomposerarrow.cpp
  13. +2 −2 src/core/composer/qgscomposermapgrid.cpp
  14. +6 −6 src/core/composer/qgscomposermousehandles.cpp
  15. +3 −3 src/core/composer/qgscomposernodesitem.cpp
  16. +2 −2 src/core/composer/qgscomposerpicture.cpp
  17. +4 −4 src/core/composer/qgscomposerutils.cpp
  18. +2 −2 src/core/composer/qgscomposition.cpp
  19. +1 −1 src/core/dxf/qgsdxfpaintengine.cpp
  20. +2 −2 src/core/effects/qgsimageoperation.cpp
  21. +7 −7 src/core/expression/qgsexpressionfunction.cpp
  22. +9 −9 src/core/geometry/qgscircle.cpp
  23. +3 −3 src/core/geometry/qgscircle.h
  24. +2 −2 src/core/geometry/qgscurvepolygon.cpp
  25. +6 −6 src/core/geometry/qgsellipse.cpp
  26. +1 −1 src/core/geometry/qgsgeometry.cpp
  27. +1 −1 src/core/geometry/qgsgeometryutils.cpp
  28. +2 −2 src/core/geometry/qgsgeos.cpp
  29. +2 −2 src/core/geometry/qgsinternalgeometryengine.cpp
  30. +4 −4 src/core/geometry/qgsregularpolygon.cpp
  31. +3 −3 src/core/layout/qgslayoutsnapper.cpp
  32. +6 −6 src/core/pal/feature.cpp
  33. +4 −4 src/core/pal/pointset.cpp
  34. +2 −2 src/core/qgsclipper.h
  35. +1 −1 src/core/qgscoordinatereferencesystem.cpp
  36. +3 −3 src/core/qgsdistancearea.cpp
  37. +4 −4 src/core/qgsmaprendererjob.cpp
  38. +2 −2 src/core/qgsmapsettings.cpp
  39. +5 −5 src/core/qgspallabeling.cpp
  40. +8 −8 src/core/qgspointxy.cpp
  41. +6 −6 src/core/qgsrenderchecker.cpp
  42. +2 −2 src/core/qgstestutils.h
  43. +1 −1 src/core/qgstracer.cpp
  44. +13 −13 src/core/qgsunittypes.cpp
  45. +1 −1 src/core/qgsvectorfilewriter.cpp
  46. +1 −1 src/core/qgsvectorlayerlabeling.cpp
  47. +1 −1 src/core/raster/qgscolorrampshader.cpp
  48. +2 −2 src/core/raster/qgsrasterchecker.cpp
  49. +3 −3 src/core/raster/qgsrasterminmaxorigin.cpp
  50. +1 −1 src/core/simplify/effectivearea.cpp
  51. +1 −1 src/core/symbology/qgs25drenderer.cpp
  52. +4 −4 src/core/symbology/qgsarrowsymbollayer.cpp
  53. +7 −7 src/core/symbology/qgsfillsymbollayer.cpp
  54. +3 −3 src/core/symbology/qgslinesymbollayer.cpp
  55. +1 −1 src/core/symbology/qgssymbollayerutils.cpp
  56. +2 −2 src/gui/layout/qgslayoutruler.cpp
  57. +1 −1 src/gui/layout/qgslayoutview.cpp
  58. +3 −3 src/gui/layout/qgslayoutviewrubberband.cpp
  59. +1 −1 src/gui/layout/qgslayoutviewtool.cpp
  60. +6 −6 src/gui/qgsadvanceddigitizingdockwidget.cpp
  61. +2 −2 src/gui/qgscolorwidgets.cpp
  62. +5 −5 src/gui/qgscomposerview.cpp
  63. +3 −3 src/gui/qgsgradientstopeditor.cpp
  64. +3 −3 src/gui/qgsmapcanvas.cpp
  65. +5 −5 src/gui/qgsmapcanvasannotationitem.cpp
  66. +2 −2 src/gui/qgsmaptoolextent.cpp
  67. +1 −1 src/gui/qgsscalecombobox.cpp
  68. +1 −1 src/gui/raster/qgsrasterhistogramwidget.cpp
  69. +3 −3 src/gui/symbology/qgsgraduatedhistogramwidget.cpp
  70. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp
  71. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.h
  72. +1 −1 src/plugins/geometry_checker/utils/qgsgeometrycheckerutils.cpp
  73. +1 −1 src/plugins/georeferencer/qgsgeorefdelegates.cpp
  74. +5 −5 src/plugins/georeferencer/qgsgeoreftransform.cpp
  75. +2 −2 src/plugins/georeferencer/qgsleastsquares.cpp
  76. +1 −1 src/plugins/georeferencer/qgsmapcoordsdialog.cpp
  77. +1 −1 src/plugins/grass/qgsgrassnewmapset.cpp
  78. +3 −3 src/plugins/grass/qtermwidget/ColorScheme.cpp
  79. +5 −5 src/plugins/grass/qtermwidget/TerminalDisplay.cpp
  80. +4 −4 src/providers/gdal/qgsgdalprovider.cpp
  81. +1 −1 src/providers/grass/qgsgrassrasterprovider.cpp
  82. +4 −4 src/providers/wcs/qgswcsprovider.cpp
  83. +4 −4 src/providers/wfs/qgswfscapabilities.cpp
  84. +3 −3 src/providers/wms/qgswmsprovider.cpp
  85. +1 −1 tests/bench/qgsbench.cpp
  86. +16 −16 tests/src/core/testqgscomposermap.cpp
  87. +10 −10 tests/src/core/testqgsrasterlayer.cpp
  88. +1 −1 tests/src/providers/grass/testqgsgrassprovider.cpp
@@ -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;
@@ -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 );
@@ -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
@@ -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;
@@ -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 )
@@ -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();
@@ -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;
}
@@ -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
@@ -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
@@ -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 );
@@ -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 )
{
@@ -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 );
@@ -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 );
@@ -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 )
@@ -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;
@@ -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;
@@ -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 );
@@ -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<float>::epsilon() )
if ( std::fabs( length3 - length4 ) < std::numeric_limits<float>::epsilon() )
distance = computeDistance( inter, start );
}

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

0 comments on commit 77c3be9

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