Resolved issue #932. 2nd version V passmarks.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-01-24 09:26:57 +02:00
parent 68e3836510
commit 864d3568c0
14 changed files with 1252 additions and 22 deletions

View File

@ -9,6 +9,7 @@
- [#927] Freeze prefix language on pattern/project creation.
- [#929] New variable type: Separator.
- Speed optimization for switching "In layout" state.
- [#932] 2nd version V passmarks.
# Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path.

View File

@ -52,6 +52,7 @@
<file>schema/pattern/v0.7.12.xsd</file>
<file>schema/pattern/v0.7.13.xsd</file>
<file>schema/pattern/v0.8.0.xsd</file>
<file>schema/pattern/v0.8.1.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

File diff suppressed because it is too large Load Diff

View File

@ -59,8 +59,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.0");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.0.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.1");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.1.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -230,7 +230,8 @@ QString VPatternConverter::XSDSchema(int ver) const
std::make_pair(FORMAT_VERSION(0, 7, 11), QStringLiteral("://schema/pattern/v0.7.11.xsd")),
std::make_pair(FORMAT_VERSION(0, 7, 12), QStringLiteral("://schema/pattern/v0.7.12.xsd")),
std::make_pair(FORMAT_VERSION(0, 7, 13), QStringLiteral("://schema/pattern/v0.7.13.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 0), CurrentSchema)
std::make_pair(FORMAT_VERSION(0, 8, 0), QStringLiteral("://schema/pattern/v0.8.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 1), CurrentSchema)
};
if (schemas.contains(ver))
@ -451,6 +452,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 0)), m_convertedFileName);
V_FALLTHROUGH
case (FORMAT_VERSION(0, 8, 0)):
ToV0_8_1();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 1)), m_convertedFileName);
V_FALLTHROUGH
case (FORMAT_VERSION(0, 8, 1)):
break;
default:
InvalidVersion(m_ver);
@ -468,7 +473,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 0),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 1),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@ -1038,6 +1043,16 @@ void VPatternConverter::ToV0_8_0()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_8_1()
{
// TODO. Delete if minimal supported version is 0.8.1
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 1),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.8.1"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 0);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 1);
protected:
virtual int MinVer() const override;
@ -123,6 +123,7 @@ private:
void ToV0_7_12();
void ToV0_7_13();
void ToV0_8_0();
void ToV0_8_1();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -495,6 +495,7 @@ 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")))
//---------------------------------------------------------------------------------------------------------------------
QString PassmarkLineTypeToString(PassmarkLineType type)
@ -511,6 +512,8 @@ QString PassmarkLineTypeToString(PassmarkLineType type)
return *strTMark;
case PassmarkLineType::VMark:
return *strVMark;
case PassmarkLineType::VMark2:
return *strVMark2;
default:
break;
}
@ -521,7 +524,7 @@ QString PassmarkLineTypeToString(PassmarkLineType type)
//---------------------------------------------------------------------------------------------------------------------
PassmarkLineType StringToPassmarkLineType(const QString &value)
{
const QStringList values = QStringList() << strOne << strTwo << strThree << *strTMark << *strVMark;
const QStringList values{strOne, strTwo, strThree, *strTMark, *strVMark, *strVMark2};
switch(values.indexOf(value))
{
@ -535,6 +538,8 @@ PassmarkLineType StringToPassmarkLineType(const QString &value)
return PassmarkLineType::TMark;
case 4: // strVMark
return PassmarkLineType::VMark;
case 5: // strVMark2
return PassmarkLineType::VMark2;
default:
break;
}

View File

@ -108,7 +108,8 @@ enum class PassmarkLineType : unsigned char
TwoLines,
ThreeLines,
TMark,
VMark
VMark,
VMark2
};
QString PassmarkLineTypeToString(PassmarkLineType type);

View File

