Incorrect behavior of empty arc and elliptical arc. Closes #129
This commit is contained in:
parent
18c804c962
commit
3ae13febd3
|
@ -1,3 +1,6 @@
|
||||||
|
# Valentina 0.7.48 (unreleased)
|
||||||
|
- [smart-pattern/valentina#129] Incorrect behavior of empty arc and elliptical arc.
|
||||||
|
|
||||||
# Version 0.7.47 May 13, 2021
|
# Version 0.7.47 May 13, 2021
|
||||||
- [smart-pattern/valentina#118] Incorrect seam allowance.
|
- [smart-pattern/valentina#118] Incorrect seam allowance.
|
||||||
- [smart-pattern/valentina#119] Improve tool Point of intersection curves.
|
- [smart-pattern/valentina#119] Improve tool Point of intersection curves.
|
||||||
|
|
|
@ -263,6 +263,11 @@ QPointF VArc::GetP2 () const
|
||||||
*/
|
*/
|
||||||
QVector<QPointF> VArc::GetPoints() const
|
QVector<QPointF> VArc::GetPoints() const
|
||||||
{
|
{
|
||||||
|
if (qFuzzyIsNull(GetRadius()))
|
||||||
|
{
|
||||||
|
return {GetCenter().toQPointF()};
|
||||||
|
}
|
||||||
|
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
QVector<qreal> sectionAngle;
|
QVector<qreal> sectionAngle;
|
||||||
|
|
||||||
|
|
|
@ -493,12 +493,23 @@ qreal VEllipticalArc::MaxLength() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VEllipticalArc::GetP(qreal angle) const
|
QPointF VEllipticalArc::GetP(qreal angle) const
|
||||||
{
|
{
|
||||||
|
if (qFuzzyIsNull(GetRadius1()) && qFuzzyIsNull(GetRadius2()))
|
||||||
|
{
|
||||||
|
return GetCenter().toQPointF();
|
||||||
|
}
|
||||||
|
|
||||||
QLineF line(0, 0, 100, 0);
|
QLineF line(0, 0, 100, 0);
|
||||||
line.setAngle(angle);
|
line.setAngle(angle);
|
||||||
|
|
||||||
const qreal a = line.p2().x() / GetRadius1();
|
const qreal a = not qFuzzyIsNull(GetRadius1()) ? line.p2().x() / GetRadius1() : 0;
|
||||||
const qreal b = line.p2().y() / GetRadius2();
|
const qreal b = not qFuzzyIsNull(GetRadius2()) ? line.p2().y() / GetRadius2() : 0;
|
||||||
const qreal k = qSqrt(a*a + b*b);
|
const qreal k = qSqrt(a*a + b*b);
|
||||||
|
|
||||||
|
if (qFuzzyIsNull(k))
|
||||||
|
{
|
||||||
|
return GetCenter().toQPointF();
|
||||||
|
}
|
||||||
|
|
||||||
QPointF p(line.p2().x() / k, line.p2().y() / k);
|
QPointF p(line.p2().x() / k, line.p2().y() / k);
|
||||||
|
|
||||||
QLineF line2(QPointF(), p);
|
QLineF line2(QPointF(), p);
|
||||||
|
@ -565,6 +576,13 @@ void VEllipticalArc::SetFormulaRadius1(const QString &formula, qreal value)
|
||||||
d->radius1 = value;
|
d->radius1 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VEllipticalArc::SetRadius1(qreal value)
|
||||||
|
{
|
||||||
|
d->formulaRadius1 = QString::number(value);
|
||||||
|
d->radius1 = value;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VEllipticalArc::SetFormulaRadius2(const QString &formula, qreal value)
|
void VEllipticalArc::SetFormulaRadius2(const QString &formula, qreal value)
|
||||||
{
|
{
|
||||||
|
@ -572,6 +590,13 @@ void VEllipticalArc::SetFormulaRadius2(const QString &formula, qreal value)
|
||||||
d->radius2 = value;
|
d->radius2 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VEllipticalArc::SetRadius2(qreal value)
|
||||||
|
{
|
||||||
|
d->formulaRadius2 = QString::number(value);
|
||||||
|
d->radius2 = value;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VEllipticalArc::SetFormulaRotationAngle(const QString &formula, qreal value)
|
void VEllipticalArc::SetFormulaRotationAngle(const QString &formula, qreal value)
|
||||||
{
|
{
|
||||||
|
@ -579,6 +604,13 @@ void VEllipticalArc::SetFormulaRotationAngle(const QString &formula, qreal value
|
||||||
d->rotationAngle = value;
|
d->rotationAngle = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VEllipticalArc::SetRotationAngle(qreal value)
|
||||||
|
{
|
||||||
|
d->formulaRotationAngle = QString::number(value);
|
||||||
|
d->rotationAngle = value;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief GetRadius1 return elliptical arc major radius.
|
* @brief GetRadius1 return elliptical arc major radius.
|
||||||
|
|
|
@ -75,14 +75,17 @@ public:
|
||||||
|
|
||||||
QString GetFormulaRotationAngle () const;
|
QString GetFormulaRotationAngle () const;
|
||||||
void SetFormulaRotationAngle (const QString &formula, qreal value);
|
void SetFormulaRotationAngle (const QString &formula, qreal value);
|
||||||
|
void SetRotationAngle(qreal value);
|
||||||
qreal GetRotationAngle() const;
|
qreal GetRotationAngle() const;
|
||||||
|
|
||||||
QString GetFormulaRadius1 () const;
|
QString GetFormulaRadius1 () const;
|
||||||
void SetFormulaRadius1 (const QString &formula, qreal value);
|
void SetFormulaRadius1 (const QString &formula, qreal value);
|
||||||
|
void SetRadius1 (qreal value);
|
||||||
qreal GetRadius1 () const;
|
qreal GetRadius1 () const;
|
||||||
|
|
||||||
QString GetFormulaRadius2 () const;
|
QString GetFormulaRadius2 () const;
|
||||||
void SetFormulaRadius2 (const QString &formula, qreal value);
|
void SetFormulaRadius2 (const QString &formula, qreal value);
|
||||||
|
void SetRadius2 (qreal value);
|
||||||
qreal GetRadius2 () const;
|
qreal GetRadius2 () const;
|
||||||
|
|
||||||
virtual qreal GetLength () const override;
|
virtual qreal GetLength () const override;
|
||||||
|
|
|
@ -456,3 +456,12 @@ void TST_VArc::TestCurveIntersectAxis()
|
||||||
|
|
||||||
Comparison(intersectionPoint, crosPoint, accuracyPointOnLine);
|
Comparison(intersectionPoint, crosPoint, accuracyPointOnLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_VArc::EmptyArc()
|
||||||
|
{
|
||||||
|
VArc empty;
|
||||||
|
|
||||||
|
Comparison(empty.GetPoints(), {QPointF()});
|
||||||
|
QCOMPARE(empty.GetLength(), 0);
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ private slots:
|
||||||
void TestCutArc();
|
void TestCutArc();
|
||||||
void TestCurveIntersectAxis_data();
|
void TestCurveIntersectAxis_data();
|
||||||
void TestCurveIntersectAxis();
|
void TestCurveIntersectAxis();
|
||||||
|
void EmptyArc();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TST_VARC_H
|
#endif // TST_VARC_H
|
||||||
|
|
|
@ -577,3 +577,29 @@ void TST_VEllipticalArc::TestFlip()
|
||||||
QCOMPARE(elArc.GetRadius1(), res.GetRadius1());
|
QCOMPARE(elArc.GetRadius1(), res.GetRadius1());
|
||||||
QCOMPARE(elArc.GetRadius2(), res.GetRadius2());
|
QCOMPARE(elArc.GetRadius2(), res.GetRadius2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_VEllipticalArc::EmptyArc_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<qreal>("radius1");
|
||||||
|
QTest::addColumn<qreal>("radius2");
|
||||||
|
QTest::addColumn<qreal>("length");
|
||||||
|
|
||||||
|
QTest::newRow("Empty elArc") << 0. << 0. << 0.;
|
||||||
|
QTest::newRow("Radius1 correct") << 50. << 0. << 50.*4;
|
||||||
|
QTest::newRow("Radius2 correct") << 0. << 30. << 30.*4;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TST_VEllipticalArc::EmptyArc()
|
||||||
|
{
|
||||||
|
QFETCH(qreal, radius1);
|
||||||
|
QFETCH(qreal, radius2);
|
||||||
|
QFETCH(qreal, length);
|
||||||
|
|
||||||
|
VEllipticalArc empty;
|
||||||
|
empty.SetRadius1(radius1);
|
||||||
|
empty.SetRadius2(radius2);
|
||||||
|
|
||||||
|
QCOMPARE(empty.GetLength(), length);
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ private slots:
|
||||||
void TestRotation();
|
void TestRotation();
|
||||||
void TestFlip_data();
|
void TestFlip_data();
|
||||||
void TestFlip();
|
void TestFlip();
|
||||||
|
void EmptyArc_data();
|
||||||
|
void EmptyArc();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(TST_VEllipticalArc)
|
Q_DISABLE_COPY(TST_VEllipticalArc)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user