diff --git a/ChangeLog.txt b/ChangeLog.txt index c78561eaa..9285536dc 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -15,6 +15,7 @@ - [#916] Improve layout generation. - [#965] Control passmark length with formula. - New placelabel shape Circle. +- Two new passmark types: U and Box. # Version 0.6.2 (unreleased) - [#903] Bug in tool Cut Spline path. diff --git a/src/libs/ifc/schema/pattern/v0.8.4.xsd b/src/libs/ifc/schema/pattern/v0.8.4.xsd index a9b06e259..f4d2b56d3 100644 --- a/src/libs/ifc/schema/pattern/v0.8.4.xsd +++ b/src/libs/ifc/schema/pattern/v0.8.4.xsd @@ -1051,6 +1051,8 @@ + + diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 94308d80b..37985ad38 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -477,6 +477,8 @@ const QString strThree = QStringLiteral("three"); Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTMark, (QLatin1String("tMark"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark, (QLatin1String("vMark"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark2, (QLatin1String("vMark2"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUMark, (QLatin1String("uMark"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBoxMark, (QLatin1String("boxMark"))) //--------------------------------------------------------------------------------------------------------------------- QString PassmarkLineTypeToString(PassmarkLineType type) @@ -495,6 +497,10 @@ QString PassmarkLineTypeToString(PassmarkLineType type) return *strVMark; case PassmarkLineType::VMark2: return *strVMark2; + case PassmarkLineType::UMark: + return *strUMark; + case PassmarkLineType::BoxMark: + return *strBoxMark; default: break; } @@ -505,7 +511,7 @@ QString PassmarkLineTypeToString(PassmarkLineType type) //--------------------------------------------------------------------------------------------------------------------- PassmarkLineType StringToPassmarkLineType(const QString &value) { - const QStringList values{strOne, strTwo, strThree, *strTMark, *strVMark, *strVMark2}; + const QStringList values{strOne, strTwo, strThree, *strTMark, *strVMark, *strVMark2, *strUMark, *strBoxMark}; switch(values.indexOf(value)) { @@ -521,6 +527,10 @@ PassmarkLineType StringToPassmarkLineType(const QString &value) return PassmarkLineType::VMark; case 5: // strVMark2 return PassmarkLineType::VMark2; + case 6: // strUMark + return PassmarkLineType::UMark; + case 7: // strBoxMark + return PassmarkLineType::BoxMark; default: break; } diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index d09b3bd75..a89994099 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -104,7 +104,9 @@ enum class PassmarkLineType : unsigned char ThreeLines, TMark, VMark, - VMark2 + VMark2, + UMark, + BoxMark }; QString PassmarkLineTypeToString(PassmarkLineType type); diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 6601067ed..87639bf92 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -31,6 +31,7 @@ #include "../vgeometry/vpointf.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vplacelabelitem.h" +#include "../vgeometry/varc.h" #include "vcontainer.h" #include "../vmisc/vabstractapplication.h" #include "../ifc/exception/vexceptioninvalidnotch.h" @@ -195,6 +196,20 @@ 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) { @@ -204,25 +219,143 @@ QVector CreateVMark2Passmark(const QLineF &line, const QVector QLineF l2 = QLineF(line.p2(), line.p1()); l2.setAngle(l2.angle() - 35); - auto FindIntersection = [seamAllowance](const QLineF &line) - { - 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 lines; - lines.append(FindIntersection(l1)); - lines.append(FindIntersection(l2)); + lines.append(FindIntersection(l1, seamAllowance)); + lines.append(FindIntersection(l2, seamAllowance)); return lines; } +//--------------------------------------------------------------------------------------------------------------------- +QVector PointsToSegments(const QVector &points) +{ + QVector lines; + if (points.size() >= 2) + { + for (int i=0; i < points.size()-1; ++i) + { + QLineF segment = QLineF(points.at(i), points.at(i+1)); + if (segment.length() > 0) + { + lines.append(segment); + } + } + } + return lines; +} + +const qreal passmarkRadiusFactor = 0.45; + +//--------------------------------------------------------------------------------------------------------------------- +QVector CreateUMarkPassmark(const QLineF &line, const QVector &seamAllowance) +{ + const qreal radius = line.length() * passmarkRadiusFactor; + + QPointF l1p1; + { + QLineF line1 = line; + line1.setAngle(line1.angle() + 90); + line1.setLength(radius); + l1p1 = line1.p2(); + } + + QPointF l2p1; + { + QLineF line2 = line; + line2.setAngle(line2.angle() - 90); + line2.setLength(radius); + l2p1 = line2.p2(); + } + + QPointF l1p2; + { + QLineF line1 = QLineF(line.p2(), line.p1()); + line1.setAngle(line1.angle() - 90); + line1.setLength(radius); + l1p2 = line1.p2(); + } + + QPointF l2p2; + { + QLineF line2 = QLineF(line.p2(), line.p1()); + line2.setAngle(line2.angle() + 90); + line2.setLength(radius); + l2p2 = line2.p2(); + } + + QLineF axis = QLineF(line.p2(), line.p1()); + axis.setLength(radius); + + QVector points; + + QLineF seg = FindIntersection(QLineF(l2p2, l2p1), seamAllowance); + seg = QLineF(seg.p2(), seg.p1()); + seg.setLength(seg.length() - radius); + points.append(seg.p1()); + points.append(seg.p2()); + + VArc arc(VPointF(axis.p2()), radius, QLineF(l1p2, l2p2).angle(), QLineF(l1p2, l2p2).angle()+180); + arc.SetApproximationScale(10); + points += arc.GetPoints(); + + seg = FindIntersection(QLineF(l1p2, l1p1), seamAllowance); + seg = QLineF(seg.p2(), seg.p1()); + seg.setLength(seg.length() - radius); + points.append(seg.p2()); + points.append(seg.p1()); + + return PointsToSegments(points); +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector CreateBoxMarkPassmark(const QLineF &line, const QVector &seamAllowance) +{ + const qreal radius = line.length() * passmarkRadiusFactor; + + QPointF l1p1; + { + QLineF line1 = line; + line1.setAngle(line1.angle() + 90); + line1.setLength(radius); + l1p1 = line1.p2(); + } + + QPointF l2p1; + { + QLineF line2 = line; + line2.setAngle(line2.angle() - 90); + line2.setLength(radius); + l2p1 = line2.p2(); + } + + QPointF l1p2; + { + QLineF line1 = QLineF(line.p2(), line.p1()); + line1.setAngle(line1.angle() - 90); + line1.setLength(radius); + l1p2 = line1.p2(); + } + + QPointF l2p2; + { + QLineF line2 = QLineF(line.p2(), line.p1()); + line2.setAngle(line2.angle() + 90); + line2.setLength(radius); + l2p2 = line2.p2(); + } + + QVector points; + + QLineF seg = FindIntersection(QLineF(l1p2, l1p1), seamAllowance); + points.append(seg.p2()); + points.append(seg.p1()); + + seg = FindIntersection(QLineF(l2p2, l2p1), seamAllowance); + points.append(seg.p1()); + points.append(seg.p2()); + + return PointsToSegments(points); +} + //--------------------------------------------------------------------------------------------------------------------- QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType angleType, const QLineF &line, const QVector &seamAllowance) @@ -254,6 +387,12 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType case PassmarkLineType::VMark2: passmarksLines += CreateVMark2Passmark(line, seamAllowance); break; + case PassmarkLineType::UMark: + passmarksLines += CreateUMarkPassmark(line, seamAllowance); + break; + case PassmarkLineType::BoxMark: + passmarksLines += CreateBoxMarkPassmark(line, seamAllowance); + break; case PassmarkLineType::OneLine: default: passmarksLines.append(line); @@ -272,6 +411,8 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType case PassmarkLineType::ThreeLines: case PassmarkLineType::VMark: case PassmarkLineType::VMark2: + case PassmarkLineType::UMark: + case PassmarkLineType::BoxMark: default: passmarksLines.append(line); break; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index b5a7fdaf0..2767e3f07 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -433,6 +433,12 @@ QString DialogTool::GetNodeName(const VPieceNode &node, bool showDetails) const case PassmarkLineType::VMark2: name += QStringLiteral("⊽"); break; + case PassmarkLineType::UMark: + name += QStringLiteral("⋃"); + break; + case PassmarkLineType::BoxMark: + name += QStringLiteral("⎕"); + break; default: break; } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index e578b1606..1b6139e53 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -584,6 +584,12 @@ void DialogPiecePath::PassmarkChanged(int index) case PassmarkLineType::VMark2: ui->radioButtonVMark2->setChecked(true); break; + case PassmarkLineType::UMark: + ui->radioButtonUMark->setChecked(true); + break; + case PassmarkLineType::BoxMark: + ui->radioButtonBoxMark->setChecked(true); + break; default: break; } @@ -692,6 +698,14 @@ void DialogPiecePath::PassmarkLineTypeChanged(int id) { lineType = PassmarkLineType::VMark2; } + else if (id == ui->buttonGroupMarkType->id(ui->radioButtonUMark)) + { + lineType = PassmarkLineType::UMark; + } + else if (id == ui->buttonGroupMarkType->id(ui->radioButtonBoxMark)) + { + lineType = PassmarkLineType::BoxMark; + } rowNode.SetPassmarkLineType(lineType); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui index 26a579574..9ef8c80b0 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui @@ -1244,6 +1244,26 @@ + + + + U mark + + + buttonGroupMarkType + + + + + + + Box mark + + + buttonGroupMarkType + + + diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 1f3981c36..cd62479d8 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -1088,6 +1088,12 @@ void DialogSeamAllowance::PassmarkChanged(int index) case PassmarkLineType::VMark2: uiTabPassmarks->radioButtonVMark2->setChecked(true); break; + case PassmarkLineType::UMark: + uiTabPassmarks->radioButtonUMark->setChecked(true); + break; + case PassmarkLineType::BoxMark: + uiTabPassmarks->radioButtonBoxMark->setChecked(true); + break; default: break; } @@ -1481,6 +1487,14 @@ void DialogSeamAllowance::PassmarkLineTypeChanged(int id) { lineType = PassmarkLineType::VMark2; } + else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonUMark)) + { + lineType = PassmarkLineType::UMark; + } + else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonBoxMark)) + { + lineType = PassmarkLineType::BoxMark; + } rowNode.SetPassmarkLineType(lineType); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui index c0322f180..8cab69636 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui @@ -367,6 +367,26 @@ + + + + U mark + + + buttonGroupLineType + + + + + + + Box mark + + + buttonGroupLineType + + +