From c5c3862bfcf5b517e37c7f88387881dbd692ffdd Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 16 Mar 2016 14:09:56 +0200 Subject: [PATCH] More human readable angle of line. --HG-- branch : develop --- src/libs/vpatterndb/variables/vlineangle.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libs/vpatterndb/variables/vlineangle.cpp b/src/libs/vpatterndb/variables/vlineangle.cpp index cb0f18bb9..f28d8136f 100644 --- a/src/libs/vpatterndb/variables/vlineangle.cpp +++ b/src/libs/vpatterndb/variables/vlineangle.cpp @@ -32,6 +32,12 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) +# include "../vmisc/vmath.h" +#else +# include +#endif + //--------------------------------------------------------------------------------------------------------------------- VLineAngle::VLineAngle() :VInternalVariable(), d(new VLineAngleData) @@ -84,7 +90,9 @@ void VLineAngle::SetValue(const VPointF *p1, const VPointF *p2) { SCASSERT(p1 != nullptr); SCASSERT(p2 != nullptr); - VInternalVariable::SetValue(QLineF(p1->toQPointF(), p2->toQPointF()).angle()); + //Correct angle. Try avoid results like 6,7563e-15. + const qreal angle = qFloor(QLineF(p1->toQPointF(), p2->toQPointF()).angle() * 100000.) / 100000.; + VInternalVariable::SetValue(angle); } //---------------------------------------------------------------------------------------------------------------------