Skip to content
Permalink
Browse files

use Qt macros also for min/max/abs/fabs - removes OSX cmath kludges

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14713 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 19, 2010
1 parent 87fec6f commit 3d44f437fc1481abfce9518b77eceb5f77cb4012
Showing with 250 additions and 296 deletions.
  1. +1 −4 src/analysis/interpolation/CloughTocherInterpolator.cc
  2. +1 −1 src/analysis/interpolation/DualEdgeTriangulation.cc
  3. +4 −4 src/analysis/interpolation/MathUtils.cc
  4. +0 −4 src/analysis/interpolation/MathUtils.h
  5. +0 −4 src/analysis/interpolation/Point3D.h
  6. +0 −4 src/analysis/interpolation/Vector3D.h
  7. +33 −37 src/analysis/raster/qgsrastermatrix.cpp
  8. +1 −1 src/app/legend/qgslegend.cpp
  9. +0 −5 src/app/qgsdisplayangle.cpp
  10. +1 −1 src/app/qgslabeldialog.cpp
  11. +2 −7 src/app/qgsmaptoolmeasureangle.cpp
  12. +1 −1 src/app/qgsmaptoolnodetool.cpp
  13. +1 −1 src/app/qgsmaptoolsimplify.cpp
  14. +0 −5 src/app/qgspointrotationitem.cpp
  15. +7 −7 src/app/qgsvectorlayerproperties.cpp
  16. +18 −13 src/core/composer/qgscomposerarrow.cpp
  17. +2 −6 src/core/composer/qgscomposeritem.cpp
  18. +6 −6 src/core/composer/qgscomposerlegend.cpp
  19. +4 −4 src/core/composer/qgscomposermap.cpp
  20. +2 −2 src/core/composer/qgscomposerpicture.cpp
  21. +1 −1 src/core/qgscoordinatereferencesystem.cpp
  22. +12 −12 src/core/qgsdistancearea.cpp
  23. +3 −3 src/core/qgsmaprenderer.cpp
  24. +3 −3 src/core/qgspallabeling.cpp
  25. +4 −4 src/core/qgspoint.cpp
  26. +1 −1 src/core/qgsrectangle.cpp
  27. +2 −3 src/core/qgsscalecalculator.cpp
  28. +0 −6 src/core/qgssearchtreenode.cpp
  29. +1 −3 src/core/qgstolerance.cpp
  30. +4 −4 src/core/qgsvectorlayer.cpp
  31. +4 −4 src/core/raster/qgscolorrampshader.cpp
  32. +32 −32 src/core/raster/qgsrasterlayer.cpp
  33. +2 −2 src/core/renderer/qgsgraduatedsymbolrenderer.cpp
  34. +2 −2 src/core/renderer/qgssinglesymbolrenderer.cpp
  35. +2 −2 src/core/renderer/qgsuniquevaluerenderer.cpp
  36. +8 −8 src/core/spatialindex/geometry/LineSegment.cc
  37. +8 −8 src/core/spatialindex/geometry/Region.cc
  38. +4 −4 src/core/spatialindex/rtree/Index.cc
  39. +10 −10 src/core/spatialindex/rtree/Node.cc
  40. +2 −2 src/core/spatialindex/rtree/RTree.cc
  41. +1 −1 src/core/spatialindex/tools/ExternalSort.cc
  42. +5 −5 src/core/spatialindex/tools/Tools.cc
  43. +1 −1 src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
  44. +1 −1 src/core/symbology-ng/qgssymbollayerv2utils.cpp
  45. +9 −9 src/gui/qgsannotationitem.cpp
  46. +4 −4 src/gui/qgsmapcanvas.cpp
  47. +2 −2 src/mapserver/qgssldrule.cpp
  48. +1 −1 src/mapserver/qgswmsserver.cpp
  49. +6 −6 src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp
  50. +4 −4 src/plugins/georeferencer/qgsgeorefplugingui.cpp
  51. +2 −3 src/plugins/georeferencer/qgsgeoreftransform.cpp
  52. +1 −1 src/plugins/georeferencer/qgsimagewarper.cpp
  53. +1 −1 src/plugins/georeferencer/qgsleastsquares.cpp
  54. +0 −4 src/plugins/georeferencer/qgsresidualplotitem.cpp
  55. +1 −1 src/plugins/grass/qgsgrassedit.cpp
  56. +1 −1 src/plugins/grass/qgsgrassnewmapset.cpp
  57. +4 −4 src/plugins/grass/qtermwidget/TerminalDisplay.cpp
  58. +10 −9 src/plugins/point_displacement_renderer/qgspointdisplacementrenderer.cpp
  59. +1 −1 src/providers/grass/qgsgrassrasterprovider.cpp
  60. +6 −6 src/providers/wms/qgswmsprovider.cpp
