From 851ed6590ce86fc319c83a10a45849015f16b4cb Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 23 Apr 2019 21:24:45 +0300 Subject: [PATCH] Correct passmark shape. It shouldn't go beyond a piece path. --HG-- branch : develop --- src/libs/vpatterndb/vpiece.cpp | 51 +++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 87639bf92..1e9e0efaa 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -74,7 +74,21 @@ QVector PieceMissingNodes(const QVector &d1Nodes, const QVecto const qreal passmarkGap = (1.5/*mm*/ / 25.4) * PrintDPI; //--------------------------------------------------------------------------------------------------------------------- -QVector CreateTwoPassmarkLines(const QLineF &line) +QLineF FindIntersection(const QLineF &line, const QVector &seamAllowance) +{ + QLineF testLine = line; + testLine.setLength(testLine.length()*10); + QVector intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine); + if (not intersections.isEmpty()) + { + return QLineF(line.p1(), intersections.last()); + } + + return line; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector CreateTwoPassmarkLines(const QLineF &line, const QVector &seamAllowance) { QPointF l1p1; { @@ -109,13 +123,16 @@ QVector CreateTwoPassmarkLines(const QLineF &line) } QVector lines; - lines.append(QLineF(l1p1, l1p2)); - lines.append(QLineF(l2p1, l2p2)); + QLineF seg = FindIntersection(QLineF(l1p2, l1p1), seamAllowance); + lines.append(QLineF(seg.p2(), seg.p1())); + + seg = FindIntersection(QLineF(l2p2, l2p1), seamAllowance); + lines.append(QLineF(seg.p2(), seg.p1())); return lines; } //--------------------------------------------------------------------------------------------------------------------- -QVector CreateThreePassmarkLines(const QLineF &line) +QVector CreateThreePassmarkLines(const QLineF &line, const QVector &seamAllowance) { QPointF l1p1; { @@ -150,9 +167,13 @@ QVector CreateThreePassmarkLines(const QLineF &line) } QVector lines; - lines.append(QLineF(l1p1, l1p2)); + QLineF seg = FindIntersection(QLineF(l1p2, l1p1), seamAllowance); + lines.append(QLineF(seg.p2(), seg.p1())); + lines.append(line); - lines.append(QLineF(l2p1, l2p2)); + + seg = FindIntersection(QLineF(l2p2, l2p1), seamAllowance); + lines.append(QLineF(seg.p2(), seg.p1())); return lines; } @@ -196,20 +217,6 @@ QVector CreateVMarkPassmark(const QLineF &line) return lines; } -//--------------------------------------------------------------------------------------------------------------------- -QLineF FindIntersection(const QLineF &line, const QVector &seamAllowance) -{ - QLineF testLine = line; - testLine.setLength(testLine.length()*10); - QVector intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine); - if (not intersections.isEmpty()) - { - return QLineF(line.p1(), intersections.last()); - } - - return line; -} - //--------------------------------------------------------------------------------------------------------------------- QVector CreateVMark2Passmark(const QLineF &line, const QVector &seamAllowance) { @@ -373,10 +380,10 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType switch (lineType) { case PassmarkLineType::TwoLines: - passmarksLines += CreateTwoPassmarkLines(line); + passmarksLines += CreateTwoPassmarkLines(line, seamAllowance); break; case PassmarkLineType::ThreeLines: - passmarksLines += CreateThreePassmarkLines(line); + passmarksLines += CreateThreePassmarkLines(line, seamAllowance); break; case PassmarkLineType::TMark: passmarksLines += CreateTMarkPassmark(line);