~neon/kolourpaint/master

« back to all changes in this revision

Viewing changes to tools/polygonal/kpToolPolygonalBase.cpp

  • Committer: Tomaz Canabrava
  • Author(s): André Agenor
  • Date: 2019-02-14 09:40:06 UTC
  • Revision ID: git-v1:d69b9ee1426dba5b270a8264a5e2a441998744f0
Replace some math macro definitions

Summary: Remove some unused include of math and add a std:: scope to math functions

Reviewers: tcanabrava

Reviewed By: tcanabrava

Differential Revision: https://phabricator.kde.org/D18876

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "kpToolPolygonalBase.h"
33
33
 
34
34
#include <cfloat>
35
 
#include <cmath>
 
35
#include <QtMath>
36
36
 
37
37
#include <QCursor>
38
38
#include <QPoint>
232
232
        int numAngles = 0;
233
233
        angles [numAngles++] = 0;
234
234
        if (controlPressed ())
235
 
            angles [numAngles++] = KP_PI / 6;
 
235
            angles [numAngles++] = M_PI / 6;
236
236
        if (shiftPressed ())
237
 
            angles [numAngles++] = KP_PI / 4;
 
237
            angles [numAngles++] = M_PI / 4;
238
238
        if (controlPressed ())
239
 
            angles [numAngles++] = KP_PI / 3;
240
 
        angles [numAngles++] = KP_PI / 2;
 
239
            angles [numAngles++] = M_PI / 3;
 
240
        angles [numAngles++] = M_PI / 2;
241
241
        Q_ASSERT (numAngles <= int (sizeof (angles) / sizeof (angles [0])));
242
242
 
243
243
        double angle = angles [numAngles - 1];
244
244
        for (int i = 0; i < numAngles - 1; i++)
245
245
        {
246
 
            double acceptingRatio = tan ((angles [i] + angles [i + 1]) / 2.0);
 
246
            double acceptingRatio = std::tan ((angles [i] + angles [i + 1]) / 2.0);
247
247
            if (ratio < acceptingRatio)
248
248
            {
249
249
                angle = angles [i];
252
252
        }
253
253
 
254
254
        // horizontal (dist from start not maintained)
255
 
        if (fabs (KP_RADIANS_TO_DEGREES (angle) - 0)
 
255
        if (std::fabs (qRadiansToDegrees (angle) - 0)
256
256
            < kpPixmapFX::AngleInDegreesEpsilon)
257
257
        {
258
258
            lineEndPoint =
259
259
                QPoint (lineEndPoint.x (), lineStartPoint.y ());
260
260
        }
261
261
        // vertical (dist from start not maintained)
262
 
        else if (fabs (KP_RADIANS_TO_DEGREES (angle) - 90)
 
262
        else if (std::fabs (qRadiansToDegrees (angle) - 90)
263
263
                 < kpPixmapFX::AngleInDegreesEpsilon)
264
264
        {
265
265
            lineEndPoint =
268
268
        // diagonal (dist from start maintained)
269
269
        else
270
270
        {
271
 
            const double dist = sqrt (static_cast<double> (diffx * diffx + diffy * diffy));
 
271
            const double dist = std::sqrt (static_cast<double> (diffx * diffx + diffy * diffy));
272
272
 
273
273
            #define sgn(a) ((a)<0?-1:1)
274
274
            // Round distances _before_ adding to any coordinate