@ -196,7 +196,36 @@ QVector<QLineF> CreateVMarkPassmark(const QLineF &line)
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType angleType, const QLineF &line)
QVector<QLineF> CreateVMark2Passmark(const QLineF &line, const QVector<QPointF> &seamAllowance)
{
QLineF l1 = QLineF(line.p2(), line.p1());
l1.setAngle(l1.angle() + 35);
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));
return lines;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType angleType, const QLineF &line,
const QVector<QPointF> &seamAllowance)
{
QVector<QLineF> passmarksLines;
@ -222,6 +251,9 @@ QVector<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType
case PassmarkLineType::VMark:
passmarksLines += CreateVMarkPassmark(line);
break;
case PassmarkLineType::VMark2:
passmarksLines += CreateVMark2Passmark(line, seamAllowance);
break;
case PassmarkLineType::OneLine:
default:
passmarksLines.append(line);
@ -239,6 +271,7 @@ QVector<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType
case PassmarkLineType::TwoLines:
case PassmarkLineType::ThreeLines:
case PassmarkLineType::VMark:
case PassmarkLineType::VMark2:
default:
passmarksLines.append(line);
break;
@ -1309,6 +1342,8 @@ QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int prev
passmarkData.passmarkLineType = path.at(passmarkIndex).GetPassmarkLineType();
passmarkData.passmarkAngleType = path.at(passmarkIndex).GetPassmarkAngleType();
const QVector<QPointF> mainPath = MainPathPoints(data);
if (not IsSeamAllowanceBuiltIn())
{
// Because rollback cannot be calulated if passmark is not first point in main path we rotate it.
@ -1327,12 +1362,12 @@ QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int prev
&& path.at(passmarkIndex).GetPassmarkAngleType() != PassmarkAngleType::Intersection2OnlyRight
&& path.at(passmarkIndex).IsShowSecondPassmark())
{
lines += BuiltInSAPassmark(passmarkData);
lines += BuiltInSAPassmark(passmarkData, mainPath);
}
return lines;
}
return BuiltInSAPassmark(passmarkData);
return BuiltInSAPassmark(passmarkData, mainPath);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1381,7 +1416,7 @@ QVector<QLineF> VPiece::SAPassmark(const VPiecePassmarkData &passmarkData, const
line.setLength(qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength));
passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType,
line);
line, seamAllowance);
}
else
{
@ -1404,7 +1439,8 @@ QVector<QLineF> VPiece::SAPassmark(const VPiecePassmarkData &passmarkData, const
{
QLineF line = QLineF(seamPassmarkSAPoint, passmarkData.passmarkSAPoint);
line.setLength(passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth));
passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, line);
passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, line,
seamAllowance);
}
else if (passmarkData.passmarkAngleType == PassmarkAngleType::Bisector)
{
@ -1457,7 +1493,7 @@ QVector<QLineF> VPiece::SAPassmark(const VPiecePassmarkData &passmarkData, const
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QLineF> VPiece::BuiltInSAPassmark(const VPiecePassmarkData &passmarkData)
QVector<QLineF> VPiece::BuiltInSAPassmark(const VPiecePassmarkData &passmarkData, const QVector<QPointF> &mainPath)
{
QVector<QLineF> passmarksLines;
@ -1467,7 +1503,8 @@ QVector<QLineF> VPiece::BuiltInSAPassmark(const VPiecePassmarkData &passmarkData
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.);
edge1.setLength(passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth));
passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, edge1);
passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, edge1,
mainPath);
return passmarksLines;
}
@ -1524,5 +1561,5 @@ QVector<QLineF> VPiece::PassmarkBisector(PassmarkStatus seamPassmarkType, const
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.);
edge1.setLength(passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth));
return CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, edge1);
return CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, edge1, seamAllowance);
}

View File

@ -181,7 +181,7 @@ private:
QVector<QLineF> CreatePassmark(const QVector<VPieceNode> &path, int previousIndex, int passmarkIndex, int nextIndex,
const VContainer *data) const;
static QVector<QLineF> BuiltInSAPassmark(const VPiecePassmarkData &passmarkData);
static QVector<QLineF> BuiltInSAPassmark(const VPiecePassmarkData &passmarkData, const QVector<QPointF> &mainPath);
static QVector<QLineF> PassmarkBisector(PassmarkStatus seamPassmarkType, const VPiecePassmarkData &passmarkData,
const QPointF &seamPassmarkSAPoint, const QVector<QPointF>& seamAllowance);

View File

@ -689,10 +689,13 @@ QString DialogTool::GetNodeName(const VPieceNode &node, bool showDetails) const
name += QLatin1Literal("|||");
break;
case PassmarkLineType::TMark:
name += QString("");
name += QStringLiteral("");
break;
case PassmarkLineType::VMark:
name += QLatin1Char('^');
name += QStringLiteral("");
break;
case PassmarkLineType::VMark2:
name += QStringLiteral("");
break;
default:
break;

