From 139efc6b164189a9806eb3380c25c522ec983cde Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 27 Jul 2017 16:01:18 +0300 Subject: [PATCH] Fixed issue #738. Bug in transformation over arc and elliptical arc. (grafted from 2274a082bae53cd5e10866c630e9446a1bcdaac1) --HG-- branch : develop --- ChangeLog.txt | 1 + src/libs/vgeometry/varc.cpp | 22 +++++++++++++++------- src/libs/vgeometry/vellipticalarc.cpp | 13 ++++++++++++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 8ef34f95f..bd1ec02ed 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -40,6 +40,7 @@ - Fixed behaviour on Windows. Valentina asks about synchronization measurements twice. - Fixed bug. Tape app saved default size value in wrong place. - [#737] Valentina produces corrupted file if unite two pieces with pins. +- [#738] Bug in transformation over arc and elliptical arc. # Version 0.5.0 May 9, 2017 - [#581] User can now filter input lists by keyword in function wizard. diff --git a/src/libs/vgeometry/varc.cpp b/src/libs/vgeometry/varc.cpp index beed72089..8241a0c75 100644 --- a/src/libs/vgeometry/varc.cpp +++ b/src/libs/vgeometry/varc.cpp @@ -124,11 +124,14 @@ VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &pref const QPointF p1 = VPointF::RotatePF(originPoint, GetP1(), degrees); const QPointF p2 = VPointF::RotatePF(originPoint, GetP2(), degrees); - VArc arc(center, GetRadius(), QLineF(static_cast(center), p1).angle(), - QLineF(static_cast(center), p2).angle()); + const qreal f1 = QLineF(static_cast(center), p1).angle(); + const qreal f2 = QLineF(static_cast(center), p2).angle(); + + VArc arc(center, GetRadius(), f1, f2); arc.setName(name() + prefix); arc.SetColor(GetColor()); arc.SetPenStyle(GetPenStyle()); + arc.SetFlipped(IsFlipped()); return arc; } @@ -140,12 +143,14 @@ VArc VArc::Flip(const QLineF &axis, const QString &prefix) const const QPointF p1 = VPointF::FlipPF(axis, GetP1()); const QPointF p2 = VPointF::FlipPF(axis, GetP2()); - VArc arc(center, GetRadius(), QLineF(static_cast(center), p1).angle(), - QLineF(static_cast(center), p2).angle()); + const qreal f1 = QLineF(static_cast(center), p1).angle(); + const qreal f2 = QLineF(static_cast(center), p2).angle(); + + VArc arc(center, GetRadius(), f1, f2); arc.setName(name() + prefix); - arc.SetFlipped(true); arc.SetColor(GetColor()); arc.SetPenStyle(GetPenStyle()); + arc.SetFlipped(not IsFlipped()); return arc; } @@ -157,11 +162,14 @@ VArc VArc::Move(qreal length, qreal angle, const QString &prefix) const const QPointF p1 = VPointF::MovePF(GetP1(), length, angle); const QPointF p2 = VPointF::MovePF(GetP2(), length, angle); - VArc arc(center, GetRadius(), QLineF(static_cast(center), p1).angle(), - QLineF(static_cast(center), p2).angle()); + const qreal f1 = QLineF(static_cast(center), p1).angle(); + const qreal f2 = QLineF(static_cast(center), p2).angle(); + + VArc arc(center, GetRadius(), f1, f2); arc.setName(name() + prefix); arc.SetColor(GetColor()); arc.SetPenStyle(GetPenStyle()); + arc.SetFlipped(IsFlipped()); return arc; } diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index 119a240f6..fad7f1e5c 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -127,14 +127,18 @@ VEllipticalArc &VEllipticalArc::operator =(const VEllipticalArc &arc) VEllipticalArc VEllipticalArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const { const VPointF center = GetCenter().Rotate(originPoint, degrees); + const QPointF p1 = VPointF::RotatePF(originPoint, GetP1(), degrees); const QPointF p2 = VPointF::RotatePF(originPoint, GetP2(), degrees); + const qreal f1 = QLineF(static_cast(center), p1).angle() - GetRotationAngle(); const qreal f2 = QLineF(static_cast(center), p2).angle() - GetRotationAngle(); + VEllipticalArc elArc(center, GetRadius1(), GetRadius2(), f1, f2, GetRotationAngle()); elArc.setName(name() + prefix); elArc.SetColor(GetColor()); elArc.SetPenStyle(GetPenStyle()); + elArc.SetFlipped(IsFlipped()); return elArc; } @@ -142,15 +146,18 @@ VEllipticalArc VEllipticalArc::Rotate(const QPointF &originPoint, qreal degrees, VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) const { const VPointF center = GetCenter().Flip(axis); + const QPointF p1 = VPointF::FlipPF(axis, GetP1()); const QPointF p2 = VPointF::FlipPF(axis, GetP2()); + const qreal f1 = QLineF(static_cast(center), p1).angle() - GetRotationAngle(); const qreal f2 = QLineF(static_cast(center), p2).angle() - GetRotationAngle(); + VEllipticalArc elArc(center, GetRadius1(), GetRadius2(), f1, f2, GetRotationAngle()); elArc.setName(name() + prefix); - elArc.SetFlipped(true); elArc.SetColor(GetColor()); elArc.SetPenStyle(GetPenStyle()); + elArc.SetFlipped(not IsFlipped()); return elArc; } @@ -158,14 +165,18 @@ VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) c VEllipticalArc VEllipticalArc::Move(qreal length, qreal angle, const QString &prefix) const { const VPointF center = GetCenter().Move(length, angle); + const QPointF p1 = VPointF::MovePF(GetP1(), length, angle); const QPointF p2 = VPointF::MovePF(GetP2(), length, angle); + const qreal f1 = QLineF(static_cast(center), p1).angle() - GetRotationAngle(); const qreal f2 = QLineF(static_cast(center), p2).angle() - GetRotationAngle(); + VEllipticalArc elArc(center, GetRadius1(), GetRadius2(), f1, f2, GetRotationAngle()); elArc.setName(name() + prefix); elArc.SetColor(GetColor()); elArc.SetPenStyle(GetPenStyle()); + elArc.SetFlipped(IsFlipped()); return elArc; }