Allow negative values.

This commit is contained in:
Roman Telezhynskyi 2023-11-14 16:37:14 +02:00
parent ae9e374629
commit 4691de62fd
51 changed files with 1249 additions and 509 deletions

View File

@ -52,6 +52,7 @@
- Tape app. Show variables in order they were added. - Tape app. Show variables in order they were added.
- Shortcuts manager. - Shortcuts manager.
- Support for custom known measurements. - Support for custom known measurements.
- Allow negative values.
# Valentina 0.7.52 September 12, 2022 # Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru. - Fix crash when default locale is ru.

View File

@ -3114,28 +3114,24 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item)
AddPropertyObjectName(i, tr("Name:"), true); AddPropertyObjectName(i, tr("Name:"), true);
VFormula angle1(spl.GetStartAngleFormula(), i->getData()); VFormula angle1(spl.GetStartAngleFormula(), i->getData());
angle1.setCheckZero(false);
angle1.setToolId(i->getId()); angle1.setToolId(i->getId());
angle1.setPostfix(degreeSymbol); angle1.setPostfix(degreeSymbol);
angle1.Eval(); angle1.Eval();
AddPropertyFormula(tr("C1: angle:"), angle1, AttrAngle1); AddPropertyFormula(tr("C1: angle:"), angle1, AttrAngle1);
VFormula length1(spl.GetC1LengthFormula(), i->getData()); VFormula length1(spl.GetC1LengthFormula(), i->getData());
length1.setCheckZero(false);
length1.setToolId(i->getId()); length1.setToolId(i->getId());
length1.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); length1.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
length1.Eval(); length1.Eval();
AddPropertyFormula(tr("C1: length:"), length1, AttrLength1); AddPropertyFormula(tr("C1: length:"), length1, AttrLength1);
VFormula angle2(spl.GetEndAngleFormula(), i->getData()); VFormula angle2(spl.GetEndAngleFormula(), i->getData());
angle2.setCheckZero(false);
angle2.setToolId(i->getId()); angle2.setToolId(i->getId());
angle2.setPostfix(degreeSymbol); angle2.setPostfix(degreeSymbol);
angle2.Eval(); angle2.Eval();
AddPropertyFormula(tr("C2: angle:"), angle2, AttrAngle2); AddPropertyFormula(tr("C2: angle:"), angle2, AttrAngle2);
VFormula length2(spl.GetC2LengthFormula(), i->getData()); VFormula length2(spl.GetC2LengthFormula(), i->getData());
length2.setCheckZero(false);
length2.setToolId(i->getId()); length2.setToolId(i->getId());
length2.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); length2.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
length2.Eval(); length2.Eval();
@ -3992,7 +3988,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
m_idToProperty[AttrName]->setValue(i->name()); m_idToProperty[AttrName]->setValue(i->name());
VFormula angle1F(spl.GetStartAngleFormula(), i->getData()); VFormula angle1F(spl.GetStartAngleFormula(), i->getData());
angle1F.setCheckZero(false);
angle1F.setToolId(i->getId()); angle1F.setToolId(i->getId());
angle1F.setPostfix(degreeSymbol); angle1F.setPostfix(degreeSymbol);
angle1F.Eval(); angle1F.Eval();
@ -4001,7 +3996,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
m_idToProperty[AttrAngle1]->setValue(angle1); m_idToProperty[AttrAngle1]->setValue(angle1);
VFormula length1F(spl.GetC1LengthFormula(), i->getData()); VFormula length1F(spl.GetC1LengthFormula(), i->getData());
length1F.setCheckZero(false);
length1F.setToolId(i->getId()); length1F.setToolId(i->getId());
length1F.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); length1F.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
length1F.Eval(); length1F.Eval();
@ -4010,7 +4004,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
m_idToProperty[AttrLength1]->setValue(length1); m_idToProperty[AttrLength1]->setValue(length1);
VFormula angle2F(spl.GetEndAngleFormula(), i->getData()); VFormula angle2F(spl.GetEndAngleFormula(), i->getData());
angle2F.setCheckZero(false);
angle2F.setToolId(i->getId()); angle2F.setToolId(i->getId());
angle2F.setPostfix(degreeSymbol); angle2F.setPostfix(degreeSymbol);
angle2F.Eval(); angle2F.Eval();
@ -4019,7 +4012,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
m_idToProperty[AttrAngle2]->setValue(angle2); m_idToProperty[AttrAngle2]->setValue(angle2);
VFormula length2F(spl.GetC2LengthFormula(), i->getData()); VFormula length2F(spl.GetC2LengthFormula(), i->getData());
length2F.setCheckZero(false);
length2F.setToolId(i->getId()); length2F.setToolId(i->getId());
length2F.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); length2F.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
length2F.Eval(); length2F.Eval();

View File