View File

@ -486,6 +486,7 @@ void DialogPiecePath::PassmarkChanged(int index)
ui->radioButtonThreeLines->setDisabled(true);
ui->radioButtonTMark->setDisabled(true);
ui->radioButtonVMark->setDisabled(true);
ui->radioButtonVMark2->setDisabled(true);
ui->radioButtonStraightforward->setDisabled(true);
ui->radioButtonBisector->setDisabled(true);
@ -516,6 +517,7 @@ void DialogPiecePath::PassmarkChanged(int index)
ui->radioButtonThreeLines->setEnabled(true);
ui->radioButtonTMark->setEnabled(true);
ui->radioButtonVMark->setEnabled(true);
ui->radioButtonVMark2->setEnabled(true);
switch(node.GetPassmarkLineType())
{
@ -534,6 +536,9 @@ void DialogPiecePath::PassmarkChanged(int index)
case PassmarkLineType::VMark:
ui->radioButtonVMark->setChecked(true);
break;
case PassmarkLineType::VMark2:
ui->radioButtonVMark2->setChecked(true);
break;
default:
break;
}
@ -642,6 +647,10 @@ void DialogPiecePath::PassmarkLineTypeChanged(int id)
{
lineType = PassmarkLineType::VMark;
}
else if (id == ui->buttonGroupMarkType->id(ui->radioButtonVMark2))
{
lineType = PassmarkLineType::VMark2;
}
rowNode.SetPassmarkLineType(lineType);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));

View File

@ -992,6 +992,9 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Acute angle that looks inside of piece</string>
</property>
<property name="text">
<string>V mark</string>
</property>
@ -1000,6 +1003,22 @@
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonVMark2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Acute angle that looks outside of piece</string>
</property>
<property name="text">
<string>V mark 2</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupMarkType</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
@ -1430,7 +1449,7 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroupAngleType"/>
<buttongroup name="buttonGroupMarkType"/>
<buttongroup name="buttonGroupAngleType"/>
</buttongroups>
</ui>

View File

@ -998,6 +998,7 @@ void DialogSeamAllowance::PassmarkChanged(int index)
uiTabPassmarks->radioButtonThreeLines->setDisabled(true);
uiTabPassmarks->radioButtonTMark->setDisabled(true);
uiTabPassmarks->radioButtonVMark->setDisabled(true);
uiTabPassmarks->radioButtonVMark2->setDisabled(true);
uiTabPassmarks->radioButtonStraightforward->setDisabled(true);
uiTabPassmarks->radioButtonBisector->setDisabled(true);
@ -1028,6 +1029,7 @@ void DialogSeamAllowance::PassmarkChanged(int index)
uiTabPassmarks->radioButtonThreeLines->setEnabled(true);
uiTabPassmarks->radioButtonTMark->setEnabled(true);
uiTabPassmarks->radioButtonVMark->setEnabled(true);
uiTabPassmarks->radioButtonVMark2->setEnabled(true);
switch(node.GetPassmarkLineType())
{
@ -1046,6 +1048,9 @@ void DialogSeamAllowance::PassmarkChanged(int index)
case PassmarkLineType::VMark:
uiTabPassmarks->radioButtonVMark->setChecked(true);
break;
case PassmarkLineType::VMark2:
uiTabPassmarks->radioButtonVMark2->setChecked(true);
break;
default:
break;
}
@ -1442,6 +1447,10 @@ void DialogSeamAllowance::PassmarkLineTypeChanged(int id)
{
lineType = PassmarkLineType::VMark;
}
else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonVMark2))
{
lineType = PassmarkLineType::VMark2;
}
rowNode.SetPassmarkLineType(lineType);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>352</width>
<height>567</height>
<height>594</height>
</rect>
</property>
<property name="windowTitle">
@ -25,7 +25,7 @@
<x>0</x>
<y>0</y>
<width>332</width>
<height>547</height>
<height>574</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -112,6 +112,9 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Acute angle that looks intside of piece</string>
</property>
<property name="text">
<string>V mark</string>
</property>
@ -120,6 +123,22 @@
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonVMark2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Acute angle that looks outside of piece</string>
</property>
<property name="text">
<string>V mark 2</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupLineType</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
@ -289,7 +308,7 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroupAngleType"/>
<buttongroup name="buttonGroupLineType"/>
<buttongroup name="buttonGroupAngleType"/>
</buttongroups>
</ui>