Allow negative values.
This commit is contained in:
parent
ae9e374629
commit
4691de62fd
|
@ -52,6 +52,7 @@
|
|||
- Tape app. Show variables in order they were added.
|
||||
- Shortcuts manager.
|
||||
- Support for custom known measurements.
|
||||
- Allow negative values.
|
||||
|
||||
# Valentina 0.7.52 September 12, 2022
|
||||
- Fix crash when default locale is ru.
|
||||
|
|
|
@ -3114,28 +3114,24 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item)
|
|||
AddPropertyObjectName(i, tr("Name:"), true);
|
||||
|
||||
VFormula angle1(spl.GetStartAngleFormula(), i->getData());
|
||||
angle1.setCheckZero(false);
|
||||
angle1.setToolId(i->getId());
|
||||
angle1.setPostfix(degreeSymbol);
|
||||
angle1.Eval();
|
||||
AddPropertyFormula(tr("C1: angle:"), angle1, AttrAngle1);
|
||||
|
||||
VFormula length1(spl.GetC1LengthFormula(), i->getData());
|
||||
length1.setCheckZero(false);
|
||||
length1.setToolId(i->getId());
|
||||
length1.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
length1.Eval();
|
||||
AddPropertyFormula(tr("C1: length:"), length1, AttrLength1);
|
||||
|
||||
VFormula angle2(spl.GetEndAngleFormula(), i->getData());
|
||||
angle2.setCheckZero(false);
|
||||
angle2.setToolId(i->getId());
|
||||
angle2.setPostfix(degreeSymbol);
|
||||
angle2.Eval();
|
||||
AddPropertyFormula(tr("C2: angle:"), angle2, AttrAngle2);
|
||||
|
||||
VFormula length2(spl.GetC2LengthFormula(), i->getData());
|
||||
length2.setCheckZero(false);
|
||||
length2.setToolId(i->getId());
|
||||
length2.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
length2.Eval();
|
||||
|
@ -3992,7 +3988,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
|
|||
m_idToProperty[AttrName]->setValue(i->name());
|
||||
|
||||
VFormula angle1F(spl.GetStartAngleFormula(), i->getData());
|
||||
angle1F.setCheckZero(false);
|
||||
angle1F.setToolId(i->getId());
|
||||
angle1F.setPostfix(degreeSymbol);
|
||||
angle1F.Eval();
|
||||
|
@ -4001,7 +3996,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
|
|||
m_idToProperty[AttrAngle1]->setValue(angle1);
|
||||
|
||||
VFormula length1F(spl.GetC1LengthFormula(), i->getData());
|
||||
length1F.setCheckZero(false);
|
||||
length1F.setToolId(i->getId());
|
||||
length1F.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
length1F.Eval();
|
||||
|
@ -4010,7 +4004,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
|
|||
m_idToProperty[AttrLength1]->setValue(length1);
|
||||
|
||||
VFormula angle2F(spl.GetEndAngleFormula(), i->getData());
|
||||
angle2F.setCheckZero(false);
|
||||
angle2F.setToolId(i->getId());
|
||||
angle2F.setPostfix(degreeSymbol);
|
||||
angle2F.Eval();
|
||||
|
@ -4019,7 +4012,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
|
|||
m_idToProperty[AttrAngle2]->setValue(angle2);
|
||||
|
||||
VFormula length2F(spl.GetC2LengthFormula(), i->getData());
|
||||
length2F.setCheckZero(false);
|
||||
length2F.setToolId(i->getId());
|
||||
length2F.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
length2F.Eval();
|
||||
|
|
|
@ -214,7 +214,7 @@ auto VAbstractArc::AngleArc() const -> qreal
|
|||
const qreal angleDiff = qAbs(GetStartAngle() - GetEndAngle());
|
||||
if (VFuzzyComparePossibleNulls(angleDiff, 0) || VFuzzyComparePossibleNulls(angleDiff, 360))
|
||||
{
|
||||
return 360;
|
||||
return !d->isAllowEmpty ? 360 : 0;
|
||||
}
|
||||
}
|
||||
QLineF l1(0, 0, 100, 0);
|
||||
|
@ -232,12 +232,39 @@ auto VAbstractArc::AngleArc() const -> qreal
|
|||
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)
|
||||
{
|
||||
d->isFlipped = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractArc::SetAllowEmpty(bool value)
|
||||
{
|
||||
d->isAllowEmpty = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractArc::SetFormulaLength(const QString &formula)
|
||||
{
|
||||
|
|
|
@ -83,8 +83,11 @@ public:
|
|||
auto IsFlipped() const -> bool;
|
||||
auto AngleArc() const -> qreal;
|
||||
|
||||
auto GetPath() const -> QPainterPath override;
|
||||
|
||||
protected:
|
||||
void SetFlipped(bool value);
|
||||
void SetAllowEmpty(bool value);
|
||||
virtual void FindF2(qreal length) = 0;
|
||||
void SetFormulaLength(const QString &formula);
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@ public:
|
|||
|
||||
QString formulaLength{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
|
||||
bool isAllowEmpty{false}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
|
||||
private:
|
||||
Q_DISABLE_ASSIGN_MOVE(VAbstractArcData) // NOLINT
|
||||
};
|
||||
|
|
|
@ -245,12 +245,33 @@ auto VAbstractCurve::ClosestPoint(QPointF scenePoint) const -> QPointF
|
|||
return points.constFirst();
|
||||
}
|
||||
|
||||
if (VFuzzyComparePoints(points.constLast(), scenePoint))
|
||||
{
|
||||
return points.constLast();
|
||||
}
|
||||
|
||||
QPointF candidatePoint;
|
||||
qreal bestDistance = INT_MAX;
|
||||
bool found = false;
|
||||
|
||||
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);
|
||||
|
||||
if (IsPointOnLineSegment(cPoint, points.at(i), points.at(i + 1)))
|
||||
|
|
|
@ -66,6 +66,7 @@ VArc::VArc(const VPointF ¢er, qreal radius, const QString &formulaRadius, qr
|
|||
d(new VArcData(radius, formulaRadius))
|
||||
{
|
||||
CreateName();
|
||||
SetFlipped(radius < 0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -74,6 +75,7 @@ VArc::VArc(const VPointF ¢er, qreal radius, qreal f1, qreal f2)
|
|||
d(new VArcData(radius))
|
||||
{
|
||||
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 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);
|
||||
|
||||
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 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);
|
||||
|
||||
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 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);
|
||||
|
||||
if (not GetAliasSuffix().isEmpty())
|
||||
|
@ -220,7 +222,7 @@ VArc::~VArc() = default;
|
|||
*/
|
||||
auto VArc::GetLength() const -> qreal
|
||||
{
|
||||
qreal length = d->radius * qDegreesToRadians(AngleArc());
|
||||
qreal length = qAbs(d->radius) * qDegreesToRadians(AngleArc());
|
||||
if (IsFlipped())
|
||||
{
|
||||
length *= -1;
|
||||
|
@ -236,7 +238,7 @@ auto VArc::GetLength() const -> qreal
|
|||
*/
|
||||
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);
|
||||
centerP1.setAngle(GetStartAngle());
|
||||
return centerP1.p2();
|
||||
|
@ -249,7 +251,7 @@ auto VArc::GetP1() 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);
|
||||
centerP2.setAngle(GetEndAngle());
|
||||
return centerP2.p2();
|
||||
|
@ -262,7 +264,7 @@ auto VArc::GetP2() const -> QPointF
|
|||
*/
|
||||
auto VArc::GetPoints() const -> QVector<QPointF>
|
||||
{
|
||||
if (qFuzzyIsNull(GetRadius()))
|
||||
if (qFuzzyIsNull(d->radius))
|
||||
{
|
||||
return {GetCenter().toQPointF()};
|
||||
}
|
||||
|
@ -305,7 +307,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
|
|||
|
||||
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());
|
||||
|
||||
|
@ -315,7 +317,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
|
|||
|
||||
QLineF lineP4P3(center, pStart);
|
||||
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.setAngle(lineP4P3.angle() + 90.0);
|
||||
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
|
||||
{
|
||||
// Always need return two arcs, so we must correct wrong length.
|
||||
const qreal fullLength = GetLength();
|
||||
|
||||
if (qAbs(fullLength) < ToPixel(2, Unit::Mm))
|
||||
if (qFuzzyIsNull(fullLength) || qFuzzyIsNull(d->radius))
|
||||
{
|
||||
arc1 = VArc();
|
||||
arc2 = VArc();
|
||||
arc1 = *this;
|
||||
arc2 = *this;
|
||||
return GetCenter().toQPointF();
|
||||
}
|
||||
|
||||
const QString errorMsg = tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
|
||||
VAbstractApplication::VApp()->IsPedantic()
|
||||
? throw VException(errorMsg)
|
||||
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||
if (qFuzzyIsNull(length) || qFuzzyIsNull(length + fullLength))
|
||||
{
|
||||
arc1 = VArc(GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), GetStartAngle(),
|
||||
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 =
|
||||
|
@ -381,7 +402,7 @@ auto VArc::CutArc(qreal length, const QString &pointName) const -> QPointF
|
|||
{
|
||||
VArc arc1;
|
||||
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)
|
||||
{
|
||||
SetFlipped(length < 0);
|
||||
SetFlipped(length < 0 || d->radius < 0);
|
||||
|
||||
if (length >= MaxLength())
|
||||
if (qAbs(length) >= qAbs(MaxLength()))
|
||||
{
|
||||
length = MaxLength();
|
||||
}
|
||||
|
||||
qreal arcAngle = qAbs(qRadiansToDegrees(length / d->radius));
|
||||
qreal arcAngle = qAbs(qRadiansToDegrees(qAbs(length) / qAbs(d->radius)));
|
||||
|
||||
if (IsFlipped())
|
||||
{
|
||||
|
@ -438,7 +459,7 @@ void VArc::FindF2(qreal length)
|
|||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -457,9 +478,7 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
|
|||
length = fullLength + length;
|
||||
}
|
||||
|
||||
const qreal maxLength = fullLength - minLength;
|
||||
|
||||
if (length < minLength)
|
||||
if (length < 0)
|
||||
{
|
||||
QString errorMsg;
|
||||
if (not pointName.isEmpty())
|
||||
|
@ -476,7 +495,7 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
|
|||
? throw VException(errorMsg)
|
||||
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
else if (length > maxLength)
|
||||
else if (length > fullLength)
|
||||
{
|
||||
QString errorMsg;
|
||||
if (not pointName.isEmpty())
|
||||
|
@ -486,7 +505,6 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.").arg(name());
|
||||
}
|
||||
VAbstractApplication::VApp()->IsPedantic()
|
||||
|
@ -494,7 +512,12 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
|
|||
: 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());
|
||||
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;
|
||||
}
|
||||
|
||||
const qreal minLengthFlipped = fullLength + minLength;
|
||||
const qreal maxLengthFlipped = -minLength;
|
||||
|
||||
if (length < minLengthFlipped)
|
||||
if (length < fullLength)
|
||||
{
|
||||
QString errorMsg;
|
||||
if (not pointName.isEmpty())
|
||||
|
@ -529,7 +549,7 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
|
|||
? throw VException(errorMsg)
|
||||
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
else if (length > maxLengthFlipped)
|
||||
else if (length > 0)
|
||||
{
|
||||
QString errorMsg;
|
||||
if (not pointName.isEmpty())
|
||||
|
@ -546,7 +566,12 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
|
|||
: 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());
|
||||
line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length) / d->radius));
|
||||
|
|
|
@ -226,6 +226,15 @@ auto JoinVectors(const QVector<QPointF> &v1, const QVector<QPointF> &v2) -> QVec
|
|||
|
||||
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
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -255,6 +264,7 @@ VEllipticalArc::VEllipticalArc(const VPointF ¢er, qreal radius1, qreal radiu
|
|||
d(new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
|
||||
{
|
||||
CreateName();
|
||||
SetFlipped(radius1 < 0 || radius2 < 0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -264,6 +274,7 @@ VEllipticalArc::VEllipticalArc(const VPointF ¢er, qreal radius1, qreal radiu
|
|||
d(new VEllipticalArcData(radius1, radius2, rotationAngle))
|
||||
{
|
||||
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;
|
||||
t.translate(originPoint.x(), originPoint.y());
|
||||
t.rotate(IsFlipped() ? degrees : -degrees);
|
||||
t.rotate(-degrees);
|
||||
t.translate(-originPoint.x(), -originPoint.y());
|
||||
|
||||
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
||||
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
||||
VEllipticalArc elArc(VAbstractArc::GetCenter(), d->radius1, d->radius2, VAbstractArc::GetStartAngle(),
|
||||
VAbstractArc::GetEndAngle(), d->rotationAngle);
|
||||
elArc.setName(name() + prefix);
|
||||
|
||||
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
|
||||
{
|
||||
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
||||
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
||||
VEllipticalArc elArc(VAbstractArc::GetCenter(), d->radius1, d->radius2, VAbstractArc::GetStartAngle(),
|
||||
VAbstractArc::GetEndAngle(), d->rotationAngle);
|
||||
elArc.setName(name() + prefix);
|
||||
|
||||
if (not GetAliasSuffix().isEmpty())
|
||||
|
@ -385,8 +396,8 @@ auto VEllipticalArc::Move(qreal length, qreal angle, const QString &prefix) cons
|
|||
QTransform t = d->m_transform;
|
||||
t.translate(position.x(), position.y());
|
||||
|
||||
VEllipticalArc elArc(oldCenter, GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
|
||||
VAbstractArc::GetEndAngle(), GetRotationAngle());
|
||||
VEllipticalArc elArc(oldCenter, d->radius1, d->radius2, VAbstractArc::GetStartAngle(), VAbstractArc::GetEndAngle(),
|
||||
d->rotationAngle);
|
||||
elArc.setName(name() + prefix);
|
||||
|
||||
if (not GetAliasSuffix().isEmpty())
|
||||
|
@ -416,7 +427,7 @@ auto VEllipticalArc::GetLength() const -> qreal
|
|||
|
||||
if (IsFlipped())
|
||||
{
|
||||
length = length * -1;
|
||||
length *= -1;
|
||||
}
|
||||
|
||||
return length;
|
||||
|
@ -473,11 +484,16 @@ auto VEllipticalArc::GetPoints() const -> QVector<QPointF>
|
|||
{
|
||||
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.
|
||||
Q_RELAXED_CONSTEXPR qreal threshold = ToPixel(0.001, Unit::Mm);
|
||||
qreal radius1 = qMax(d->radius1, threshold);
|
||||
qreal radius2 = qMax(d->radius2, threshold);
|
||||
qreal max = qMax(d->radius1, d->radius2);
|
||||
qreal radius1 = qMax(qAbs(d->radius1), threshold);
|
||||
qreal radius2 = qMax(qAbs(d->radius2), threshold);
|
||||
qreal max = qMax(qAbs(d->radius1), qAbs(d->radius2));
|
||||
qreal scale = 1;
|
||||
|
||||
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.
|
||||
t.scale(scale, scale);
|
||||
}
|
||||
t.rotate(-GetRotationAngle());
|
||||
t.rotate(-d->rotationAngle);
|
||||
t.translate(-center.x(), -center.y());
|
||||
|
||||
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
|
||||
{
|
||||
return QLineF(GetCenter().toQPointF(), GetP1()).angle() - GetRotationAngle();
|
||||
return QLineF(GetCenter().toQPointF(), GetP1()).angle() - d->rotationAngle;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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.
|
||||
* @return point cutting
|
||||
*/
|
||||
auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2,
|
||||
const QString &pointName) const -> QPointF
|
||||
auto VEllipticalArc::CutArc(qreal length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const
|
||||
-> QPointF
|
||||
{
|
||||
// Always need return two arcs, so we must correct wrong length.
|
||||
qreal len = 0;
|
||||
const qreal fullLength = GetLength();
|
||||
|
||||
if (fullLength <= minLength)
|
||||
if (qFuzzyIsNull(fullLength) || (qFuzzyIsNull(d->radius1) && qFuzzyIsNull(d->radius2)))
|
||||
{
|
||||
arc1 = VEllipticalArc();
|
||||
arc2 = VEllipticalArc();
|
||||
|
||||
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 {};
|
||||
arc1 = *this;
|
||||
arc2 = *this;
|
||||
return GetCenter().toQPointF();
|
||||
}
|
||||
|
||||
const qreal maxLength = fullLength - minLength;
|
||||
|
||||
if (length < minLength)
|
||||
if (qFuzzyIsNull(length) || qFuzzyIsNull(length + fullLength))
|
||||
{
|
||||
len = minLength;
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
else if (length > maxLength)
|
||||
{
|
||||
len = maxLength;
|
||||
arc2 = *this;
|
||||
|
||||
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;
|
||||
return GetP1();
|
||||
}
|
||||
else
|
||||
|
||||
if (VFuzzyComparePossibleNulls(length, fullLength))
|
||||
{
|
||||
len = length;
|
||||
arc1 = *this;
|
||||
|
||||
arc2 = VEllipticalArc(GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2, GetEndAngle(),
|
||||
GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
|
||||
GetFormulaRotationAngle(), getIdObject(), getMode());
|
||||
arc2.SetApproximationScale(GetApproximationScale());
|
||||
arc2.SetFlipped(IsFlipped());
|
||||
arc2.SetAllowEmpty(true);
|
||||
|
||||
return GetP2();
|
||||
}
|
||||
|
||||
qreal len = CorrectCutLength(length, fullLength, pointName);
|
||||
|
||||
// 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,
|
||||
d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle,
|
||||
GetFormulaRotationAngle(), getIdObject(), getMode());
|
||||
arc1.SetApproximationScale(GetApproximationScale());
|
||||
arc1.SetFlipped(IsFlipped());
|
||||
|
||||
// the second arc has startAngle just like endAngle of the first 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(),
|
||||
arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
|
||||
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 arc2;
|
||||
return this->CutArc(length, arc1, arc2, pointName);
|
||||
return CutArc(length, arc1, arc2, pointName);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::CreateName()
|
||||
{
|
||||
QString name = ELARC_ + QStringLiteral("%1").arg(this->GetCenter().name());
|
||||
QString name = ELARC_ + this->GetCenter().name();
|
||||
const QString nameStr = QStringLiteral("_%1");
|
||||
|
||||
if (getMode() == Draw::Modeling && getIdObject() != NULL_ID)
|
||||
|
@ -653,12 +651,12 @@ void VEllipticalArc::CreateAlias()
|
|||
void VEllipticalArc::FindF2(qreal length)
|
||||
{
|
||||
qreal gap = 180;
|
||||
if (length < 0)
|
||||
if (length < 0 || d->radius1 < 0 || d->radius2 < 0)
|
||||
{
|
||||
SetFlipped(true);
|
||||
gap = -gap;
|
||||
}
|
||||
while (length > MaxLength())
|
||||
else if (qAbs(length) > qAbs(MaxLength()))
|
||||
{
|
||||
length = MaxLength();
|
||||
}
|
||||
|
@ -666,7 +664,8 @@ void VEllipticalArc::FindF2(qreal length)
|
|||
// We need to calculate the second angle
|
||||
// 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(radius1.angle() + gap);
|
||||
qreal endAngle = radius1.angle();
|
||||
|
@ -676,16 +675,17 @@ void VEllipticalArc::FindF2(qreal 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)
|
||||
{
|
||||
gap = gap / 2;
|
||||
if (gap < 0.0001)
|
||||
if (qAbs(gap) < 0.0001)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (lenBez > length)
|
||||
|
||||
if (qAbs(lenBez) > qAbs(length))
|
||||
{ // we selected too big end angle
|
||||
radius1.setAngle(endAngle - qAbs(gap));
|
||||
}
|
||||
|
@ -703,15 +703,21 @@ void VEllipticalArc::FindF2(qreal length)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VEllipticalArc::MaxLength() const -> qreal
|
||||
{
|
||||
const qreal h = qPow(d->radius1 - d->radius2, 2) / qPow(d->radius1 + d->radius2, 2);
|
||||
const qreal ellipseLength = M_PI * (d->radius1 + d->radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h)));
|
||||
const qreal h = qPow(qAbs(d->radius1) - qAbs(d->radius2), 2) / qPow(qAbs(d->radius1) + qAbs(d->radius2), 2);
|
||||
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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VEllipticalArc::GetP(qreal angle) const -> QPointF
|
||||
{
|
||||
if (qFuzzyIsNull(GetRadius1()) && qFuzzyIsNull(GetRadius2()))
|
||||
if (qFuzzyIsNull(d->radius1) && qFuzzyIsNull(d->radius2))
|
||||
{
|
||||
return GetCenter().toQPointF();
|
||||
}
|
||||
|
@ -719,8 +725,8 @@ auto VEllipticalArc::GetP(qreal angle) const -> QPointF
|
|||
QLineF line(0, 0, 100, 0);
|
||||
line.setAngle(angle);
|
||||
|
||||
const qreal a = not qFuzzyIsNull(GetRadius1()) ? line.p2().x() / GetRadius1() : 0;
|
||||
const qreal b = not qFuzzyIsNull(GetRadius2()) ? line.p2().y() / GetRadius2() : 0;
|
||||
const qreal a = not qFuzzyIsNull(d->radius1) ? line.p2().x() / qAbs(d->radius1) : 0;
|
||||
const qreal b = not qFuzzyIsNull(d->radius2) ? line.p2().y() / qAbs(d->radius2) : 0;
|
||||
const qreal k = qSqrt(a * a + b * b);
|
||||
|
||||
if (qFuzzyIsNull(k))
|
||||
|
@ -733,7 +739,7 @@ auto VEllipticalArc::GetP(qreal angle) const -> QPointF
|
|||
QLineF line2(QPointF(), p);
|
||||
SCASSERT(VFuzzyComparePossibleNulls(line2.angle(), line.angle()))
|
||||
|
||||
line2.setAngle(line2.angle() + GetRotationAngle());
|
||||
line2.setAngle(line2.angle() + d->rotationAngle);
|
||||
return line2.p2() + VAbstractArc::GetCenter().toQPointF();
|
||||
}
|
||||
|
||||
|
@ -746,7 +752,7 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
|
|||
}
|
||||
|
||||
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());
|
||||
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());
|
||||
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;
|
||||
|
||||
if (start.angle() >= end.angle())
|
||||
|
@ -839,6 +836,78 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
|
|||
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.
|
||||
|
|
|
@ -101,9 +101,8 @@ public:
|
|||
auto GetStartAngle() const -> qreal override;
|
||||
auto GetEndAngle() const -> qreal override;
|
||||
|
||||
auto CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const
|
||||
-> QPointF;
|
||||
auto CutArc(const qreal &length, const QString &pointName) const -> QPointF;
|
||||
auto CutArc(qreal length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const -> QPointF;
|
||||
auto CutArc(qreal length, const QString &pointName) const -> QPointF;
|
||||
|
||||
static auto OptimizeAngle(qreal angle) -> qreal;
|
||||
|
||||
|
@ -118,6 +117,8 @@ private:
|
|||
auto MaxLength() const -> qreal;
|
||||
auto GetP(qreal angle) const -> 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
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
QString formula{}; // 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)
|
||||
const VContainer *data{nullptr}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
quint32 toolId{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
|
|
|
@ -142,7 +142,6 @@ auto VPieceNode::GetSABefore(const VContainer *data) const -> qreal
|
|||
}
|
||||
|
||||
VFormula formula(d->m_formulaWidthBefore, data);
|
||||
formula.setCheckZero(false);
|
||||
formula.Eval();
|
||||
|
||||
if (formula.error())
|
||||
|
@ -175,7 +174,6 @@ auto VPieceNode::GetSABefore(const VContainer *data, Unit unit) const -> qreal
|
|||
}
|
||||
|
||||
VFormula formula(d->m_formulaWidthBefore, data);
|
||||
formula.setCheckZero(false);
|
||||
formula.Eval();
|
||||
|
||||
if (formula.error())
|
||||
|
@ -229,7 +227,6 @@ auto VPieceNode::GetSAAfter(const VContainer *data) const -> qreal
|
|||
}
|
||||
|
||||
VFormula formula(d->m_formulaWidthAfter, data);
|
||||
formula.setCheckZero(false);
|
||||
formula.Eval();
|
||||
|
||||
if (formula.error())
|
||||
|
@ -263,7 +260,6 @@ auto VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const -> qreal
|
|||
}
|
||||
|
||||
VFormula formula(d->m_formulaWidthAfter, data);
|
||||
formula.setCheckZero(false);
|
||||
formula.Eval();
|
||||
|
||||
if (formula.error())
|
||||
|
@ -395,7 +391,6 @@ auto VPieceNode::GetPassmarkWidth(const VContainer *data, Unit unit) const -> qr
|
|||
{
|
||||
VFormula formula(d->m_formulaPassmarkWidth, data);
|
||||
formula.setCheckZero(true);
|
||||
formula.setCheckLessThanZero(false);
|
||||
formula.Eval();
|
||||
|
||||
if (formula.error())
|
||||
|
@ -428,8 +423,6 @@ auto VPieceNode::GetPassmarkAngle(const VContainer *data) const -> qreal
|
|||
if (d->m_manualPassmarkAngle)
|
||||
{
|
||||
VFormula formula(d->m_formulaPassmarkAngle, data);
|
||||
formula.setCheckZero(false);
|
||||
formula.setCheckLessThanZero(false);
|
||||
formula.Eval();
|
||||
|
||||
if (formula.error())
|
||||
|
|
|
@ -64,7 +64,7 @@ struct FormulaData
|
|||
QLabel *labelEditFormula{nullptr};
|
||||
QLabel *labelResult{nullptr};
|
||||
QString postfix;
|
||||
bool checkZero{true};
|
||||
bool checkZero{false};
|
||||
bool checkLessThanZero{false};
|
||||
};
|
||||
|
||||
|
|
|
@ -163,7 +163,6 @@ void DialogAlongLine::EvalFormula()
|
|||
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||
formulaData.labelResult = ui->labelResultCalculation;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, m_flagFormula);
|
||||
}
|
||||
|
|
|
@ -525,17 +525,7 @@ void DialogArc::EvalRadius()
|
|||
formulaData.labelResult = ui->labelResultRadius;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
|
||||
const qreal radius = 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();
|
||||
}
|
||||
Eval(formulaData, m_flagRadius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -550,7 +540,6 @@ void DialogArc::EvalF()
|
|||
formulaData.labelEditFormula = ui->labelEditF1;
|
||||
formulaData.labelResult = ui->labelResultF1;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
m_angleF1 = Eval(formulaData, m_flagF1);
|
||||
|
||||
|
|
|
@ -550,7 +550,6 @@ void DialogArcWithLength::EvalF()
|
|||
formulaData.labelEditFormula = ui->labelEditF1;
|
||||
formulaData.labelResult = ui->labelResultF1;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, m_flagF1);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,6 @@ void DialogBisector::EvalFormula()
|
|||
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||
formulaData.labelResult = ui->labelResultCalculation;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, m_flagFormula);
|
||||
}
|
||||
|
|
|
@ -309,7 +309,6 @@ void DialogCurveIntersectAxis::EvalAngle()
|
|||
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||
formulaData.labelResult = ui->labelResultCalculation;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagFormula);
|
||||
}
|
||||
|
|
|
@ -125,7 +125,6 @@ void DialogCutArc::EvalFormula()
|
|||
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||
formulaData.labelResult = ui->labelResultCalculation;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, m_flagFormula);
|
||||
}
|
||||
|
@ -427,10 +426,9 @@ void DialogCutArc::ShowDialog(bool click)
|
|||
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(getArcId());
|
||||
QPointF p = arc->ClosestPoint(scene->getScenePos());
|
||||
qreal len = arc->GetLengthByPoint(p);
|
||||
if (len > 0)
|
||||
{
|
||||
SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit())));
|
||||
}
|
||||
|
||||
len = !arc->IsFlipped() ? qBound(0.0, len, arc->GetLength()) : qBound(arc->GetLength(), -len, 0.0);
|
||||
SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit())));
|
||||
}
|
||||
|
||||
FinishCreating();
|
||||
|
|
|
@ -332,7 +332,6 @@ void DialogCutSpline::EvalFormula()
|
|||
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||
formulaData.labelResult = ui->labelResultCalculation;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, m_flagFormula);
|
||||
}
|
||||
|
|
|
@ -332,7 +332,6 @@ void DialogCutSplinePath::EvalFormula()
|
|||
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||
formulaData.labelResult = ui->labelResultCalculation;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, m_flagFormula);
|
||||
}
|
||||
|
|
|
@ -397,7 +397,6 @@ void DialogEllipticalArc::EvalRadiuses()
|
|||
formulaData.labelEditFormula = ui->labelEditRadius1;
|
||||
formulaData.labelResult = ui->labelResultRadius1;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, m_flagRadius1);
|
||||
|
||||
|
@ -420,7 +419,6 @@ void DialogEllipticalArc::EvalAngles()
|
|||
formulaData.labelEditFormula = ui->labelEditF1;
|
||||
formulaData.labelResult = ui->labelResultF1;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
m_angleF1 = Eval(formulaData, m_flagF1);
|
||||
|
||||
|
|
|
@ -141,7 +141,6 @@ void DialogEndLine::EvalAngle()
|
|||
formulaData.labelEditFormula = ui->labelEditAngle;
|
||||
formulaData.labelResult = ui->labelResultCalculationAngle;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagError);
|
||||
}
|
||||
|
@ -155,7 +154,6 @@ void DialogEndLine::EvalLength()
|
|||
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||
formulaData.labelResult = ui->labelResultCalculation;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkLessThanZero = false;
|
||||
|
||||
Eval(formulaData, flagFormula);
|
||||
}
|
||||
|
|
|
@ -349,7 +349,6 @@ void DialogLineIntersectAxis::EvalAngle()
|
|||
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||
formulaData.labelResult = ui->labelResultCalculation;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagFormula);
|
||||
}
|
||||
|
@ -388,7 +387,7 @@ void DialogLineIntersectAxis::PointNameChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogLineIntersectAxis::FXAngle()
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
auto *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
dialog->setWindowTitle(tr("Edit angle"));
|
||||
dialog->SetFormula(GetAngle());
|
||||
dialog->setPostfix(degreeSymbol);
|
||||
|
|
|
@ -791,7 +791,6 @@ void DialogMove::EvalAngle()
|
|||
formulaData.labelEditFormula = ui->labelEditAngle;
|
||||
formulaData.labelResult = ui->labelResultAngle;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagAngle);
|
||||
|
||||
|
@ -810,7 +809,6 @@ void DialogMove::EvalRotationAngle()
|
|||
formulaData.labelEditFormula = ui->labelEditRotationAngle;
|
||||
formulaData.labelResult = ui->labelResultRotationAngle;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagRotationAngle);
|
||||
|
||||
|
|
|
@ -663,7 +663,6 @@ void DialogRotation::EvalAngle()
|
|||
formulaData.labelEditFormula = ui->labelEditAngle;
|
||||
formulaData.labelResult = ui->labelResultAngle;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagAngle);
|
||||
|
||||
|
|
|
@ -389,7 +389,6 @@ void DialogSpline::EvalAngle1()
|
|||
formulaData.labelEditFormula = ui->labelEditAngle1;
|
||||
formulaData.labelResult = ui->labelResultAngle1;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagAngle1);
|
||||
}
|
||||
|
@ -403,7 +402,6 @@ void DialogSpline::EvalAngle2()
|
|||
formulaData.labelEditFormula = ui->labelEditAngle2;
|
||||
formulaData.labelResult = ui->labelResultAngle2;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagAngle2);
|
||||
}
|
||||
|
@ -417,7 +415,6 @@ void DialogSpline::EvalLength1()
|
|||
formulaData.labelEditFormula = ui->labelEditLength1;
|
||||
formulaData.labelResult = ui->labelResultLength1;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, flagLength1);
|
||||
|
@ -432,7 +429,6 @@ void DialogSpline::EvalLength2()
|
|||
formulaData.labelEditFormula = ui->labelEditLength2;
|
||||
formulaData.labelResult = ui->labelResultLength2;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, flagLength2);
|
||||
|
|
|
@ -574,7 +574,6 @@ void DialogSplinePath::EvalAngle1()
|
|||
formulaData.labelEditFormula = ui->labelEditAngle1;
|
||||
formulaData.labelResult = ui->labelResultAngle1;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagAngle1[row]);
|
||||
|
||||
|
@ -600,7 +599,6 @@ void DialogSplinePath::EvalAngle2()
|
|||
formulaData.labelEditFormula = ui->labelEditAngle2;
|
||||
formulaData.labelResult = ui->labelResultAngle2;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagAngle2[row]);
|
||||
|
||||
|
@ -626,7 +624,6 @@ void DialogSplinePath::EvalLength1()
|
|||
formulaData.labelEditFormula = ui->labelEditLength1;
|
||||
formulaData.labelResult = ui->labelResultLength1;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, flagLength1[row]);
|
||||
|
@ -653,7 +650,6 @@ void DialogSplinePath::EvalLength2()
|
|||
formulaData.labelEditFormula = ui->labelEditLength2;
|
||||
formulaData.labelResult = ui->labelResultLength2;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, flagLength2[row]);
|
||||
|
|
|
@ -820,7 +820,6 @@ void DialogPiecePath::EvalWidth()
|
|||
formulaData.labelEditFormula = ui->labelEditWidth;
|
||||
formulaData.labelResult = ui->labelResultWidth;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
m_saWidth = Eval(formulaData, m_flagFormula);
|
||||
|
@ -851,7 +850,6 @@ void DialogPiecePath::EvalWidthBefore()
|
|||
formulaData.labelEditFormula = ui->labelEditBefore;
|
||||
formulaData.labelResult = ui->labelResultBefore;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
const QString formula = GetFormulaSAWidthBefore();
|
||||
|
@ -886,7 +884,6 @@ void DialogPiecePath::EvalWidthAfter()
|
|||
formulaData.labelEditFormula = ui->labelEditAfter;
|
||||
formulaData.labelResult = ui->labelResultAfter;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
const QString formula = GetFormulaSAWidthAfter();
|
||||
|
@ -919,7 +916,6 @@ void DialogPiecePath::EvalVisible()
|
|||
formulaData.labelEditFormula = ui->labelEditVisible;
|
||||
formulaData.labelResult = ui->labelResultVisible;
|
||||
formulaData.postfix = QString();
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, m_flagFormulaVisible);
|
||||
|
@ -970,7 +966,6 @@ void DialogPiecePath::EvalPassmarkWidth()
|
|||
formulaData.labelResult = ui->labelResultPassmarkWidth;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = true;
|
||||
formulaData.checkLessThanZero = false;
|
||||
|
||||
Eval(formulaData, m_flagFormulaPassmarkWidth);
|
||||
|
||||
|
@ -1000,8 +995,6 @@ void DialogPiecePath::EvalPassmarkAngle()
|
|||
formulaData.labelEditFormula = ui->labelEditPassmarkAngle;
|
||||
formulaData.labelResult = ui->labelResultPassmarkAngle;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = false;
|
||||
|
||||
Eval(formulaData, m_flagFormulaPassmarkAngle);
|
||||
|
||||
|
@ -1078,6 +1071,8 @@ void DialogPiecePath::FXPassmarkLength()
|
|||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit passmark length"));
|
||||
dialog->SetFormula(GetFormulaPassmarkLength());
|
||||
dialog->setCheckZero(true);
|
||||
dialog->setCheckLessThanZero(true);
|
||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
|
@ -1091,6 +1086,7 @@ void DialogPiecePath::FXPassmarkWidth()
|
|||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit passmark width"));
|
||||
dialog->SetFormula(GetFormulaPassmarkWidth());
|
||||
dialog->setCheckZero(true);
|
||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
|
|
|
@ -370,7 +370,6 @@ void DialogPlaceLabel::EvalAngle()
|
|||
formulaData.labelEditFormula = ui->labelEditFormulaAngle;
|
||||
formulaData.labelResult = ui->labelResultCalculationAngle;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, m_flagAngle);
|
||||
}
|
||||
|
@ -384,7 +383,6 @@ void DialogPlaceLabel::EvalVisible()
|
|||
formulaData.labelEditFormula = ui->labelEditVisible;
|
||||
formulaData.labelResult = ui->labelResultVisible;
|
||||
formulaData.postfix = QString();
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, m_flagFormulaVisible);
|
||||
|
@ -396,6 +394,7 @@ void DialogPlaceLabel::FXWidth()
|
|||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit rectangle width"));
|
||||
dialog->SetFormula(GetWidth());
|
||||
dialog->setCheckLessThanZero(true);
|
||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
|
@ -409,6 +408,7 @@ void DialogPlaceLabel::FXHeight()
|
|||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit rectangle width"));
|
||||
dialog->SetFormula(GetHeight());
|
||||
dialog->setCheckLessThanZero(true);
|
||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
|
|
|
@ -2340,7 +2340,6 @@ void DialogSeamAllowance::EvalWidth()
|
|||
formulaData.labelEditFormula = uiTabPaths->labelEditWidth;
|
||||
formulaData.labelResult = uiTabPaths->labelResultWidth;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
m_saWidth = Eval(formulaData, flagFormula);
|
||||
|
@ -2373,7 +2372,6 @@ void DialogSeamAllowance::EvalWidthBefore()
|
|||
formulaData.labelEditFormula = uiTabPaths->labelEditBefore;
|
||||
formulaData.labelResult = uiTabPaths->labelResultBefore;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, flagFormulaBefore);
|
||||
|
@ -2404,7 +2402,6 @@ void DialogSeamAllowance::EvalWidthAfter()
|
|||
formulaData.labelEditFormula = uiTabPaths->labelEditAfter;
|
||||
formulaData.labelResult = uiTabPaths->labelResultAfter;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = true;
|
||||
|
||||
Eval(formulaData, flagFormulaAfter);
|
||||
|
@ -2465,7 +2462,6 @@ void DialogSeamAllowance::EvalPassmarkWidth()
|
|||
formulaData.labelResult = uiTabPassmarks->labelResultPassmarkWidth;
|
||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = true;
|
||||
formulaData.checkLessThanZero = false;
|
||||
|
||||
Eval(formulaData, flagFormulaPassmarkWidth);
|
||||
|
||||
|
@ -2493,8 +2489,6 @@ void DialogSeamAllowance::EvalPassmarkAngle()
|
|||
formulaData.labelEditFormula = uiTabPassmarks->labelEditPassmarkAngle;
|
||||
formulaData.labelResult = uiTabPassmarks->labelResultPassmarkAngle;
|
||||
formulaData.postfix = degreeSymbol;
|
||||
formulaData.checkZero = false;
|
||||
formulaData.checkLessThanZero = false;
|
||||
|
||||
Eval(formulaData, flagFormulaPassmarkAngle);
|
||||
|
||||
|
@ -2557,6 +2551,8 @@ void DialogSeamAllowance::FXPassmarkLength()
|
|||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit passmark length"));
|
||||
dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkLength));
|
||||
dialog->setCheckLessThanZero(true);
|
||||
dialog->setCheckZero(true);
|
||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
|
@ -2570,6 +2566,7 @@ void DialogSeamAllowance::FXPassmarkWidth()
|
|||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit passmark width"));
|
||||
dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkWidth));
|
||||
dialog->setCheckZero(true);
|
||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
|
|
|
@ -344,7 +344,6 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove *
|
|||
auto VToolMove::GetFormulaAngle() const -> VFormula
|
||||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
|
@ -367,7 +366,6 @@ void VToolMove::SetFormulaAngle(const VFormula &value)
|
|||
auto VToolMove::GetFormulaRotationAngle() const -> VFormula
|
||||
{
|
||||
VFormula fAngle(formulaRotationAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
|
@ -390,7 +388,6 @@ void VToolMove::SetFormulaRotationAngle(const VFormula &value)
|
|||
auto VToolMove::GetFormulaLength() const -> VFormula
|
||||
{
|
||||
VFormula fLength(formulaLength, getData());
|
||||
fLength.setCheckZero(true);
|
||||
fLength.setToolId(m_id);
|
||||
fLength.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
fLength.Eval();
|
||||
|
|
|
@ -286,7 +286,6 @@ auto VToolRotation::OriginPointName() const -> QString
|
|||
auto VToolRotation::GetFormulaAngle() const -> VFormula
|
||||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
|
|
|
@ -208,13 +208,10 @@ void VToolArc::SetFormulaRadius(const VFormula &value)
|
|||
{
|
||||
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<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
arc->SetFormulaRadius(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
}
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
arc->SetFormulaRadius(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +222,6 @@ auto VToolArc::GetFormulaF1() const -> VFormula
|
|||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula f1(arc->GetFormulaF1(), getData());
|
||||
f1.setCheckZero(false);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
f1.Eval();
|
||||
|
@ -252,7 +248,6 @@ auto VToolArc::GetFormulaF2() const -> VFormula
|
|||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula f2(arc->GetFormulaF2(), getData());
|
||||
f2.setCheckZero(false);
|
||||
f2.setToolId(m_id);
|
||||
f2.setPostfix(degreeSymbol);
|
||||
f2.Eval();
|
||||
|
|
|
@ -178,7 +178,6 @@ auto VToolArcWithLength::GetFormulaRadius() const -> VFormula
|
|||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula radius(arc->GetFormulaRadius(), getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
radius.Eval();
|
||||
|
@ -190,13 +189,10 @@ void VToolArcWithLength::SetFormulaRadius(const VFormula &value)
|
|||
{
|
||||
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<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
arc->SetFormulaRadius(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
}
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
arc->SetFormulaRadius(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,7 +203,6 @@ auto VToolArcWithLength::GetFormulaF1() const -> VFormula
|
|||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula f1(arc->GetFormulaF1(), getData());
|
||||
f1.setCheckZero(false);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
f1.Eval();
|
||||
|
|
|
@ -206,7 +206,6 @@ auto VToolEllipticalArc::GetFormulaRadius1() const -> VFormula
|
|||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula radius1(elArc->GetFormulaRadius1(), getData());
|
||||
radius1.setCheckZero(true);
|
||||
radius1.setToolId(m_id);
|
||||
radius1.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
radius1.Eval();
|
||||
|
@ -218,13 +217,10 @@ void VToolEllipticalArc::SetFormulaRadius1(const VFormula &value)
|
|||
{
|
||||
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<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
elArc->SetFormulaRadius1(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
}
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
elArc->SetFormulaRadius1(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,7 +231,6 @@ auto VToolEllipticalArc::GetFormulaRadius2() const -> VFormula
|
|||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula radius2(elArc->GetFormulaRadius2(), getData());
|
||||
radius2.setCheckZero(true);
|
||||
radius2.setToolId(m_id);
|
||||
radius2.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
radius2.Eval();
|
||||
|
@ -247,13 +242,10 @@ void VToolEllipticalArc::SetFormulaRadius2(const VFormula &value)
|
|||
{
|
||||
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<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
elArc->SetFormulaRadius2(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
}
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
elArc->SetFormulaRadius2(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +256,6 @@ auto VToolEllipticalArc::GetFormulaF1() const -> VFormula
|
|||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula f1(elArc->GetFormulaF1(), getData());
|
||||
f1.setCheckZero(false);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
f1.Eval();
|
||||
|
@ -290,7 +281,6 @@ auto VToolEllipticalArc::GetFormulaF2() const -> VFormula
|
|||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula f2(elArc->GetFormulaF2(), getData());
|
||||
f2.setCheckZero(false);
|
||||
f2.setToolId(m_id);
|
||||
f2.setPostfix(degreeSymbol);
|
||||
f2.Eval();
|
||||
|
@ -316,7 +306,6 @@ auto VToolEllipticalArc::GetFormulaRotationAngle() const -> VFormula
|
|||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula rotationAngle(elArc->GetFormulaRotationAngle(), getData());
|
||||
rotationAngle.setCheckZero(false);
|
||||
rotationAngle.setToolId(m_id);
|
||||
rotationAngle.setPostfix(degreeSymbol);
|
||||
rotationAngle.Eval();
|
||||
|
|
|
@ -215,7 +215,6 @@ auto VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle, const
|
|||
auto VToolCurveIntersectAxis::GetFormulaAngle() const -> VFormula
|
||||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
|
|
|
@ -35,8 +35,10 @@
|
|||
|
||||
#include "../../../../../dialogs/tools/dialogendline.h"
|
||||
#include "../../../../../dialogs/tools/dialogtool.h"
|
||||
#include "../../../../../visualization/visualization.h"
|
||||
#include "../../../../../visualization/line/vistoolendline.h"
|
||||
#include "../../../../../visualization/visualization.h"
|
||||
#include "../../../../vabstracttool.h"
|
||||
#include "../../../vdrawtool.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
@ -45,8 +47,6 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vpatterndb/vtranslatevars.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../../../../vabstracttool.h"
|
||||
#include "../../../vdrawtool.h"
|
||||
#include "vtoollinepoint.h"
|
||||
|
||||
template <class T> class QSharedPointer;
|
||||
|
@ -60,9 +60,9 @@ const QString VToolEndLine::ToolType = QStringLiteral("endLine");
|
|||
* @param parent parent object.
|
||||
*/
|
||||
VToolEndLine::VToolEndLine(const VToolEndLineInitData &initData, QGraphicsItem *parent)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor,
|
||||
initData.formulaLength, initData.basePointId, 0, initData.notes, parent),
|
||||
formulaAngle(initData.formulaAngle)
|
||||
: VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor,
|
||||
initData.formulaLength, initData.basePointId, 0, initData.notes, parent),
|
||||
formulaAngle(initData.formulaAngle)
|
||||
{
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -133,11 +133,11 @@ auto VToolEndLine::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene
|
|||
auto VToolEndLine::Create(VToolEndLineInitData &initData) -> VToolEndLine *
|
||||
{
|
||||
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||
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.setLength(VAbstractValApplication::VApp()
|
||||
->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data)));
|
||||
line.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); // First set angle.
|
||||
line.setLength(
|
||||
VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data)));
|
||||
|
||||
VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
@ -174,8 +174,7 @@ auto VToolEndLine::Create(VToolEndLineInitData &initData) -> VToolEndLine *
|
|||
/**
|
||||
* @brief SaveDialog save options into file after change in dialog.
|
||||
*/
|
||||
void VToolEndLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
|
||||
QList<quint32> &newDependencies)
|
||||
void VToolEndLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies, QList<quint32> &newDependencies)
|
||||
{
|
||||
SCASSERT(not m_dialog.isNull())
|
||||
const QPointer<DialogEndLine> dialogTool = qobject_cast<DialogEndLine *>(m_dialog);
|
||||
|
@ -191,7 +190,7 @@ void VToolEndLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepend
|
|||
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
|
||||
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
|
||||
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
||||
[](const QString ¬es) noexcept {return notes.isEmpty();});
|
||||
[](const QString ¬es) noexcept { return notes.isEmpty(); });
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -241,7 +240,6 @@ void VToolEndLine::SetVisualization()
|
|||
auto VToolEndLine::GetFormulaAngle() const -> VFormula
|
||||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
|
@ -273,9 +271,9 @@ void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint3
|
|||
{
|
||||
ContextMenu<DialogEndLine>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
catch (const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
return; // Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,6 @@ auto VToolLineIntersectAxis::SecondLinePoint() const -> QString
|
|||
auto VToolLineIntersectAxis::GetFormulaAngle() const -> VFormula
|
||||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
|
|
|
@ -226,7 +226,6 @@ void VToolLinePoint::SetLineColor(const QString &value)
|
|||
auto VToolLinePoint::GetFormulaLength() const -> VFormula
|
||||
{
|
||||
VFormula fLength(formulaLength, this->getData());
|
||||
fLength.setCheckZero(false);
|
||||
fLength.setToolId(m_id);
|
||||
fLength.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
fLength.Eval();
|
||||
|
@ -237,7 +236,7 @@ auto VToolLinePoint::GetFormulaLength() const -> VFormula
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLinePoint::SetFormulaLength(const VFormula &value)
|
||||
{
|
||||
if (value.error() == false)
|
||||
if (!value.error())
|
||||
{
|
||||
formulaLength = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
|
|
|
@ -33,20 +33,20 @@
|
|||
|
||||
#include "../../../../dialogs/tools/dialogpointfromcircleandtangent.h"
|
||||
#include "../../../../dialogs/tools/dialogtool.h"
|
||||
#include "../../../../visualization/visualization.h"
|
||||
#include "../../../../visualization/line/vistoolpointfromcircleandtangent.h"
|
||||
#include "../../../../visualization/visualization.h"
|
||||
#include "../../../vabstracttool.h"
|
||||
#include "../../vdrawtool.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../ifc/exception/vexceptionobjecterror.h"
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../vgeometry/vgobject.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vpatterndb/vformula.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../../../vabstracttool.h"
|
||||
#include "../../vdrawtool.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
template <class T> class QSharedPointer;
|
||||
|
@ -56,11 +56,11 @@ const QString VToolPointFromCircleAndTangent::ToolType = QStringLiteral("pointFr
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointFromCircleAndTangent::VToolPointFromCircleAndTangent(const VToolPointFromCircleAndTangentInitData &initData,
|
||||
QGraphicsItem *parent)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent),
|
||||
circleCenterId(initData.circleCenterId),
|
||||
tangentPointId(initData.tangentPointId),
|
||||
circleRadius(initData.circleRadius),
|
||||
crossPoint(initData.crossPoint)
|
||||
: VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent),
|
||||
circleCenterId(initData.circleCenterId),
|
||||
tangentPointId(initData.tangentPointId),
|
||||
circleRadius(initData.circleRadius),
|
||||
crossPoint(initData.crossPoint)
|
||||
{
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ void VToolPointFromCircleAndTangent::SetDialog()
|
|||
{
|
||||
SCASSERT(not m_dialog.isNull())
|
||||
const QPointer<DialogPointFromCircleAndTangent> dialogTool =
|
||||
qobject_cast<DialogPointFromCircleAndTangent *>(m_dialog);
|
||||
qobject_cast<DialogPointFromCircleAndTangent *>(m_dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetCircleCenterId(circleCenterId);
|
||||
|
@ -87,7 +87,7 @@ auto VToolPointFromCircleAndTangent::Create(const QPointer<DialogTool> &dialog,
|
|||
{
|
||||
SCASSERT(not dialog.isNull())
|
||||
const QPointer<DialogPointFromCircleAndTangent> dialogTool =
|
||||
qobject_cast<DialogPointFromCircleAndTangent *>(dialog);
|
||||
qobject_cast<DialogPointFromCircleAndTangent *>(dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
VToolPointFromCircleAndTangentInitData initData;
|
||||
|
@ -116,25 +116,27 @@ auto VToolPointFromCircleAndTangent::Create(VToolPointFromCircleAndTangentInitDa
|
|||
-> VToolPointFromCircleAndTangent *
|
||||
{
|
||||
const qreal radius =
|
||||
VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.circleRadius, initData.data));
|
||||
VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.circleRadius, initData.data));
|
||||
const VPointF cPoint = *initData.data->GeometricObject<VPointF>(initData.circleCenterId);
|
||||
const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId);
|
||||
|
||||
QPointF point;
|
||||
const bool success = VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(tPoint),
|
||||
static_cast<QPointF>(cPoint), radius,
|
||||
initData.crossPoint, &point);
|
||||
const bool success = VToolPointFromCircleAndTangent::FindPoint(
|
||||
static_cast<QPointF>(tPoint), static_cast<QPointF>(cPoint), radius, initData.crossPoint, &point);
|
||||
if (not success)
|
||||
{
|
||||
const QString errorMsg = tr("Error calculating point '%1'. Tangent to circle with center '%2' and radius '%3' "
|
||||
"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) :
|
||||
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);
|
||||
auto *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
|
@ -153,7 +155,7 @@ auto VToolPointFromCircleAndTangent::Create(VToolPointFromCircleAndTangentInitDa
|
|||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(initData.id, Tool::PointFromCircleAndTangent, initData.doc);
|
||||
VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(initData);
|
||||
auto *point = new VToolPointFromCircleAndTangent(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
|
@ -171,9 +173,9 @@ auto VToolPointFromCircleAndTangent::FindPoint(const QPointF &p, const QPointF &
|
|||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
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)
|
||||
{
|
||||
case 2:
|
||||
*intersectionPoint = (crossPoint == CrossCirclesPoint::FirstPoint ? p1 : p2);
|
||||
|
@ -216,12 +218,9 @@ void VToolPointFromCircleAndTangent::SetCircleRadius(const VFormula &value)
|
|||
{
|
||||
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);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
circleRadius = value.GetFormula(FormulaType::FromUser);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,10 +252,10 @@ void VToolPointFromCircleAndTangent::ShowContextMenu(QGraphicsSceneContextMenuEv
|
|||
{
|
||||
ContextMenu<DialogPointFromCircleAndTangent>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
catch (const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
return; // Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +275,7 @@ void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement, QList<q
|
|||
{
|
||||
SCASSERT(not m_dialog.isNull())
|
||||
const QPointer<DialogPointFromCircleAndTangent> dialogTool =
|
||||
qobject_cast<DialogPointFromCircleAndTangent *>(m_dialog);
|
||||
qobject_cast<DialogPointFromCircleAndTangent *>(m_dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
AddDependence(oldDependencies, circleCenterId);
|
||||
|
@ -291,7 +290,7 @@ void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement, QList<q
|
|||
doc->SetAttribute(domElement, AttrCrossPoint,
|
||||
QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint())));
|
||||
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
||||
[](const QString ¬es) noexcept {return notes.isEmpty();});
|
||||
[](const QString ¬es) noexcept { return notes.isEmpty(); });
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#ifndef VTOOLPOINTFROMCIRCLEANDTANGENT_H
|
||||
#define VTOOLPOINTFROMCIRCLEANDTANGENT_H
|
||||
|
||||
|
||||
#include <QDomElement>
|
||||
#include <QGraphicsItem>
|
||||
#include <QMetaObject>
|
||||
|
@ -48,12 +47,13 @@ template <class T> class QSharedPointer;
|
|||
struct VToolPointFromCircleAndTangentInitData : VToolSinglePointInitData
|
||||
{
|
||||
VToolPointFromCircleAndTangentInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
circleCenterId(NULL_ID),
|
||||
circleRadius('0'),
|
||||
tangentPointId(NULL_ID),
|
||||
crossPoint(CrossCirclesPoint::FirstPoint)
|
||||
{}
|
||||
: VToolSinglePointInitData(),
|
||||
circleCenterId(NULL_ID),
|
||||
circleRadius('0'),
|
||||
tangentPointId(NULL_ID),
|
||||
crossPoint(CrossCirclesPoint::FirstPoint)
|
||||
{
|
||||
}
|
||||
|
||||
quint32 circleCenterId;
|
||||
QString circleRadius;
|
||||
|
@ -64,6 +64,7 @@ struct VToolPointFromCircleAndTangentInitData : VToolSinglePointInitData
|
|||
class VToolPointFromCircleAndTangent : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT // NOLINT
|
||||
|
||||
public:
|
||||
virtual void SetDialog() override;
|
||||
static auto Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
|
@ -73,20 +74,24 @@ public:
|
|||
QPointF *intersectionPoint) -> bool;
|
||||
static const QString ToolType;
|
||||
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 CircleCenterPointName() const -> QString;
|
||||
|
||||
auto GetCircleRadius() const -> VFormula;
|
||||
void SetCircleRadius(const VFormula &value);
|
||||
void SetCircleRadius(const VFormula &value);
|
||||
|
||||
auto GetCrossCirclesPoint() const -> CrossCirclesPoint;
|
||||
void SetCrossCirclesPoint(const CrossCirclesPoint &value);
|
||||
void SetCrossCirclesPoint(const CrossCirclesPoint &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) override;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override;
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id = NULL_ID) override;
|
||||
|
||||
protected:
|
||||
virtual void RemoveReferens() override;
|
||||
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
|
||||
|
@ -94,6 +99,7 @@ protected:
|
|||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) override;
|
||||
virtual void SetVisualization() override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(VToolPointFromCircleAndTangent) // NOLINT
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ auto VToolPointOfContact::FindPoint(qreal radius, const QPointF ¢er, const Q
|
|||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
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)
|
||||
{
|
||||
case 0:
|
||||
|
@ -126,8 +126,7 @@ auto VToolPointOfContact::FindPoint(qreal radius, const QPointF ¢er, const Q
|
|||
{
|
||||
const bool flagP1 = VGObject::IsPointOnLineSegment(p1, firstPoint, secondPoint);
|
||||
const bool flagP2 = VGObject::IsPointOnLineSegment(p2, firstPoint, secondPoint);
|
||||
if ((flagP1 == true && flagP2 == true) ||
|
||||
(flagP1 == false && flagP2 == false) /*In case we have something wrong*/)
|
||||
if ((flagP1 && flagP2) || (!flagP1 && !flagP2) /*In case we have something wrong*/)
|
||||
{
|
||||
// We don't have options for choosing correct point. Use closest to segment first point.
|
||||
if (QLineF(firstPoint, p1).length() <= QLineF(firstPoint, p2).length())
|
||||
|
@ -139,17 +138,16 @@ auto VToolPointOfContact::FindPoint(qreal radius, const QPointF ¢er, const Q
|
|||
*intersectionPoint = p2;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{ // In this case we have one real and one theoretical intersection.
|
||||
if (flagP1)
|
||||
{
|
||||
*intersectionPoint = p1;
|
||||
return true;
|
||||
}
|
||||
|
||||
*intersectionPoint = p2;
|
||||
// In this case we have one real and one theoretical intersection.
|
||||
if (flagP1)
|
||||
{
|
||||
*intersectionPoint = p1;
|
||||
return true;
|
||||
}
|
||||
|
||||
*intersectionPoint = p2;
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
qDebug() << "Unxpected value" << res;
|
||||
|
@ -417,7 +415,6 @@ void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event,
|
|||
auto VToolPointOfContact::getArcRadius() const -> VFormula
|
||||
{
|
||||
VFormula radius(arcRadius, this->getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
radius.Eval();
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#ifndef VTOOLPOINTOFCONTACT_H
|
||||
#define VTOOLPOINTOFCONTACT_H
|
||||
|
||||
|
||||
#include <QDomElement>
|
||||
#include <QGraphicsItem>
|
||||
#include <QMetaObject>
|
||||
|
@ -48,12 +47,13 @@ template <class T> class QSharedPointer;
|
|||
struct VToolPointOfContactInitData : VToolSinglePointInitData
|
||||
{
|
||||
VToolPointOfContactInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
radius('0'),
|
||||
center(NULL_ID),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID)
|
||||
{}
|
||||
: VToolSinglePointInitData(),
|
||||
radius('0'),
|
||||
center(NULL_ID),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID)
|
||||
{
|
||||
}
|
||||
|
||||
QString radius;
|
||||
quint32 center;
|
||||
|
@ -67,8 +67,9 @@ struct VToolPointOfContactInitData : VToolSinglePointInitData
|
|||
class VToolPointOfContact : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT // NOLINT
|
||||
|
||||
public:
|
||||
virtual void SetDialog() override;
|
||||
virtual void SetDialog() override;
|
||||
static auto FindPoint(qreal radius, const QPointF ¢er, const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
QPointF *intersectionPoint) -> bool;
|
||||
static auto Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
|
@ -76,41 +77,45 @@ public:
|
|||
static auto Create(VToolPointOfContactInitData &initData) -> VToolPointOfContact *;
|
||||
static const QString ToolType;
|
||||
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 FirstPointName() const -> QString;
|
||||
auto SecondPointName() const -> QString;
|
||||
|
||||
auto getArcRadius() const -> VFormula;
|
||||
void setArcRadius(const VFormula &value);
|
||||
void setArcRadius(const VFormula &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) override;
|
||||
virtual void ShowVisualization(bool show) override;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override;
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id = NULL_ID) override;
|
||||
|
||||
protected:
|
||||
virtual void RemoveReferens() override;
|
||||
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
|
||||
QList<quint32> &newDependencies) override;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) override;
|
||||
virtual void SetVisualization() override;
|
||||
virtual void RemoveReferens() override;
|
||||
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
|
||||
QList<quint32> &newDependencies) override;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) override;
|
||||
virtual void SetVisualization() override;
|
||||
virtual auto MakeToolTip() const -> QString override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(VToolPointOfContact) // NOLINT
|
||||
|
||||
/** @brief radius string with formula radius arc. */
|
||||
QString arcRadius;
|
||||
QString arcRadius;
|
||||
|
||||
/** @brief center id center arc point. */
|
||||
quint32 center;
|
||||
quint32 center;
|
||||
|
||||
/** @brief firstPointId id first line point. */
|
||||
quint32 firstPointId;
|
||||
quint32 firstPointId;
|
||||
|
||||
/** @brief secondPointId id second line point. */
|
||||
quint32 secondPointId;
|
||||
quint32 secondPointId;
|
||||
|
||||
VToolPointOfContact(const VToolPointOfContactInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
|
|
@ -33,20 +33,20 @@
|
|||
|
||||
#include "../../../../dialogs/tools/dialogpointofintersectioncircles.h"
|
||||
#include "../../../../dialogs/tools/dialogtool.h"
|
||||
#include "../../../../visualization/visualization.h"
|
||||
#include "../../../../visualization/line/vistoolpointofintersectioncircles.h"
|
||||
#include "../../../../visualization/visualization.h"
|
||||
#include "../../../vabstracttool.h"
|
||||
#include "../../vdrawtool.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../ifc/exception/vexceptionobjecterror.h"
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../vgeometry/vgobject.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vpatterndb/vformula.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../../../vabstracttool.h"
|
||||
#include "../../vdrawtool.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
template <class T> class QSharedPointer;
|
||||
|
@ -55,13 +55,13 @@ const QString VToolPointOfIntersectionCircles::ToolType = QStringLiteral("pointO
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionCircles::VToolPointOfIntersectionCircles(
|
||||
const VToolPointOfIntersectionCirclesInitData &initData, QGraphicsItem *parent)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent),
|
||||
firstCircleCenterId(initData.firstCircleCenterId),
|
||||
secondCircleCenterId(initData.secondCircleCenterId),
|
||||
firstCircleRadius(initData.firstCircleRadius),
|
||||
secondCircleRadius(initData.secondCircleRadius),
|
||||
crossPoint(initData.crossPoint)
|
||||
const VToolPointOfIntersectionCirclesInitData &initData, QGraphicsItem *parent)
|
||||
: VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent),
|
||||
firstCircleCenterId(initData.firstCircleCenterId),
|
||||
secondCircleCenterId(initData.secondCircleCenterId),
|
||||
firstCircleRadius(initData.firstCircleRadius),
|
||||
secondCircleRadius(initData.secondCircleRadius),
|
||||
crossPoint(initData.crossPoint)
|
||||
{
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void VToolPointOfIntersectionCircles::SetDialog()
|
|||
{
|
||||
SCASSERT(not m_dialog.isNull())
|
||||
const QPointer<DialogPointOfIntersectionCircles> dialogTool =
|
||||
qobject_cast<DialogPointOfIntersectionCircles *>(m_dialog);
|
||||
qobject_cast<DialogPointOfIntersectionCircles *>(m_dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFirstCircleCenterId(firstCircleCenterId);
|
||||
|
@ -90,7 +90,7 @@ auto VToolPointOfIntersectionCircles::Create(const QPointer<DialogTool> &dialog,
|
|||
{
|
||||
SCASSERT(not dialog.isNull())
|
||||
const QPointer<DialogPointOfIntersectionCircles> dialogTool =
|
||||
qobject_cast<DialogPointOfIntersectionCircles *>(dialog);
|
||||
qobject_cast<DialogPointOfIntersectionCircles *>(dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
VToolPointOfIntersectionCirclesInitData initData;
|
||||
|
@ -119,10 +119,10 @@ auto VToolPointOfIntersectionCircles::Create(const QPointer<DialogTool> &dialog,
|
|||
auto VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInitData &initData)
|
||||
-> VToolPointOfIntersectionCircles *
|
||||
{
|
||||
const qreal calcC1Radius = VAbstractValApplication::VApp()
|
||||
->toPixel(CheckFormula(initData.id, initData.firstCircleRadius, initData.data));
|
||||
const qreal calcC2Radius = VAbstractValApplication::VApp()
|
||||
->toPixel(CheckFormula(initData.id, initData.secondCircleRadius, initData.data));
|
||||
const qreal calcC1Radius =
|
||||
VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.firstCircleRadius, initData.data));
|
||||
const qreal calcC2Radius =
|
||||
VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.secondCircleRadius, initData.data));
|
||||
|
||||
const VPointF c1Point = *initData.data->GeometricObject<VPointF>(initData.firstCircleCenterId);
|
||||
const VPointF c2Point = *initData.data->GeometricObject<VPointF>(initData.secondCircleCenterId);
|
||||
|
@ -134,9 +134,11 @@ auto VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInit
|
|||
if (not success)
|
||||
{
|
||||
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());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
"no point of intersection")
|
||||
.arg(initData.name, c1Point.name(), c2Point.name());
|
||||
VAbstractApplication::VApp()->IsPedantic()
|
||||
? throw VExceptionObjectError(errorMsg)
|
||||
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
|
@ -177,9 +179,9 @@ auto VToolPointOfIntersectionCircles::FindPoint(const QPointF &c1Point, const QP
|
|||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
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)
|
||||
{
|
||||
case 2:
|
||||
if (crossPoint == CrossCirclesPoint::FirstPoint)
|
||||
|
@ -218,7 +220,6 @@ auto VToolPointOfIntersectionCircles::SecondCircleCenterPointName() const -> QSt
|
|||
auto VToolPointOfIntersectionCircles::GetFirstCircleRadius() const -> VFormula
|
||||
{
|
||||
VFormula radius(firstCircleRadius, getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
radius.Eval();
|
||||
|
@ -228,14 +229,11 @@ auto VToolPointOfIntersectionCircles::GetFirstCircleRadius() const -> VFormula
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
firstCircleRadius = value.GetFormula(FormulaType::FromUser);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,7 +241,6 @@ void VToolPointOfIntersectionCircles::SetFirstCircleRadius(const VFormula &value
|
|||
auto VToolPointOfIntersectionCircles::GetSecondCircleRadius() const -> VFormula
|
||||
{
|
||||
VFormula radius(secondCircleRadius, getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits()));
|
||||
radius.Eval();
|
||||
|
@ -253,14 +250,11 @@ auto VToolPointOfIntersectionCircles::GetSecondCircleRadius() const -> VFormula
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
secondCircleRadius = value.GetFormula(FormulaType::FromUser);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,10 +286,10 @@ void VToolPointOfIntersectionCircles::ShowContextMenu(QGraphicsSceneContextMenuE
|
|||
{
|
||||
ContextMenu<DialogPointOfIntersectionCircles>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
catch (const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
return; // Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +309,7 @@ void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement, QList<
|
|||
{
|
||||
SCASSERT(not m_dialog.isNull())
|
||||
const QPointer<DialogPointOfIntersectionCircles> dialogTool =
|
||||
qobject_cast<DialogPointOfIntersectionCircles *>(m_dialog);
|
||||
qobject_cast<DialogPointOfIntersectionCircles *>(m_dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
AddDependence(oldDependencies, firstCircleCenterId);
|
||||
|
@ -331,7 +325,7 @@ void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement, QList<
|
|||
doc->SetAttribute(domElement, AttrCrossPoint,
|
||||
QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint())));
|
||||
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
||||
[](const QString ¬es) noexcept {return notes.isEmpty();});
|
||||
[](const QString ¬es) noexcept { return notes.isEmpty(); });
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -88,7 +88,7 @@ void VisToolMove::RefreshGeometry()
|
|||
qreal tempRoationAngle = 0;
|
||||
|
||||
QLineF line;
|
||||
if (qFuzzyIsNull(m_length))
|
||||
if (qIsInf(m_length))
|
||||
{
|
||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||
{
|
||||
|
@ -157,21 +157,30 @@ void VisToolMove::RefreshGeometry()
|
|||
DrawPath(m_angleArc, arc.GetPath(), Qt::SolidLine, Qt::RoundCap);
|
||||
}
|
||||
DrawLine(this, line, Qt::DashLine);
|
||||
DrawPoint(m_pointFinish, line.p2());
|
||||
|
||||
static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
if (qFuzzyIsNull(m_length))
|
||||
{
|
||||
SetToolTip(tr("Length = %1%2, angle = %3°, <b>%4</b> - sticking angle, "
|
||||
"<b>Mouse click</b> - finish selecting a position")
|
||||
.arg(LengthToUser(tempLength), prefix, AngleToUser(tempAngle), VModifierKey::Shift()));
|
||||
setVisible(true);
|
||||
}
|
||||
else
|
||||
|
||||
DrawPoint(m_pointFinish, line.p2());
|
||||
|
||||
if (GetMode() == Mode::Creation)
|
||||
{
|
||||
SetToolTip(tr("Length = %1%2, angle = %3°, rotation angle = %4°, <b>%5</b> - sticking angle, "
|
||||
"<b>%6</b> - change rotation origin point, <b>Mouse click</b> - finish creating")
|
||||
.arg(LengthToUser(tempLength), prefix, AngleToUser(tempAngle), AngleToUser(tempRoationAngle),
|
||||
VModifierKey::Shift(), VModifierKey::Control()));
|
||||
static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
if (qIsInf(m_length))
|
||||
{
|
||||
SetToolTip(tr("Length = %1%2, angle = %3°, <b>%4</b> - sticking angle, "
|
||||
"<b>Mouse click</b> - finish selecting a position")
|
||||
.arg(LengthToUser(tempLength), prefix, AngleToUser(tempAngle), VModifierKey::Shift()));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetToolTip(tr("Length = %1%2, angle = %3°, rotation angle = %4°, <b>%5</b> - sticking angle, "
|
||||
"<b>%6</b> - change rotation origin point, <b>Mouse click</b> - finish creating")
|
||||
.arg(LengthToUser(tempLength), prefix, AngleToUser(tempAngle), AngleToUser(tempRoationAngle),
|
||||
VModifierKey::Shift(), VModifierKey::Control()));
|
||||
}
|
||||
}
|
||||
|
||||
CreateMovedRotatedObjects(iPoint, iCurve, tempLength, tempAngle, tempRoationAngle, origin);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QtGlobal>
|
||||
#include <limits>
|
||||
|
||||
#include "../vmisc/def.h"
|
||||
#include "visoperation.h"
|
||||
|
@ -74,7 +75,7 @@ private:
|
|||
Q_DISABLE_COPY_MOVE(VisToolMove) // NOLINT
|
||||
qreal m_angle{0};
|
||||
qreal m_rotationAngle{INT_MIN};
|
||||
qreal m_length{0};
|
||||
qreal m_length{std::numeric_limits<qreal>::infinity()};
|
||||
VScaledEllipse *m_pointOrigin{nullptr};
|
||||
VScaledEllipse *m_pointRotationOrigin{nullptr};
|
||||
VScaledEllipse *m_pointFinish{nullptr};
|
||||
|
|
|
@ -82,6 +82,7 @@ void VisToolCutArc::RefreshGeometry()
|
|||
{
|
||||
QPointF p = arc->ClosestPoint(ScenePos());
|
||||
qreal length = arc->GetLengthByPoint(p);
|
||||
length = !arc->IsFlipped() ? qBound(0.0, length, arc->GetLength()) : qBound(arc->GetLength(), -length, 0.0);
|
||||
|
||||
DrawPoint(m_point, p);
|
||||
|
||||
|
|
|
@ -93,18 +93,39 @@ void TST_VArc::CompareTwoWays()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
void TST_VArc::NegativeArc()
|
||||
void TST_VArc::ArcByLength_data()
|
||||
{
|
||||
const VPointF center;
|
||||
const qreal radius = 100;
|
||||
const qreal f1 = 1;
|
||||
const qreal f2 = 316;
|
||||
const qreal length = M_PI * radius / 180 * 45;
|
||||
VArc arc(-length, center, radius, f1);
|
||||
QTest::addColumn<qreal>("radius");
|
||||
QTest::addColumn<qreal>("startAngle");
|
||||
QTest::addColumn<qreal>("endAngle");
|
||||
QTest::addColumn<qreal>("arcAngle");
|
||||
QTest::addColumn<bool>("flipped");
|
||||
QTest::addColumn<int>("direction");
|
||||
|
||||
QCOMPARE(arc.GetLength(), -length);
|
||||
QCOMPARE(arc.GetEndAngle(), f2);
|
||||
QTest::newRow("Positive radius, positive length") << 100. << 1. << 316. << 315. << false << 1;
|
||||
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::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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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)
|
||||
{
|
||||
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
|
||||
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);
|
||||
|
@ -227,11 +313,11 @@ void TST_VArc::TestGetPoints()
|
|||
|
||||
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
||||
{ // circle square
|
||||
gSquare = M_PI * radius * radius;
|
||||
gSquare = M_PI * qAbs(radius) * qAbs(radius);
|
||||
}
|
||||
else
|
||||
{ // 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));
|
||||
}
|
||||
|
||||
|
@ -258,6 +344,7 @@ void TST_VArc::TestRotation_data()
|
|||
QTest::addColumn<QString>("prefix");
|
||||
|
||||
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.AngleArc(), rotatedArc.AngleArc());
|
||||
QCOMPARE(arcOrigin.GetRadius(), rotatedArc.GetRadius());
|
||||
QCOMPARE(arcOrigin.IsFlipped(), rotatedArc.IsFlipped());
|
||||
// cppcheck-suppress unreadVariable
|
||||
const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix);
|
||||
QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg));
|
||||
|
@ -300,16 +388,20 @@ void TST_VArc::TestFlip_data()
|
|||
|
||||
QLineF axis(QPointF(4, 6), QPointF(12, 6));
|
||||
|
||||
QTest::newRow("Vertical axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle()
|
||||
<< axis << "a2";
|
||||
QTest::newRow("Vertical axis, positive radius")
|
||||
<< 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);
|
||||
p2 = QPointF(10, 0);
|
||||
|
||||
axis = QLineF(QPointF(9, -1), QPointF(9, 6));
|
||||
|
||||
QTest::newRow("Horizontal axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle()
|
||||
<< axis << "a2";
|
||||
QTest::newRow("Horizontal axis, positive radius")
|
||||
<< 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());
|
||||
|
||||
|
@ -326,8 +418,10 @@ void TST_VArc::TestFlip_data()
|
|||
axis = QLineF(p1Axis.x(), p1Axis.y(), p1Axis.x() + radius, p1Axis.y());
|
||||
axis.setAngle(45);
|
||||
|
||||
QTest::newRow("Diagonal axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle()
|
||||
<< axis << "a2";
|
||||
QTest::newRow("Diagonal axis, positive radius")
|
||||
<< 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);
|
||||
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.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<qreal>("radius");
|
||||
|
@ -364,40 +458,65 @@ void TST_VArc::TestCutArc_data()
|
|||
QTest::addColumn<qreal>("cutLength");
|
||||
QTest::addColumn<QPointF>("cutPoint");
|
||||
|
||||
QPointF center(189.13625196850393, 344.1267401574803);
|
||||
qreal radius = ToPixel(10, Unit::Cm);
|
||||
qreal startAngle = 45.0;
|
||||
qreal length = ToPixel(-10, Unit::Cm);
|
||||
qreal cutLength = ToPixel(6, Unit::Cm);
|
||||
const QPointF center(189.13625196850393, 344.1267401574803);
|
||||
Q_RELAXED_CONSTEXPR qreal radius = ToPixel(10, Unit::Cm);
|
||||
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
|
||||
QTest::newRow("Arc -10 cm length, cut length 6 cm")
|
||||
<< center << radius << startAngle << length << cutLength << cutPoint;
|
||||
|
||||
cutLength = ToPixel(-4, Unit::Cm);
|
||||
<< center << radius << 45.0 << -length << ToPixel(6, Unit::Cm) << cutPoint;
|
||||
|
||||
// Opposite case
|
||||
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);
|
||||
|
||||
// See file <root>/src/app/share/collection/bugs/Issue_#957.val
|
||||
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
|
||||
cutLength = ToPixel(3, Unit::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(qreal, radius);
|
||||
|
|
|
@ -40,15 +40,16 @@ public:
|
|||
|
||||
private slots:
|
||||
void CompareTwoWays();
|
||||
void NegativeArc();
|
||||
void ArcByLength_data();
|
||||
void ArcByLength();
|
||||
void TestGetPoints_data();
|
||||
void TestGetPoints();
|
||||
void TestRotation_data();
|
||||
void TestRotation();
|
||||
void TestFlip_data();
|
||||
void TestFlip();
|
||||
void TestCutArc_data();
|
||||
void TestCutArc();
|
||||
void TestCutArcByLength_data();
|
||||
void TestCutArcByLength();
|
||||
void TestCurveIntersectAxis_data();
|
||||
void TestCurveIntersectAxis();
|
||||
void EmptyArc();
|
||||
|
|
|
@ -55,22 +55,85 @@ void TST_VEllipticalArc::CompareTwoWays_data()
|
|||
QTest::addColumn<qreal>("f2");
|
||||
QTest::addColumn<qreal>("rotationAngle");
|
||||
|
||||
QTest::newRow("Test case 1") << QPointF() << 100. << 200. << 0. << 90.0 << 0.;
|
||||
QTest::newRow("Test case 2") << QPointF() << 100. << 200. << 0. << 180.0 << 0.;
|
||||
QTest::newRow("Test case 3") << QPointF() << 100. << 200. << 0. << 270.0 << 0.;
|
||||
QTest::newRow("Test case 4") << QPointF() << 100. << 200. << 0. << 360.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 7") << QPointF(10, 10) << 100. << 200. << 0. << 270.0 << 80.;
|
||||
QTest::newRow("Test case 8") << QPointF(10, 10) << 100. << 200. << 0. << 360.0 << 80.;
|
||||
QTest::newRow("Test case 9") << QPointF() << 100. << 200. << 0. << 90.0 << 80.;
|
||||
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 12") << QPointF() << 100. << 200. << 0. << 360.0 << 80.;
|
||||
QTest::newRow("Test case 13") << QPointF(10, 10) << 100. << 200. << 0. << 90.0 << 80.;
|
||||
QTest::newRow("Test case 14") << QPointF(10, 10) << 100. << 200. << 0. << 180.0 << 80.;
|
||||
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 1, +r, +r") << 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 1, +r, -r") << 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, +r, +r") << QPointF() << 100. << 200. << 0. << 180.0 << 0.;
|
||||
QTest::newRow("Test case 2, -r, +r") << QPointF() << -100. << 200. << 0. << 180.0 << 0.;
|
||||
QTest::newRow("Test case 2, +r, -r") << QPointF() << 100. << -200. << 0. << 180.0 << 0.;
|
||||
QTest::newRow("Test case 2, -r, -r") << QPointF() << -100. << -200. << 0. << 180.0 << 0.;
|
||||
|
||||
QTest::newRow("Test case 3, +r, +r") << QPointF() << 100. << 200. << 0. << 270.0 << 0.;
|
||||
QTest::newRow("Test case 3, -r, +r") << QPointF() << -100. << 200. << 0. << 270.0 << 0.;
|
||||
QTest::newRow("Test case 3, +r, -r") << QPointF() << 100. << -200. << 0. << 270.0 << 0.;
|
||||
QTest::newRow("Test case 3, -r, -r") << QPointF() << -100. << -200. << 0. << 270.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 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);
|
||||
|
||||
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
|
||||
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::NegativeArc()
|
||||
void TST_VEllipticalArc::ArcByLength_data()
|
||||
{
|
||||
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 qreal radius1 = 100;
|
||||
const qreal radius2 = 200;
|
||||
const qreal f1 = 1;
|
||||
const qreal f2 = 181;
|
||||
const qreal rotationAngle = 0;
|
||||
|
||||
// Full ellipse
|
||||
const qreal h = ((radius1 - radius2) * (radius1 - radius2)) / ((radius1 + radius2) * (radius1 + radius2));
|
||||
const qreal length = M_PI * (radius1 + radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h))) / 2;
|
||||
VEllipticalArc arc(-length, center, radius1, radius2, f1, rotationAngle);
|
||||
const qreal h = ((qAbs(radius1) - qAbs(radius2)) * (qAbs(radius1) - qAbs(radius2))) /
|
||||
((qAbs(radius1) + qAbs(radius2)) * (qAbs(radius1) + qAbs(radius2)));
|
||||
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
|
||||
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;
|
||||
QVERIFY2(arc.GetEndAngle() - f2 <= angleEps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2)));
|
||||
|
||||
QCOMPARE(arc.IsFlipped(), flipped);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
|
@ -172,106 +262,445 @@ void TST_VEllipticalArc::TestData()
|
|||
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 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 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 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 -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 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 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")
|
||||
<< 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")
|
||||
<< 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 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 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;
|
||||
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 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 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, 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 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")
|
||||
<< 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")
|
||||
<< 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")
|
||||
<< 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 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 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 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")
|
||||
<< 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")
|
||||
<< 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")
|
||||
<< 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 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 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, 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 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 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, -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 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 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, 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 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 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, -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 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 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, 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 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 12000, 1200, rotation 30")
|
||||
<< 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 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")
|
||||
<< 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")
|
||||
<< 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")
|
||||
<< 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));
|
||||
// distance from the center to the focus
|
||||
|
||||
QPointF focus1 = static_cast<QPointF>(center);
|
||||
QPointF focus2 = static_cast<QPointF>(center);
|
||||
auto focus1 = static_cast<QPointF>(center);
|
||||
auto focus2 = static_cast<QPointF>(center);
|
||||
|
||||
if (radius1 < radius2)
|
||||
if (qAbs(radius1) < qAbs(radius2))
|
||||
{
|
||||
focus1.setY(focus1.ry() + c);
|
||||
QLineF line(static_cast<QPointF>(center), focus1);
|
||||
|
@ -354,7 +783,7 @@ void TST_VEllipticalArc::TestGetPoints2()
|
|||
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);
|
||||
line.setAngle(line.angle() + rotationAngle);
|
||||
ellipsePoint = line.p2();
|
||||
|
@ -401,7 +830,7 @@ void TST_VEllipticalArc::TestGetPoints3()
|
|||
|
||||
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
||||
{ // 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 arcSquare = qAbs(VAbstractPiece::SumTrapezoids(points) / 2.0);
|
||||
const qreal diffSquare = qAbs(ellipseSquare - arcSquare);
|
||||
|
@ -430,9 +859,15 @@ void TST_VEllipticalArc::TestGetPoints4()
|
|||
|
||||
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
||||
{ // calculated full ellipse length
|
||||
const qreal h = ((radius1 - radius2) * (radius1 - radius2)) / ((radius1 + radius2) * (radius1 + radius2));
|
||||
const qreal ellipseLength = M_PI * (radius1 + radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h)));
|
||||
const qreal epsLength = ToPixel(1, Unit::Mm); // computing error
|
||||
const qreal h = ((qAbs(radius1) - qAbs(radius2)) * (qAbs(radius1) - qAbs(radius2))) /
|
||||
((qAbs(radius1) + qAbs(radius2)) * (qAbs(radius1) + qAbs(radius2)));
|
||||
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 diffLength = qAbs(arcLength - ellipseLength);
|
||||
// cppcheck-suppress unreadVariable
|
||||
|
@ -487,17 +922,37 @@ void TST_VEllipticalArc::TestGetPoints5()
|
|||
|
||||
if (points.size() > 2 && qFuzzyIsNull(rotationAngle))
|
||||
{
|
||||
const qreal testAccuracy = ToPixel(1.5, Unit::Mm);
|
||||
ComparePointsDistance(arc.GetP1(), points.constFirst(), testAccuracy);
|
||||
ComparePointsDistance(arc.GetP2(), points.constLast(), testAccuracy);
|
||||
Q_RELAXED_CONSTEXPR qreal testAccuracy = ToPixel(1.5, Unit::Mm);
|
||||
|
||||
if (!arc.IsFlipped())
|
||||
{
|
||||
ComparePointsDistance(arc.GetP1(), points.constFirst(), 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;
|
||||
|
||||
f1 = QLineF(static_cast<QPointF>(center), points.constFirst()).angle();
|
||||
QVERIFY2(f1 - stAngle <= eps, qUtf8Printable(QStringLiteral("f1: %1; expected: %2").arg(f1).arg(stAngle)));
|
||||
if (!arc.IsFlipped())
|
||||
{
|
||||
f1 = QLineF(static_cast<QPointF>(center), points.constFirst()).angle();
|
||||
QVERIFY2(f1 - stAngle <= eps, qUtf8Printable(QStringLiteral("f1: %1; expected: %2").arg(f1).arg(stAngle)));
|
||||
|
||||
f2 = QLineF(static_cast<QPointF>(center), points.constLast()).angle();
|
||||
QVERIFY2(f2 - enAngle <= eps, qUtf8Printable(QStringLiteral("f2: %1; expected: %2").arg(f2).arg(enAngle)));
|
||||
f2 = QLineF(static_cast<QPointF>(center), points.constLast()).angle();
|
||||
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<QString>("prefix");
|
||||
|
||||
QTest::newRow("Test el arc 1") << 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 3.2") << QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 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 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 5") << QPointF(10, 10) << 10. << 20.0 << 0. << 180. << 90. << 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 7") << QPointF(10, 10) << 10. << 20.0 << 0. << 270. << 90. << 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 1, +r, +r") << 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 1, +r, -r") << 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, +r, +r") << QPointF() << 10. << 20.0 << 0. << 90. << 0. << 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 2, +r, -r") << QPointF() << 10. << -20.0 << 0. << 90. << 0. << 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 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()
|
||||
{
|
||||
QTest::addColumn<VEllipticalArc>("elArc");
|
||||
QTest::addColumn<qreal>("radius1");
|
||||
QTest::addColumn<qreal>("radius2");
|
||||
QTest::addColumn<QLineF>("axis");
|
||||
QTest::addColumn<QString>("prefix");
|
||||
|
||||
const VEllipticalArc elArc(VPointF(), 10., 20.0, 1., 91., 0.);
|
||||
|
||||
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));
|
||||
|
||||
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.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()
|
||||
{
|
||||
QFETCH(VEllipticalArc, elArc);
|
||||
QFETCH(qreal, radius1);
|
||||
QFETCH(qreal, radius2);
|
||||
QFETCH(QLineF, axis);
|
||||
QFETCH(QString, prefix);
|
||||
|
||||
const VEllipticalArc elArc(VPointF(), radius1, radius2, 1., 91., 0.);
|
||||
|
||||
const VEllipticalArc res = elArc.Flip(axis, prefix);
|
||||
|
||||
// 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));
|
||||
|
||||
QCOMPARE(qRound(elArc.GetLength() * -1), qRound(res.GetLength()));
|
||||
|
|
|
@ -44,14 +44,15 @@ public:
|
|||
private slots:
|
||||
void CompareTwoWays_data();
|
||||
void CompareTwoWays();
|
||||
void NegativeArc();
|
||||
void ArcByLength_data();
|
||||
void ArcByLength();
|
||||
void TestGetPoints1_data();
|
||||
void TestGetPoints2_data();
|
||||
void TestGetPoints3_data();
|
||||
void TestGetPoints4_data();
|
||||
void TestGetPoints1();
|
||||
void TestGetPoints2_data();
|
||||
void TestGetPoints2();
|
||||
void TestGetPoints3_data();
|
||||
void TestGetPoints3();
|
||||
void TestGetPoints4_data();
|
||||
void TestGetPoints4();
|
||||
void TestGetPoints5_data();
|
||||
void TestGetPoints5();
|
||||
|
|
Loading…
Reference in New Issue
Block a user