From 5b2587d704ce6b54f659b785bc74b347c2d8a570 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 11 Jan 2020 14:51:25 +0200 Subject: [PATCH] Fix regressions. ref #989 --HG-- branch : release --- src/libs/vgeometry/vellipticalarc.cpp | 9 +++++++ src/test/ValentinaTest/tst_vellipticalarc.cpp | 26 ++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index 533508117..c3cf109f6 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -300,6 +300,15 @@ QVector VEllipticalArc::GetPoints() const #else polygon = path.toSubpathPolygons().first(); // clazy:exclude=detaching-temporary #endif + +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + if (not polygon.isEmpty() && not VFuzzyComparePoints(GetP1(), polygon.constFirst())) +#else + if (not polygon.isEmpty() && not VFuzzyComparePoints(GetP1(), polygon.first())) // clazy:exclude=detaching-temporary +#endif + { + polygon.removeFirst(); // remove point (0;0) + } } return polygon; diff --git a/src/test/ValentinaTest/tst_vellipticalarc.cpp b/src/test/ValentinaTest/tst_vellipticalarc.cpp index d6ed5499d..920bc8a95 100644 --- a/src/test/ValentinaTest/tst_vellipticalarc.cpp +++ b/src/test/ValentinaTest/tst_vellipticalarc.cpp @@ -84,8 +84,9 @@ void TST_VEllipticalArc::CompareTwoWays() VEllipticalArc arc2(length, center, radius1, radius2, f1, rotationAngle); - const qreal lengthEps = ToPixel(0.4, Unit::Mm); // computing error - const QString errorLengthMsg = + const qreal lengthEps = ToPixel(0.45, Unit::Mm); // computing error + + QString errorLengthMsg = QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"); QVERIFY2(qAbs(arc2.GetLength() - length) <= lengthEps, qUtf8Printable(errorLengthMsg.arg(lengthEps).arg(arc2.GetLength()).arg(length))); @@ -117,12 +118,16 @@ void TST_VEllipticalArc::NegativeArc() const qreal length = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h)))/2; VEllipticalArc arc(-length, center, radius1, radius2, f1, rotationAngle); - const qreal eps = 1; // computing error + const qreal eps = ToPixel(0.45, Unit::Mm); // computing error const QString errorMsg = - QString("Difference between real and computing lengthes bigger than eps = %1.").number(eps); + QString("Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3"); - QVERIFY2(qAbs(arc.GetLength() + length) <= eps, qUtf8Printable(errorMsg)); - QVERIFY2(arc.GetEndAngle() - f2 <= eps, qUtf8Printable(errorMsg)); + QVERIFY2(qAbs(arc.GetLength() + length) <= eps, + qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length))); + + const qreal angleEps = 0.4; + QVERIFY2(arc.GetEndAngle() - f2 <= angleEps, + qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2))); } // cppcheck-suppress unusedFunction @@ -502,7 +507,14 @@ void TST_VEllipticalArc::TestRotation() QVERIFY2(qAbs(arcOrigin.AngleArc() - rotatedArc.AngleArc()) <= 1.6, qUtf8Printable(QString("a1 = %1, a2 - %2").arg(arcOrigin.AngleArc()).arg(rotatedArc.AngleArc()))); - QVERIFY(qAbs(arcOrigin.GetLength() - rotatedArc.GetLength()) <= ToPixel(1, Unit::Mm)); + + QString errorLengthMsg = + QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"); + QVERIFY2(qAbs(arcOrigin.GetLength() - rotatedArc.GetLength()) <= ToPixel(1, Unit::Mm), + qUtf8Printable(errorLengthMsg.arg(ToPixel(1, Unit::Mm)) + .arg(arcOrigin.GetLength()) + .arg(rotatedArc.GetLength()))); + QCOMPARE(arcOrigin.GetRadius1(), rotatedArc.GetRadius1()); QCOMPARE(arcOrigin.GetRadius2(), rotatedArc.GetRadius2()); QCOMPARE(arcOrigin.GetRotationAngle(), rotatedArc.GetRotationAngle());