Fixed issue #647. Shoulder tool broken in latest test builds.
--HG-- branch : develop
This commit is contained in:
parent
0612305ea8
commit
862b5823e7
26
src/app/share/collection/bugs/Issue_#647.val
Normal file
26
src/app/share/collection/bugs/Issue_#647.val
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<pattern>
|
||||||
|
<!--Pattern created with Valentina (http://www.valentina-project.org/).-->
|
||||||
|
<version>0.4.6</version>
|
||||||
|
<unit>cm</unit>
|
||||||
|
<author/>
|
||||||
|
<description/>
|
||||||
|
<notes/>
|
||||||
|
<measurements/>
|
||||||
|
<increments/>
|
||||||
|
<draw name="Pattern piece 1">
|
||||||
|
<calculation>
|
||||||
|
<point type="single" x="0.79375" y="1.05833" id="1" name="A" mx="0.132292" my="0.264583"/>
|
||||||
|
<point type="endLine" typeLine="hair" id="2" name="A1" basePoint="1" mx="0.132292" lineColor="black" angle="180" my="0.264583" length="7"/>
|
||||||
|
<point type="endLine" typeLine="hair" id="3" name="A2" basePoint="2" mx="0.132292" lineColor="black" angle="90" my="0.264583" length="2"/>
|
||||||
|
<point type="endLine" typeLine="hair" id="4" name="A3" basePoint="1" mx="0.132292" lineColor="black" angle="270" my="0.264583" length="14"/>
|
||||||
|
<point type="endLine" typeLine="hair" id="5" name="A4" basePoint="4" mx="0.132292" lineColor="black" angle="180" my="0.264583" length="16"/>
|
||||||
|
<point type="pointOfIntersection" id="6" name="A5" firstPoint="5" secondPoint="2" mx="0.132292" my="0.264583"/>
|
||||||
|
<point type="endLine" typeLine="hair" id="7" name="A6" basePoint="6" mx="0.132292" lineColor="black" angle="270" my="0.264583" length="2"/>
|
||||||
|
<point type="shoulder" typeLine="hair" id="8" name="A7" p2Line="7" pShoulder="3" mx="0.132292" lineColor="black" my="0.264583" length="15" p1Line="2"/>
|
||||||
|
</calculation>
|
||||||
|
<modeling/>
|
||||||
|
<details/>
|
||||||
|
<groups/>
|
||||||
|
</draw>
|
||||||
|
</pattern>
|
|
@ -130,15 +130,18 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
|
||||||
|
|
||||||
const qint32 res = VGObject::LineIntersectCircle(pShoulder, length, line, p1, p2);
|
const qint32 res = VGObject::LineIntersectCircle(pShoulder, length, line, p1, p2);
|
||||||
|
|
||||||
// If possition is right we will find only one result.
|
if (res == 1 || res == 2)
|
||||||
// If found two cases this is wrong result. Return default position.
|
|
||||||
if (res == 1)
|
|
||||||
{
|
{
|
||||||
const QLineF line = QLineF(p1Line, p1);
|
const QLineF line1 = QLineF(p1Line, p1);
|
||||||
if (line.length() > baseLength && baseAngle == qRound(line.angle()))
|
const QLineF line2 = QLineF(p1Line, p2);
|
||||||
|
if (line1.length() > baseLength && baseAngle == qRound(line1.angle()))
|
||||||
{
|
{
|
||||||
shoulderPoint = p1;
|
shoulderPoint = p1;
|
||||||
}
|
}
|
||||||
|
else if (res == 2 && line2.length() > baseLength && baseAngle == qRound(line2.angle()))
|
||||||
|
{
|
||||||
|
shoulderPoint = p2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return shoulderPoint;
|
return shoulderPoint;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h"
|
#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h"
|
||||||
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h"
|
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h"
|
||||||
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h"
|
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h"
|
||||||
|
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h"
|
||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
|
@ -266,3 +267,43 @@ void TST_FindPoint::TestTriangle()
|
||||||
QPointF resultPoint = VToolTriangle::FindPoint(axisP1, axisP2, firstPoint, secondPoint);
|
QPointF resultPoint = VToolTriangle::FindPoint(axisP1, axisP2, firstPoint, secondPoint);
|
||||||
QCOMPARE(point, resultPoint);
|
QCOMPARE(point, resultPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_FindPoint::TestShoulderPoint_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QPointF>("p1");
|
||||||
|
QTest::addColumn<QPointF>("p2");
|
||||||
|
QTest::addColumn<QPointF>("pShoulder");
|
||||||
|
QTest::addColumn<qreal>("length");
|
||||||
|
QTest::addColumn<QPointF>("point");
|
||||||
|
|
||||||
|
// See file <root>/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 <root>/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);
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ private slots:
|
||||||
void TestTriangle_data();
|
void TestTriangle_data();
|
||||||
void TestTriangle();
|
void TestTriangle();
|
||||||
|
|
||||||
|
void TestShoulderPoint_data();
|
||||||
|
void TestShoulderPoint();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TST_FINDPOINT_H
|
#endif // TST_FINDPOINT_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user