@ -214,7 +214,7 @@ auto VAbstractArc::AngleArc() const -> qreal
const qreal angleDiff = qAbs(GetStartAngle() - GetEndAngle()); const qreal angleDiff = qAbs(GetStartAngle() - GetEndAngle());
if (VFuzzyComparePossibleNulls(angleDiff, 0) || VFuzzyComparePossibleNulls(angleDiff, 360)) if (VFuzzyComparePossibleNulls(angleDiff, 0) || VFuzzyComparePossibleNulls(angleDiff, 360))
{ {
return 360; return !d->isAllowEmpty ? 360 : 0;
} }
} }
QLineF l1(0, 0, 100, 0); QLineF l1(0, 0, 100, 0);
@ -232,12 +232,39 @@ auto VAbstractArc::AngleArc() const -> qreal
return ang; return ang;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VAbstractArc::GetPath() const -> QPainterPath
{
QPainterPath path;
const QVector<QPointF> points = GetPoints();
if (points.count() >= 2)
{
path.addPolygon(QPolygonF(points));
}
else
{
QPointF center = GetCenter().toQPointF();
QRectF rec = QRectF(center.x(), center.y(), accuracyPointOnLine * 2, accuracyPointOnLine * 2);
rec.translate(-rec.center().x(), -rec.center().y());
path.addEllipse(rec);
}
return path;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFlipped(bool value) void VAbstractArc::SetFlipped(bool value)
{ {
d->isFlipped = value; d->isFlipped = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetAllowEmpty(bool value)
{
d->isAllowEmpty = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaLength(const QString &formula) void VAbstractArc::SetFormulaLength(const QString &formula)
{ {

View File

@ -83,8 +83,11 @@ public:
auto IsFlipped() const -> bool; auto IsFlipped() const -> bool;
auto AngleArc() const -> qreal; auto AngleArc() const -> qreal;
auto GetPath() const -> QPainterPath override;
protected: protected:
void SetFlipped(bool value); void SetFlipped(bool value);
void SetAllowEmpty(bool value);
virtual void FindF2(qreal length) = 0; virtual void FindF2(qreal length) = 0;
void SetFormulaLength(const QString &formula); void SetFormulaLength(const QString &formula);

View File

@ -66,6 +66,8 @@ public:
QString formulaLength{}; // NOLINT(misc-non-private-member-variables-in-classes) QString formulaLength{}; // NOLINT(misc-non-private-member-variables-in-classes)
bool isAllowEmpty{false}; // NOLINT(misc-non-private-member-variables-in-classes)
private: private:
Q_DISABLE_ASSIGN_MOVE(VAbstractArcData) // NOLINT Q_DISABLE_ASSIGN_MOVE(VAbstractArcData) // NOLINT
}; };

View File

@ -245,12 +245,33 @@ auto VAbstractCurve::ClosestPoint(QPointF scenePoint) const -> QPointF
return points.constFirst(); return points.constFirst();
} }
if (VFuzzyComparePoints(points.constLast(), scenePoint))
{
return points.constLast();
}
QPointF candidatePoint; QPointF candidatePoint;
qreal bestDistance = INT_MAX; qreal bestDistance = INT_MAX;
bool found = false; bool found = false;
for (qint32 i = 0; i < points.count() - 1; ++i) for (qint32 i = 0; i < points.count() - 1; ++i)
{ {
qreal length = QLineF(points.at(i), scenePoint).length();
if (length < bestDistance)
{
candidatePoint = points.at(i);
bestDistance = length;
found = true;
}
length = QLineF(points.at(i + 1), scenePoint).length();
if (length < bestDistance)
{
candidatePoint = points.at(i + 1);
bestDistance = length;
found = true;
}
const QPointF cPoint = VGObject::ClosestPoint(QLineF(points.at(i), points.at(i + 1)), scenePoint); const QPointF cPoint = VGObject::ClosestPoint(QLineF(points.at(i), points.at(i + 1)), scenePoint);
if (IsPointOnLineSegment(cPoint, points.at(i), points.at(i + 1))) if (IsPointOnLineSegment(cPoint, points.at(i), points.at(i + 1)))

View File

@ -66,6 +66,7 @@ VArc::VArc(const VPointF &center, qreal radius, const QString &formulaRadius, qr
d(new VArcData(radius, formulaRadius)) d(new VArcData(radius, formulaRadius))
{ {
CreateName(); CreateName();
SetFlipped(radius < 0);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -74,6 +75,7 @@ VArc::VArc(const VPointF &center, qreal radius, qreal f1, qreal f2)
d(new VArcData(radius)) d(new VArcData(radius))
{ {
CreateName(); CreateName();
SetFlipped(radius < 0);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -143,7 +145,7 @@ auto VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &pref
const qreal f1 = QLineF(static_cast<QPointF>(center), p1).angle(); const qreal f1 = QLineF(static_cast<QPointF>(center), p1).angle();
const qreal f2 = QLineF(static_cast<QPointF>(center), p2).angle(); const qreal f2 = QLineF(static_cast<QPointF>(center), p2).angle();
VArc arc(center, GetRadius(), f1, f2); VArc arc(center, d->radius, f1, f2);
arc.setName(name() + prefix); arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty()) if (not GetAliasSuffix().isEmpty())
@ -169,7 +171,7 @@ auto VArc::Flip(const QLineF &axis, const QString &prefix) const -> VArc
const qreal f1 = QLineF(static_cast<QPointF>(center), p1).angle(); const qreal f1 = QLineF(static_cast<QPointF>(center), p1).angle();
const qreal f2 = QLineF(static_cast<QPointF>(center), p2).angle(); const qreal f2 = QLineF(static_cast<QPointF>(center), p2).angle();
VArc arc(center, GetRadius(), f1, f2); VArc arc(center, d->radius, f1, f2);
arc.setName(name() + prefix); arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty()) if (not GetAliasSuffix().isEmpty())
@ -195,7 +197,7 @@ auto VArc::Move(qreal length, qreal angle, const QString &prefix) const -> VArc
const qreal f1 = QLineF(static_cast<QPointF>(center), p1).angle(); const qreal f1 = QLineF(static_cast<QPointF>(center), p1).angle();
const qreal f2 = QLineF(static_cast<QPointF>(center), p2).angle(); const qreal f2 = QLineF(static_cast<QPointF>(center), p2).angle();
VArc arc(center, GetRadius(), f1, f2); VArc arc(center, d->radius, f1, f2);
arc.setName(name() + prefix); arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty()) if (not GetAliasSuffix().isEmpty())
@ -220,7 +222,7 @@ VArc::~VArc() = default;
*/ */
auto VArc::GetLength() const -> qreal auto VArc::GetLength() const -> qreal
{ {
qreal length = d->radius * qDegreesToRadians(AngleArc()); qreal length = qAbs(d->radius) * qDegreesToRadians(AngleArc());
if (IsFlipped()) if (IsFlipped())
{ {
length *= -1; length *= -1;
@ -236,7 +238,7 @@ auto VArc::GetLength() const -> qreal
*/ */
auto VArc::GetP1() const -> QPointF auto VArc::GetP1() const -> QPointF
{ {
QPointF p1(GetCenter().x() + d->radius, GetCenter().y()); QPointF p1(GetCenter().x() + qAbs(d->radius), GetCenter().y());
QLineF centerP1(static_cast<QPointF>(GetCenter()), p1); QLineF centerP1(static_cast<QPointF>(GetCenter()), p1);
centerP1.setAngle(GetStartAngle()); centerP1.setAngle(GetStartAngle());
return centerP1.p2(); return centerP1.p2();
@ -249,7 +251,7 @@ auto VArc::GetP1() const -> QPointF
*/ */
auto VArc::GetP2() const -> QPointF auto VArc::GetP2() const -> QPointF
{ {
QPointF p2(GetCenter().x() + d->radius, GetCenter().y()); QPointF p2(GetCenter().x() + qAbs(d->radius), GetCenter().y());
QLineF centerP2(static_cast<QPointF>(GetCenter()), p2); QLineF centerP2(static_cast<QPointF>(GetCenter()), p2);
centerP2.setAngle(GetEndAngle()); centerP2.setAngle(GetEndAngle());
return centerP2.p2(); return centerP2.p2();
@ -262,7 +264,7 @@ auto VArc::GetP2() const -> QPointF
*/ */
auto VArc::GetPoints() const -> QVector<QPointF> auto VArc::GetPoints() const -> QVector<QPointF>
{ {
if (qFuzzyIsNull(GetRadius())) if (qFuzzyIsNull(d->radius))
{ {
return {GetCenter().toQPointF()}; return {GetCenter().toQPointF()};
} }
@ -305,7 +307,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
for (int i = 0; i < sectionAngle.size(); ++i) for (int i = 0; i < sectionAngle.size(); ++i)
{ {
const qreal lDistance = GetRadius() * 4.0 / 3.0 * qTan(qDegreesToRadians(sectionAngle.at(i)) * 0.25); const qreal lDistance = qAbs(d->radius) * 4.0 / 3.0 * qTan(qDegreesToRadians(sectionAngle.at(i)) * 0.25);
const QPointF center = static_cast<QPointF>(GetCenter()); const QPointF center = static_cast<QPointF>(GetCenter());
@ -315,7 +317,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
QLineF lineP4P3(center, pStart); QLineF lineP4P3(center, pStart);
lineP4P3.setAngle(lineP4P3.angle() + sectionAngle.at(i)); lineP4P3.setAngle(lineP4P3.angle() + sectionAngle.at(i));
lineP4P3.setLength(GetRadius()); // in case of computing error lineP4P3.setLength(qAbs(d->radius)); // in case of computing error
lineP4P3 = QLineF(lineP4P3.p2(), center); lineP4P3 = QLineF(lineP4P3.p2(), center);
lineP4P3.setAngle(lineP4P3.angle() + 90.0); lineP4P3.setAngle(lineP4P3.angle() + 90.0);
lineP4P3.setLength(lDistance); lineP4P3.setLength(lDistance);
@ -345,20 +347,39 @@ auto VArc::GetPoints() const -> QVector<QPointF>
*/ */
auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName) const -> QPointF auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName) const -> QPointF
{ {
// Always need return two arcs, so we must correct wrong length.
const qreal fullLength = GetLength(); const qreal fullLength = GetLength();
if (qAbs(fullLength) < ToPixel(2, Unit::Mm)) if (qFuzzyIsNull(fullLength) || qFuzzyIsNull(d->radius))
{ {
arc1 = VArc(); arc1 = *this;
arc2 = VArc(); arc2 = *this;
return GetCenter().toQPointF();
}
const QString errorMsg = tr("Unable to cut curve '%1'. The curve is too short.").arg(name()); if (qFuzzyIsNull(length) || qFuzzyIsNull(length + fullLength))
VAbstractApplication::VApp()->IsPedantic() {
? throw VException(errorMsg) arc1 = VArc(GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), GetStartAngle(),
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; GetFormulaF1(), getIdObject(), getMode());
arc1.SetApproximationScale(GetApproximationScale());
arc1.SetFlipped(IsFlipped());
arc1.SetAllowEmpty(true);
return {}; arc2 = *this;
return GetP1();
}
if (VFuzzyComparePossibleNulls(length, fullLength))
{
arc1 = *this;
arc2 = VArc(GetCenter(), d->radius, d->formulaRadius, GetEndAngle(), GetFormulaF2(), GetEndAngle(),
GetFormulaF2(), getIdObject(), getMode());
arc2.SetApproximationScale(GetApproximationScale());
arc2.SetFlipped(IsFlipped());
arc2.SetAllowEmpty(true);
return GetP2();
} }
QLineF line = QLineF line =
@ -381,7 +402,7 @@ auto VArc::CutArc(qreal length, const QString &pointName) const -> QPointF
{ {
VArc arc1; VArc arc1;
VArc arc2; VArc arc2;
return this->CutArc(length, arc1, arc2, pointName); return CutArc(length, arc1, arc2, pointName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -423,14 +444,14 @@ void VArc::CreateAlias()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VArc::FindF2(qreal length) void VArc::FindF2(qreal length)
{ {
SetFlipped(length < 0); SetFlipped(length < 0 || d->radius < 0);
if (length >= MaxLength()) if (qAbs(length) >= qAbs(MaxLength()))
{ {
length = MaxLength(); length = MaxLength();
} }
qreal arcAngle = qAbs(qRadiansToDegrees(length / d->radius)); qreal arcAngle = qAbs(qRadiansToDegrees(qAbs(length) / qAbs(d->radius)));
if (IsFlipped()) if (IsFlipped())
{ {
@ -438,7 +459,7 @@ void VArc::FindF2(qreal length)
} }
QLineF startAngle(0, 0, 100, 0); QLineF startAngle(0, 0, 100, 0);
startAngle.setAngle(GetStartAngle() + arcAngle); // We use QLineF just because it is easy way correct angle value startAngle.setAngle(GetStartAngle() + arcAngle); // We use QLineF just because it is easy way to correct angle value
SetFormulaF2(QString::number(startAngle.angle()), startAngle.angle()); SetFormulaF2(QString::number(startAngle.angle()), startAngle.angle());
} }
@ -457,9 +478,7 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
length = fullLength + length; length = fullLength + length;
} }
const qreal maxLength = fullLength - minLength; if (length < 0)
if (length < minLength)
{ {
QString errorMsg; QString errorMsg;
if (not pointName.isEmpty()) if (not pointName.isEmpty())
@ -476,7 +495,7 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
? throw VException(errorMsg) ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; : qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
else if (length > maxLength) else if (length > fullLength)
{ {
QString errorMsg; QString errorMsg;
if (not pointName.isEmpty()) if (not pointName.isEmpty())
@ -486,7 +505,6 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
} }
else else
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.").arg(name()); errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.").arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() VAbstractApplication::VApp()->IsPedantic()
@ -494,7 +512,12 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; : qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
length = qBound(minLength, length, maxLength); if (qFuzzyIsNull(d->radius))
{
return {static_cast<QPointF>(GetCenter()), static_cast<QPointF>(GetCenter())};
}
length = qBound(0.0, length, fullLength);
QLineF line(static_cast<QPointF>(GetCenter()), GetP1()); QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
line.setAngle(line.angle() + qRadiansToDegrees(length / d->radius)); line.setAngle(line.angle() + qRadiansToDegrees(length / d->radius));
@ -509,10 +532,7 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
length = fullLength + length; length = fullLength + length;
} }
const qreal minLengthFlipped = fullLength + minLength; if (length < fullLength)
const qreal maxLengthFlipped = -minLength;
if (length < minLengthFlipped)
{ {
QString errorMsg; QString errorMsg;
if (not pointName.isEmpty()) if (not pointName.isEmpty())
@ -529,7 +549,7 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
? throw VException(errorMsg) ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; : qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
else if (length > maxLengthFlipped) else if (length > 0)
{ {
QString errorMsg; QString errorMsg;
if (not pointName.isEmpty()) if (not pointName.isEmpty())
@ -546,7 +566,12 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; : qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
length = qBound(minLengthFlipped, length, maxLengthFlipped); if (qFuzzyIsNull(d->radius))
{
return {static_cast<QPointF>(GetCenter()), static_cast<QPointF>(GetCenter())};
}
length = qBound(fullLength, length, 0.0);
QLineF line(static_cast<QPointF>(GetCenter()), GetP1()); QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length) / d->radius)); line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length) / d->radius));

View File

@ -226,6 +226,15 @@ auto JoinVectors(const QVector<QPointF> &v1, const QVector<QPointF> &v2) -> QVec
return v; return v;
} }
//---------------------------------------------------------------------------------------------------------------------
auto IsBoundedIntersection(QLineF::IntersectType type, QPointF p, const QLineF &segment1, const QLineF &segment2)
-> bool
{
return type == QLineF::BoundedIntersection ||
(type == QLineF::UnboundedIntersection && VGObject::IsPointOnLineSegment(p, segment1.p1(), segment2.p1()) &&
VGObject::IsPointOnLineSegment(p, segment2.p1(), segment2.p2()));
}
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -255,6 +264,7 @@ VEllipticalArc::VEllipticalArc(const VPointF &center, qreal radius1, qreal radiu
d(new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle)) d(new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
{ {
CreateName(); CreateName();
SetFlipped(radius1 < 0 || radius2 < 0);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -264,6 +274,7 @@ VEllipticalArc::VEllipticalArc(const VPointF &center, qreal radius1, qreal radiu
d(new VEllipticalArcData(radius1, radius2, rotationAngle)) d(new VEllipticalArcData(radius1, radius2, rotationAngle))
{ {
CreateName(); CreateName();
SetFlipped(radius1 < 0 || radius2 < 0);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -333,11 +344,11 @@ auto VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const QString &p
QTransform t = d->m_transform; QTransform t = d->m_transform;
t.translate(originPoint.x(), originPoint.y()); t.translate(originPoint.x(), originPoint.y());
t.rotate(IsFlipped() ? degrees : -degrees); t.rotate(-degrees);
t.translate(-originPoint.x(), -originPoint.y()); t.translate(-originPoint.x(), -originPoint.y());
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(), VEllipticalArc elArc(VAbstractArc::GetCenter(), d->radius1, d->radius2, VAbstractArc::GetStartAngle(),
VAbstractArc::GetEndAngle(), GetRotationAngle()); VAbstractArc::GetEndAngle(), d->rotationAngle);
elArc.setName(name() + prefix); elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty()) if (not GetAliasSuffix().isEmpty())
@ -356,8 +367,8 @@ auto VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const QString &p
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) const -> VEllipticalArc auto VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) const -> VEllipticalArc
{ {
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(), VEllipticalArc elArc(VAbstractArc::GetCenter(), d->radius1, d->radius2, VAbstractArc::GetStartAngle(),
VAbstractArc::GetEndAngle(), GetRotationAngle()); VAbstractArc::GetEndAngle(), d->rotationAngle);
elArc.setName(name() + prefix); elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty()) if (not GetAliasSuffix().isEmpty())
@ -385,8 +396,8 @@ auto VEllipticalArc::Move(qreal length, qreal angle, const QString &prefix) cons
QTransform t = d->m_transform; QTransform t = d->m_transform;
t.translate(position.x(), position.y()); t.translate(position.x(), position.y());
VEllipticalArc elArc(oldCenter, GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(), VEllipticalArc elArc(oldCenter, d->radius1, d->radius2, VAbstractArc::GetStartAngle(), VAbstractArc::GetEndAngle(),
VAbstractArc::GetEndAngle(), GetRotationAngle()); d->rotationAngle);
elArc.setName(name() + prefix); elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty()) if (not GetAliasSuffix().isEmpty())
@ -416,7 +427,7 @@ auto VEllipticalArc::GetLength() const -> qreal
if (IsFlipped()) if (IsFlipped())
{ {
length = length * -1; length *= -1;
} }
return length; return length;
@ -473,11 +484,16 @@ auto VEllipticalArc::GetPoints() const -> QVector<QPointF>
{ {
const QPointF center = VAbstractArc::GetCenter().toQPointF(); const QPointF center = VAbstractArc::GetCenter().toQPointF();
if (qFuzzyIsNull(d->radius1) && qFuzzyIsNull(d->radius2))
{
return {center};
}
// Don't work with 0 radius. Always make it bigger than 0. // Don't work with 0 radius. Always make it bigger than 0.
Q_RELAXED_CONSTEXPR qreal threshold = ToPixel(0.001, Unit::Mm); Q_RELAXED_CONSTEXPR qreal threshold = ToPixel(0.001, Unit::Mm);
qreal radius1 = qMax(d->radius1, threshold); qreal radius1 = qMax(qAbs(d->radius1), threshold);
qreal radius2 = qMax(d->radius2, threshold); qreal radius2 = qMax(qAbs(d->radius2), threshold);
qreal max = qMax(d->radius1, d->radius2); qreal max = qMax(qAbs(d->radius1), qAbs(d->radius2));
qreal scale = 1; qreal scale = 1;
if (max > maxRadius) if (max > maxRadius)
@ -499,24 +515,24 @@ auto VEllipticalArc::GetPoints() const -> QVector<QPointF>
// To avoid this we calculate an arc for scaled radiuses and then scale up to original size. // To avoid this we calculate an arc for scaled radiuses and then scale up to original size.
t.scale(scale, scale); t.scale(scale, scale);
} }
t.rotate(-GetRotationAngle()); t.rotate(-d->rotationAngle);
t.translate(-center.x(), -center.y()); t.translate(-center.x(), -center.y());
std::transform(points.begin(), points.end(), points.begin(), [t](const QPointF &point) { return t.map(point); }); std::transform(points.begin(), points.end(), points.begin(), [t](const QPointF &point) { return t.map(point); });
return points; return IsFlipped() ? Reverse(points) : points;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::GetStartAngle() const -> qreal auto VEllipticalArc::GetStartAngle() const -> qreal
{ {
return QLineF(GetCenter().toQPointF(), GetP1()).angle() - GetRotationAngle(); return QLineF(GetCenter().toQPointF(), GetP1()).angle() - d->rotationAngle;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::GetEndAngle() const -> qreal auto VEllipticalArc::GetEndAngle() const -> qreal
{ {
return QLineF(GetCenter().toQPointF(), GetP2()).angle() - GetRotationAngle(); return QLineF(GetCenter().toQPointF(), GetP2()).angle() - d->rotationAngle;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -527,96 +543,78 @@ auto VEllipticalArc::GetEndAngle() const -> qreal
* @param arc2 second arc. * @param arc2 second arc.
* @return point cutting * @return point cutting
*/ */
auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2, auto VEllipticalArc::CutArc(qreal length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const
const QString &pointName) const -> QPointF -> QPointF
{ {
// Always need return two arcs, so we must correct wrong length.
qreal len = 0;
const qreal fullLength = GetLength(); const qreal fullLength = GetLength();
if (fullLength <= minLength) if (qFuzzyIsNull(fullLength) || (qFuzzyIsNull(d->radius1) && qFuzzyIsNull(d->radius2)))
{ {
arc1 = VEllipticalArc(); arc1 = *this;
arc2 = VEllipticalArc(); arc2 = *this;
return GetCenter().toQPointF();
const QString errorMsg = QObject::tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return {};
} }
const qreal maxLength = fullLength - minLength; if (qFuzzyIsNull(length) || qFuzzyIsNull(length + fullLength))
{
arc1 = VEllipticalArc(GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
GetStartAngle(), GetFormulaF1(), GetStartAngle(), GetFormulaF1(), d->rotationAngle,
GetFormulaRotationAngle(), getIdObject(), getMode());
arc1.SetApproximationScale(GetApproximationScale());
arc1.SetFlipped(IsFlipped());
arc1.SetAllowEmpty(true);
if (length < minLength) arc2 = *this;
{
len = minLength;
QString errorMsg; return GetP1();
if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal "
"value.")
.arg(name(), pointName);
} }
else
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
else if (length > maxLength)
{
len = maxLength;
QString errorMsg; if (VFuzzyComparePossibleNulls(length, fullLength))
if (not pointName.isEmpty())
{ {
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.") arc1 = *this;
.arg(name(), pointName);
} arc2 = VEllipticalArc(GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2, GetEndAngle(),
else GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
{ GetFormulaRotationAngle(), getIdObject(), getMode());
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.") arc2.SetApproximationScale(GetApproximationScale());
.arg(name()); arc2.SetFlipped(IsFlipped());
} arc2.SetAllowEmpty(true);
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg) return GetP2();
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
else
{
len = length;
} }
qreal len = CorrectCutLength(length, fullLength, pointName);
// the first arc has given length and startAngle just like in the origin arc // the first arc has given length and startAngle just like in the origin arc
arc1 = VEllipticalArc(len, QString().setNum(length), GetCenter(), d->radius1, d->radius2, d->formulaRadius1, arc1 = VEllipticalArc(len, QString().setNum(length), GetCenter(), d->radius1, d->radius2, d->formulaRadius1,
d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle, d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle,
GetFormulaRotationAngle(), getIdObject(), getMode()); GetFormulaRotationAngle(), getIdObject(), getMode());
arc1.SetApproximationScale(GetApproximationScale());
arc1.SetFlipped(IsFlipped());
// the second arc has startAngle just like endAngle of the first arc // the second arc has startAngle just like endAngle of the first arc
// and it has endAngle just like endAngle of the origin arc // and it has endAngle just like endAngle of the origin arc
arc2 = VEllipticalArc(GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2, arc1.GetEndAngle(), arc2 = VEllipticalArc(GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2, arc1.GetEndAngle(),
arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle, arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
GetFormulaRotationAngle(), getIdObject(), getMode()); GetFormulaRotationAngle(), getIdObject(), getMode());
return arc1.GetP1(); arc2.SetApproximationScale(GetApproximationScale());
arc2.SetFlipped(IsFlipped());
return arc1.GetP2();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::CutArc(const qreal &length, const QString &pointName) const -> QPointF auto VEllipticalArc::CutArc(qreal length, const QString &pointName) const -> QPointF
{ {
VEllipticalArc arc1; VEllipticalArc arc1;
VEllipticalArc arc2; VEllipticalArc arc2;
return this->CutArc(length, arc1, arc2, pointName); return CutArc(length, arc1, arc2, pointName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::CreateName() void VEllipticalArc::CreateName()
{ {
QString name = ELARC_ + QStringLiteral("%1").arg(this->GetCenter().name()); QString name = ELARC_ + this->GetCenter().name();
const QString nameStr = QStringLiteral("_%1"); const QString nameStr = QStringLiteral("_%1");
if (getMode() == Draw::Modeling && getIdObject() != NULL_ID) if (getMode() == Draw::Modeling && getIdObject() != NULL_ID)
@ -653,12 +651,12 @@ void VEllipticalArc::CreateAlias()
void VEllipticalArc::FindF2(qreal length) void VEllipticalArc::FindF2(qreal length)
{ {
qreal gap = 180; qreal gap = 180;
if (length < 0) if (length < 0 || d->radius1 < 0 || d->radius2 < 0)
{ {
SetFlipped(true); SetFlipped(true);
gap = -gap; gap = -gap;
} }
while (length > MaxLength()) else if (qAbs(length) > qAbs(MaxLength()))
{ {
length = MaxLength(); length = MaxLength();
} }
@ -666,7 +664,8 @@ void VEllipticalArc::FindF2(qreal length)
// We need to calculate the second angle // We need to calculate the second angle
// first approximation of angle between start and end angles // first approximation of angle between start and end angles
QLineF radius1(GetCenter().x(), GetCenter().y(), GetCenter().x() + d->radius1, GetCenter().y()); VPointF center = GetCenter();
QLineF radius1(center.x(), center.y(), center.x() + qAbs(d->radius1), center.y());
radius1.setAngle(GetStartAngle()); radius1.setAngle(GetStartAngle());
radius1.setAngle(radius1.angle() + gap); radius1.setAngle(radius1.angle() + gap);
qreal endAngle = radius1.angle(); qreal endAngle = radius1.angle();
@ -676,16 +675,17 @@ void VEllipticalArc::FindF2(qreal length)
qreal lenBez = GetLength(); // first approximation of length qreal lenBez = GetLength(); // first approximation of length
const qreal eps = ToPixel(0.001, Unit::Mm); Q_RELAXED_CONSTEXPR qreal eps = ToPixel(0.001, Unit::Mm);
while (qAbs(lenBez - length) > eps) while (qAbs(lenBez - length) > eps)
{ {
gap = gap / 2; gap = gap / 2;
if (gap < 0.0001) if (qAbs(gap) < 0.0001)
{ {
break; break;
} }
if (lenBez > length)
if (qAbs(lenBez) > qAbs(length))
{ // we selected too big end angle { // we selected too big end angle
radius1.setAngle(endAngle - qAbs(gap)); radius1.setAngle(endAngle - qAbs(gap));
} }
@ -703,15 +703,21 @@ void VEllipticalArc::FindF2(qreal length)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::MaxLength() const -> qreal auto VEllipticalArc::MaxLength() const -> qreal
{ {
const qreal h = qPow(d->radius1 - d->radius2, 2) / qPow(d->radius1 + d->radius2, 2); const qreal h = qPow(qAbs(d->radius1) - qAbs(d->radius2), 2) / qPow(qAbs(d->radius1) + qAbs(d->radius2), 2);
const qreal ellipseLength = M_PI * (d->radius1 + d->radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h))); qreal ellipseLength = M_PI * (qAbs(d->radius1) + qAbs(d->radius2)) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h)));
if (d->radius1 < 0 || d->radius2 < 0)
{
ellipseLength *= -1;
}
return ellipseLength; return ellipseLength;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::GetP(qreal angle) const -> QPointF auto VEllipticalArc::GetP(qreal angle) const -> QPointF
{ {
if (qFuzzyIsNull(GetRadius1()) && qFuzzyIsNull(GetRadius2())) if (qFuzzyIsNull(d->radius1) && qFuzzyIsNull(d->radius2))
{ {
return GetCenter().toQPointF(); return GetCenter().toQPointF();
} }
@ -719,8 +725,8 @@ auto VEllipticalArc::GetP(qreal angle) const -> QPointF
QLineF line(0, 0, 100, 0); QLineF line(0, 0, 100, 0);
line.setAngle(angle); line.setAngle(angle);
const qreal a = not qFuzzyIsNull(GetRadius1()) ? line.p2().x() / GetRadius1() : 0; const qreal a = not qFuzzyIsNull(d->radius1) ? line.p2().x() / qAbs(d->radius1) : 0;
const qreal b = not qFuzzyIsNull(GetRadius2()) ? line.p2().y() / GetRadius2() : 0; const qreal b = not qFuzzyIsNull(d->radius2) ? line.p2().y() / qAbs(d->radius2) : 0;
const qreal k = qSqrt(a * a + b * b); const qreal k = qSqrt(a * a + b * b);
if (qFuzzyIsNull(k)) if (qFuzzyIsNull(k))
@ -733,7 +739,7 @@ auto VEllipticalArc::GetP(qreal angle) const -> QPointF
QLineF line2(QPointF(), p); QLineF line2(QPointF(), p);
SCASSERT(VFuzzyComparePossibleNulls(line2.angle(), line.angle())) SCASSERT(VFuzzyComparePossibleNulls(line2.angle(), line.angle()))
line2.setAngle(line2.angle() + GetRotationAngle()); line2.setAngle(line2.angle() + d->rotationAngle);
return line2.p2() + VAbstractArc::GetCenter().toQPointF(); return line2.p2() + VAbstractArc::GetCenter().toQPointF();
} }
@ -746,7 +752,7 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
} }
QPointF center = VAbstractArc::GetCenter().toQPointF(); QPointF center = VAbstractArc::GetCenter().toQPointF();
qreal radius = qMax(d->radius1, d->radius2) * 2; qreal radius = qMax(qAbs(d->radius1), qAbs(d->radius2)) * 2;
QLineF start(center.x(), center.y(), center.x() + radius, center.y()); QLineF start(center.x(), center.y(), center.x() + radius, center.y());
start.setAngle(VAbstractArc::GetStartAngle()); start.setAngle(VAbstractArc::GetStartAngle());
@ -754,15 +760,6 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
QLineF end(center.x(), center.y(), center.x() + radius, center.y()); QLineF end(center.x(), center.y(), center.x() + radius, center.y());
end.setAngle(VAbstractArc::GetEndAngle()); end.setAngle(VAbstractArc::GetEndAngle());
auto IsBoundedIntersection =
[](QLineF::IntersectType type, QPointF p, const QLineF &segment1, const QLineF &segment2)
{
return type == QLineF::BoundedIntersection ||
(type == QLineF::UnboundedIntersection &&
VGObject::IsPointOnLineSegment(p, segment1.p1(), segment2.p1()) &&
VGObject::IsPointOnLineSegment(p, segment2.p1(), segment2.p2()));
};
bool begin = true; bool begin = true;
if (start.angle() >= end.angle()) if (start.angle() >= end.angle())
@ -839,6 +836,78 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
return arc; return arc;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::CorrectCutLength(qreal length, qreal fullLength, const QString &pointName) const -> qreal
{
qreal len = length;
auto TooSmallWarning = [this, pointName]()
{
QString errorMsg;
if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal "
"value.")
.arg(name(), pointName);
}
else
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
};
auto TooBigWarning = [this, pointName]()
{
QString errorMsg;
if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), pointName);
}
else
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
};
if (!IsFlipped())
{
if (length < 0)
{
len = 0;
TooSmallWarning();
}
else if (length > fullLength)
{
len = fullLength;
TooBigWarning();
}
}
else
{
if (length < fullLength)
{
len = fullLength;
TooSmallWarning();
}
else if (length > 0)
{
len = 0;
TooBigWarning();
}
}
return len;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetFormulaRadius1 return formula for major radius. * @brief GetFormulaRadius1 return formula for major radius.

View File

@ -101,9 +101,8 @@ public:
auto GetStartAngle() const -> qreal override; auto GetStartAngle() const -> qreal override;
auto GetEndAngle() const -> qreal override; auto GetEndAngle() const -> qreal override;
auto CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const auto CutArc(qreal length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const -> QPointF;
-> QPointF; auto CutArc(qreal length, const QString &pointName) const -> QPointF;
auto CutArc(const qreal &length, const QString &pointName) const -> QPointF;
static auto OptimizeAngle(qreal angle) -> qreal; static auto OptimizeAngle(qreal angle) -> qreal;
@ -118,6 +117,8 @@ private:
auto MaxLength() const -> qreal; auto MaxLength() const -> qreal;
auto GetP(qreal angle) const -> QPointF; auto GetP(qreal angle) const -> QPointF;
auto ArcPoints(QVector<QPointF> points) const -> QVector<QPointF>; auto ArcPoints(QVector<QPointF> points) const -> QVector<QPointF>;
auto CorrectCutLength(qreal length, qreal fullLength, const QString &pointName) const -> qreal;
}; };
Q_DECLARE_METATYPE(VEllipticalArc) // NOLINT Q_DECLARE_METATYPE(VEllipticalArc) // NOLINT

View File

@ -53,7 +53,7 @@ public:
QString formula{}; // NOLINT(misc-non-private-member-variables-in-classes) QString formula{}; // NOLINT(misc-non-private-member-variables-in-classes)
QString strValue{tr("Error")}; // NOLINT(misc-non-private-member-variables-in-classes) QString strValue{tr("Error")}; // NOLINT(misc-non-private-member-variables-in-classes)
bool checkZero{true}; // NOLINT(misc-non-private-member-variables-in-classes) bool checkZero{false}; // NOLINT(misc-non-private-member-variables-in-classes)
bool checkLessThanZero{false}; // NOLINT(misc-non-private-member-variables-in-classes) bool checkLessThanZero{false}; // NOLINT(misc-non-private-member-variables-in-classes)
const VContainer *data{nullptr}; // NOLINT(misc-non-private-member-variables-in-classes) const VContainer *data{nullptr}; // NOLINT(misc-non-private-member-variables-in-classes)
quint32 toolId{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes) quint32 toolId{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes)

View File

@ -142,7 +142,6 @@ auto VPieceNode::GetSABefore(const VContainer *data) const -> qreal
} }
VFormula formula(d->m_formulaWidthBefore, data); VFormula formula(d->m_formulaWidthBefore, data);
formula.setCheckZero(false);
formula.Eval(); formula.Eval();
if (formula.error()) if (formula.error())
@ -175,7 +174,6 @@ auto VPieceNode::GetSABefore(const VContainer *data, Unit unit) const -> qreal
} }
VFormula formula(d->m_formulaWidthBefore, data); VFormula formula(d->m_formulaWidthBefore, data);
formula.setCheckZero(false);
formula.Eval(); formula.Eval();
if (formula.error()) if (formula.error())
@ -229,7 +227,6 @@ auto VPieceNode::GetSAAfter(const VContainer *data) const -> qreal
} }
VFormula formula(d->m_formulaWidthAfter, data); VFormula formula(d->m_formulaWidthAfter, data);
formula.setCheckZero(false);
formula.Eval(); formula.Eval();
if (formula.error()) if (formula.error())
@ -263,7 +260,6 @@ auto VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const -> qreal
} }
VFormula formula(d->m_formulaWidthAfter, data); VFormula formula(d->m_formulaWidthAfter, data);
formula.setCheckZero(false);
formula.Eval(); formula.Eval();
if (formula.error()) if (formula.error())
@ -395,7 +391,6 @@ auto VPieceNode::GetPassmarkWidth(const VContainer *data, Unit unit) const -> qr
{ {
VFormula formula(d->m_formulaPassmarkWidth, data); VFormula formula(d->m_formulaPassmarkWidth, data);
formula.setCheckZero(true); formula.setCheckZero(true);
formula.setCheckLessThanZero(false);
formula.Eval(); formula.Eval();
if (formula.error()) if (formula.error())
@ -428,8 +423,6 @@ auto VPieceNode::GetPassmarkAngle(const VContainer *data) const -> qreal
if (d->m_manualPassmarkAngle) if (d->m_manualPassmarkAngle)
{ {
VFormula formula(d->m_formulaPassmarkAngle, data); VFormula formula(d->m_formulaPassmarkAngle, data);
formula.setCheckZero(false);
formula.setCheckLessThanZero(false);
formula.Eval(); formula.Eval();
if (formula.error()) if (formula.error())

View File

@ -64,7 +64,7 @@ struct FormulaData
QLabel *labelEditFormula{nullptr}; QLabel *labelEditFormula{nullptr};
QLabel *labelResult{nullptr}; QLabel *labelResult{nullptr};
QString postfix; QString postfix;
bool checkZero{true}; bool checkZero{false};
bool checkLessThanZero{false}; bool checkLessThanZero{false};
}; };

View File

@ -163,7 +163,6 @@ void DialogAlongLine::EvalFormula()
formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelEditFormula = ui->labelEditFormula;
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
Eval(formulaData, m_flagFormula); Eval(formulaData, m_flagFormula);
} }

View File

@ -525,17 +525,7 @@ void DialogArc::EvalRadius()
formulaData.labelResult = ui->labelResultRadius; formulaData.labelResult = ui->labelResultRadius;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
const qreal radius = Eval(formulaData, m_flagRadius); Eval(formulaData, m_flagRadius);
if (radius < 0)
{
m_flagRadius = false;
ChangeColor(ui->labelEditRadius, errorColor);
ui->labelResultRadius->setText(tr("Error"));
ui->labelResultRadius->setToolTip(tr("Radius can't be negative"));
DialogArc::CheckState();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -550,7 +540,6 @@ void DialogArc::EvalF()
formulaData.labelEditFormula = ui->labelEditF1; formulaData.labelEditFormula = ui->labelEditF1;
formulaData.labelResult = ui->labelResultF1; formulaData.labelResult = ui->labelResultF1;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
m_angleF1 = Eval(formulaData, m_flagF1); m_angleF1 = Eval(formulaData, m_flagF1);

View File

@ -550,7 +550,6 @@ void DialogArcWithLength::EvalF()
formulaData.labelEditFormula = ui->labelEditF1; formulaData.labelEditFormula = ui->labelEditF1;
formulaData.labelResult = ui->labelResultF1; formulaData.labelResult = ui->labelResultF1;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, m_flagF1); Eval(formulaData, m_flagF1);
} }

View File

@ -157,7 +157,6 @@ void DialogBisector::EvalFormula()
formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelEditFormula = ui->labelEditFormula;
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
Eval(formulaData, m_flagFormula); Eval(formulaData, m_flagFormula);
} }

View File

@ -309,7 +309,6 @@ void DialogCurveIntersectAxis::EvalAngle()
formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelEditFormula = ui->labelEditFormula;
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagFormula); Eval(formulaData, flagFormula);
} }

View File

@ -125,7 +125,6 @@ void DialogCutArc::EvalFormula()
formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelEditFormula = ui->labelEditFormula;
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
Eval(formulaData, m_flagFormula); Eval(formulaData, m_flagFormula);
} }
@ -427,11 +426,10 @@ void DialogCutArc::ShowDialog(bool click)
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(getArcId()); const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(getArcId());
QPointF p = arc->ClosestPoint(scene->getScenePos()); QPointF p = arc->ClosestPoint(scene->getScenePos());
qreal len = arc->GetLengthByPoint(p); qreal len = arc->GetLengthByPoint(p);
if (len > 0)
{ len = !arc->IsFlipped() ? qBound(0.0, len, arc->GetLength()) : qBound(arc->GetLength(), -len, 0.0);
SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit()))); SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit())));
} }
}
FinishCreating(); FinishCreating();
} }

