From 670f08eb9bb10d71d33369caa349f28752100d69 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 30 Nov 2023 11:51:14 +0200 Subject: [PATCH] Include external V notch as part of a cut boundary. --- src/libs/vlayout/vboundary.cpp | 61 +++++++++++++++++++++++++------ src/libs/vlayout/vboundary.h | 2 +- src/libs/vpatterndb/vpassmark.cpp | 2 +- 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/libs/vlayout/vboundary.cpp b/src/libs/vlayout/vboundary.cpp index de344fc01..022b204fe 100644 --- a/src/libs/vlayout/vboundary.cpp +++ b/src/libs/vlayout/vboundary.cpp @@ -87,7 +87,6 @@ auto PrepareSequenceItem(const QVector &path, bool drawMode, VBoun //--------------------------------------------------------------------------------------------------------------------- auto PrepareTPassmarkShape(const VLayoutPassmark &passmark, bool drawMode) -> QVector> { - QVector shape1; if (passmark.lines.isEmpty()) { return {}; @@ -101,6 +100,7 @@ auto PrepareTPassmarkShape(const VLayoutPassmark &passmark, bool drawMode) -> QV }; QLineF line1 = passmark.lines.constFirst(); + QVector shape1; shape1.append(TurnPoint(line1.p1())); shape1.append(TurnPoint(line1.p2())); @@ -126,6 +126,50 @@ auto PrepareTPassmarkShape(const VLayoutPassmark &passmark, bool drawMode) -> QV return {shape1, shape2}; } +//--------------------------------------------------------------------------------------------------------------------- +auto PrepareExternalVPassmarkShape(const VLayoutPassmark &passmark, bool drawMode) -> QVector> +{ + if (passmark.lines.isEmpty()) + { + return {}; + } + + auto TurnPoint = [](QPointF point) + { + VLayoutPoint p(point); + p.SetTurnPoint(true); + return p; + }; + + QLineF line1 = passmark.lines.constFirst(); + QVector shape; + + if (!drawMode) + { + shape.append(TurnPoint(line1.p2())); + } + + shape.append(TurnPoint(line1.p1())); + shape.append(TurnPoint(line1.p2())); + + if (passmark.lines.size() <= 1) + { + return {shape}; + } + + const QLineF &line2 = passmark.lines.constLast(); + + shape.append(TurnPoint(line2.p1())); + shape.append(TurnPoint(line2.p2())); + + if (!drawMode) + { + shape.append(TurnPoint(line2.p1())); + } + + return {shape}; +} + //--------------------------------------------------------------------------------------------------------------------- auto PrepareNoneBreakingPassmarkShape(const VLayoutPassmark &passmark) -> QVector> { @@ -229,17 +273,15 @@ auto PreparePassmarkShape(const VLayoutPassmark &passmark, bool drawMode) -> QVe { case PassmarkLineType::OneLine: case PassmarkLineType::InternalVMark: - case PassmarkLineType::ExternalVMark: case PassmarkLineType::BoxMark: case PassmarkLineType::CheckMark: return PrepareNoneBreakingPassmarkShape(passmark); - break; + case PassmarkLineType::ExternalVMark: + return PrepareExternalVPassmarkShape(passmark, drawMode); case PassmarkLineType::TMark: return PrepareTPassmarkShape(passmark, drawMode); - break; case PassmarkLineType::UMark: return PrepareUPassmarkShape(passmark); - break; default: break; } @@ -511,7 +553,7 @@ auto VBoundary::Combine(const QVector &passmarks, bool drawMode for (const auto &passmark : passmarks) { - if (SkipPassmark(passmark, drawMode, layoutAllowance)) + if (SkipPassmark(passmark, layoutAllowance)) { continue; } @@ -550,7 +592,7 @@ auto VBoundary::Combine(const QVector &passmarks, bool drawMode } //--------------------------------------------------------------------------------------------------------------------- -auto VBoundary::SkipPassmark(const VLayoutPassmark &passmark, bool drawMode, bool layoutAllowance) const -> bool +auto VBoundary::SkipPassmark(const VLayoutPassmark &passmark, bool layoutAllowance) const -> bool { if (m_seamAllowance) { @@ -574,11 +616,6 @@ auto VBoundary::SkipPassmark(const VLayoutPassmark &passmark, bool drawMode, boo return true; } - if (!drawMode && passmark.type == PassmarkLineType::ExternalVMark) - { - return true; - } - return false; } diff --git a/src/libs/vlayout/vboundary.h b/src/libs/vlayout/vboundary.h index 3d5cab5a6..41a4ced23 100644 --- a/src/libs/vlayout/vboundary.h +++ b/src/libs/vlayout/vboundary.h @@ -70,7 +70,7 @@ private: bool m_builtInSeamAllowance; QString m_pieceName{}; - auto SkipPassmark(const VLayoutPassmark &passmark, bool drawMode, bool layoutAllowance) const -> bool; + auto SkipPassmark(const VLayoutPassmark &passmark, bool layoutAllowance) const -> bool; void InsertPassmark(const VBoundarySequenceItemData &item, QList &sequence, bool drawMode) const; diff --git a/src/libs/vpatterndb/vpassmark.cpp b/src/libs/vpatterndb/vpassmark.cpp index 93e47ee62..fb6c453a2 100644 --- a/src/libs/vpatterndb/vpassmark.cpp +++ b/src/libs/vpatterndb/vpassmark.cpp @@ -384,7 +384,7 @@ auto CreateExternalVMarkPassmark(const VPiecePassmarkData &passmarkData, const Q QLineF l2 = line; l2.setAngle(l2.angle() + angle); - return {l1, {l2.p2(), l2.p1()}}; + return {{l1.p2(), l1.p1()}, l2}; } //---------------------------------------------------------------------------------------------------------------------