From 96939530fe1b997f2161ea94356888cb37ca2a2a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 8 Mar 2020 14:26:42 +0100 Subject: Get rid of c-style M_PI. --- plugingui/knob.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'plugingui') diff --git a/plugingui/knob.cc b/plugingui/knob.cc index 3d09d51..25200a7 100644 --- a/plugingui/knob.cc +++ b/plugingui/knob.cc @@ -29,13 +29,12 @@ #include "painter.h" #include -#include +#include -// M_PI is not defined in math.h if __STRICT_ANSI__ is defined. -#ifdef __STRICT_ANSI__ -#undef __STRICT_ANSI__ -#endif -#include +namespace +{ +const double pi = std::atan(1.0) * 4.0; +} namespace GUI { @@ -211,11 +210,11 @@ void Knob::repaintEvent(RepaintEvent* repaintEvent) // Make it start from 20% and stop at 80% double padval = current_value * 0.8 + 0.1; - double from_x = sin((-1 * padval + 1) * 2 * M_PI) * radius * 0.6; - double from_y = cos((-1 * padval + 1) * 2 * M_PI) * radius * 0.6; + double from_x = sin((-1 * padval + 1) * 2 * pi) * radius * 0.6; + double from_y = cos((-1 * padval + 1) * 2 * pi) * radius * 0.6; - double to_x = sin((-1 * padval + 1) * 2 * M_PI) * radius * 0.8; - double to_y = cos((-1 * padval + 1) * 2 * M_PI) * radius * 0.8; + double to_x = sin((-1 * padval + 1) * 2 * pi) * radius * 0.8; + double to_y = cos((-1 * padval + 1) * 2 * pi) * radius * 0.8; // Draw "fat" line by drawing 9 lines with moved start/ending points. p.setColour(Colour(1.0f, 0.0f, 0.0f, 1.0f)); -- cgit v1.2.3