View File

@ -332,7 +332,6 @@ void DialogCutSpline::EvalFormula()
formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelEditFormula = ui->labelEditFormula;
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
Eval(formulaData, m_flagFormula); Eval(formulaData, m_flagFormula);
} }

View File

@ -332,7 +332,6 @@ void DialogCutSplinePath::EvalFormula()
formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelEditFormula = ui->labelEditFormula;
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
Eval(formulaData, m_flagFormula); Eval(formulaData, m_flagFormula);
} }

View File

@ -397,7 +397,6 @@ void DialogEllipticalArc::EvalRadiuses()
formulaData.labelEditFormula = ui->labelEditRadius1; formulaData.labelEditFormula = ui->labelEditRadius1;
formulaData.labelResult = ui->labelResultRadius1; formulaData.labelResult = ui->labelResultRadius1;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkLessThanZero = true;
Eval(formulaData, m_flagRadius1); Eval(formulaData, m_flagRadius1);
@ -420,7 +419,6 @@ void DialogEllipticalArc::EvalAngles()
formulaData.labelEditFormula = ui->labelEditF1; formulaData.labelEditFormula = ui->labelEditF1;
formulaData.labelResult = ui->labelResultF1; formulaData.labelResult = ui->labelResultF1;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
m_angleF1 = Eval(formulaData, m_flagF1); m_angleF1 = Eval(formulaData, m_flagF1);

View File

@ -141,7 +141,6 @@ void DialogEndLine::EvalAngle()
formulaData.labelEditFormula = ui->labelEditAngle; formulaData.labelEditFormula = ui->labelEditAngle;
formulaData.labelResult = ui->labelResultCalculationAngle; formulaData.labelResult = ui->labelResultCalculationAngle;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagError); Eval(formulaData, flagError);
} }
@ -155,7 +154,6 @@ void DialogEndLine::EvalLength()
formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelEditFormula = ui->labelEditFormula;
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkLessThanZero = false;
Eval(formulaData, flagFormula); Eval(formulaData, flagFormula);
} }

View File

@ -349,7 +349,6 @@ void DialogLineIntersectAxis::EvalAngle()
formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelEditFormula = ui->labelEditFormula;
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagFormula); Eval(formulaData, flagFormula);
} }
@ -388,7 +387,7 @@ void DialogLineIntersectAxis::PointNameChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::FXAngle() void DialogLineIntersectAxis::FXAngle()
{ {
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); auto *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit angle")); dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle()); dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol); dialog->setPostfix(degreeSymbol);

View File

@ -791,7 +791,6 @@ void DialogMove::EvalAngle()
formulaData.labelEditFormula = ui->labelEditAngle; formulaData.labelEditFormula = ui->labelEditAngle;
formulaData.labelResult = ui->labelResultAngle; formulaData.labelResult = ui->labelResultAngle;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagAngle); Eval(formulaData, flagAngle);
@ -810,7 +809,6 @@ void DialogMove::EvalRotationAngle()
formulaData.labelEditFormula = ui->labelEditRotationAngle; formulaData.labelEditFormula = ui->labelEditRotationAngle;
formulaData.labelResult = ui->labelResultRotationAngle; formulaData.labelResult = ui->labelResultRotationAngle;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagRotationAngle); Eval(formulaData, flagRotationAngle);

View File

@ -663,7 +663,6 @@ void DialogRotation::EvalAngle()
formulaData.labelEditFormula = ui->labelEditAngle; formulaData.labelEditFormula = ui->labelEditAngle;
formulaData.labelResult = ui->labelResultAngle; formulaData.labelResult = ui->labelResultAngle;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagAngle); Eval(formulaData, flagAngle);

View File

@ -389,7 +389,6 @@ void DialogSpline::EvalAngle1()
formulaData.labelEditFormula = ui->labelEditAngle1; formulaData.labelEditFormula = ui->labelEditAngle1;
formulaData.labelResult = ui->labelResultAngle1; formulaData.labelResult = ui->labelResultAngle1;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagAngle1); Eval(formulaData, flagAngle1);
} }
@ -403,7 +402,6 @@ void DialogSpline::EvalAngle2()
formulaData.labelEditFormula = ui->labelEditAngle2; formulaData.labelEditFormula = ui->labelEditAngle2;
formulaData.labelResult = ui->labelResultAngle2; formulaData.labelResult = ui->labelResultAngle2;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagAngle2); Eval(formulaData, flagAngle2);
} }
@ -417,7 +415,6 @@ void DialogSpline::EvalLength1()
formulaData.labelEditFormula = ui->labelEditLength1; formulaData.labelEditFormula = ui->labelEditLength1;
formulaData.labelResult = ui->labelResultLength1; formulaData.labelResult = ui->labelResultLength1;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
Eval(formulaData, flagLength1); Eval(formulaData, flagLength1);
@ -432,7 +429,6 @@ void DialogSpline::EvalLength2()
formulaData.labelEditFormula = ui->labelEditLength2; formulaData.labelEditFormula = ui->labelEditLength2;
formulaData.labelResult = ui->labelResultLength2; formulaData.labelResult = ui->labelResultLength2;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
Eval(formulaData, flagLength2); Eval(formulaData, flagLength2);

View File

@ -574,7 +574,6 @@ void DialogSplinePath::EvalAngle1()
formulaData.labelEditFormula = ui->labelEditAngle1; formulaData.labelEditFormula = ui->labelEditAngle1;
formulaData.labelResult = ui->labelResultAngle1; formulaData.labelResult = ui->labelResultAngle1;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagAngle1[row]); Eval(formulaData, flagAngle1[row]);
@ -600,7 +599,6 @@ void DialogSplinePath::EvalAngle2()
formulaData.labelEditFormula = ui->labelEditAngle2; formulaData.labelEditFormula = ui->labelEditAngle2;
formulaData.labelResult = ui->labelResultAngle2; formulaData.labelResult = ui->labelResultAngle2;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, flagAngle2[row]); Eval(formulaData, flagAngle2[row]);
@ -626,7 +624,6 @@ void DialogSplinePath::EvalLength1()
formulaData.labelEditFormula = ui->labelEditLength1; formulaData.labelEditFormula = ui->labelEditLength1;
formulaData.labelResult = ui->labelResultLength1; formulaData.labelResult = ui->labelResultLength1;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
Eval(formulaData, flagLength1[row]); Eval(formulaData, flagLength1[row]);
@ -653,7 +650,6 @@ void DialogSplinePath::EvalLength2()
formulaData.labelEditFormula = ui->labelEditLength2; formulaData.labelEditFormula = ui->labelEditLength2;
formulaData.labelResult = ui->labelResultLength2; formulaData.labelResult = ui->labelResultLength2;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
Eval(formulaData, flagLength2[row]); Eval(formulaData, flagLength2[row]);

View File

