Two new passmark types: U and Box.
--HG-- branch : develop
This commit is contained in:
parent
57d6d79a53
commit
2c58263df1
|
@ -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.
|
||||
|
|
|
@ -1051,6 +1051,8 @@
|
|||
<xs:enumeration value="tMark"/>
|
||||
<xs:enumeration value="vMark"/>
|
||||
<xs:enumeration value="vMark2"/>
|
||||
<xs:enumeration value="uMark"/>
|
||||
<xs:enumeration value="boxMark"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="passmarkAngleType">
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,9 @@ enum class PassmarkLineType : unsigned char
|
|||
ThreeLines,
|
||||
TMark,
|
||||
VMark,
|
||||
VMark2
|
||||
VMark2,
|
||||
UMark,
|
||||
BoxMark
|
||||
};
|
||||
|
||||
QString PassmarkLineTypeToString(PassmarkLineType type);
|
||||
|
|
|
@ -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<QLineF> CreateVMarkPassmark(const QLineF &line)
|
|||
return lines;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QLineF FindIntersection(const QLineF &line, const QVector<QPointF> &seamAllowance)
|
||||
{
|
||||
QLineF testLine = line;
|
||||
testLine.setLength(testLine.length()*10);
|
||||
QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine);
|
||||
if (not intersections.isEmpty())
|
||||
{
|
||||
return QLineF(line.p1(), intersections.last());
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QLineF> CreateVMark2Passmark(const QLineF &line, const QVector<QPointF> &seamAllowance)
|
||||
{
|
||||
|
@ -204,25 +219,143 @@ QVector<QLineF> CreateVMark2Passmark(const QLineF &line, const QVector<QPointF>
|
|||
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<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine);
|
||||
if (not intersections.isEmpty())
|
||||
{
|
||||
return QLineF(line.p1(), intersections.last());
|
||||
}
|
||||
|
||||
return line;
|
||||
};
|
||||
|
||||
QVector<QLineF> lines;
|
||||
lines.append(FindIntersection(l1));
|
||||
lines.append(FindIntersection(l2));
|
||||
lines.append(FindIntersection(l1, seamAllowance));
|
||||
lines.append(FindIntersection(l2, seamAllowance));
|
||||
return lines;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QLineF> PointsToSegments(const QVector<QPointF> &points)
|
||||
{
|
||||
QVector<QLineF> 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<QLineF> CreateUMarkPassmark(const QLineF &line, const QVector<QPointF> &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<QPointF> 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<QLineF> CreateBoxMarkPassmark(const QLineF &line, const QVector<QPointF> &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<QPointF> 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<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType angleType, const QLineF &line,
|
||||
const QVector<QPointF> &seamAllowance)
|
||||
|
@ -254,6 +387,12 @@ QVector<QLineF> 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<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType
|
|||
case PassmarkLineType::ThreeLines:
|
||||
case PassmarkLineType::VMark:
|
||||
case PassmarkLineType::VMark2:
|
||||
case PassmarkLineType::UMark:
|
||||
case PassmarkLineType::BoxMark:
|
||||
default:
|
||||
passmarksLines.append(line);
|
||||
break;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -1244,6 +1244,26 @@
|
|||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonUMark">
|
||||
<property name="text">
|
||||
<string>U mark</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroupMarkType</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonBoxMark">
|
||||
<property name="text">
|
||||
<string>Box mark</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroupMarkType</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -367,6 +367,26 @@
|
|||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonUMark">
|
||||
<property name="text">
|
||||
<string>U mark</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroupLineType</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonBoxMark">
|
||||
<property name="text">
|
||||
<string>Box mark</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroupLineType</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue
Block a user