diff --git a/src/app/share/collection/bugs/Issue_#647.val b/src/app/share/collection/bugs/Issue_#647.val new file mode 100644 index 000000000..d9fad1d09 --- /dev/null +++ b/src/app/share/collection/bugs/Issue_#647.val @@ -0,0 +1,26 @@ + + + + 0.4.6 + cm + + + + + + + + + + + + + + + + + +
+ + + diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index 5d7a17377..727b888b9 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -130,15 +130,18 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li const qint32 res = VGObject::LineIntersectCircle(pShoulder, length, line, p1, p2); - // If possition is right we will find only one result. - // If found two cases this is wrong result. Return default position. - if (res == 1) + if (res == 1 || res == 2) { - const QLineF line = QLineF(p1Line, p1); - if (line.length() > baseLength && baseAngle == qRound(line.angle())) + const QLineF line1 = QLineF(p1Line, p1); + const QLineF line2 = QLineF(p1Line, p2); + if (line1.length() > baseLength && baseAngle == qRound(line1.angle())) { shoulderPoint = p1; } + else if (res == 2 && line2.length() > baseLength && baseAngle == qRound(line2.angle())) + { + shoulderPoint = p2; + } } return shoulderPoint; diff --git a/src/test/ValentinaTest/tst_findpoint.cpp b/src/test/ValentinaTest/tst_findpoint.cpp index 43acd44bf..d7d969994 100644 --- a/src/test/ValentinaTest/tst_findpoint.cpp +++ b/src/test/ValentinaTest/tst_findpoint.cpp @@ -31,6 +31,7 @@ #include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" #include @@ -266,3 +267,43 @@ void TST_FindPoint::TestTriangle() QPointF resultPoint = VToolTriangle::FindPoint(axisP1, axisP2, firstPoint, secondPoint); QCOMPARE(point, resultPoint); } + +//--------------------------------------------------------------------------------------------------------------------- +void TST_FindPoint::TestShoulderPoint_data() +{ + QTest::addColumn("p1"); + QTest::addColumn("p2"); + QTest::addColumn("pShoulder"); + QTest::addColumn("length"); + QTest::addColumn("point"); + + // See file /src/app/share/collection/bugs/Issue_#647.val + QTest::newRow("Value found") << QPointF(-234.5669291338583, 39.999874015748034) + << QPointF(-574.724409448819, 115.5904251968504) + << QPointF(-234.5669291338583, -35.590677165354336) + << 566.92913385826773 + << QPointF(-767.2805101289953, 158.3806697924456); + + // The same file /src/app/share/collection/bugs/Issue_#647.val + // The length changed to get default value + QPointF p2(-574.724409448819, 115.5904251968504); + QTest::newRow("Value not found") << QPointF(-234.5669291338583, 39.999874015748034) + << p2 + << QPointF(-234.5669291338583, -35.590677165354336) + << 75.59055118110237 + << p2; +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_FindPoint::TestShoulderPoint() +{ + QFETCH(QPointF, p1); + QFETCH(QPointF, p2); + QFETCH(QPointF, pShoulder); + QFETCH(qreal, length); + QFETCH(QPointF, point); + + QPointF resultPoint = VToolShoulderPoint::FindPoint(p1, p2, pShoulder, length); + + QCOMPARE(point, resultPoint); +} diff --git a/src/test/ValentinaTest/tst_findpoint.h b/src/test/ValentinaTest/tst_findpoint.h index 694deb3a4..75fe13ee6 100644 --- a/src/test/ValentinaTest/tst_findpoint.h +++ b/src/test/ValentinaTest/tst_findpoint.h @@ -50,6 +50,8 @@ private slots: void TestTriangle_data(); void TestTriangle(); + void TestShoulderPoint_data(); + void TestShoulderPoint(); }; #endif // TST_FINDPOINT_H