@ -820,7 +820,6 @@ void DialogPiecePath::EvalWidth()
formulaData.labelEditFormula = ui->labelEditWidth; formulaData.labelEditFormula = ui->labelEditWidth;
formulaData.labelResult = ui->labelResultWidth; formulaData.labelResult = ui->labelResultWidth;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
m_saWidth = Eval(formulaData, m_flagFormula); m_saWidth = Eval(formulaData, m_flagFormula);
@ -851,7 +850,6 @@ void DialogPiecePath::EvalWidthBefore()
formulaData.labelEditFormula = ui->labelEditBefore; formulaData.labelEditFormula = ui->labelEditBefore;
formulaData.labelResult = ui->labelResultBefore; formulaData.labelResult = ui->labelResultBefore;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
const QString formula = GetFormulaSAWidthBefore(); const QString formula = GetFormulaSAWidthBefore();
@ -886,7 +884,6 @@ void DialogPiecePath::EvalWidthAfter()
formulaData.labelEditFormula = ui->labelEditAfter; formulaData.labelEditFormula = ui->labelEditAfter;
formulaData.labelResult = ui->labelResultAfter; formulaData.labelResult = ui->labelResultAfter;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
const QString formula = GetFormulaSAWidthAfter(); const QString formula = GetFormulaSAWidthAfter();
@ -919,7 +916,6 @@ void DialogPiecePath::EvalVisible()
formulaData.labelEditFormula = ui->labelEditVisible; formulaData.labelEditFormula = ui->labelEditVisible;
formulaData.labelResult = ui->labelResultVisible; formulaData.labelResult = ui->labelResultVisible;
formulaData.postfix = QString(); formulaData.postfix = QString();
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
Eval(formulaData, m_flagFormulaVisible); Eval(formulaData, m_flagFormulaVisible);
@ -970,7 +966,6 @@ void DialogPiecePath::EvalPassmarkWidth()
formulaData.labelResult = ui->labelResultPassmarkWidth; formulaData.labelResult = ui->labelResultPassmarkWidth;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = true; formulaData.checkZero = true;
formulaData.checkLessThanZero = false;
Eval(formulaData, m_flagFormulaPassmarkWidth); Eval(formulaData, m_flagFormulaPassmarkWidth);
@ -1000,8 +995,6 @@ void DialogPiecePath::EvalPassmarkAngle()
formulaData.labelEditFormula = ui->labelEditPassmarkAngle; formulaData.labelEditFormula = ui->labelEditPassmarkAngle;
formulaData.labelResult = ui->labelResultPassmarkAngle; formulaData.labelResult = ui->labelResultPassmarkAngle;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
formulaData.checkLessThanZero = false;
Eval(formulaData, m_flagFormulaPassmarkAngle); Eval(formulaData, m_flagFormulaPassmarkAngle);
@ -1078,6 +1071,8 @@ void DialogPiecePath::FXPassmarkLength()
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this)); QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark length")); dialog->setWindowTitle(tr("Edit passmark length"));
dialog->SetFormula(GetFormulaPassmarkLength()); dialog->SetFormula(GetFormulaPassmarkLength());
dialog->setCheckZero(true);
dialog->setCheckLessThanZero(true);
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
@ -1091,6 +1086,7 @@ void DialogPiecePath::FXPassmarkWidth()
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this)); QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark width")); dialog->setWindowTitle(tr("Edit passmark width"));
dialog->SetFormula(GetFormulaPassmarkWidth()); dialog->SetFormula(GetFormulaPassmarkWidth());
dialog->setCheckZero(true);
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {

View File

@ -370,7 +370,6 @@ void DialogPlaceLabel::EvalAngle()
formulaData.labelEditFormula = ui->labelEditFormulaAngle; formulaData.labelEditFormula = ui->labelEditFormulaAngle;
formulaData.labelResult = ui->labelResultCalculationAngle; formulaData.labelResult = ui->labelResultCalculationAngle;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
Eval(formulaData, m_flagAngle); Eval(formulaData, m_flagAngle);
} }
@ -384,7 +383,6 @@ void DialogPlaceLabel::EvalVisible()
formulaData.labelEditFormula = ui->labelEditVisible; formulaData.labelEditFormula = ui->labelEditVisible;
formulaData.labelResult = ui->labelResultVisible; formulaData.labelResult = ui->labelResultVisible;
formulaData.postfix = QString(); formulaData.postfix = QString();
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
Eval(formulaData, m_flagFormulaVisible); Eval(formulaData, m_flagFormulaVisible);
@ -396,6 +394,7 @@ void DialogPlaceLabel::FXWidth()
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this)); QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit rectangle width")); dialog->setWindowTitle(tr("Edit rectangle width"));
dialog->SetFormula(GetWidth()); dialog->SetFormula(GetWidth());
dialog->setCheckLessThanZero(true);
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
@ -409,6 +408,7 @@ void DialogPlaceLabel::FXHeight()
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this)); QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit rectangle width")); dialog->setWindowTitle(tr("Edit rectangle width"));
dialog->SetFormula(GetHeight()); dialog->SetFormula(GetHeight());
dialog->setCheckLessThanZero(true);
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {

View File

@ -2340,7 +2340,6 @@ void DialogSeamAllowance::EvalWidth()
formulaData.labelEditFormula = uiTabPaths->labelEditWidth; formulaData.labelEditFormula = uiTabPaths->labelEditWidth;
formulaData.labelResult = uiTabPaths->labelResultWidth; formulaData.labelResult = uiTabPaths->labelResultWidth;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
m_saWidth = Eval(formulaData, flagFormula); m_saWidth = Eval(formulaData, flagFormula);
@ -2373,7 +2372,6 @@ void DialogSeamAllowance::EvalWidthBefore()
formulaData.labelEditFormula = uiTabPaths->labelEditBefore; formulaData.labelEditFormula = uiTabPaths->labelEditBefore;
formulaData.labelResult = uiTabPaths->labelResultBefore; formulaData.labelResult = uiTabPaths->labelResultBefore;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
Eval(formulaData, flagFormulaBefore); Eval(formulaData, flagFormulaBefore);
@ -2404,7 +2402,6 @@ void DialogSeamAllowance::EvalWidthAfter()
formulaData.labelEditFormula = uiTabPaths->labelEditAfter; formulaData.labelEditFormula = uiTabPaths->labelEditAfter;
formulaData.labelResult = uiTabPaths->labelResultAfter; formulaData.labelResult = uiTabPaths->labelResultAfter;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = true; formulaData.checkLessThanZero = true;
Eval(formulaData, flagFormulaAfter); Eval(formulaData, flagFormulaAfter);
@ -2465,7 +2462,6 @@ void DialogSeamAllowance::EvalPassmarkWidth()
formulaData.labelResult = uiTabPassmarks->labelResultPassmarkWidth; formulaData.labelResult = uiTabPassmarks->labelResultPassmarkWidth;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = true; formulaData.checkZero = true;
formulaData.checkLessThanZero = false;
Eval(formulaData, flagFormulaPassmarkWidth); Eval(formulaData, flagFormulaPassmarkWidth);
@ -2493,8 +2489,6 @@ void DialogSeamAllowance::EvalPassmarkAngle()
formulaData.labelEditFormula = uiTabPassmarks->labelEditPassmarkAngle; formulaData.labelEditFormula = uiTabPassmarks->labelEditPassmarkAngle;
formulaData.labelResult = uiTabPassmarks->labelResultPassmarkAngle; formulaData.labelResult = uiTabPassmarks->labelResultPassmarkAngle;
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false;
formulaData.checkLessThanZero = false;
Eval(formulaData, flagFormulaPassmarkAngle); Eval(formulaData, flagFormulaPassmarkAngle);
@ -2557,6 +2551,8 @@ void DialogSeamAllowance::FXPassmarkLength()
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this)); QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark length")); dialog->setWindowTitle(tr("Edit passmark length"));
dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkLength)); dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkLength));
dialog->setCheckLessThanZero(true);
dialog->setCheckZero(true);
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
@ -2570,6 +2566,7 @@ void DialogSeamAllowance::FXPassmarkWidth()
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this)); QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark width")); dialog->setWindowTitle(tr("Edit passmark width"));
dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkWidth)); dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkWidth));
dialog->setCheckZero(true);
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {

View File

@ -344,7 +344,6 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove *
auto VToolMove::GetFormulaAngle() const -> VFormula auto VToolMove::GetFormulaAngle() const -> VFormula
{ {
VFormula fAngle(formulaAngle, getData()); VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(m_id); fAngle.setToolId(m_id);
fAngle.setPostfix(degreeSymbol); fAngle.setPostfix(degreeSymbol);
fAngle.Eval(); fAngle.Eval();
@ -367,7 +366,6 @@ void VToolMove::SetFormulaAngle(const VFormula &value)
auto VToolMove::GetFormulaRotationAngle() const -> VFormula auto VToolMove::GetFormulaRotationAngle() const -> VFormula
{ {
VFormula fAngle(formulaRotationAngle, getData()); VFormula fAngle(formulaRotationAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(m_id); fAngle.setToolId(m_id);
fAngle.setPostfix(degreeSymbol); fAngle.setPostfix(degreeSymbol);
fAngle.Eval(); fAngle.Eval();
@ -390,7 +388,6 @@ void VToolMove::SetFormulaRotationAngle(const VFormula &value)
auto VToolMove::GetFormulaLength() const -> VFormula auto VToolMove::GetFormulaLength() const -> VFormula
{ {
VFormula fLength(formulaLength, getData()); VFormula fLength(formulaLength, getData());
fLength.setCheckZero(true);
fLength.setToolId(m_id); fLength.setToolId(m_id);
fLength.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); fLength.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
fLength.Eval(); fLength.Eval();

View File

@ -286,7 +286,6 @@ auto VToolRotation::OriginPointName() const -> QString
auto VToolRotation::GetFormulaAngle() const -> VFormula auto VToolRotation::GetFormulaAngle() const -> VFormula
{ {
VFormula fAngle(formulaAngle, getData()); VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(m_id); fAngle.setToolId(m_id);
fAngle.setPostfix(degreeSymbol); fAngle.setPostfix(degreeSymbol);
fAngle.Eval(); fAngle.Eval();

View File

@ -207,8 +207,6 @@ auto VToolArc::GetFormulaRadius() const -> VFormula
void VToolArc::SetFormulaRadius(const VFormula &value) void VToolArc::SetFormulaRadius(const VFormula &value)
{ {
if (!value.error()) if (!value.error())
{
if (value.getDoubleValue() > 0) // Formula don't check this, but radius can't be 0 or negative
{ {
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj); QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
@ -216,7 +214,6 @@ void VToolArc::SetFormulaRadius(const VFormula &value)
SaveOption(obj); SaveOption(obj);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolArc::GetFormulaF1() const -> VFormula auto VToolArc::GetFormulaF1() const -> VFormula
@ -225,7 +222,6 @@ auto VToolArc::GetFormulaF1() const -> VFormula
SCASSERT(arc.isNull() == false) SCASSERT(arc.isNull() == false)
VFormula f1(arc->GetFormulaF1(), getData()); VFormula f1(arc->GetFormulaF1(), getData());
f1.setCheckZero(false);
f1.setToolId(m_id); f1.setToolId(m_id);
f1.setPostfix(degreeSymbol); f1.setPostfix(degreeSymbol);
f1.Eval(); f1.Eval();
@ -252,7 +248,6 @@ auto VToolArc::GetFormulaF2() const -> VFormula
SCASSERT(arc.isNull() == false) SCASSERT(arc.isNull() == false)
VFormula f2(arc->GetFormulaF2(), getData()); VFormula f2(arc->GetFormulaF2(), getData());
f2.setCheckZero(false);
f2.setToolId(m_id); f2.setToolId(m_id);
f2.setPostfix(degreeSymbol); f2.setPostfix(degreeSymbol);
f2.Eval(); f2.Eval();

View File

@ -178,7 +178,6 @@ auto VToolArcWithLength::GetFormulaRadius() const -> VFormula
SCASSERT(arc.isNull() == false) SCASSERT(arc.isNull() == false)
VFormula radius(arc->GetFormulaRadius(), getData()); VFormula radius(arc->GetFormulaRadius(), getData());
radius.setCheckZero(true);
radius.setToolId(m_id); radius.setToolId(m_id);
radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
radius.Eval(); radius.Eval();
@ -189,8 +188,6 @@ auto VToolArcWithLength::GetFormulaRadius() const -> VFormula
void VToolArcWithLength::SetFormulaRadius(const VFormula &value) void VToolArcWithLength::SetFormulaRadius(const VFormula &value)
{ {
if (value.error() == false) if (value.error() == false)
{
if (value.getDoubleValue() > 0) // Formula don't check this, but radius can't be 0 or negative
{ {
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj); QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
@ -198,7 +195,6 @@ void VToolArcWithLength::SetFormulaRadius(const VFormula &value)
SaveOption(obj); SaveOption(obj);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolArcWithLength::GetFormulaF1() const -> VFormula auto VToolArcWithLength::GetFormulaF1() const -> VFormula
@ -207,7 +203,6 @@ auto VToolArcWithLength::GetFormulaF1() const -> VFormula
SCASSERT(arc.isNull() == false) SCASSERT(arc.isNull() == false)
VFormula f1(arc->GetFormulaF1(), getData()); VFormula f1(arc->GetFormulaF1(), getData());
f1.setCheckZero(false);
f1.setToolId(m_id); f1.setToolId(m_id);
f1.setPostfix(degreeSymbol); f1.setPostfix(degreeSymbol);
f1.Eval(); f1.Eval();

View File

@ -206,7 +206,6 @@ auto VToolEllipticalArc::GetFormulaRadius1() const -> VFormula
SCASSERT(elArc.isNull() == false) SCASSERT(elArc.isNull() == false)
VFormula radius1(elArc->GetFormulaRadius1(), getData()); VFormula radius1(elArc->GetFormulaRadius1(), getData());
radius1.setCheckZero(true);
radius1.setToolId(m_id); radius1.setToolId(m_id);
radius1.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius1.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
radius1.Eval(); radius1.Eval();
@ -217,8 +216,6 @@ auto VToolEllipticalArc::GetFormulaRadius1() const -> VFormula
void VToolEllipticalArc::SetFormulaRadius1(const VFormula &value) void VToolEllipticalArc::SetFormulaRadius1(const VFormula &value)
{ {
if (!value.error()) if (!value.error())
{
if (value.getDoubleValue() > 0) // Formula don't check this, but radius1 can't be 0 or negative
{ {
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj); QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
@ -226,7 +223,6 @@ void VToolEllipticalArc::SetFormulaRadius1(const VFormula &value)
SaveOption(obj); SaveOption(obj);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolEllipticalArc::GetFormulaRadius2() const -> VFormula auto VToolEllipticalArc::GetFormulaRadius2() const -> VFormula
@ -235,7 +231,6 @@ auto VToolEllipticalArc::GetFormulaRadius2() const -> VFormula
SCASSERT(elArc.isNull() == false) SCASSERT(elArc.isNull() == false)
VFormula radius2(elArc->GetFormulaRadius2(), getData()); VFormula radius2(elArc->GetFormulaRadius2(), getData());
radius2.setCheckZero(true);
radius2.setToolId(m_id); radius2.setToolId(m_id);
radius2.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius2.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
radius2.Eval(); radius2.Eval();
@ -246,8 +241,6 @@ auto VToolEllipticalArc::GetFormulaRadius2() const -> VFormula
void VToolEllipticalArc::SetFormulaRadius2(const VFormula &value) void VToolEllipticalArc::SetFormulaRadius2(const VFormula &value)
{ {
if (!value.error()) if (!value.error())
{
if (value.getDoubleValue() > 0) // Formula don't check this, but radius2 can't be 0 or negative
{ {
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj); QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
@ -255,7 +248,6 @@ void VToolEllipticalArc::SetFormulaRadius2(const VFormula &value)
SaveOption(obj); SaveOption(obj);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolEllipticalArc::GetFormulaF1() const -> VFormula auto VToolEllipticalArc::GetFormulaF1() const -> VFormula
@ -264,7 +256,6 @@ auto VToolEllipticalArc::GetFormulaF1() const -> VFormula
SCASSERT(elArc.isNull() == false) SCASSERT(elArc.isNull() == false)
VFormula f1(elArc->GetFormulaF1(), getData()); VFormula f1(elArc->GetFormulaF1(), getData());
f1.setCheckZero(false);
f1.setToolId(m_id); f1.setToolId(m_id);
f1.setPostfix(degreeSymbol); f1.setPostfix(degreeSymbol);
f1.Eval(); f1.Eval();
@ -290,7 +281,6 @@ auto VToolEllipticalArc::GetFormulaF2() const -> VFormula
SCASSERT(elArc.isNull() == false) SCASSERT(elArc.isNull() == false)
VFormula f2(elArc->GetFormulaF2(), getData()); VFormula f2(elArc->GetFormulaF2(), getData());
f2.setCheckZero(false);
f2.setToolId(m_id); f2.setToolId(m_id);
f2.setPostfix(degreeSymbol); f2.setPostfix(degreeSymbol);
f2.Eval(); f2.Eval();
@ -316,7 +306,6 @@ auto VToolEllipticalArc::GetFormulaRotationAngle() const -> VFormula
SCASSERT(elArc.isNull() == false) SCASSERT(elArc.isNull() == false)
VFormula rotationAngle(elArc->GetFormulaRotationAngle(), getData()); VFormula rotationAngle(elArc->GetFormulaRotationAngle(), getData());
rotationAngle.setCheckZero(false);
rotationAngle.setToolId(m_id); rotationAngle.setToolId(m_id);
rotationAngle.setPostfix(degreeSymbol); rotationAngle.setPostfix(degreeSymbol);
rotationAngle.Eval(); rotationAngle.Eval();

View File

@ -215,7 +215,6 @@ auto VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle, const
auto VToolCurveIntersectAxis::GetFormulaAngle() const -> VFormula auto VToolCurveIntersectAxis::GetFormulaAngle() const -> VFormula
{ {
VFormula fAngle(formulaAngle, getData()); VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(m_id); fAngle.setToolId(m_id);
fAngle.setPostfix(degreeSymbol); fAngle.setPostfix(degreeSymbol);
fAngle.Eval(); fAngle.Eval();

View File

@ -35,8 +35,10 @@
#include "../../../../../dialogs/tools/dialogendline.h" #include "../../../../../dialogs/tools/dialogendline.h"
#include "../../../../../dialogs/tools/dialogtool.h" #include "../../../../../dialogs/tools/dialogtool.h"
#include "../../../../../visualization/visualization.h"
#include "../../../../../visualization/line/vistoolendline.h" #include "../../../../../visualization/line/vistoolendline.h"
#include "../../../../../visualization/visualization.h"
#include "../../../../vabstracttool.h"
#include "../../../vdrawtool.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
@ -45,8 +47,6 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
#include "../../../../vabstracttool.h"
#include "../../../vdrawtool.h"
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
template <class T> class QSharedPointer; template <class T> class QSharedPointer;
@ -136,8 +136,8 @@ auto VToolEndLine::Create(VToolEndLineInitData &initData) -> VToolEndLine *
QLineF line = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x() + 100, basePoint->y())); QLineF line = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x() + 100, basePoint->y()));
line.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); // First set angle. line.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); // First set angle.
line.setLength(VAbstractValApplication::VApp() line.setLength(
->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data))); VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data)));
VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my); VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my);
p->SetShowLabel(initData.showLabel); p->SetShowLabel(initData.showLabel);
@ -174,8 +174,7 @@ auto VToolEndLine::Create(VToolEndLineInitData &initData) -> VToolEndLine *
/** /**
* @brief SaveDialog save options into file after change in dialog. * @brief SaveDialog save options into file after change in dialog.
*/ */
void VToolEndLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies, void VToolEndLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies, QList<quint32> &newDependencies)
QList<quint32> &newDependencies)
{ {
SCASSERT(not m_dialog.isNull()) SCASSERT(not m_dialog.isNull())
const QPointer<DialogEndLine> dialogTool = qobject_cast<DialogEndLine *>(m_dialog); const QPointer<DialogEndLine> dialogTool = qobject_cast<DialogEndLine *>(m_dialog);
@ -241,7 +240,6 @@ void VToolEndLine::SetVisualization()
auto VToolEndLine::GetFormulaAngle() const -> VFormula auto VToolEndLine::GetFormulaAngle() const -> VFormula
{ {
VFormula fAngle(formulaAngle, getData()); VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(m_id); fAngle.setToolId(m_id);
fAngle.setPostfix(degreeSymbol); fAngle.setPostfix(degreeSymbol);
fAngle.Eval(); fAngle.Eval();

View File

@ -221,7 +221,6 @@ auto VToolLineIntersectAxis::SecondLinePoint() const -> QString
auto VToolLineIntersectAxis::GetFormulaAngle() const -> VFormula auto VToolLineIntersectAxis::GetFormulaAngle() const -> VFormula
{ {
VFormula fAngle(formulaAngle, getData()); VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(m_id); fAngle.setToolId(m_id);
fAngle.setPostfix(degreeSymbol); fAngle.setPostfix(degreeSymbol);
fAngle.Eval(); fAngle.Eval();

View File

@ -226,7 +226,6 @@ void VToolLinePoint::SetLineColor(const QString &value)
auto VToolLinePoint::GetFormulaLength() const -> VFormula auto VToolLinePoint::GetFormulaLength() const -> VFormula
{ {
VFormula fLength(formulaLength, this->getData()); VFormula fLength(formulaLength, this->getData());
fLength.setCheckZero(false);
fLength.setToolId(m_id); fLength.setToolId(m_id);
fLength.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); fLength.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
fLength.Eval(); fLength.Eval();
@ -237,7 +236,7 @@ auto VToolLinePoint::GetFormulaLength() const -> VFormula
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::SetFormulaLength(const VFormula &value) void VToolLinePoint::SetFormulaLength(const VFormula &value)
{ {
if (value.error() == false) if (!value.error())
{ {
formulaLength = value.GetFormula(FormulaType::FromUser); formulaLength = value.GetFormula(FormulaType::FromUser);

View File

@ -33,20 +33,20 @@
#include "../../../../dialogs/tools/dialogpointfromcircleandtangent.h" #include "../../../../dialogs/tools/dialogpointfromcircleandtangent.h"
#include "../../../../dialogs/tools/dialogtool.h" #include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../visualization/visualization.h"
#include "../../../../visualization/line/vistoolpointfromcircleandtangent.h" #include "../../../../visualization/line/vistoolpointfromcircleandtangent.h"
#include "../../../../visualization/visualization.h"
#include "../../../vabstracttool.h"
#include "../../vdrawtool.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionobjecterror.h"
#include "../ifc/xml/vdomdocument.h"
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "../ifc/xml/vdomdocument.h"
#include "../vgeometry/vgobject.h" #include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h" #include "../vpatterndb/vformula.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
#include "../../../vabstracttool.h"
#include "../../vdrawtool.h"
#include "vtoolsinglepoint.h" #include "vtoolsinglepoint.h"
template <class T> class QSharedPointer; template <class T> class QSharedPointer;
@ -121,20 +121,22 @@ auto VToolPointFromCircleAndTangent::Create(VToolPointFromCircleAndTangentInitDa
const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId); const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId);
QPointF point; QPointF point;
const bool success = VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(tPoint), const bool success = VToolPointFromCircleAndTangent::FindPoint(
static_cast<QPointF>(cPoint), radius, static_cast<QPointF>(tPoint), static_cast<QPointF>(cPoint), radius, initData.crossPoint, &point);
initData.crossPoint, &point);
if (not success) if (not success)
{ {
const QString errorMsg = tr("Error calculating point '%1'. Tangent to circle with center '%2' and radius '%3' " const QString errorMsg = tr("Error calculating point '%1'. Tangent to circle with center '%2' and radius '%3' "
"from point '%4' cannot be found") "from point '%4' cannot be found")
.arg(initData.name, cPoint.name()).arg(radius).arg(tPoint.name()); .arg(initData.name, cPoint.name())
.arg(radius)
.arg(tPoint.name());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); auto *p = new VPointF(point, initData.name, initData.mx, initData.my);
p->SetShowLabel(initData.showLabel); p->SetShowLabel(initData.showLabel);
if (initData.typeCreation == Source::FromGui) if (initData.typeCreation == Source::FromGui)
@ -153,7 +155,7 @@ auto VToolPointFromCircleAndTangent::Create(VToolPointFromCircleAndTangentInitDa
if (initData.parse == Document::FullParse) if (initData.parse == Document::FullParse)
{ {
VAbstractTool::AddRecord(initData.id, Tool::PointFromCircleAndTangent, initData.doc); VAbstractTool::AddRecord(initData.id, Tool::PointFromCircleAndTangent, initData.doc);
VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(initData); auto *point = new VToolPointFromCircleAndTangent(initData);
initData.scene->addItem(point); initData.scene->addItem(point);
InitToolConnections(initData.scene, point); InitToolConnections(initData.scene, point);
VAbstractPattern::AddTool(initData.id, point); VAbstractPattern::AddTool(initData.id, point);
@ -171,7 +173,7 @@ auto VToolPointFromCircleAndTangent::FindPoint(const QPointF &p, const QPointF &
SCASSERT(intersectionPoint != nullptr) SCASSERT(intersectionPoint != nullptr)
QPointF p1, p2; QPointF p1, p2;
const int res = VGObject::ContactPoints (p, center, radius, p1, p2); const int res = VGObject::ContactPoints(p, center, qAbs(radius), p1, p2);
switch (res) switch (res)
{ {
@ -215,15 +217,12 @@ auto VToolPointFromCircleAndTangent::GetCircleRadius() const -> VFormula
void VToolPointFromCircleAndTangent::SetCircleRadius(const VFormula &value) void VToolPointFromCircleAndTangent::SetCircleRadius(const VFormula &value)
{ {
if (value.error() == false) if (value.error() == false)
{
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
{ {
circleRadius = value.GetFormula(FormulaType::FromUser); circleRadius = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
SaveOption(obj); SaveOption(obj);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolPointFromCircleAndTangent::GetCrossCirclesPoint() const -> CrossCirclesPoint auto VToolPointFromCircleAndTangent::GetCrossCirclesPoint() const -> CrossCirclesPoint

View File

@ -29,7 +29,6 @@
#ifndef VTOOLPOINTFROMCIRCLEANDTANGENT_H #ifndef VTOOLPOINTFROMCIRCLEANDTANGENT_H
#define VTOOLPOINTFROMCIRCLEANDTANGENT_H #define VTOOLPOINTFROMCIRCLEANDTANGENT_H
#include <QDomElement> #include <QDomElement>
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QMetaObject> #include <QMetaObject>
@ -53,7 +52,8 @@ struct VToolPointFromCircleAndTangentInitData : VToolSinglePointInitData
circleRadius('0'), circleRadius('0'),
tangentPointId(NULL_ID), tangentPointId(NULL_ID),
crossPoint(CrossCirclesPoint::FirstPoint) crossPoint(CrossCirclesPoint::FirstPoint)
{} {
}
quint32 circleCenterId; quint32 circleCenterId;
QString circleRadius; QString circleRadius;
@ -64,6 +64,7 @@ struct VToolPointFromCircleAndTangentInitData : VToolSinglePointInitData
class VToolPointFromCircleAndTangent : public VToolSinglePoint class VToolPointFromCircleAndTangent : public VToolSinglePoint
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
virtual void SetDialog() override; virtual void SetDialog() override;
static auto Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, static auto Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
@ -73,7 +74,10 @@ public:
QPointF *intersectionPoint) -> bool; QPointF *intersectionPoint) -> bool;
static const QString ToolType; static const QString ToolType;
virtual auto type() const -> int override { return Type; } virtual auto type() const -> int override { return Type; }
enum { Type = UserType + static_cast<int>(Tool::PointFromCircleAndTangent) }; enum
{
Type = UserType + static_cast<int>(Tool::PointFromCircleAndTangent)
};
auto TangentPointName() const -> QString; auto TangentPointName() const -> QString;
auto CircleCenterPointName() const -> QString; auto CircleCenterPointName() const -> QString;
@ -87,6 +91,7 @@ public:
virtual void ShowVisualization(bool show) override; virtual void ShowVisualization(bool show) override;
protected slots: protected slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id = NULL_ID) override; virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id = NULL_ID) override;
protected: protected:
virtual void RemoveReferens() override; virtual void RemoveReferens() override;
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies, virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
@ -94,6 +99,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void ReadToolAttributes(const QDomElement &domElement) override;
virtual void SetVisualization() override; virtual void SetVisualization() override;
private: private:
Q_DISABLE_COPY_MOVE(VToolPointFromCircleAndTangent) // NOLINT Q_DISABLE_COPY_MOVE(VToolPointFromCircleAndTangent) // NOLINT

View File

@ -114,7 +114,7 @@ auto VToolPointOfContact::FindPoint(qreal radius, const QPointF &center, const Q
SCASSERT(intersectionPoint != nullptr) SCASSERT(intersectionPoint != nullptr)
QPointF p1, p2; QPointF p1, p2;
qint32 res = VGObject::LineIntersectCircle(center, radius, QLineF(firstPoint, secondPoint), p1, p2); qint32 res = VGObject::LineIntersectCircle(center, qAbs(radius), QLineF(firstPoint, secondPoint), p1, p2);
switch (res) switch (res)
{ {
case 0: case 0:
@ -126,8 +126,7 @@ auto VToolPointOfContact::FindPoint(qreal radius, const QPointF &center, const Q
{ {
const bool flagP1 = VGObject::IsPointOnLineSegment(p1, firstPoint, secondPoint); const bool flagP1 = VGObject::IsPointOnLineSegment(p1, firstPoint, secondPoint);
const bool flagP2 = VGObject::IsPointOnLineSegment(p2, firstPoint, secondPoint); const bool flagP2 = VGObject::IsPointOnLineSegment(p2, firstPoint, secondPoint);
if ((flagP1 == true && flagP2 == true) || if ((flagP1 && flagP2) || (!flagP1 && !flagP2) /*In case we have something wrong*/)
(flagP1 == false && flagP2 == false) /*In case we have something wrong*/)
{ {
// We don't have options for choosing correct point. Use closest to segment first point. // We don't have options for choosing correct point. Use closest to segment first point.
if (QLineF(firstPoint, p1).length() <= QLineF(firstPoint, p2).length()) if (QLineF(firstPoint, p1).length() <= QLineF(firstPoint, p2).length())
@ -139,8 +138,8 @@ auto VToolPointOfContact::FindPoint(qreal radius, const QPointF &center, const Q
*intersectionPoint = p2; *intersectionPoint = p2;
return true; return true;
} }
else
{ // In this case we have one real and one theoretical intersection. // In this case we have one real and one theoretical intersection.
if (flagP1) if (flagP1)
{ {
*intersectionPoint = p1; *intersectionPoint = p1;
@ -150,7 +149,6 @@ auto VToolPointOfContact::FindPoint(qreal radius, const QPointF &center, const Q
*intersectionPoint = p2; *intersectionPoint = p2;
return true; return true;
} }
}
default: default:
qDebug() << "Unxpected value" << res; qDebug() << "Unxpected value" << res;
break; break;
@ -417,7 +415,6 @@ void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event,
auto VToolPointOfContact::getArcRadius() const -> VFormula auto VToolPointOfContact::getArcRadius() const -> VFormula
{ {
VFormula radius(arcRadius, this->getData()); VFormula radius(arcRadius, this->getData());
radius.setCheckZero(true);
radius.setToolId(m_id); radius.setToolId(m_id);
radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
radius.Eval(); radius.Eval();

View File

@ -29,7 +29,6 @@
#ifndef VTOOLPOINTOFCONTACT_H #ifndef VTOOLPOINTOFCONTACT_H
#define VTOOLPOINTOFCONTACT_H #define VTOOLPOINTOFCONTACT_H
#include <QDomElement> #include <QDomElement>
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QMetaObject> #include <QMetaObject>
@ -53,7 +52,8 @@ struct VToolPointOfContactInitData : VToolSinglePointInitData
center(NULL_ID), center(NULL_ID),
firstPointId(NULL_ID), firstPointId(NULL_ID),
secondPointId(NULL_ID) secondPointId(NULL_ID)
{} {
}
QString radius; QString radius;
quint32 center; quint32 center;
@ -67,6 +67,7 @@ struct VToolPointOfContactInitData : VToolSinglePointInitData
class VToolPointOfContact : public VToolSinglePoint class VToolPointOfContact : public VToolSinglePoint
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
virtual void SetDialog() override; virtual void SetDialog() override;
static auto FindPoint(qreal radius, const QPointF &center, const QPointF &firstPoint, const QPointF &secondPoint, static auto FindPoint(qreal radius, const QPointF &center, const QPointF &firstPoint, const QPointF &secondPoint,
@ -76,7 +77,10 @@ public:
static auto Create(VToolPointOfContactInitData &initData) -> VToolPointOfContact *; static auto Create(VToolPointOfContactInitData &initData) -> VToolPointOfContact *;
static const QString ToolType; static const QString ToolType;
virtual auto type() const -> int override { return Type; } virtual auto type() const -> int override { return Type; }
enum { Type = UserType + static_cast<int>(Tool::PointOfContact) }; enum
{
Type = UserType + static_cast<int>(Tool::PointOfContact)
};
auto ArcCenterPointName() const -> QString; auto ArcCenterPointName() const -> QString;
auto FirstPointName() const -> QString; auto FirstPointName() const -> QString;
@ -88,6 +92,7 @@ public:
virtual void ShowVisualization(bool show) override; virtual void ShowVisualization(bool show) override;
protected slots: protected slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id = NULL_ID) override; virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id = NULL_ID) override;
protected: protected:
virtual void RemoveReferens() override; virtual void RemoveReferens() override;
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies, virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,

View File

@ -33,20 +33,20 @@
#include "../../../../dialogs/tools/dialogpointofintersectioncircles.h" #include "../../../../dialogs/tools/dialogpointofintersectioncircles.h"
#include "../../../../dialogs/tools/dialogtool.h" #include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../visualization/visualization.h"
#include "../../../../visualization/line/vistoolpointofintersectioncircles.h" #include "../../../../visualization/line/vistoolpointofintersectioncircles.h"
#include "../../../../visualization/visualization.h"
#include "../../../vabstracttool.h"
#include "../../vdrawtool.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionobjecterror.h"
#include "../ifc/xml/vdomdocument.h"
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "../ifc/xml/vdomdocument.h"
#include "../vgeometry/vgobject.h" #include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h" #include "../vpatterndb/vformula.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
#include "../../../vabstracttool.h"
#include "../../vdrawtool.h"
#include "vtoolsinglepoint.h" #include "vtoolsinglepoint.h"
template <class T> class QSharedPointer; template <class T> class QSharedPointer;
@ -119,10 +119,10 @@ auto VToolPointOfIntersectionCircles::Create(const QPointer<DialogTool> &dialog,
auto VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInitData &initData) auto VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInitData &initData)
-> VToolPointOfIntersectionCircles * -> VToolPointOfIntersectionCircles *
{ {
const qreal calcC1Radius = VAbstractValApplication::VApp() const qreal calcC1Radius =
->toPixel(CheckFormula(initData.id, initData.firstCircleRadius, initData.data)); VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.firstCircleRadius, initData.data));
const qreal calcC2Radius = VAbstractValApplication::VApp() const qreal calcC2Radius =
->toPixel(CheckFormula(initData.id, initData.secondCircleRadius, initData.data)); VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.secondCircleRadius, initData.data));
const VPointF c1Point = *initData.data->GeometricObject<VPointF>(initData.firstCircleCenterId); const VPointF c1Point = *initData.data->GeometricObject<VPointF>(initData.firstCircleCenterId);
const VPointF c2Point = *initData.data->GeometricObject<VPointF>(initData.secondCircleCenterId); const VPointF c2Point = *initData.data->GeometricObject<VPointF>(initData.secondCircleCenterId);
@ -134,9 +134,11 @@ auto VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInit
if (not success) if (not success)
{ {
const QString errorMsg = tr("Error calculating point '%1'. Circles with centers in points '%2' and '%3' have " const QString errorMsg = tr("Error calculating point '%1'. Circles with centers in points '%2' and '%3' have "
"no point of intersection").arg(initData.name, c1Point.name(), c2Point.name()); "no point of intersection")
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : .arg(initData.name, c1Point.name(), c2Point.name());
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
@ -177,7 +179,7 @@ auto VToolPointOfIntersectionCircles::FindPoint(const QPointF &c1Point, const QP
SCASSERT(intersectionPoint != nullptr) SCASSERT(intersectionPoint != nullptr)
QPointF p1, p2; QPointF p1, p2;
const int res = VGObject::IntersectionCircles(c1Point, c1Radius, c2Point, c2Radius, p1, p2); const int res = VGObject::IntersectionCircles(c1Point, qAbs(c1Radius), c2Point, qAbs(c2Radius), p1, p2);
switch (res) switch (res)
{ {
@ -218,7 +220,6 @@ auto VToolPointOfIntersectionCircles::SecondCircleCenterPointName() const -> QSt
auto VToolPointOfIntersectionCircles::GetFirstCircleRadius() const -> VFormula auto VToolPointOfIntersectionCircles::GetFirstCircleRadius() const -> VFormula
{ {
VFormula radius(firstCircleRadius, getData()); VFormula radius(firstCircleRadius, getData());
radius.setCheckZero(true);
radius.setToolId(m_id); radius.setToolId(m_id);
radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
radius.Eval(); radius.Eval();
@ -228,22 +229,18 @@ auto VToolPointOfIntersectionCircles::GetFirstCircleRadius() const -> VFormula
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionCircles::SetFirstCircleRadius(const VFormula &value) void VToolPointOfIntersectionCircles::SetFirstCircleRadius(const VFormula &value)
{ {
if (value.error() == false) if (!value.error())
{
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
{ {
firstCircleRadius = value.GetFormula(FormulaType::FromUser); firstCircleRadius = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
SaveOption(obj); SaveOption(obj);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolPointOfIntersectionCircles::GetSecondCircleRadius() const -> VFormula auto VToolPointOfIntersectionCircles::GetSecondCircleRadius() const -> VFormula
{ {
VFormula radius(secondCircleRadius, getData()); VFormula radius(secondCircleRadius, getData());
radius.setCheckZero(true);
radius.setToolId(m_id); radius.setToolId(m_id);
radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
radius.Eval(); radius.Eval();
@ -253,16 +250,13 @@ auto VToolPointOfIntersectionCircles::GetSecondCircleRadius() const -> VFormula
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionCircles::SetSecondCircleRadius(const VFormula &value) void VToolPointOfIntersectionCircles::SetSecondCircleRadius(const VFormula &value)
{ {
if (value.error() == false) if (!value.error())
{
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
{ {
secondCircleRadius = value.GetFormula(FormulaType::FromUser); secondCircleRadius = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
SaveOption(obj); SaveOption(obj);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolPointOfIntersectionCircles::GetCrossCirclesPoint() const -> CrossCirclesPoint auto VToolPointOfIntersectionCircles::GetCrossCirclesPoint() const -> CrossCirclesPoint

View File

@ -88,7 +88,7 @@ void VisToolMove::RefreshGeometry()
qreal tempRoationAngle = 0; qreal tempRoationAngle = 0;
QLineF line; QLineF line;
if (qFuzzyIsNull(m_length)) if (qIsInf(m_length))
{ {
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{ {
@ -157,10 +157,18 @@ void VisToolMove::RefreshGeometry()
DrawPath(m_angleArc, arc.GetPath(), Qt::SolidLine, Qt::RoundCap); DrawPath(m_angleArc, arc.GetPath(), Qt::SolidLine, Qt::RoundCap);
} }
DrawLine(this, line, Qt::DashLine); DrawLine(this, line, Qt::DashLine);
if (qFuzzyIsNull(m_length))
{
setVisible(true);
}
DrawPoint(m_pointFinish, line.p2()); DrawPoint(m_pointFinish, line.p2());
if (GetMode() == Mode::Creation)
{
static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
if (qFuzzyIsNull(m_length)) if (qIsInf(m_length))
{ {
SetToolTip(tr("Length = %1%2, angle = %3°, <b>%4</b> - sticking angle, " SetToolTip(tr("Length = %1%2, angle = %3°, <b>%4</b> - sticking angle, "
"<b>Mouse click</b> - finish selecting a position") "<b>Mouse click</b> - finish selecting a position")
@ -173,6 +181,7 @@ void VisToolMove::RefreshGeometry()
.arg(LengthToUser(tempLength), prefix, AngleToUser(tempAngle), AngleToUser(tempRoationAngle), .arg(LengthToUser(tempLength), prefix, AngleToUser(tempAngle), AngleToUser(tempRoationAngle),
VModifierKey::Shift(), VModifierKey::Control())); VModifierKey::Shift(), VModifierKey::Control()));
} }
}
CreateMovedRotatedObjects(iPoint, iCurve, tempLength, tempAngle, tempRoationAngle, origin); CreateMovedRotatedObjects(iPoint, iCurve, tempLength, tempAngle, tempRoationAngle, origin);
} }

View File

@ -37,6 +37,7 @@
#include <QString> #include <QString>
#include <QVector> #include <QVector>
#include <QtGlobal> #include <QtGlobal>
#include <limits>
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "visoperation.h" #include "visoperation.h"
@ -74,7 +75,7 @@ private:
Q_DISABLE_COPY_MOVE(VisToolMove) // NOLINT Q_DISABLE_COPY_MOVE(VisToolMove) // NOLINT
qreal m_angle{0}; qreal m_angle{0};
qreal m_rotationAngle{INT_MIN}; qreal m_rotationAngle{INT_MIN};
qreal m_length{0}; qreal m_length{std::numeric_limits<qreal>::infinity()};
VScaledEllipse *m_pointOrigin{nullptr}; VScaledEllipse *m_pointOrigin{nullptr};
VScaledEllipse *m_pointRotationOrigin{nullptr}; VScaledEllipse *m_pointRotationOrigin{nullptr};
VScaledEllipse *m_pointFinish{nullptr}; VScaledEllipse *m_pointFinish{nullptr};

View File

@ -82,6 +82,7 @@ void VisToolCutArc::RefreshGeometry()
{ {
QPointF p = arc->ClosestPoint(ScenePos()); QPointF p = arc->ClosestPoint(ScenePos());
qreal length = arc->GetLengthByPoint(p); qreal length = arc->GetLengthByPoint(p);
length = !arc->IsFlipped() ? qBound(0.0, length, arc->GetLength()) : qBound(arc->GetLength(), -length, 0.0);
DrawPoint(m_point, p); DrawPoint(m_point, p);

View File

@ -93,18 +93,39 @@ void TST_VArc::CompareTwoWays()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction void TST_VArc::ArcByLength_data()
void TST_VArc::NegativeArc()
{ {
const VPointF center; QTest::addColumn<qreal>("radius");
const qreal radius = 100; QTest::addColumn<qreal>("startAngle");
const qreal f1 = 1; QTest::addColumn<qreal>("endAngle");
const qreal f2 = 316; QTest::addColumn<qreal>("arcAngle");
const qreal length = M_PI * radius / 180 * 45; QTest::addColumn<bool>("flipped");
VArc arc(-length, center, radius, f1); QTest::addColumn<int>("direction");
QCOMPARE(arc.GetLength(), -length); QTest::newRow("Positive radius, positive length") << 100. << 1. << 316. << 315. << false << 1;
QCOMPARE(arc.GetEndAngle(), f2); QTest::newRow("Positive radius, negative length") << 100. << 1. << 316. << 45. << true << -1;
QTest::newRow("Negative radius, negative length") << -100. << 1. << 316. << 45. << true << -1;
QTest::newRow("Negative radius, positive length") << -100. << 1. << 316. << 45. << true << -1;
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VArc::ArcByLength()
{
QFETCH(qreal, radius);
QFETCH(qreal, startAngle);
QFETCH(qreal, endAngle);
QFETCH(qreal, arcAngle);
QFETCH(bool, flipped);
QFETCH(int, direction);
const qreal length = (M_PI * qAbs(radius) / 180 * arcAngle) * direction;
VArc arc(length, VPointF(), radius, startAngle);
QCOMPARE(arc.GetLength(), length);
QCOMPARE(arc.GetEndAngle(), endAngle);
QCOMPARE(arc.IsFlipped(), flipped);
QCOMPARE(arc.GetRadius(), radius);
QCOMPARE(arc.AngleArc(), arcAngle);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -116,82 +137,147 @@ void TST_VArc::TestGetPoints_data()
QTest::addColumn<qreal>("endAngle"); QTest::addColumn<qreal>("endAngle");
QTest::newRow("Full circle: radius 10") << 10.0 << 0.0 << 360.0; QTest::newRow("Full circle: radius 10") << 10.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius -10") << -10.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius 150") << 150.0 << 0.0 << 360.0; QTest::newRow("Full circle: radius 150") << 150.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius -150") << -150.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius 1500") << 1500.0 << 0.0 << 360.0; QTest::newRow("Full circle: radius 1500") << 1500.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius -1500") << -1500.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius 50000") << 50000.0 << 0.0 << 360.0; QTest::newRow("Full circle: radius 50000") << 50000.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius -50000") << -50000.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius 90000") << 90000.0 << 0.0 << 360.0; QTest::newRow("Full circle: radius 90000") << 90000.0 << 0.0 << 360.0;
QTest::newRow("Full circle: radius -90000") << -90000.0 << 0.0 << 360.0;
QTest::newRow("Arc less than 45 degree, radius 100") << 100.0 << 0.0 << 10.5; QTest::newRow("Arc less than 45 degree, radius 100") << 100.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius -100") << -100.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius 150") << 150.0 << 0.0 << 10.5; QTest::newRow("Arc less than 45 degree, radius 150") << 150.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius -150") << -150.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius 1500") << 1500.0 << 0.0 << 10.5; QTest::newRow("Arc less than 45 degree, radius 1500") << 1500.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius -1500") << -1500.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius 50000") << 50000.0 << 0.0 << 10.5; QTest::newRow("Arc less than 45 degree, radius 50000") << 50000.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius -50000") << -50000.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius 90000") << 90000.0 << 0.0 << 10.5; QTest::newRow("Arc less than 45 degree, radius 90000") << 90000.0 << 0.0 << 10.5;
QTest::newRow("Arc less than 45 degree, radius -90000") << -90000.0 << 0.0 << 10.5;
QTest::newRow("Arc 45 degree, radius 100") << 100.0 << 0.0 << 45.0; QTest::newRow("Arc 45 degree, radius 100") << 100.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius -100") << -100.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius 150") << 150.0 << 0.0 << 45.0; QTest::newRow("Arc 45 degree, radius 150") << 150.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius -150") << -150.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius 1500") << 1500.0 << 0.0 << 45.0; QTest::newRow("Arc 45 degree, radius 1500") << 1500.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius -1500") << -1500.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius 50000") << 50000.0 << 0.0 << 45.0; QTest::newRow("Arc 45 degree, radius 50000") << 50000.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius -50000") << -50000.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius 90000") << 90000.0 << 0.0 << 45.0; QTest::newRow("Arc 45 degree, radius 90000") << 90000.0 << 0.0 << 45.0;
QTest::newRow("Arc 45 degree, radius -90000") << -90000.0 << 0.0 << 45.0;
QTest::newRow("Arc less than 90 degree, radius 100") << 100.0 << 0.0 << 75.0; QTest::newRow("Arc less than 90 degree, radius 100") << 100.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius -100") << -100.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius 150") << 150.0 << 0.0 << 75.0; QTest::newRow("Arc less than 90 degree, radius 150") << 150.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius -150") << -150.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius 1500") << 1500.0 << 0.0 << 75.0; QTest::newRow("Arc less than 90 degree, radius 1500") << 1500.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius -1500") << -1500.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius 50000") << 50000.0 << 0.0 << 75.0; QTest::newRow("Arc less than 90 degree, radius 50000") << 50000.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius -50000") << -50000.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius 90000") << 90000.0 << 0.0 << 75.0; QTest::newRow("Arc less than 90 degree, radius 90000") << 90000.0 << 0.0 << 75.0;
QTest::newRow("Arc less than 90 degree, radius -90000") << -90000.0 << 0.0 << 75.0;
QTest::newRow("Arc 90 degree, radius 100") << 100.0 << 0.0 << 90.0; QTest::newRow("Arc 90 degree, radius 100") << 100.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius -100") << -100.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius 150") << 150.0 << 0.0 << 90.0; QTest::newRow("Arc 90 degree, radius 150") << 150.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius -150") << -150.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius 1500") << 1500.0 << 0.0 << 90.0; QTest::newRow("Arc 90 degree, radius 1500") << 1500.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius -1500") << -1500.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius 50000") << 50000.0 << 0.0 << 90.0; QTest::newRow("Arc 90 degree, radius 50000") << 50000.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius -50000") << -50000.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius 90000") << 90000.0 << 0.0 << 90.0; QTest::newRow("Arc 90 degree, radius 90000") << 90000.0 << 0.0 << 90.0;
QTest::newRow("Arc 90 degree, radius -90000") << -90000.0 << 0.0 << 90.0;
QTest::newRow("Arc less than 135 degree, radius 100") << 100.0 << 0.0 << 110.6; QTest::newRow("Arc less than 135 degree, radius 100") << 100.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius -100") << -100.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius 150") << 150.0 << 0.0 << 110.6; QTest::newRow("Arc less than 135 degree, radius 150") << 150.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius -150") << -150.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius 1500") << 1500.0 << 0.0 << 110.6; QTest::newRow("Arc less than 135 degree, radius 1500") << 1500.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius -1500") << -1500.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius 50000") << 50000.0 << 0.0 << 110.6; QTest::newRow("Arc less than 135 degree, radius 50000") << 50000.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius -50000") << -50000.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius 90000") << 90000.0 << 0.0 << 110.6; QTest::newRow("Arc less than 135 degree, radius 90000") << 90000.0 << 0.0 << 110.6;
QTest::newRow("Arc less than 135 degree, radius -90000") << -90000.0 << 0.0 << 110.6;
QTest::newRow("Arc 135 degree, radius 100") << 100.0 << 0.0 << 135.0; QTest::newRow("Arc 135 degree, radius 100") << 100.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius -100") << -100.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius 150") << 150.0 << 0.0 << 135.0; QTest::newRow("Arc 135 degree, radius 150") << 150.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius -150") << -150.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius 1500") << 1500.0 << 0.0 << 135.0; QTest::newRow("Arc 135 degree, radius 1500") << 1500.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius -1500") << -1500.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius 50000") << 50000.0 << 0.0 << 135.0; QTest::newRow("Arc 135 degree, radius 50000") << 50000.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius -50000") << -50000.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius 90000") << 90000.0 << 0.0 << 135.0; QTest::newRow("Arc 135 degree, radius 90000") << 90000.0 << 0.0 << 135.0;
QTest::newRow("Arc 135 degree, radius -90000") << -90000.0 << 0.0 << 135.0;
QTest::newRow("Arc less than 180 degree, radius 100") << 100.0 << 0.0 << 160.7; QTest::newRow("Arc less than 180 degree, radius 100") << 100.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius -100") << -100.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius 150") << 150.0 << 0.0 << 160.7; QTest::newRow("Arc less than 180 degree, radius 150") << 150.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius -150") << -150.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius 1500") << 1500.0 << 0.0 << 160.7; QTest::newRow("Arc less than 180 degree, radius 1500") << 1500.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius -1500") << -1500.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius 50000") << 50000.0 << 0.0 << 160.7; QTest::newRow("Arc less than 180 degree, radius 50000") << 50000.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius -50000") << -50000.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius 90000") << 90000.0 << 0.0 << 160.7; QTest::newRow("Arc less than 180 degree, radius 90000") << 90000.0 << 0.0 << 160.7;
QTest::newRow("Arc less than 180 degree, radius -90000") << -90000.0 << 0.0 << 160.7;
QTest::newRow("Arc 180 degree, radius 100") << 100.0 << 0.0 << 180.0; QTest::newRow("Arc 180 degree, radius 100") << 100.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius -100") << -100.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius 150") << 150.0 << 0.0 << 180.0; QTest::newRow("Arc 180 degree, radius 150") << 150.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius -150") << -150.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius 1500") << 1500.0 << 0.0 << 180.0; QTest::newRow("Arc 180 degree, radius 1500") << 1500.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius -1500") << -1500.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius 50000") << 50000.0 << 0.0 << 180.0; QTest::newRow("Arc 180 degree, radius 50000") << 50000.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius -50000") << -50000.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius 90000") << 90000.0 << 0.0 << 180.0; QTest::newRow("Arc 180 degree, radius 90000") << 90000.0 << 0.0 << 180.0;
QTest::newRow("Arc 180 degree, radius -90000") << -90000.0 << 0.0 << 180.0;
QTest::newRow("Arc less than 270 degree, radius 100") << 100.0 << 0.0 << 150.3; QTest::newRow("Arc less than 270 degree, radius 100") << 100.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius -100") << -100.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius 150") << 150.0 << 0.0 << 150.3; QTest::newRow("Arc less than 270 degree, radius 150") << 150.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius -150") << -150.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius 1500") << 1500.0 << 0.0 << 150.3; QTest::newRow("Arc less than 270 degree, radius 1500") << 1500.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius -1500") << -1500.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius 50000") << 50000.0 << 0.0 << 150.3; QTest::newRow("Arc less than 270 degree, radius 50000") << 50000.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius -50000") << -50000.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius 90000") << 90000.0 << 0.0 << 150.3; QTest::newRow("Arc less than 270 degree, radius 90000") << 90000.0 << 0.0 << 150.3;
QTest::newRow("Arc less than 270 degree, radius -90000") << -90000.0 << 0.0 << 150.3;
QTest::newRow("Arc 270 degree, radius 100") << 100.0 << 0.0 << 270.0; QTest::newRow("Arc 270 degree, radius 100") << 100.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius -100") << -100.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius 150") << 150.0 << 0.0 << 270.0; QTest::newRow("Arc 270 degree, radius 150") << 150.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius -150") << -150.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius 1500") << 1500.0 << 0.0 << 270.0; QTest::newRow("Arc 270 degree, radius 1500") << 1500.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius -1500") << -1500.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius 50000") << 50000.0 << 0.0 << 270.0; QTest::newRow("Arc 270 degree, radius 50000") << 50000.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius -50000") << -50000.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius 90000") << 90000.0 << 0.0 << 270.0; QTest::newRow("Arc 270 degree, radius 90000") << 90000.0 << 0.0 << 270.0;
QTest::newRow("Arc 270 degree, radius -90000") << -90000.0 << 0.0 << 270.0;
QTest::newRow("Arc less than 360 degree, radius 100") << 100.0 << 0.0 << 340.0; QTest::newRow("Arc less than 360 degree, radius 100") << 100.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius -100") << -100.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius 150") << 150.0 << 0.0 << 340.0; QTest::newRow("Arc less than 360 degree, radius 150") << 150.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius -150") << -150.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius 1500") << 1500.0 << 0.0 << 340.0; QTest::newRow("Arc less than 360 degree, radius 1500") << 1500.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius -1500") << -1500.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius 50000") << 50000.0 << 0.0 << 340.0; QTest::newRow("Arc less than 360 degree, radius 50000") << 50000.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius -50000") << -50000.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius 90000") << 90000.0 << 0.0 << 340.0; QTest::newRow("Arc less than 360 degree, radius 90000") << 90000.0 << 0.0 << 340.0;
QTest::newRow("Arc less than 360 degree, radius -90000") << -90000.0 << 0.0 << 340.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius 100") << 100.0 << 90.0 << 135.0; QTest::newRow("Arc start 90 degree, angle 45 degree, radius 100") << 100.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius -100") << -100.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius 150") << 150.0 << 90.0 << 135.0; QTest::newRow("Arc start 90 degree, angle 45 degree, radius 150") << 150.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius -150") << -150.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius 1500") << 1500.0 << 90.0 << 135.0; QTest::newRow("Arc start 90 degree, angle 45 degree, radius 1500") << 1500.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius -1500") << -1500.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius 50000") << 50000.0 << 90.0 << 135.0; QTest::newRow("Arc start 90 degree, angle 45 degree, radius 50000") << 50000.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius -50000") << -50000.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius 90000") << 90000.0 << 90.0 << 135.0; QTest::newRow("Arc start 90 degree, angle 45 degree, radius 90000") << 90000.0 << 90.0 << 135.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radius -90000") << -90000.0 << 90.0 << 135.0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -214,7 +300,7 @@ void TST_VArc::TestGetPoints()
for (auto point : points) for (auto point : points)
{ {
QLineF rLine(static_cast<QPointF>(center), point); QLineF rLine(static_cast<QPointF>(center), point);
const qreal value = qAbs(rLine.length() - radius); const qreal value = qAbs(rLine.length() - qAbs(radius));
// cppcheck-suppress unreadVariable // cppcheck-suppress unreadVariable
const QString errorMsg = u"Broken the first rule. All points should be on the same distance from " const QString errorMsg = u"Broken the first rule. All points should be on the same distance from "
u"the center. Error ='%1'."_s.arg(value); u"the center. Error ='%1'."_s.arg(value);
@ -227,11 +313,11 @@ void TST_VArc::TestGetPoints()
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0)) if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{ // circle square { // circle square
gSquare = M_PI * radius * radius; gSquare = M_PI * qAbs(radius) * qAbs(radius);
} }
else else
{ // sector square { // sector square
gSquare = (M_PI * radius * radius) / 360.0 * arc.AngleArc(); gSquare = (M_PI * qAbs(radius) * qAbs(radius)) / 360.0 * arc.AngleArc();
points.append(static_cast<QPointF>(center)); points.append(static_cast<QPointF>(center));
} }
@ -258,6 +344,7 @@ void TST_VArc::TestRotation_data()
QTest::addColumn<QString>("prefix"); QTest::addColumn<QString>("prefix");
QTest::newRow("Test arc 1") << QPointF(10, 10) << 10. << 0. << 90. << QPointF() << 90. << "_r"; QTest::newRow("Test arc 1") << QPointF(10, 10) << 10. << 0. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test arc 2") << QPointF(10, 10) << -10. << 0. << 90. << QPointF() << 90. << "_r";
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -277,6 +364,7 @@ void TST_VArc::TestRotation()
QCOMPARE(arcOrigin.GetLength(), rotatedArc.GetLength()); QCOMPARE(arcOrigin.GetLength(), rotatedArc.GetLength());
QCOMPARE(arcOrigin.AngleArc(), rotatedArc.AngleArc()); QCOMPARE(arcOrigin.AngleArc(), rotatedArc.AngleArc());
QCOMPARE(arcOrigin.GetRadius(), rotatedArc.GetRadius()); QCOMPARE(arcOrigin.GetRadius(), rotatedArc.GetRadius());
QCOMPARE(arcOrigin.IsFlipped(), rotatedArc.IsFlipped());
// cppcheck-suppress unreadVariable // cppcheck-suppress unreadVariable
const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix); const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix);
QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg)); QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg));
@ -300,16 +388,20 @@ void TST_VArc::TestFlip_data()
QLineF axis(QPointF(4, 6), QPointF(12, 6)); QLineF axis(QPointF(4, 6), QPointF(12, 6));
QTest::newRow("Vertical axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() QTest::newRow("Vertical axis, positive radius")
<< axis << "a2"; << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() << axis << "a2";
QTest::newRow("Vertical axis, negative radius")
<< center << -radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() << axis << "a2";
p1 = QPointF(15, 5); p1 = QPointF(15, 5);
p2 = QPointF(10, 0); p2 = QPointF(10, 0);
axis = QLineF(QPointF(9, -1), QPointF(9, 6)); axis = QLineF(QPointF(9, -1), QPointF(9, 6));
QTest::newRow("Horizontal axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() QTest::newRow("Horizontal axis, positive radius")
<< axis << "a2"; << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() << axis << "a2";
QTest::newRow("Horizontal axis, negative radius")
<< center << -radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() << axis << "a2";
QLineF l(center.x(), center.y(), center.x() + radius, center.y()); QLineF l(center.x(), center.y(), center.x() + radius, center.y());
@ -326,8 +418,10 @@ void TST_VArc::TestFlip_data()
axis = QLineF(p1Axis.x(), p1Axis.y(), p1Axis.x() + radius, p1Axis.y()); axis = QLineF(p1Axis.x(), p1Axis.y(), p1Axis.x() + radius, p1Axis.y());
axis.setAngle(45); axis.setAngle(45);
QTest::newRow("Diagonal axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() QTest::newRow("Diagonal axis, positive radius")
<< axis << "a2"; << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() << axis << "a2";
QTest::newRow("Diagonal axis, negative radius")
<< center << -radius << QLineF(center, p1).angle() << QLineF(center, p2).angle() << axis << "a2";
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -347,7 +441,7 @@ void TST_VArc::TestFlip()
const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix); const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix);
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
QVERIFY2(res.IsFlipped(), qUtf8Printable("The arc is not flipped")); QVERIFY2(res.IsFlipped() == radius > 0, qUtf8Printable("The arc is not flipped"));
QCOMPARE(originArc.GetLength() * -1, res.GetLength()); QCOMPARE(originArc.GetLength() * -1, res.GetLength());
QCOMPARE(originArc.GetRadius(), res.GetRadius()); QCOMPARE(originArc.GetRadius(), res.GetRadius());
@ -355,7 +449,7 @@ void TST_VArc::TestFlip()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TST_VArc::TestCutArc_data() void TST_VArc::TestCutArcByLength_data()
{ {
QTest::addColumn<QPointF>("center"); QTest::addColumn<QPointF>("center");
QTest::addColumn<qreal>("radius"); QTest::addColumn<qreal>("radius");
@ -364,40 +458,65 @@ void TST_VArc::TestCutArc_data()
QTest::addColumn<qreal>("cutLength"); QTest::addColumn<qreal>("cutLength");
QTest::addColumn<QPointF>("cutPoint"); QTest::addColumn<QPointF>("cutPoint");
QPointF center(189.13625196850393, 344.1267401574803); const QPointF center(189.13625196850393, 344.1267401574803);
qreal radius = ToPixel(10, Unit::Cm); Q_RELAXED_CONSTEXPR qreal radius = ToPixel(10, Unit::Cm);
qreal startAngle = 45.0;
qreal length = ToPixel(-10, Unit::Cm);
qreal cutLength = ToPixel(6, Unit::Cm);
QPointF cutPoint(539.3657292513009, 202.04366960088566); QPointF cutPoint(539.3657292513009, 202.04366960088566);
Q_RELAXED_CONSTEXPR qreal length = ToPixel(10, Unit::Cm);
// See file <root>/src/app/share/collection/bugs/Issue_#957.val // See file <root>/src/app/share/collection/bugs/Issue_#957.val
QTest::newRow("Arc -10 cm length, cut length 6 cm") QTest::newRow("Arc -10 cm length, cut length 6 cm")
<< center << radius << startAngle << length << cutLength << cutPoint; << center << radius << 45.0 << -length << ToPixel(6, Unit::Cm) << cutPoint;
cutLength = ToPixel(-4, Unit::Cm);
// Opposite case // Opposite case
QTest::newRow("Arc -10 cm length, cut length -4 cm") QTest::newRow("Arc -10 cm length, cut length -4 cm")
<< center << radius << startAngle << length << cutLength << cutPoint; << center << radius << 45.0 << -length << ToPixel(-4, Unit::Cm) << cutPoint;
startAngle = 135;
length = ToPixel(10, Unit::Cm);
cutLength = ToPixel(-7, Unit::Cm);
cutPoint = QPointF(-145.1588983496871, 167.78888781060192); cutPoint = QPointF(-145.1588983496871, 167.78888781060192);
// See file <root>/src/app/share/collection/bugs/Issue_#957.val // See file <root>/src/app/share/collection/bugs/Issue_#957.val
QTest::newRow("Arc 10 cm length, cut length -7 cm") QTest::newRow("Arc 10 cm length, cut length -7 cm")
<< center << radius << startAngle << length << cutLength << cutPoint; << center << radius << 135. << length << ToPixel(-7, Unit::Cm) << cutPoint;
// Opposite case // Opposite case
cutLength = ToPixel(3, Unit::Cm);
QTest::newRow("Arc 10 cm length, cut length 3 cm") QTest::newRow("Arc 10 cm length, cut length 3 cm")
<< center << radius << startAngle << length << cutLength << cutPoint; << center << radius << 135. << length << ToPixel(3, Unit::Cm) << cutPoint;
QLineF l = QLineF(center, QPointF(center.x() + radius, center.y()));
l.setAngle(135);
QTest::newRow("Arc 10 cm length, cut length 0 cm") << center << radius << 135. << length << 0. << l.p2();
QTest::newRow("Arc 10 cm length (-10 cm radius), cut length 0 cm")
<< center << -radius << 135. << length << 0. << l.p2();
QTest::newRow("Arc -10 cm length (-10 cm radius), cut length 0 cm")
<< center << -radius << 135. << -length << 0. << l.p2();
QTest::newRow("Arc -10 cm length (10 cm radius), cut length 10 cm")
<< center << radius << 135. << -length << length << l.p2();
QTest::newRow("Arc -10 cm length (-10 cm radius), cut length 10 cm")
<< center << -radius << 135. << -length << length << l.p2();
const qreal arcAngle = qAbs(qRadiansToDegrees(ToPixel(10, Unit::Cm) / qAbs(radius)));
l = QLineF(center, QPointF(center.x() + radius, center.y()));
l.setAngle(135 + arcAngle);
QTest::newRow("Arc 10 cm length, cut length 10 cm")
<< center << radius << 135. << length << ToPixel(10, Unit::Cm) << l.p2();
l = QLineF(center, QPointF(center.x() + radius, center.y()));
l.setAngle(135 - arcAngle);
QTest::newRow("Arc -10 cm length (10 cm radius), cut length -10 cm")
<< center << radius << 135. << -length << -radius << l.p2();
QTest::newRow("Arc -10 cm length (-10 cm radius), cut length -10 cm")
<< center << -radius << 135. << -length << -radius << l.p2();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TST_VArc::TestCutArc() void TST_VArc::TestCutArcByLength()
{ {
QFETCH(QPointF, center); QFETCH(QPointF, center);
QFETCH(qreal, radius); QFETCH(qreal, radius);

View File

@ -40,15 +40,16 @@ public:
private slots: private slots:
void CompareTwoWays(); void CompareTwoWays();
void NegativeArc(); void ArcByLength_data();
void ArcByLength();
void TestGetPoints_data(); void TestGetPoints_data();
void TestGetPoints(); void TestGetPoints();
void TestRotation_data(); void TestRotation_data();
void TestRotation(); void TestRotation();
void TestFlip_data(); void TestFlip_data();
void TestFlip(); void TestFlip();
void TestCutArc_data(); void TestCutArcByLength_data();
void TestCutArc(); void TestCutArcByLength();
void TestCurveIntersectAxis_data(); void TestCurveIntersectAxis_data();
void TestCurveIntersectAxis(); void TestCurveIntersectAxis();
void EmptyArc(); void EmptyArc();

View File

@ -55,22 +55,85 @@ void TST_VEllipticalArc::CompareTwoWays_data()
QTest::addColumn<qreal>("f2"); QTest::addColumn<qreal>("f2");
QTest::addColumn<qreal>("rotationAngle"); QTest::addColumn<qreal>("rotationAngle");
QTest::newRow("Test case 1") << QPointF() << 100. << 200. << 0. << 90.0 << 0.; QTest::newRow("Test case 1, +r, +r") << QPointF() << 100. << 200. << 0. << 90.0 << 0.;
QTest::newRow("Test case 2") << QPointF() << 100. << 200. << 0. << 180.0 << 0.; QTest::newRow("Test case 1, -r, +r") << QPointF() << -100. << 200. << 0. << 90.0 << 0.;
QTest::newRow("Test case 3") << QPointF() << 100. << 200. << 0. << 270.0 << 0.; QTest::newRow("Test case 1, +r, -r") << QPointF() << 100. << -200. << 0. << 90.0 << 0.;
QTest::newRow("Test case 4") << QPointF() << 100. << 200. << 0. << 360.0 << 0.; QTest::newRow("Test case 1, -r, -r") << QPointF() << -100. << -200. << 0. << 90.0 << 0.;
QTest::newRow("Test case 5") << QPointF(10, 10) << 100. << 200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 6") << QPointF(10, 10) << 100. << 200. << 0. << 180.0 << 80.; QTest::newRow("Test case 2, +r, +r") << QPointF() << 100. << 200. << 0. << 180.0 << 0.;
QTest::newRow("Test case 7") << QPointF(10, 10) << 100. << 200. << 0. << 270.0 << 80.; QTest::newRow("Test case 2, -r, +r") << QPointF() << -100. << 200. << 0. << 180.0 << 0.;
QTest::newRow("Test case 8") << QPointF(10, 10) << 100. << 200. << 0. << 360.0 << 80.; QTest::newRow("Test case 2, +r, -r") << QPointF() << 100. << -200. << 0. << 180.0 << 0.;
QTest::newRow("Test case 9") << QPointF() << 100. << 200. << 0. << 90.0 << 80.; QTest::newRow("Test case 2, -r, -r") << QPointF() << -100. << -200. << 0. << 180.0 << 0.;
QTest::newRow("Test case 10") << QPointF() << 100. << 200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 11") << QPointF() << 100. << 200. << 0. << 270.0 << 80.; QTest::newRow("Test case 3, +r, +r") << QPointF() << 100. << 200. << 0. << 270.0 << 0.;
QTest::newRow("Test case 12") << QPointF() << 100. << 200. << 0. << 360.0 << 80.; QTest::newRow("Test case 3, -r, +r") << QPointF() << -100. << 200. << 0. << 270.0 << 0.;
QTest::newRow("Test case 13") << QPointF(10, 10) << 100. << 200. << 0. << 90.0 << 80.; QTest::newRow("Test case 3, +r, -r") << QPointF() << 100. << -200. << 0. << 270.0 << 0.;
QTest::newRow("Test case 14") << QPointF(10, 10) << 100. << 200. << 0. << 180.0 << 80.; QTest::newRow("Test case 3, -r, -r") << QPointF() << -100. << -200. << 0. << 270.0 << 0.;
QTest::newRow("Test case 15") << QPointF(10, 10) << 100. << 200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 16") << QPointF(10, 10) << 100. << 200. << 0. << 360.0 << 80.; QTest::newRow("Test case 4, +r, +r") << QPointF() << 100. << 200. << 0. << 360.0 << 0.;
QTest::newRow("Test case 4, -r, +r") << QPointF() << -100. << 200. << 0. << 360.0 << 0.;
QTest::newRow("Test case 4, +r, -r") << QPointF() << 100. << -200. << 0. << 360.0 << 0.;
QTest::newRow("Test case 4, -r, -r") << QPointF() << -100. << -200. << 0. << 360.0 << 0.;
QTest::newRow("Test case 5, +r, +r") << QPointF(10, 10) << 100. << 200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 5, -r, +r") << QPointF(10, 10) << -100. << 200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 5, +r, -r") << QPointF(10, 10) << 100. << -200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 5, -r, -r") << QPointF(10, 10) << -100. << -200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 6, +r, +r") << QPointF(10, 10) << 100. << 200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 6, -r, +r") << QPointF(10, 10) << -100. << 200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 6, +r, -r") << QPointF(10, 10) << 100. << -200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 6, -r, -r") << QPointF(10, 10) << -100. << -200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 7, +r, +r") << QPointF(10, 10) << 100. << 200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 7, -r, +r") << QPointF(10, 10) << -100. << 200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 7, +r, -r") << QPointF(10, 10) << 100. << -200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 7, -r, -r") << QPointF(10, 10) << -100. << -200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 8, +r, +r") << QPointF(10, 10) << 100. << 200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 8, -r, +r") << QPointF(10, 10) << -100. << 200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 8, +r, -r") << QPointF(10, 10) << 100. << -200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 8, -r, -r") << QPointF(10, 10) << -100. << -200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 9, +r, +r") << QPointF() << 100. << 200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 9, -r, +r") << QPointF() << -100. << 200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 9, +r, -r") << QPointF() << 100. << -200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 9, -r, -r") << QPointF() << -100. << -200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 10, +r, +r") << QPointF() << 100. << 200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 10, -r, +r") << QPointF() << -100. << 200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 10, +r, -r") << QPointF() << 100. << -200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 10, -r, -r") << QPointF() << -100. << -200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 11, +r, +r") << QPointF() << 100. << 200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 11, -r, +r") << QPointF() << -100. << 200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 11, +r, -r") << QPointF() << 100. << -200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 11, -r, -r") << QPointF() << -100. << -200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 12, +r, +r") << QPointF() << 100. << 200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 12, -r, +r") << QPointF() << -100. << 200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 12, +r, -r") << QPointF() << 100. << -200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 12, -r, -r") << QPointF() << -100. << -200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 13, +r, +r") << QPointF(10, 10) << 100. << 200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 13, -r, +r") << QPointF(10, 10) << -100. << 200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 13, +r, -r") << QPointF(10, 10) << 100. << -200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 13, -r, -r") << QPointF(10, 10) << -100. << -200. << 0. << 90.0 << 80.;
QTest::newRow("Test case 14, +r, +r") << QPointF(10, 10) << 100. << 200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 14, -r, +r") << QPointF(10, 10) << -100. << 200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 14, +r, -r") << QPointF(10, 10) << 100. << -200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 14, -r, -r") << QPointF(10, 10) << -100. << -200. << 0. << 180.0 << 80.;
QTest::newRow("Test case 15, +r, +r") << QPointF(10, 10) << 100. << 200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 15, -r, +r") << QPointF(10, 10) << -100. << 200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 15, +r, -r") << QPointF(10, 10) << 100. << -200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 15, -r, -r") << QPointF(10, 10) << -100. << -200. << 0. << 270.0 << 80.;
QTest::newRow("Test case 16, +r, +r") << QPointF(10, 10) << 100. << 200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 16, -r, +r") << QPointF(10, 10) << -100. << 200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 16, +r, -r") << QPointF(10, 10) << 100. << -200. << 0. << 360.0 << 80.;
QTest::newRow("Test case 16, -r, -r") << QPointF(10, 10) << -100. << -200. << 0. << 360.0 << 80.;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -91,7 +154,7 @@ void TST_VEllipticalArc::CompareTwoWays()
VEllipticalArc arc2(length, center, radius1, radius2, f1, rotationAngle); VEllipticalArc arc2(length, center, radius1, radius2, f1, rotationAngle);
const qreal lengthEps = ToPixel(0.45, Unit::Mm); // computing error Q_RELAXED_CONSTEXPR qreal lengthEps = ToPixel(0.45, Unit::Mm); // computing error
// cppcheck-suppress unreadVariable // cppcheck-suppress unreadVariable
QString errorLengthMsg = u"Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"_s; QString errorLengthMsg = u"Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"_s;
@ -111,30 +174,57 @@ void TST_VEllipticalArc::CompareTwoWays()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction void TST_VEllipticalArc::ArcByLength_data()
void TST_VEllipticalArc::NegativeArc()
{ {
QTest::addColumn<qreal>("radius1");
QTest::addColumn<qreal>("radius2");
QTest::addColumn<qreal>("f1");
QTest::addColumn<qreal>("f2");
QTest::addColumn<qreal>("rotationAngle");
QTest::addColumn<bool>("flipped");
QTest::addColumn<int>("direction");
QTest::newRow("+r, +r, +length") << 100. << 200. << 1. << 181. << 0. << false << 1;
QTest::newRow("+r, +r, -length") << 100. << 200. << 1. << 181. << 0. << true << -1;
QTest::newRow("-r, +r, +length") << -100. << 200. << 1. << 181. << 0. << true << -1;
QTest::newRow("-r, +r, -length") << -100. << 200. << 1. << 181. << 0. << true << -1;
QTest::newRow("+r, -r, +length") << 100. << -200. << 1. << 181. << 0. << true << -1;
QTest::newRow("+r, -r, -length") << 100. << -200. << 1. << 181. << 0. << true << -1;
QTest::newRow("-r, -r, +length") << -100. << -200. << 1. << 181. << 0. << true << -1;
QTest::newRow("-r, -r, -length") << -100. << -200. << 1. << 181. << 0. << true << -1;
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VEllipticalArc::ArcByLength()
{
QFETCH(qreal, radius1);
QFETCH(qreal, radius2);
QFETCH(qreal, f1);
QFETCH(qreal, f2);
QFETCH(qreal, rotationAngle);
QFETCH(bool, flipped);
QFETCH(int, direction);
const VPointF center; const VPointF center;
const qreal radius1 = 100;
const qreal radius2 = 200;
const qreal f1 = 1;
const qreal f2 = 181;
const qreal rotationAngle = 0;
// Full ellipse // Full ellipse
const qreal h = ((radius1 - radius2) * (radius1 - radius2)) / ((radius1 + radius2) * (radius1 + radius2)); const qreal h = ((qAbs(radius1) - qAbs(radius2)) * (qAbs(radius1) - qAbs(radius2))) /
const qreal length = M_PI * (radius1 + radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h))) / 2; ((qAbs(radius1) + qAbs(radius2)) * (qAbs(radius1) + qAbs(radius2)));
VEllipticalArc arc(-length, center, radius1, radius2, f1, rotationAngle); const qreal length =
(M_PI * (qAbs(radius1) + qAbs(radius2)) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h))) / 2) * direction;
VEllipticalArc arc(length, center, radius1, radius2, f1, rotationAngle);
const qreal eps = ToPixel(0.45, Unit::Mm); // computing error Q_RELAXED_CONSTEXPR qreal eps = ToPixel(0.45, Unit::Mm); // computing error
// cppcheck-suppress unreadVariable // cppcheck-suppress unreadVariable
const QString errorMsg = const QString errorMsg =
u"Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3"_s; QStringLiteral("Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3");
QVERIFY2(qAbs(arc.GetLength() + length) <= eps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length))); QVERIFY2(qAbs(arc.GetLength() - length) <= eps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length)));
const qreal angleEps = 0.4; const qreal angleEps = 0.4;
QVERIFY2(arc.GetEndAngle() - f2 <= angleEps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2))); QVERIFY2(arc.GetEndAngle() - f2 <= angleEps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2)));
QCOMPARE(arc.IsFlipped(), flipped);
} }
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
@ -172,106 +262,445 @@ void TST_VEllipticalArc::TestData()
QTest::addColumn<qreal>("rotationAngle"); QTest::addColumn<qreal>("rotationAngle");
QTest::newRow("Full circle: radiuses 10, 20; start 0") << 10.0 << 20.0 << 0.0 << 360.0 << 0.0; QTest::newRow("Full circle: radiuses 10, 20; start 0") << 10.0 << 20.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses -10, 20; start 0") << -10.0 << 20.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses 10, -20; start 0") << 10.0 << -20.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses -10, -20; start 0") << -10.0 << -20.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, 200; start 0") << 150.0 << 200.0 << 0.0 << 360.0 << 0.0; QTest::newRow("Full circle: radiuses 150, 200; start 0") << 150.0 << 200.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses -150, 200; start 0") << -150.0 << 200.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, -200; start 0") << 150.0 << -200.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses -150, -200; start 0") << -150.0 << -200.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 0") << 150.0 << 200.0 << 0.0 << 360.0 << 30.0; QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 0") << 150.0 << 200.0 << 0.0 << 360.0 << 30.0;
QTest::newRow("Full circle: radiuses -150, 200, rotation 30; start 0") << -150.0 << 200.0 << 0.0 << 360.0 << 30.0;
QTest::newRow("Full circle: radiuses 150, -200, rotation 30; start 0") << 150.0 << -200.0 << 0.0 << 360.0 << 30.0;
QTest::newRow("Full circle: radiuses -150, -200, rotation 30; start 0") << -150.0 << -200.0 << 0.0 << 360.0 << 30.0;
QTest::newRow("Full circle: radiuses 1500, 1000; start 0") << 1500.0 << 1000.0 << 0.0 << 360.0 << 0.0; QTest::newRow("Full circle: radiuses 1500, 1000; start 0") << 1500.0 << 1000.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses -1500, 1000; start 0") << -1500.0 << 1000.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses 1500, -1000; start 0") << 1500.0 << -1000.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses -1500, -1000; start 0") << -1500.0 << -1000.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 0") << 1500.0 << 1000.0 << 0.0 << 360.0 << 50.0; QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 0") << 1500.0 << 1000.0 << 0.0 << 360.0 << 50.0;
QTest::newRow("Full circle: radiuses -1500, 1000, rotation 50; start 0")
<< -1500.0 << 1000.0 << 0.0 << 360.0 << 50.0;
QTest::newRow("Full circle: radiuses 1500, -1000, rotation 50; start 0")
<< 1500.0 << -1000.0 << 0.0 << 360.0 << 50.0;
QTest::newRow("Full circle: radiuses -1500, -1000, rotation 50; start 0")
<< -1500.0 << -1000.0 << 0.0 << 360.0 << 50.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 0") QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 0")
<< 15000.0 << 10000.0 << 0.0 << 360.0 << 90.0; << 15000.0 << 10000.0 << 0.0 << 360.0 << 90.0;
QTest::newRow("Full circle: radiuses -15000, 10000, rotation 90; start 0")
<< -15000.0 << 10000.0 << 0.0 << 360.0 << 90.0;
QTest::newRow("Full circle: radiuses 15000, -10000, rotation 90; start 0")
<< 15000.0 << -10000.0 << 0.0 << 360.0 << 90.0;
QTest::newRow("Full circle: radiuses -15000, -10000, rotation 90; start 0")
<< -15000.0 << -10000.0 << 0.0 << 360.0 << 90.0;
QTest::newRow("Full circle: radiuses 10, 20; start 90") << 10.0 << 20.0 << 90.0 << 90.0 << 0.0; QTest::newRow("Full circle: radiuses 10, 20; start 90") << 10.0 << 20.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses -10, 20; start 90") << -10.0 << 20.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 10, -20; start 90") << 10.0 << -20.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses -10, -20; start 90") << -10.0 << -20.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, 200; start 90") << 150.0 << 200.0 << 90.0 << 90.0 << 0.0; QTest::newRow("Full circle: radiuses 150, 200; start 90") << 150.0 << 200.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses -150, 200; start 90") << -150.0 << 200.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, -200; start 90") << 150.0 << -200.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses -150, -200; start 90") << -150.0 << -200.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 90") << 150.0 << 200.0 << 90.0 << 90.0 << 30.0; QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 90") << 150.0 << 200.0 << 90.0 << 90.0 << 30.0;
QTest::newRow("Full circle: radiuses -150, 200, rotation 30; start 90") << -150.0 << 200.0 << 90.0 << 90.0 << 30.0;
QTest::newRow("Full circle: radiuses 150, -200, rotation 30; start 90") << 150.0 << -200.0 << 90.0 << 90.0 << 30.0;
QTest::newRow("Full circle: radiuses -150, -200, rotation 30; start 90")
<< -150.0 << -200.0 << 90.0 << 90.0 << 30.0;
QTest::newRow("Full circle: radiuses 1500, 1000; start 90") << 1500.0 << 1000.0 << 90.0 << 90.0 << 0.0; QTest::newRow("Full circle: radiuses 1500, 1000; start 90") << 1500.0 << 1000.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses -1500, 1000; start 90") << 1500.0 << -1000.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 1500, -1000; start 90") << 1500.0 << -1000.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses -1500, -1000; start 90") << -1500.0 << -1000.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90") QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90")
<< 1500.0 << 1000.0 << 90.0 << 90.0 << 50.0; << 1500.0 << 1000.0 << 90.0 << 90.0 << 50.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90")
<< 1500.0 << 1000.0 << 90.0 << 90.0 << 50.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90")
<< 1500.0 << 1000.0 << 90.0 << 90.0 << 50.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90")
<< 1500.0 << 1000.0 << 90.0 << 90.0 << 50.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 90") QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 90")
<< 15000.0 << 10000.0 << 90.0 << 90.0 << 90.0; << 15000.0 << 10000.0 << 90.0 << 90.0 << 90.0;
QTest::newRow("Full circle: radiuses -15000, 10000, rotation 90; start 90")
<< -15000.0 << 10000.0 << 90.0 << 90.0 << 90.0;
QTest::newRow("Full circle: radiuses 15000, -10000, rotation 90; start 90")
<< 15000.0 << -10000.0 << 90.0 << 90.0 << 90.0;
QTest::newRow("Full circle: radiuses -15000, -10000, rotation 90; start 90")
<< -15000.0 << -10000.0 << 90.0 << 90.0 << 90.0;
QTest::newRow("Arc less than 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 10.5 << 0.0; QTest::newRow("Arc less than 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses -100, 50") << -100.0 << 50.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses 100, -50") << 100.0 << -50.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses -100, -50") << -100.0 << -50.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses 150, 50, rotation 180") << 150.0 << 50.0 << 0.0 << 10.5 << 180.0; QTest::newRow("Arc less than 45 degree, radiuses 150, 50, rotation 180") << 150.0 << 50.0 << 0.0 << 10.5 << 180.0;
QTest::newRow("Arc less than 45 degree, radiuses -150, 50, rotation 180") << -150.0 << 50.0 << 0.0 << 10.5 << 180.0;
QTest::newRow("Arc less than 45 degree, radiuses 150, -50, rotation 180") << 150.0 << -50.0 << 0.0 << 10.5 << 180.0;
QTest::newRow("Arc less than 45 degree, radiuses -150, -50, rotation 180")
<< -150.0 << -50.0 << 0.0 << 10.5 << 180.0;
QTest::newRow("Arc less than 45 degree, radiuses 1500, 800, rotation 90") << 1500.0 << 800.0 << 0.0 << 10.5 << 90.0; QTest::newRow("Arc less than 45 degree, radiuses 1500, 800, rotation 90") << 1500.0 << 800.0 << 0.0 << 10.5 << 90.0;
QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000, rotation 40") QTest::newRow("Arc less than 45 degree, radiuses -1500, 800, rotation 90")
<< -1500.0 << 800.0 << 0.0 << 10.5 << 90.0;
QTest::newRow("Arc less than 45 degree, radiuses 1500, -800, rotation 90")
<< 1500.0 << -800.0 << 0.0 << 10.5 << 90.0;
QTest::newRow("Arc less than 45 degree, radiuses -1500, -800, rotation 90")
<< -1500.0 << -800.0 << 0.0 << 10.5 << 90.0;
QTest::newRow("Arc less than 45 degree, radiuses 50000, 10000, rotation 40")
<< 50000.0 << 10000.0 << 0.0 << 10.5 << 40.0; << 50000.0 << 10000.0 << 0.0 << 10.5 << 40.0;
QTest::newRow("Arc less than 45 degree, radiuses -50000, 10000, rotation 40")
<< 50000.0 << 10000.0 << 0.0 << 10.5 << 40.0;
QTest::newRow("Arc less than 45 degree, radiuses 50000, -10000, rotation 40")
<< 50000.0 << 10000.0 << 0.0 << 10.5 << 40.0;
QTest::newRow("Arc less than 45 degree, radiuses -50000, -10000, rotation 40")
<< -50000.0 << -10000.0 << 0.0 << 10.5 << 40.0;
QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 10.5 << 0.0; QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses -15000, 10000") << -15000.0 << 10000.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses 15000, -10000") << 15000.0 << -10000.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses -15000, -10000") << -15000.0 << -10000.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc 45 degree, radiuses 100, 50, rotation 45") << 100.0 << 50.0 << 0.0 << 45.0 << 45.0; QTest::newRow("Arc 45 degree, radiuses 100, 50, rotation 45") << 100.0 << 50.0 << 0.0 << 45.0 << 45.0;
QTest::newRow("Arc 45 degree, radiuses -100, 50, rotation 45") << -100.0 << 50.0 << 0.0 << 45.0 << 45.0;
QTest::newRow("Arc 45 degree, radiuses 100, -50, rotation 45") << 100.0 << -50.0 << 0.0 << 45.0 << 45.0;
QTest::newRow("Arc 45 degree, radiuses -100, -50, rotation 45") << -100.0 << -50.0 << 0.0 << 45.0 << 45.0;
QTest::newRow("Arc 45 degree, radiuses 150, 15, rotation 30") << 150.0 << 15.0 << 0.0 << 45.0 << 30.0; QTest::newRow("Arc 45 degree, radiuses 150, 15, rotation 30") << 150.0 << 15.0 << 0.0 << 45.0 << 30.0;
QTest::newRow("Arc 45 degree, radiuses -150, 15, rotation 30") << -150.0 << 15.0 << 0.0 << 45.0 << 30.0;
QTest::newRow("Arc 45 degree, radiuses 150, -15, rotation 30") << 150.0 << -15.0 << 0.0 << 45.0 << 30.0;
QTest::newRow("Arc 45 degree, radiuses -150, -15, rotation 30") << -150.0 << -15.0 << 0.0 << 45.0 << 30.0;
QTest::newRow("Arc 45 degree, radiuses 1500, 150, rotation 45") << 1500.0 << 150.0 << 0.0 << 45.0 << 45.0; QTest::newRow("Arc 45 degree, radiuses 1500, 150, rotation 45") << 1500.0 << 150.0 << 0.0 << 45.0 << 45.0;
QTest::newRow("Arc 45 degree, radiuses -1500, 150, rotation 45") << -1500.0 << 150.0 << 0.0 << 45.0 << 45.0;
QTest::newRow("Arc 45 degree, radiuses 1500, -150, rotation 45") << 1500.0 << -150.0 << 0.0 << 45.0 << 45.0;
QTest::newRow("Arc 45 degree, radiuses -1500, -150, rotation 45") << -1500.0 << -150.0 << 0.0 << 45.0 << 45.0;
QTest::newRow("Arc 45 degree, radiuses 15000, 15000") << 15000.0 << 15000.0 << 0.0 << 45.0 << 0.0; QTest::newRow("Arc 45 degree, radiuses 15000, 15000") << 15000.0 << 15000.0 << 0.0 << 45.0 << 0.0;
QTest::newRow("Arc 45 degree, radiuses -15000, 15000") << -15000.0 << 15000.0 << 0.0 << 45.0 << 0.0;
QTest::newRow("Arc 45 degree, radiuses 15000, -15000") << 15000.0 << -15000.0 << 0.0 << 45.0 << 0.0;
QTest::newRow("Arc 45 degree, radiuses -15000, -15000") << -15000.0 << -15000.0 << 0.0 << 45.0 << 0.0;
QTest::newRow("Arc 45 degree, radiuses 15000, 10000, rotation 270") << 15000.0 << 10000.0 << 0.0 << 45.0 << 270.0; QTest::newRow("Arc 45 degree, radiuses 15000, 10000, rotation 270") << 15000.0 << 10000.0 << 0.0 << 45.0 << 270.0;
QTest::newRow("Arc 45 degree, radiuses -15000, 10000, rotation 270") << -15000.0 << 10000.0 << 0.0 << 45.0 << 270.0;
QTest::newRow("Arc 45 degree, radiuses 15000, -10000, rotation 270") << 15000.0 << -10000.0 << 0.0 << 45.0 << 270.0;
QTest::newRow("Arc 45 degree, radiuses -15000, -10000, rotation 270")
<< -15000.0 << -10000.0 << 0.0 << 45.0 << 270.0;
QTest::newRow("Arc less than 90 degree, radiuses 100, 400, rotation 50") << 100.0 << 400.0 << 0.0 << 75.0 << 50.0; QTest::newRow("Arc less than 90 degree, radiuses 100, 400, rotation 50") << 100.0 << 400.0 << 0.0 << 75.0 << 50.0;
QTest::newRow("Arc less than 90 degree, radiuses -100, 400, rotation 50") << -100.0 << 400.0 << 0.0 << 75.0 << 50.0;
QTest::newRow("Arc less than 90 degree, radiuses 100, -400, rotation 50") << 100.0 << -400.0 << 0.0 << 75.0 << 50.0;
QTest::newRow("Arc less than 90 degree, radiuses -100, -400, rotation 50")
<< -100.0 << -400.0 << 0.0 << 75.0 << 50.0;
QTest::newRow("Arc less than 90 degree, radiuses 150, 400, rotation 90") << 150.0 << 400.0 << 0.0 << 75.0 << 90.0; QTest::newRow("Arc less than 90 degree, radiuses 150, 400, rotation 90") << 150.0 << 400.0 << 0.0 << 75.0 << 90.0;
QTest::newRow("Arc less than 90 degree, radiuses -150, 400, rotation 90") << -150.0 << 400.0 << 0.0 << 75.0 << 90.0;
QTest::newRow("Arc less than 90 degree, radiuses 150, -400, rotation 90") << 150.0 << -400.0 << 0.0 << 75.0 << 90.0;
QTest::newRow("Arc less than 90 degree, radiuses -150, -400, rotation 90")
<< -150.0 << -400.0 << 0.0 << 75.0 << 90.0;
QTest::newRow("Arc less than 90 degree, radiuses 1500, 50000, rotation 180") QTest::newRow("Arc less than 90 degree, radiuses 1500, 50000, rotation 180")
<< 1500.0 << 50000.0 << 0.0 << 75.0 << 180.0; << 1500.0 << 50000.0 << 0.0 << 75.0 << 180.0;
QTest::newRow("Arc less than 90 degree, radiuses -1500, 50000, rotation 180")
<< -1500.0 << 50000.0 << 0.0 << 75.0 << 180.0;
QTest::newRow("Arc less than 90 degree, radiuses 1500, -50000, rotation 180")
<< 1500.0 << -50000.0 << 0.0 << 75.0 << 180.0;
QTest::newRow("Arc less than 90 degree, radiuses -1500, -50000, rotation 180")
<< -1500.0 << -50000.0 << 0.0 << 75.0 << 180.0;
QTest::newRow("Arc less than 90 degree, radiuses 50000, 5000, rotation 30") QTest::newRow("Arc less than 90 degree, radiuses 50000, 5000, rotation 30")
<< 50000.0 << 5000.0 << 0.0 << 75.0 << 30.0; << 50000.0 << 5000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc less than 90 degree, radiuses -50000, 5000, rotation 30")
<< -50000.0 << 5000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc less than 90 degree, radiuses 50000, -5000, rotation 30")
<< 50000.0 << -5000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc less than 90 degree, radiuses -50000, -5000, rotation 30")
<< -50000.0 << -5000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc less than 90 degree, radiuses 90000, 50000, rotation 30") QTest::newRow("Arc less than 90 degree, radiuses 90000, 50000, rotation 30")
<< 90000.0 << 50000.0 << 0.0 << 75.0 << 30.0; << 90000.0 << 50000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc less than 90 degree, radiuses -90000, 50000, rotation 30")
<< -90000.0 << 50000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc less than 90 degree, radiuses 90000, -50000, rotation 30")
<< 90000.0 << -50000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc less than 90 degree, radiuses -90000, -50000, rotation 30")
<< -90000.0 << -50000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses 100, 50, rotation 30") << 100.0 << 50.0 << 0.0 << 90.0 << 30.0; QTest::newRow("Arc 90 degree, radiuses 100, 50, rotation 30") << 100.0 << 50.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses -100, 50, rotation 30") << -100.0 << 50.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses 100, -50, rotation 30") << 100.0 << -50.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses -100, -50, rotation 30") << -100.0 << -50.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 90.0 << 0.0; QTest::newRow("Arc 90 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 90.0 << 0.0;
QTest::newRow("Arc 90 degree, radiuses -150, 400") << -150.0 << 400.0 << 0.0 << 90.0 << 0.0;
QTest::newRow("Arc 90 degree, radiuses 150, -400") << 150.0 << -400.0 << 0.0 << 90.0 << 0.0;
QTest::newRow("Arc 90 degree, radiuses -150, -400") << -150.0 << -400.0 << 0.0 << 90.0 << 0.0;
QTest::newRow("Arc 90 degree, radiuses 1500, 800, rotation 70") << 1500.0 << 800.0 << 0.0 << 90.0 << 70.0; QTest::newRow("Arc 90 degree, radiuses 1500, 800, rotation 70") << 1500.0 << 800.0 << 0.0 << 90.0 << 70.0;
QTest::newRow("Arc 90 degree, radiuses 15000, 5000, rotation 30") << 15000.0 << 1500.0 << 0.0 << 90.0 << 30.0; QTest::newRow("Arc 90 degree, radiuses -1500, 800, rotation 70") << -1500.0 << 800.0 << 0.0 << 90.0 << 70.0;
QTest::newRow("Arc 90 degree, radiuses 1500, -800, rotation 70") << 1500.0 << -800.0 << 0.0 << 90.0 << 70.0;
QTest::newRow("Arc 90 degree, radiuses -1500, -800, rotation 70") << -1500.0 << -800.0 << 0.0 << 90.0 << 70.0;
QTest::newRow("Arc 90 degree, radiuses 15000, 1500, rotation 30") << 15000.0 << 1500.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses -15000, 1500, rotation 30") << -15000.0 << 1500.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses 15000, -1500, rotation 30") << 15000.0 << -1500.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses -15000, -1500, rotation 30") << -15000.0 << -1500.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses 15000, 14000, rotation 235") << 15000.0 << 14000.0 << 0.0 << 90.0 << 235.0; QTest::newRow("Arc 90 degree, radiuses 15000, 14000, rotation 235") << 15000.0 << 14000.0 << 0.0 << 90.0 << 235.0;
QTest::newRow("Arc 90 degree, radiuses -15000, 14000, rotation 235") << -15000.0 << 14000.0 << 0.0 << 90.0 << 235.0;
QTest::newRow("Arc 90 degree, radiuses 15000, -14000, rotation 235") << 15000.0 << -14000.0 << 0.0 << 90.0 << 235.0;
QTest::newRow("Arc 90 degree, radiuses -15000, -14000, rotation 235")
<< -15000.0 << -14000.0 << 0.0 << 90.0 << 235.0;
QTest::newRow("Arc less than 135 degree, radiuses 100, 50, rotation 60") << 100.0 << 50.0 << 0.0 << 110.6 << 60.0; QTest::newRow("Arc less than 135 degree, radiuses 100, 50, rotation 60") << 100.0 << 50.0 << 0.0 << 110.6 << 60.0;
QTest::newRow("Arc less than 135 degree, radiuses -100, 50, rotation 60") << -100.0 << 50.0 << 0.0 << 110.6 << 60.0;
QTest::newRow("Arc less than 135 degree, radiuses 100, -50, rotation 60") << 100.0 << -50.0 << 0.0 << 110.6 << 60.0;
QTest::newRow("Arc less than 135 degree, radiuses -100, -50, rotation 60")
<< -100.0 << -50.0 << 0.0 << 110.6 << 60.0;
QTest::newRow("Arc less than 135 degree, radiuses 150, 400, rotation 300") QTest::newRow("Arc less than 135 degree, radiuses 150, 400, rotation 300")
<< 150.0 << 400.0 << 0.0 << 110.6 << 300.0; << 150.0 << 400.0 << 0.0 << 110.6 << 300.0;
QTest::newRow("Arc less than 135 degree, radiuses -150, 400, rotation 300")
<< -150.0 << 400.0 << 0.0 << 110.6 << 300.0;
QTest::newRow("Arc less than 135 degree, radiuses 150, -400, rotation 300")
<< 150.0 << -400.0 << 0.0 << 110.6 << 300.0;
QTest::newRow("Arc less than 135 degree, radiuses -150, -400, rotation 300")
<< -150.0 << -400.0 << 0.0 << 110.6 << 300.0;
QTest::newRow("Arc less than 135 degree, radiuses 1500, 800, rotation 360") QTest::newRow("Arc less than 135 degree, radiuses 1500, 800, rotation 360")
<< 1500.0 << 800.0 << 0.0 << 110.6 << 360.0; << 1500.0 << 800.0 << 0.0 << 110.6 << 360.0;
QTest::newRow("Arc less than 135 degree, radiuses -1500, 800, rotation 360")
<< -1500.0 << 800.0 << 0.0 << 110.6 << 360.0;
QTest::newRow("Arc less than 135 degree, radiuses 1500, -800, rotation 360")
<< 1500.0 << -800.0 << 0.0 << 110.6 << 360.0;
QTest::newRow("Arc less than 135 degree, radiuses -1500, -800, rotation 360")
<< -1500.0 << -800.0 << 0.0 << 110.6 << 360.0;
QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500, rotation 290") QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500, rotation 290")
<< 15000.0 << 1500.0 << 0.0 << 110.6 << 290.0; << 15000.0 << 1500.0 << 0.0 << 110.6 << 290.0;
QTest::newRow("Arc less than 135 degree, radiuses -15000, 1500, rotation 290")
<< -15000.0 << 1500.0 << 0.0 << 110.6 << 290.0;
QTest::newRow("Arc less than 135 degree, radiuses 15000, -1500, rotation 290")
<< 15000.0 << -1500.0 << 0.0 << 110.6 << 290.0;
QTest::newRow("Arc less than 135 degree, radiuses -15000, -1500, rotation 290")
<< -15000.0 << -1500.0 << 0.0 << 110.6 << 290.0;
QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500") << 15000.0 << 1500.0 << 0.0 << 110.6 << 0.0; QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500") << 15000.0 << 1500.0 << 0.0 << 110.6 << 0.0;
QTest::newRow("Arc less than 135 degree, radiuses -15000, 1500") << -15000.0 << 1500.0 << 0.0 << 110.6 << 0.0;
QTest::newRow("Arc less than 135 degree, radiuses 15000, -1500") << 15000.0 << -1500.0 << 0.0 << 110.6 << 0.0;
QTest::newRow("Arc less than 135 degree, radiuses -15000, -1500") << -15000.0 << -1500.0 << 0.0 << 110.6 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 135.0 << 0.0; QTest::newRow("Arc 135 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses -100, 50") << -100.0 << 50.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 100, -50") << 100.0 << -50.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses -100, -50") << -100.0 << -50.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 135.0 << 0.0; QTest::newRow("Arc 135 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses -150, 400") << -150.0 << 400.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 150, -400") << 150.0 << -400.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses -150, -400") << -150.0 << -400.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 135.0 << 0.0; QTest::newRow("Arc 135 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses -1500, 800") << -1500.0 << 800.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 1500, -800") << 1500.0 << -800.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses -1500, -800") << -1500.0 << -800.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 15000, 1500, rotation 20") << 15000.0 << 1500.0 << 0.0 << 135.0 << 20.0; QTest::newRow("Arc 135 degree, radiuses 15000, 1500, rotation 20") << 15000.0 << 1500.0 << 0.0 << 135.0 << 20.0;
QTest::newRow("Arc 135 degree, radiuses -15000, 1500, rotation 20") << -15000.0 << 1500.0 << 0.0 << 135.0 << 20.0;
QTest::newRow("Arc 135 degree, radiuses 15000, -1500, rotation 20") << 15000.0 << -1500.0 << 0.0 << 135.0 << 20.0;
QTest::newRow("Arc 135 degree, radiuses -15000, -1500, rotation 20") << -15000.0 << -1500.0 << 0.0 << 135.0 << 20.0;
QTest::newRow("Arc 135 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 135.0 << 0.0; QTest::newRow("Arc 135 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses -15000, 10000") << -15000.0 << 10000.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 15000, -10000") << 15000.0 << -10000.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc 135 degree, radiuses -15000, -10000") << -15000.0 << -10000.0 << 0.0 << 135.0 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 160.7 << 0.0; QTest::newRow("Arc less than 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses -100, 50") << -100.0 << 50.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 100, -50") << 100.0 << -50.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses -100, -50") << -100.0 << -50.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 160.7 << 0.0; QTest::newRow("Arc less than 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses -150, 400") << -150.0 << 400.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 150, -400") << 150.0 << -400.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses -150, -400") << -150.0 << -400.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 160.7 << 0.0; QTest::newRow("Arc less than 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses -1500, 800") << -1500.0 << 800.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 1500, -800") << 1500.0 << -800.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses -1500, -800") << -1500.0 << -800.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 15000, 1500, rotation 270") QTest::newRow("Arc less than 180 degree, radiuses 15000, 1500, rotation 270")
<< 15000.0 << 1500.0 << 0.0 << 160.7 << 270.0; << 15000.0 << 1500.0 << 0.0 << 160.7 << 270.0;
QTest::newRow("Arc less than 180 degree, radiuses -15000, 1500, rotation 270")
<< -15000.0 << 1500.0 << 0.0 << 160.7 << 270.0;
QTest::newRow("Arc less than 180 degree, radiuses 15000, -1500, rotation 270")
<< 15000.0 << -1500.0 << 0.0 << 160.7 << 270.0;
QTest::newRow("Arc less than 180 degree, radiuses -15000, -1500, rotation 270")
<< -15000.0 << -1500.0 << 0.0 << 160.7 << 270.0;
QTest::newRow("Arc less than 180 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 160.7 << 0.0; QTest::newRow("Arc less than 180 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses -15000, 10000") << -15000.0 << 10000.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 15000, -10000") << 15000.0 << -10000.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses -15000, -10000") << -15000.0 << -10000.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 180.0 << 0.0; QTest::newRow("Arc 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses -100, 50") << -100.0 << 50.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 100, -50") << 100.0 << -50.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses -100, -50") << -100.0 << -50.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 180.0 << 0.0; QTest::newRow("Arc 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses -150, 400") << -150.0 << 400.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 150, -400") << 150.0 << -400.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses -150, -400") << -150.0 << -400.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 180.0 << 0.0; QTest::newRow("Arc 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses -1500, 800") << -1500.0 << 800.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 1500, -800") << 1500.0 << -800.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses -1500, -800") << -1500.0 << -800.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 15000, 1500, rotation 60") << 15000.0 << 1500.0 << 0.0 << 180.0 << 60.0; QTest::newRow("Arc 180 degree, radiuses 15000, 1500, rotation 60") << 15000.0 << 1500.0 << 0.0 << 180.0 << 60.0;
QTest::newRow("Arc 180 degree, radiuses -15000, 1500, rotation 60") << -15000.0 << 1500.0 << 0.0 << 180.0 << 60.0;
QTest::newRow("Arc 180 degree, radiuses 15000, -1500, rotation 60") << 15000.0 << -1500.0 << 0.0 << 180.0 << 60.0;
QTest::newRow("Arc 180 degree, radiuses -15000, -1500, rotation 60") << -15000.0 << -1500.0 << 0.0 << 180.0 << 60.0;
QTest::newRow("Arc 180 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 180.0 << 0.0; QTest::newRow("Arc 180 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses -15000, 10000") << -15000.0 << 10000.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 15000, -10000") << 15000.0 << -10000.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc 180 degree, radiuses -15000, -10000") << -15000.0 << -10000.0 << 0.0 << 180.0 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 150.3 << 0.0; QTest::newRow("Arc less than 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses -100, 50") << -100.0 << 50.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 100, -50") << 100.0 << -50.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses -100, -50") << -100.0 << -50.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 150.3 << 0.0; QTest::newRow("Arc less than 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses -150, 400") << -150.0 << 400.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 150, -400") << 150.0 << -400.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses -150, -400") << -150.0 << -400.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 150.3 << 0.0; QTest::newRow("Arc less than 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses -1500, 800") << -1500.0 << 800.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 1500, -800") << 1500.0 << -800.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses -1500, -800") << -1500.0 << -800.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 15000, 1500, rotation 20") QTest::newRow("Arc less than 270 degree, radiuses 15000, 1500, rotation 20")
<< 15000.0 << 1500.0 << 0.0 << 150.3 << 20.0; << 15000.0 << 1500.0 << 0.0 << 150.3 << 20.0;
QTest::newRow("Arc less than 270 degree, radiuses -15000, 1500, rotation 20")
<< -15000.0 << 1500.0 << 0.0 << 150.3 << 20.0;
QTest::newRow("Arc less than 270 degree, radiuses 15000, -1500, rotation 20")
<< 15000.0 << -1500.0 << 0.0 << 150.3 << 20.0;
QTest::newRow("Arc less than 270 degree, radiuses -15000, -1500, rotation 20")
<< -15000.0 << -1500.0 << 0.0 << 150.3 << 20.0;
QTest::newRow("Arc less than 270 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 150.3 << 0.0; QTest::newRow("Arc less than 270 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses -15000, 10000") << -15000.0 << 10000.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 15000, -10000") << 15000.0 << -10000.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses -15000, -10000") << -15000.0 << -10000.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 270.0 << 0.0; QTest::newRow("Arc 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses -100, 50") << -100.0 << 50.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 100, -50") << 100.0 << -50.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses -100, -50") << -100.0 << -50.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 270.0 << 0.0; QTest::newRow("Arc 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses -150, 400") << -150.0 << 400.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 150, -400") << 150.0 << -400.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses -150, -400") << -150.0 << -400.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 270.0 << 0.0; QTest::newRow("Arc 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses -1500, 800") << -1500.0 << 800.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 1500, -800") << 1500.0 << -800.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses -1500, -800") << -1500.0 << -800.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 15000, 1500, rotation 90") << 15000.0 << 1500.0 << 0.0 << 270.0 << 90.0; QTest::newRow("Arc 270 degree, radiuses 15000, 1500, rotation 90") << 15000.0 << 1500.0 << 0.0 << 270.0 << 90.0;
QTest::newRow("Arc 270 degree, radiuses -15000, 1500, rotation 90") << -15000.0 << 1500.0 << 0.0 << 270.0 << 90.0;
QTest::newRow("Arc 270 degree, radiuses 15000, -1500, rotation 90") << 15000.0 << -1500.0 << 0.0 << 270.0 << 90.0;
QTest::newRow("Arc 270 degree, radiuses -15000, -1500, rotation 90") << -15000.0 << -1500.0 << 0.0 << 270.0 << 90.0;
QTest::newRow("Arc 270 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 270.0 << 0.0; QTest::newRow("Arc 270 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses -15000, 10000") << -15000.0 << 10000.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 15000, -10000") << 15000.0 << -10000.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc 270 degree, radiuses -15000, -10000") << -15000.0 << -10000.0 << 0.0 << 270.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 340.0 << 0.0; QTest::newRow("Arc less than 360 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses -100, 50") << -100.0 << 50.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 100, -50") << 100.0 << -50.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses -100, -50") << -100.0 << -50.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 340.0 << 0.0; QTest::newRow("Arc less than 360 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses -150, 400") << -150.0 << 400.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 150, -400") << 150.0 << -400.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses -150, -400") << -150.0 << -400.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 340.0 << 0.0; QTest::newRow("Arc less than 360 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses -1500, 800") << -1500.0 << 800.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 1500, -800") << 1500.0 << -800.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses -1500, -800") << -1500.0 << -800.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 12000, 1200, rotation 30") QTest::newRow("Arc less than 360 degree, radiuses 12000, 1200, rotation 30")
<< 12000.0 << 1200.0 << 0.0 << 340.0 << 30.0; << 12000.0 << 1200.0 << 0.0 << 340.0 << 30.0;
QTest::newRow("Arc less than 360 degree, radiuses 12000, 10000") << 15000.0 << 10000.0 << 0.0 << 340.0 << 0.0; QTest::newRow("Arc less than 360 degree, radiuses -12000, 1200, rotation 30")
<< -12000.0 << 1200.0 << 0.0 << 340.0 << 30.0;
QTest::newRow("Arc less than 360 degree, radiuses 12000, -1200, rotation 30")
<< 12000.0 << -1200.0 << 0.0 << 340.0 << 30.0;
QTest::newRow("Arc less than 360 degree, radiuses -12000, -1200, rotation 30")
<< -12000.0 << -1200.0 << 0.0 << 340.0 << 30.0;
QTest::newRow("Arc less than 360 degree, radiuses 12000, 10000") << 12000.0 << 10000.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses -12000, 10000") << -12000.0 << 10000.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 12000, -10000") << 12000.0 << -10000.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses -12000, -10000") << -12000.0 << -10000.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 90.0 << 135.0 << 0.0; QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -100, 50") << -100.0 << 50.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 100, -50") << 100.0 << -50.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -100, -50")
<< -100.0 << -50.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 150, 400") << 150.0 << 400.0 << 90.0 << 135.0 << 0.0; QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 150, 400") << 150.0 << 400.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -150, 400")
<< -150.0 << 400.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 150, -400")
<< 150.0 << -400.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -150, -400")
<< -150.0 << -400.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 1500, 800") QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 1500, 800")
<< 1500.0 << 800.0 << 90.0 << 135.0 << 0.0; << 1500.0 << 800.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -1500, 800")
<< -1500.0 << 800.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 1500, -800")
<< 1500.0 << -800.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -1500, -800")
<< -1500.0 << -800.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 13000, 1000") QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 13000, 1000")
<< 15000.0 << 1000.0 << 90.0 << 135.0 << 0.0; << 13000.0 << 1000.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -13000, 1000")
<< -13000.0 << 1000.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 13000, -1000")
<< 13000.0 << -1000.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -13000, -1000")
<< -13000.0 << -1000.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 15000, 10000") QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 15000, 10000")
<< 15000.0 << 10000.0 << 90.0 << 135.0 << 0.0; << 15000.0 << 10000.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -15000, 10000")
<< -15000.0 << 10000.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 15000, -10000")
<< 15000.0 << -10000.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses -15000, -10000")
<< -15000.0 << -10000.0 << 90.0 << 135.0 << 0.0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -326,10 +755,10 @@ void TST_VEllipticalArc::TestGetPoints2()
const qreal c = qSqrt(qAbs(radius2 * radius2 - radius1 * radius1)); const qreal c = qSqrt(qAbs(radius2 * radius2 - radius1 * radius1));
// distance from the center to the focus // distance from the center to the focus
QPointF focus1 = static_cast<QPointF>(center); auto focus1 = static_cast<QPointF>(center);
QPointF focus2 = static_cast<QPointF>(center); auto focus2 = static_cast<QPointF>(center);
if (radius1 < radius2) if (qAbs(radius1) < qAbs(radius2))
{ {
focus1.setY(focus1.ry() + c); focus1.setY(focus1.ry() + c);
QLineF line(static_cast<QPointF>(center), focus1); QLineF line(static_cast<QPointF>(center), focus1);
@ -354,7 +783,7 @@ void TST_VEllipticalArc::TestGetPoints2()
focus2 = line.p2(); focus2 = line.p2();
} }
QPointF ellipsePoint(center.x() + radius1, center.y()); QPointF ellipsePoint(center.x() + qAbs(radius1), center.y());
QLineF line(static_cast<QPointF>(center), ellipsePoint); QLineF line(static_cast<QPointF>(center), ellipsePoint);
line.setAngle(line.angle() + rotationAngle); line.setAngle(line.angle() + rotationAngle);
ellipsePoint = line.p2(); ellipsePoint = line.p2();
@ -401,7 +830,7 @@ void TST_VEllipticalArc::TestGetPoints3()
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0)) if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{ // calculated full ellipse square { // calculated full ellipse square
const qreal ellipseSquare = M_PI * radius1 * radius2; const qreal ellipseSquare = M_PI * qAbs(radius1) * qAbs(radius2);
const qreal epsSquare = ellipseSquare * 1.7 / 100; // computing error 1.7 % from origin square const qreal epsSquare = ellipseSquare * 1.7 / 100; // computing error 1.7 % from origin square
const qreal arcSquare = qAbs(VAbstractPiece::SumTrapezoids(points) / 2.0); const qreal arcSquare = qAbs(VAbstractPiece::SumTrapezoids(points) / 2.0);
const qreal diffSquare = qAbs(ellipseSquare - arcSquare); const qreal diffSquare = qAbs(ellipseSquare - arcSquare);
@ -430,9 +859,15 @@ void TST_VEllipticalArc::TestGetPoints4()
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0)) if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{ // calculated full ellipse length { // calculated full ellipse length
const qreal h = ((radius1 - radius2) * (radius1 - radius2)) / ((radius1 + radius2) * (radius1 + radius2)); const qreal h = ((qAbs(radius1) - qAbs(radius2)) * (qAbs(radius1) - qAbs(radius2))) /
const qreal ellipseLength = M_PI * (radius1 + radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h))); ((qAbs(radius1) + qAbs(radius2)) * (qAbs(radius1) + qAbs(radius2)));
const qreal epsLength = ToPixel(1, Unit::Mm); // computing error qreal ellipseLength = M_PI * (qAbs(radius1) + qAbs(radius2)) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h)));
if (radius1 < 0 || radius2 < 0)
{
ellipseLength *= -1;
}
Q_RELAXED_CONSTEXPR qreal epsLength = ToPixel(1, Unit::Mm); // computing error
const qreal arcLength = VEllipticalArc(center, radius1, radius2, 0, 360, 0).GetLength(); const qreal arcLength = VEllipticalArc(center, radius1, radius2, 0, 360, 0).GetLength();
const qreal diffLength = qAbs(arcLength - ellipseLength); const qreal diffLength = qAbs(arcLength - ellipseLength);
// cppcheck-suppress unreadVariable // cppcheck-suppress unreadVariable
@ -487,18 +922,38 @@ void TST_VEllipticalArc::TestGetPoints5()
if (points.size() > 2 && qFuzzyIsNull(rotationAngle)) if (points.size() > 2 && qFuzzyIsNull(rotationAngle))
{ {
const qreal testAccuracy = ToPixel(1.5, Unit::Mm); Q_RELAXED_CONSTEXPR qreal testAccuracy = ToPixel(1.5, Unit::Mm);
if (!arc.IsFlipped())
{
ComparePointsDistance(arc.GetP1(), points.constFirst(), testAccuracy); ComparePointsDistance(arc.GetP1(), points.constFirst(), testAccuracy);
ComparePointsDistance(arc.GetP2(), points.constLast(), testAccuracy); ComparePointsDistance(arc.GetP2(), points.constLast(), testAccuracy);
}
else
{
ComparePointsDistance(arc.GetP1(), points.constLast(), testAccuracy);
ComparePointsDistance(arc.GetP2(), points.constFirst(), testAccuracy);
}
const qreal eps = 0.15; const qreal eps = 0.15;
if (!arc.IsFlipped())
{
f1 = QLineF(static_cast<QPointF>(center), points.constFirst()).angle(); f1 = QLineF(static_cast<QPointF>(center), points.constFirst()).angle();
QVERIFY2(f1 - stAngle <= eps, qUtf8Printable(QStringLiteral("f1: %1; expected: %2").arg(f1).arg(stAngle))); QVERIFY2(f1 - stAngle <= eps, qUtf8Printable(QStringLiteral("f1: %1; expected: %2").arg(f1).arg(stAngle)));
f2 = QLineF(static_cast<QPointF>(center), points.constLast()).angle(); f2 = QLineF(static_cast<QPointF>(center), points.constLast()).angle();
QVERIFY2(f2 - enAngle <= eps, qUtf8Printable(QStringLiteral("f2: %1; expected: %2").arg(f2).arg(enAngle))); QVERIFY2(f2 - enAngle <= eps, qUtf8Printable(QStringLiteral("f2: %1; expected: %2").arg(f2).arg(enAngle)));
} }
else
{
f1 = QLineF(static_cast<QPointF>(center), points.constLast()).angle();
QVERIFY2(f1 - stAngle <= eps, qUtf8Printable(QStringLiteral("f1: %1; expected: %2").arg(f1).arg(stAngle)));
f2 = QLineF(static_cast<QPointF>(center), points.constFirst()).angle();
QVERIFY2(f2 - enAngle <= eps, qUtf8Printable(QStringLiteral("f2: %1; expected: %2").arg(f2).arg(enAngle)));
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -514,17 +969,96 @@ void TST_VEllipticalArc::TestRotation_data()
QTest::addColumn<qreal>("degrees"); QTest::addColumn<qreal>("degrees");
QTest::addColumn<QString>("prefix"); QTest::addColumn<QString>("prefix");
QTest::newRow("Test el arc 1") << QPointF() << 10. << 20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 1, +r, +r") << QPointF() << 10. << 20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 2") << QPointF() << 10. << 20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 1, -r, +r") << QPointF() << -10. << 20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.2") << QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 1, +r, -r") << QPointF() << 10. << -20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.1") << QPointF(10, 10) << 10. << 20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 1, -r, -r") << QPointF() << -10. << -20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3") << QPointF(10, 10) << 10. << 20.0 << 1. << 91. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 4") << QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 90. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 2, +r, +r") << QPointF() << 10. << 20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 5") << QPointF(10, 10) << 10. << 20.0 << 0. << 180. << 90. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 2, -r, +r") << QPointF() << -10. << 20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 6") << QPointF(10, 10) << 10. << 20.0 << 1. << 181. << 90. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 2, +r, -r") << QPointF() << 10. << -20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 7") << QPointF(10, 10) << 10. << 20.0 << 0. << 270. << 90. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 2, -r, -r") << QPointF() << -10. << -20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 8") << QPointF(10, 10) << 10. << 20.0 << 1. << 271. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 9") << QPointF(10, 10) << 10. << 20.0 << 0. << 360. << 90. << QPointF() << 90. << "_r"; QTest::newRow("Test el arc 3.2, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.2, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.2, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.2, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.1, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.1, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.1, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.1, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 1. << 91. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 1. << 91. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 1. << 91. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 1. << 91. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 4, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 4, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 0. << 90. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 4, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 0. << 90. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 4, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 0. << 90. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 5, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 0. << 180. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 5, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 0. << 180. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 5, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 0. << 180. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 5, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 0. << 180. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 6, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 1. << 181. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 6, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 1. << 181. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 6, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 1. << 181. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 6, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 1. << 181. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 7, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 0. << 270. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 7, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 0. << 270. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 7, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 0. << 270. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 7, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 0. << 270. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 8, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 1. << 271. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 8, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 1. << 271. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 8, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 1. << 271. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 8, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 1. << 271. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 9, +r, +r")
<< QPointF(10, 10) << 10. << 20.0 << 0. << 360. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 9, -r, +r")
<< QPointF(10, 10) << -10. << 20.0 << 0. << 360. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 9, +r, -r")
<< QPointF(10, 10) << 10. << -20.0 << 0. << 360. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 9, -r, -r")
<< QPointF(10, 10) << -10. << -20.0 << 0. << 360. << 90. << QPointF() << 90. << "_r";
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -563,37 +1097,48 @@ void TST_VEllipticalArc::TestRotation()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TST_VEllipticalArc::TestFlip_data() void TST_VEllipticalArc::TestFlip_data()
{ {
QTest::addColumn<VEllipticalArc>("elArc"); QTest::addColumn<qreal>("radius1");
QTest::addColumn<qreal>("radius2");
QTest::addColumn<QLineF>("axis"); QTest::addColumn<QLineF>("axis");
QTest::addColumn<QString>("prefix"); QTest::addColumn<QString>("prefix");
const VEllipticalArc elArc(VPointF(), 10., 20.0, 1., 91., 0.);
QLineF axis(QPointF(600, 30), QPointF(600, 1800)); QLineF axis(QPointF(600, 30), QPointF(600, 1800));
QTest::newRow("Vertical axis") << elArc << axis << "a2"; QTest::newRow("Vertical axis, +r, +r") << 10. << 20.0 << axis << "a2";
QTest::newRow("Vertical axis, -r, +r") << -10. << 20.0 << axis << "a2";
QTest::newRow("Vertical axis, +r, -r") << 10. << -20.0 << axis << "a2";
QTest::newRow("Vertical axis, -r, -r") << -10. << -20.0 << axis << "a2";
axis = QLineF(QPointF(600, 30), QPointF(1200, 30)); axis = QLineF(QPointF(600, 30), QPointF(1200, 30));
QTest::newRow("Horizontal axis") << elArc << axis << "a2"; QTest::newRow("Horizontal axis, +r, +r") << 10. << 20.0 << axis << "a2";
QTest::newRow("Horizontal axis, -r, +r") << -10. << 20.0 << axis << "a2";
QTest::newRow("Horizontal axis, +r, -r") << 10. << -20.0 << axis << "a2";
QTest::newRow("Horizontal axis, -r, -r") << -10. << -20.0 << axis << "a2";
axis = QLineF(QPointF(600, 30), QPointF(600, 1800)); axis = QLineF(QPointF(600, 30), QPointF(600, 1800));
axis.setAngle(45); axis.setAngle(45);
QTest::newRow("Diagonal axis") << elArc << axis << "a2"; QTest::newRow("Diagonal axis, +r, +r") << 10. << 20.0 << axis << "a2";
QTest::newRow("Diagonal axis, -r, +r") << -10. << 20.0 << axis << "a2";
QTest::newRow("Diagonal axis, +r, -r") << 10. << -20.0 << axis << "a2";
QTest::newRow("Diagonal axis, -r, -r") << -10. << -20.0 << axis << "a2";
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TST_VEllipticalArc::TestFlip() void TST_VEllipticalArc::TestFlip()
{ {
QFETCH(VEllipticalArc, elArc); QFETCH(qreal, radius1);
QFETCH(qreal, radius2);
QFETCH(QLineF, axis); QFETCH(QLineF, axis);
QFETCH(QString, prefix); QFETCH(QString, prefix);
const VEllipticalArc elArc(VPointF(), radius1, radius2, 1., 91., 0.);
const VEllipticalArc res = elArc.Flip(axis, prefix); const VEllipticalArc res = elArc.Flip(axis, prefix);
// cppcheck-suppress unreadVariable // cppcheck-suppress unreadVariable
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); const QString errorMsg = QStringLiteral("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
QCOMPARE(qRound(elArc.GetLength() * -1), qRound(res.GetLength())); QCOMPARE(qRound(elArc.GetLength() * -1), qRound(res.GetLength()));

View File

@ -44,14 +44,15 @@ public:
private slots: private slots:
void CompareTwoWays_data(); void CompareTwoWays_data();
void CompareTwoWays(); void CompareTwoWays();
void NegativeArc(); void ArcByLength_data();
void ArcByLength();
void TestGetPoints1_data(); void TestGetPoints1_data();
void TestGetPoints2_data();
void TestGetPoints3_data();
void TestGetPoints4_data();
void TestGetPoints1(); void TestGetPoints1();
void TestGetPoints2_data();
void TestGetPoints2(); void TestGetPoints2();
void TestGetPoints3_data();
void TestGetPoints3(); void TestGetPoints3();
void TestGetPoints4_data();
void TestGetPoints4(); void TestGetPoints4();
void TestGetPoints5_data(); void TestGetPoints5_data();
void TestGetPoints5(); void TestGetPoints5();