Skip to content

Commit 7f44737

Browse files
committed
Remove redundant math constant defines
Since we use _USE_MATH_DEFINES for windows builds, these are not required
1 parent 07a570f commit 7f44737

15 files changed

+5
-65
lines changed

python/core/symbology/qgssymbollayer.sip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212

1313

14-
1514
class QgsSymbolLayer
1615
{
1716

src/analysis/raster/qgskde.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
#define NO_DATA -9999
2222

23-
#ifndef M_PI
24-
#define M_PI 3.14159265358979323846
25-
#endif
26-
2723
QgsKernelDensityEstimation::QgsKernelDensityEstimation( const QgsKernelDensityEstimation::Parameters &parameters, const QString &outputFile, const QString &outputFormat )
2824
: mSource( parameters.source )
2925
, mOutputFile( outputFile )

src/app/dwg/libdxfrw/drw_base.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@
3838
# define DRW_POSIX
3939
#endif
4040

41-
#ifndef M_PI
42-
#define M_PI 3.141592653589793238462643
43-
#endif
44-
#ifndef M_PI_2
45-
#define M_PI_2 1.57079632679489661923
46-
#endif
4741
#define M_PIx2 6.283185307179586 // 2*PI
4842
#define ARAD 57.29577951308232
4943

src/app/qgsdecorationnortharrowdialog.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow()
152152
myQPainter.rotate( rotation );
153153
//work out how to shift the image so that it appears in the center of the canvas
154154
//(x cos a + y sin a - x, -x sin a + y cos a - y)
155-
const double PI = 3.14159265358979323846;
156-
double myRadiansDouble = ( PI / 180 ) * rotation;
155+
double myRadiansDouble = ( M_PI / 180 ) * rotation;
157156
int xShift = static_cast<int>( (
158157
( centerXDouble * std::cos( myRadiansDouble ) ) +
159158
( centerYDouble * std::sin( myRadiansDouble ) )

src/app/qgsmaptoolrotatefeature.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
#include <limits>
3737
#include <cmath>
3838

39-
#define PI 3.14159265
40-
4139
QgsAngleMagnetWidget::QgsAngleMagnetWidget( const QString &label, QWidget *parent )
4240
: QWidget( parent )
4341
{
@@ -152,7 +150,7 @@ void QgsMapToolRotateFeature::canvasMoveEvent( QgsMapMouseEvent *e )
152150
{
153151
const double XDistance = e->pos().x() - mStPoint.x();
154152
const double YDistance = e->pos().y() - mStPoint.y();
155-
double rotation = std::atan2( YDistance, XDistance ) * ( 180 / PI );
153+
double rotation = std::atan2( YDistance, XDistance ) * ( 180 / M_PI );
156154

157155
if ( mRotationWidget )
158156
{
@@ -297,7 +295,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
297295

298296
double XDistance = mInitialPos.x() - mAnchorPoint->x();
299297
double YDistance = mInitialPos.y() - mAnchorPoint->y() ;
300-
mRotationOffset = std::atan2( YDistance, XDistance ) * ( 180 / PI );
298+
mRotationOffset = std::atan2( YDistance, XDistance ) * ( 180 / M_PI );
301299

302300
createRotationWidget();
303301
if ( e->modifiers() & Qt::ShiftModifier )
@@ -349,7 +347,7 @@ void QgsMapToolRotateFeature::applyRotation( double rotation )
349347
}
350348

351349
//calculations for affine transformation
352-
double angle = -1 * mRotation * ( PI / 180 );
350+
double angle = -1 * mRotation * ( M_PI / 180 );
353351
QgsPointXY anchorPoint = toLayerCoordinates( vlayer, mStartPointMapCoords );
354352
double a = std::cos( angle );
355353
double b = -1 * std::sin( angle );

src/app/qgsmaptoolselectradius.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ email : jpalmer at linz dot govt dot nz
2424
#include <cmath>
2525
#include <QMouseEvent>
2626

27-
#ifndef M_PI
28-
#define M_PI 3.1415926535897931159979634685
29-
#endif
30-
3127
const int RADIUS_SEGMENTS = 40;
3228

3329
QgsMapToolSelectRadius::QgsMapToolSelectRadius( QgsMapCanvas *canvas )

src/core/geometry/qgsinternalgeometryengine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ QgsVector calcMotion( const QgsPoint &a, const QgsPoint &b, const QgsPoint &c,
373373

374374
// wonderful nasty hack which has survived through JOSM -> id -> QGIS
375375
// to deal with almost-straight segments (angle is closer to 180 than to 90/270).
376-
if ( dotProduct < -0.707106781186547 )
376+
if ( dotProduct < -M_SQRT1_2 )
377377
dotProduct += 1.0;
378378

379379
QgsVector new_v = p + q;

src/core/pal/feature.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444
#include <cmath>
4545
#include <cfloat>
4646

47-
#ifndef M_PI
48-
#define M_PI 3.14159265358979323846
49-
#endif
50-
5147
using namespace pal;
5248

5349
FeaturePart::FeaturePart( QgsLabelFeature *feat, const GEOSGeometry *geom )

src/core/pal/labelposition.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
#include <cmath>
3939
#include <cfloat>
4040

41-
#ifndef M_PI
42-
#define M_PI 3.1415926535897931159979634685
43-
#endif
44-
4541
using namespace pal;
4642

4743
LabelPosition::LabelPosition( int id, double x1, double y1, double w, double h, double alpha, double cost, FeaturePart *feature, bool isReversed, Quadrant quadrant )

src/core/pal/util.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@
3737
#include "qgslogger.h"
3838
#include <cfloat>
3939

40-
#ifndef M_PI
41-
#define M_PI 3.14159265358979323846
42-
#endif
43-
44-
#ifndef M_PI_2
45-
#define M_PI_2 1.57079632679489661923
46-
#endif
47-
48-
#ifndef M_SQRT2
49-
#define M_SQRT2 1.41421356237309504880
50-
#endif
51-
5240
void pal::Util::sort( void **items, int N, bool ( *greater )( void *l, void *r ) )
5341
{
5442

src/core/qgsdistancearea.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
#include "qgsunittypes.h"
3535
#include "qgsexception.h"
3636

37-
// MSVC compiler doesn't have defined M_PI in math.h
38-
#ifndef M_PI
39-
#define M_PI 3.14159265358979323846
40-
#endif
41-
4237
#define DEG2RAD(x) ((x)*M_PI/180)
4338
#define RAD2DEG(r) (180.0 * (r) / M_PI)
4439
#define POW2(x) ((x)*(x))

src/core/symbology/qgspointclusterrenderer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#include "qgsproperty.h"
2525
#include <cmath>
2626

27-
#ifndef M_SQRT2
28-
#define M_SQRT2 1.41421356237309504880
29-
#endif
30-
3127
QgsPointClusterRenderer::QgsPointClusterRenderer()
3228
: QgsPointDistanceRenderer( QStringLiteral( "pointCluster" ) )
3329
{

src/core/symbology/qgspointdisplacementrenderer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
#include <QPainter>
2626
#include <cmath>
2727

28-
#ifndef M_SQRT2
29-
#define M_SQRT2 1.41421356237309504880
30-
#endif
31-
3228
QgsPointDisplacementRenderer::QgsPointDisplacementRenderer( const QString &labelAttributeName )
3329
: QgsPointDistanceRenderer( QStringLiteral( "pointDisplacement" ), labelAttributeName )
3430
, mPlacement( Ring )

src/core/symbology/qgspointdistancerenderer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727

2828
#include <cmath>
2929

30-
#ifndef M_SQRT2
31-
#define M_SQRT2 1.41421356237309504880
32-
#endif
33-
3430
QgsPointDistanceRenderer::QgsPointDistanceRenderer( const QString &rendererName, const QString &labelAttributeName )
3531
: QgsFeatureRenderer( rendererName )
3632
, mLabelAttributeName( labelAttributeName )

src/core/symbology/qgssymbollayer.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
#ifndef QGSSYMBOLLAYER_H
1616
#define QGSSYMBOLLAYER_H
1717

18-
// MSVC compiler doesn't have defined M_PI in math.h
19-
#ifndef M_PI
20-
#define M_PI 3.14159265358979323846
21-
#endif
22-
2318
#define DEG2RAD(x) ((x)*M_PI/180)
2419
#define DEFAULT_SCALE_METHOD QgsSymbol::ScaleDiameter
2520

0 commit comments

Comments
 (0)