@@ -16,11 +16,8 @@

#include "CloughTocherInterpolator.h"
#include "qgslogger.h"
#ifndef Q_OS_MACX

#include <cmath>
#else
#include <math.h>
#endif

double CloughTocherInterpolator::calcBernsteinPoly( int n, int i, int j, int k, double u, double v, double w )
{
@@ -383,7 +383,7 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
//Take the higher z-Value in case of two equal points
Point3D* newPoint = mPointVector[mPointVector.count()-1];
Point3D* existingPoint = mPointVector[mTwiceInsPoint];
existingPoint->setZ( std::max( newPoint->getZ(), existingPoint->getZ() ) );
existingPoint->setZ( qMax( newPoint->getZ(), existingPoint->getZ() ) );

mPointVector.remove( mPointVector.count() - 1 );
delete newPoint;
@@ -205,7 +205,7 @@ double MathUtils::distPointFromLine( Point3D* thepoint, Point3D* p1, Point3D* p2
double a = normal.getX();
double b = normal.getY();
double c = -( normal.getX() * p2->getX() + normal.getY() * p2->getY() );
double distance = fabs(( a * thepoint->getX() + b * thepoint->getY() + c ) / ( sqrt( a * a + b * b ) ) );
double distance = qAbs(( a * thepoint->getX() + b * thepoint->getY() + c ) / ( sqrt( a * a + b * b ) ) );
return distance;
}
else
@@ -250,8 +250,8 @@ bool MathUtils::inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3
double px = testp->getX();
double py = testp->getY();

double xmin = min( min( ax, px ), min( bx, cx ) );
double ymin = min( min( ay, py ), min( by, cy ) );
double xmin = qMin( qMin( ax, px ), qMin( bx, cx ) );
double ymin = qMin( qMin( ay, py ), qMin( by, cy ) );
ax -= xmin;
bx -= xmin;
cx -= xmin;
@@ -479,7 +479,7 @@ double MathUtils::power( double a, int b )
return 1;
}
double tmp = a;
for ( int i = 2; i <= fabs(( double )b ); i++ )
for ( int i = 2; i <= qAbs(( double )b ); i++ )
{

a *= tmp;
@@ -17,11 +17,7 @@
#ifndef MATHUTILS_H
#define MATHUTILS_H

#ifndef Q_OS_MACX
#include <cmath>
#else
#include <math.h>
#endif
#include "Vector3D.h"
#include "Point3D.h"

@@ -17,11 +17,7 @@
#ifndef POINT3D_H
#define POINT3D_H

#ifndef Q_OS_MACX
#include <cmath>
#else
#include <math.h>
#endif
#include <iostream>

/**Point3D is a class to represent a three dimensional point*/
@@ -17,11 +17,7 @@
#ifndef VECTOR3D_H
#define VECTOR3D_H

#ifndef Q_OS_MACX
#include <cmath>
#else
#include <math.h>
#endif

class ANALYSIS_EXPORT Vector3D
/**
@@ -18,18 +18,14 @@
#include "qgsrastermatrix.h"
#include <string.h>

#ifndef Q_OS_MACX
#include <cmath>
#else
#include <math.h>
#endif

QgsRasterMatrix::QgsRasterMatrix(): mColumns( 0 ), mRows( 0 ), mData( 0 )
{
}

QgsRasterMatrix::QgsRasterMatrix( int nCols, int nRows, float* data, double nodataValue ):
mColumns( nCols ), mRows( nRows ), mData( data ), mNodataValue( nodataValue )
mColumns( nCols ), mRows( nRows ), mData( data ), mNodataValue( nodataValue )
{
}

@@ -163,22 +159,22 @@ bool QgsRasterMatrix::atangens()

bool QgsRasterMatrix::oneArgumentOperation( OneArgOperator op )
{
if( !mData )
if ( !mData )
{
return false;
}

int nEntries = mColumns * mRows;
double value;
for( int i = 0; i < nEntries; ++i )
for ( int i = 0; i < nEntries; ++i )
{
value = mData[i];
if( value != mNodataValue )
if ( value != mNodataValue )
{
switch( op )
switch ( op )
{
case opSQRT:
if( value < 0 ) //no complex numbers
if ( value < 0 ) //no complex numbers
{
mData[i] = static_cast<float>( mNodataValue );
}
@@ -213,15 +209,15 @@ bool QgsRasterMatrix::oneArgumentOperation( OneArgOperator op )

bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix& other )
{
if( isNumber() && other.isNumber() ) //operation on two 1x1 matrices
if ( isNumber() && other.isNumber() ) //operation on two 1x1 matrices
{
//operations with nodata values always generate nodata
if( mData[0] == mNodataValue || other.number() == other.nodataValue() )
if ( mData[0] == mNodataValue || other.number() == other.nodataValue() )
{
mData[0] = static_cast<float>( mNodataValue );
return true;
}
switch( op )
switch ( op )
{
case opPLUS:
mData[0] = static_cast<float>( number() + other.number() );
@@ -233,7 +229,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
mData[0] = static_cast<float>( number() * other.number() );
break;
case opDIV:
if( other.number() == 0 )
if ( other.number() == 0 )
{
mData[0] = static_cast<float>( mNodataValue );
}
@@ -243,7 +239,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
}
break;
case opPOW:
if( !testPowerValidity( mData[0], ( float ) other.number() ) )
if ( !testPowerValidity( mData[0], ( float ) other.number() ) )
{
mData[0] = static_cast<float>( mNodataValue );
}
@@ -275,22 +271,22 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
}

//two matrices
if( !isNumber() && !other.isNumber() )
if ( !isNumber() && !other.isNumber() )
{
float* matrix = other.mData;
int nEntries = mColumns * mRows;
double value1, value2;

for( int i = 0; i < nEntries; ++i )
for ( int i = 0; i < nEntries; ++i )
{
value1 = mData[i]; value2 = matrix[i];
if( value1 == mNodataValue || value2 == other.mNodataValue )
if ( value1 == mNodataValue || value2 == other.mNodataValue )
{
mData[i] = static_cast<float>( mNodataValue );
}
else
{
switch( op )
switch ( op )
{
case opPLUS:
mData[i] = static_cast<float>( value1 + value2 );
@@ -302,7 +298,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
mData[i] = static_cast<float>( value1 * value2 );
break;
case opDIV:
if( value2 == 0 )
if ( value2 == 0 )
{
mData[i] = static_cast<float>( mNodataValue );
}
@@ -312,7 +308,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
}
break;
case opPOW:
if( !testPowerValidity( value1, value2 ) )
if ( !testPowerValidity( value1, value2 ) )
{
mData[i] = static_cast<float>( mNodataValue );
}
@@ -346,7 +342,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
}

//this matrix is a single number and the other one a real matrix
if( isNumber() )
if ( isNumber() )
{
float* matrix = other.mData;
int nEntries = other.nColumns() * other.nRows();
@@ -355,24 +351,24 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
mData = new float[nEntries]; mColumns = other.nColumns(); mRows = other.nRows();
mNodataValue = other.nodataValue();

if( value == mNodataValue )
if ( value == mNodataValue )
{
for( int i = 0; i < nEntries; ++i )
for ( int i = 0; i < nEntries; ++i )
{
mData[i] = static_cast<float>( mNodataValue );
}
return true;
}

for( int i = 0; i < nEntries; ++i )
for ( int i = 0; i < nEntries; ++i )
{
if( matrix[i] == other.mNodataValue )
if ( matrix[i] == other.mNodataValue )
{
mData[i] = static_cast<float>( mNodataValue );
continue;
}

switch( op )
switch ( op )
{
case opPLUS:
mData[i] = static_cast<float>( value + matrix[i] );
@@ -384,7 +380,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
mData[i] = static_cast<float>( value * matrix[i] );
break;
case opDIV:
if( matrix[i] == 0 )
if ( matrix[i] == 0 )
{
mData[i] = static_cast<float>( mNodataValue );
}
@@ -394,7 +390,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
}
break;
case opPOW:
if( !testPowerValidity( value, matrix[i] ) )
if ( !testPowerValidity( value, matrix[i] ) )
{
mData[i] = static_cast<float>( mNodataValue );
}
@@ -430,23 +426,23 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
double value = other.number();
int nEntries = mColumns * mRows;

if( other.number() == other.mNodataValue )
if ( other.number() == other.mNodataValue )
{
for( int i = 0; i < nEntries; ++i )
for ( int i = 0; i < nEntries; ++i )
{
mData[i] = static_cast<float>( mNodataValue );
}
return true;
}

for( int i = 0; i < nEntries; ++i )
for ( int i = 0; i < nEntries; ++i )
{
if( mData[i] == mNodataValue )
if ( mData[i] == mNodataValue )
{
continue;
}

switch( op )
switch ( op )
{
case opPLUS:
mData[i] = static_cast<float>( mData[i] + value );
@@ -458,7 +454,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
mData[i] = static_cast<float>( mData[i] * value );
break;
case opDIV:
if( value == 0 )
if ( value == 0 )
{
mData[i] = static_cast<float>( mNodataValue );
}
@@ -468,7 +464,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
}
break;
case opPOW:
if( !testPowerValidity( mData[i], value ) )
if ( !testPowerValidity( mData[i], value ) )
{
mData[i] = static_cast<float>( mNodataValue );
}
@@ -503,7 +499,7 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa

bool QgsRasterMatrix::testPowerValidity( double base, double power )
{
if(( base == 0 && power < 0 ) || ( power < 0 && ( power - floor( power ) ) > 0 ) )
if (( base == 0 && power < 0 ) || ( power < 0 && ( power - floor( power ) ) > 0 ) )
{
return false;
}
@@ -1688,7 +1688,7 @@ void QgsLegend::legendLayerZoomNative()
QgsDebugMsg( "Raster units per pixel : " + QString::number( layer->rasterUnitsPerPixel() ) );
QgsDebugMsg( "MapUnitsPerPixel before : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );

mMapCanvas->zoomByFactor( fabs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel() ) );
mMapCanvas->zoomByFactor( qAbs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel() ) );
mMapCanvas->refresh();

QgsDebugMsg( "MapUnitsPerPixel after : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );
@@ -15,12 +15,7 @@

#include "qgsdisplayangle.h"
#include <QSettings>

#ifndef Q_OS_MACX
#include <cmath>
#else
#include <math.h>
#endif

QgsDisplayAngle::QgsDisplayAngle( QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f )
{
@@ -330,7 +330,7 @@ void QgsLabelDialog::changeBufferColor( void )
int QgsLabelDialog::itemNoForField( QString theFieldName, QStringList theFieldList )
{
//if no matches assume first item in list is blank and return that
return std::max( 0, theFieldList.indexOf( theFieldName ) );
return qMax( 0, theFieldList.indexOf( theFieldName ) );
}

QgsLabelDialog::~QgsLabelDialog()
@@ -22,12 +22,7 @@
#include "qgsrubberband.h"
#include <QMouseEvent>
#include <QSettings>

#ifndef Q_OS_MACX
#include <cmath>
#else
#include <math.h>
#endif

QgsMapToolMeasureAngle::QgsMapToolMeasureAngle( QgsMapCanvas* canvas ): QgsMapTool( canvas ), mRubberBand( 0 ), mResultDisplay( 0 )
{
@@ -57,9 +52,9 @@ void QgsMapToolMeasureAngle::canvasMoveEvent( QMouseEvent * e )
double azimutOne = distArea->bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
double azimutTwo = distArea->bearing( mAnglePoints.at( 1 ), point );
double resultAngle = azimutTwo - azimutOne;
QgsDebugMsg( QString::number( fabs( resultAngle ) ) );
QgsDebugMsg( QString::number( qAbs( resultAngle ) ) );
QgsDebugMsg( QString::number( M_PI ) );
if ( fabs( resultAngle ) > M_PI )
if ( qAbs( resultAngle ) > M_PI )
{
if ( resultAngle < 0 )
{
@@ -21,7 +21,7 @@
#include "qgsvectordataprovider.h"
#include "qgstolerance.h"
#include "qgsgeometry.h"
#include <math.h>
#include <cmath>
#include <QMouseEvent>
#include <QMessageBox>
#include "qgslogger.h"

0 comments on commit 3d44f43

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