From 39e68160d77225dd79d3c16b72b46fc8b5c305bf Mon Sep 17 00:00:00 2001 From: DSCaskey <31944718+DSCaskey@users.noreply.github.com> Date: Sat, 30 Nov 2024 15:17:18 -0500 Subject: [PATCH] fix notch and path line weights in pattern pieces --- src/libs/ifc/ifcdef.cpp | 6 +- src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.7.2.xsd | 1042 ++++++++++++++++++ src/libs/ifc/xml/vpatternconverter.cpp | 24 +- src/libs/ifc/xml/vpatternconverter.h | 3 +- src/libs/vlayout/vlayoutpiece.cpp | 5 +- src/libs/vtools/tools/pattern_piece_tool.cpp | 39 +- src/libs/vtools/tools/pattern_piece_tool.h | 20 +- src/libs/vwidgets/lineweight_combobox.cpp | 3 +- 9 files changed, 1106 insertions(+), 37 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.7.2.xsd diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index a3b61d33cc6b..721fc8417b8e 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -281,7 +281,8 @@ QMap lineWeightList() const QStringList lineWeights = QStringList() << "0" << "0.05" << "0.09" << "0.13" << "0.15" << "0.18" << "0.2" << "0.25" << "0.3" << "0.35" << "0.4" << "0.5" << "0.53" << "0.6" << "0.7" << "0.8" << "0.9" << "1" - << "1.06" << "1.2" << "1.4" << "1.58" << "2" << "2.11"; + << "1.06" << "1.2" << "1.4" << "1.58" << "2" << "2.11" + << "3"; for (int i = 0; i < lineWeights.size(); ++i) { @@ -357,6 +358,9 @@ QMap lineWeightList() case 23: name = "2.11mm"; break; + case 24: + name = "3.00mm"; + break; case 0: default: name = "0.00mm"; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 8aa782f5e6a8..61df19886f09 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -60,5 +60,6 @@ schema/pattern/v0.6.9.xsd schema/pattern/v0.7.0.xsd schema/pattern/v0.7.1.xsd + schema/pattern/v0.7.2.xsd diff --git a/src/libs/ifc/schema/pattern/v0.7.2.xsd b/src/libs/ifc/schema/pattern/v0.7.2.xsd new file mode 100644 index 000000000000..49d0d741b2a3 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.7.2.xsd @@ -0,0 +1,1042 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 1b8cffbf7c93..615ce30dda22 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -92,8 +92,8 @@ Q_LOGGING_CATEGORY(PatternConverter, "patternConverter") */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.1"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.1.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.2"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.2.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -350,7 +350,9 @@ QString VPatternConverter::getSchema(int ver) const case (0x000700): return QStringLiteral("://schema/pattern/v0.7.0.xsd");; case (0x000701): - qCDebug(PatternConverter, "Current schema - ://schema/pattern/v0.7.1.xsd"); + return QStringLiteral("://schema/pattern/v0.7.1.xsd");; + case (0x000702): + qCDebug(PatternConverter, "Current schema - ://schema/pattern/v0.7.2.xsd"); return CurrentSchema; default: InvalidVersion(ver); @@ -545,6 +547,10 @@ void VPatternConverter::applyPatches() ValidateXML(getSchema(0x000701), m_convertedFileName); V_FALLTHROUGH case (0x000701): + toVersion0_7_2(); + ValidateXML(getSchema(0x000702), m_convertedFileName); + V_FALLTHROUGH + case (0x000702): break; default: InvalidVersion(m_ver); @@ -563,7 +569,7 @@ void VPatternConverter::downgradeToCurrentMaxVersion() bool VPatternConverter::isReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 1), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 2), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -1409,6 +1415,16 @@ void VPatternConverter::toVersion0_7_1() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::toVersion0_7_2() +{ + // TODO. Delete if minimal supported version is 0.7.2 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 2), + "Time to refactor the code."); + setVersion(QStringLiteral("0.7.2")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index b66b1be15303..d7c214ee124c 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -80,7 +80,7 @@ class VPatternConverter : public VAbstractConverter static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 1); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 2); protected: virtual int minVer() const override; @@ -144,6 +144,7 @@ class VPatternConverter : public VAbstractConverter void toVersion0_6_9(); void toVersion0_7_0(); void toVersion0_7_1(); + void toVersion0_7_2(); void TagUnitToV0_2_0(); diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index c35521552854..5a65f1ef348e 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -1281,11 +1281,12 @@ void VLayoutPiece::createAllowanceItem(QGraphicsItem *parent) const //--------------------------------------------------------------------------------------------------------------------- void VLayoutPiece::createNotchesItem(QGraphicsItem *parent) const { - QColor color = QColor(qApp->Settings()->getDefaultNotchColor()); + QColor color = QColor(qApp->Settings()->getDefaultNotchColor()); + qreal lineWeight = ToPixel(qApp->Settings()->getDefaultCutLineweight(), Unit::Mm); QGraphicsPathItem *item = new QGraphicsPathItem(parent); item->setPath(createNotchesPath()); - item->setPen(QPen(color, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + item->setPen(QPen(color, lineWeight, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/pattern_piece_tool.cpp b/src/libs/vtools/tools/pattern_piece_tool.cpp index 8192ebf4eaf0..58a137d67992 100644 --- a/src/libs/vtools/tools/pattern_piece_tool.cpp +++ b/src/libs/vtools/tools/pattern_piece_tool.cpp @@ -911,19 +911,23 @@ void PatternPieceTool::paint(QPainter *painter, const QStyleOptionGraphicsItem * lineWeight = ToPixel(qApp->Settings()->getDefaultCutLineweight(), Unit::Mm); } - m_seamLine->setPen(QPen(color, scaleWidth(lineWeight, sceneScale(scene())), + this->setPen(QPen(color, scaleWidth(lineWeight, sceneScale(scene())), lineTypeToPenStyle(lineType), Qt::RoundCap, Qt::RoundJoin)); QBrush brush = QBrush(QColor(piece.getColor())); brush.setStyle(static_cast(fills().indexOf(QRegExp(piece.getFill())))); brush.setTransform(brush.transform().scale(150.0, 150.0)); brush.setTransform(painter->combinedTransform().inverted()); - m_seamLine->setBrush(brush); this->setBrush(brush); } + //set allowance brush + m_allowanceFill->setPen(Qt::NoPen); + //set notches pen - color = QColor(qApp->Settings()->getDefaultNotchColor()); + color = QColor(qApp->Settings()->getDefaultNotchColor()); + lineWeight = ToPixel(qApp->Settings()->getDefaultCutLineweight(), Unit::Mm); + m_notches->setPen(QPen(color, scaleWidth(lineWeight, sceneScale(scene())), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); @@ -1433,7 +1437,7 @@ PatternPieceTool::PatternPieceTool(VAbstractPattern *doc, VContainer *data, cons , m_pieceScene(scene) , m_blockName(blockName) , m_cutLine(new NonScalingFillPathItem(this)) - , m_seamLine(new NonScalingFillPathItem(this)) + , m_allowanceFill(new NonScalingFillPathItem(this)) , m_dataLabel(new VTextGraphicsItem(this)) , m_patternInfo(new VTextGraphicsItem(this)) , m_grainLine(new VGrainlineItem(this)) @@ -1508,15 +1512,13 @@ void PatternPieceTool::RefreshGeometry() if (!piece.isHideSeamLine() || !piece.IsSeamAllowance() || piece.IsSeamAllowanceBuiltIn()) { m_mainPath = QPainterPath(); - m_seamLine->setPath(m_mainPath); - m_cutLine->setBrush(QBrush(QColor(qApp->Settings()->getDefaultCutColor()), Qt::Dense7Pattern)); + m_allowanceFill->setBrush(QBrush(QColor(qApp->Settings()->getDefaultCutColor()), Qt::Dense7Pattern)); } else { m_mainPath = path; // need for returning a bounding rect when main path is not visible path = QPainterPath(); - m_seamLine->setPath(QPainterPath()); - m_cutLine->setBrush(QBrush(Qt::NoBrush)); // Disable if the main path was hidden + m_allowanceFill->setBrush(QBrush(Qt::NoBrush)); // Disable if the main path was hidden } this->setPath(path); @@ -1528,28 +1530,29 @@ void PatternPieceTool::RefreshGeometry() seamAllowancePoints = piece.SeamAllowancePoints(this->getData()); } - m_notches->setPath(piece.getNotchesPath(this->getData(), seamAllowancePoints)); - if (piece.IsSeamAllowance() && !piece.IsSeamAllowanceBuiltIn() && qApp->Settings()->showSeamAllowances()) { - path.addPath(piece.SeamAllowancePath(seamAllowancePoints)); - path.setFillRule(Qt::OddEvenFill); - m_cutPath = path; + m_cutPath = piece.SeamAllowancePath(seamAllowancePoints); m_cutLine->setPath(m_cutPath); + + QPainterPath allowancePath = path; + allowancePath.addPath(m_cutPath); + allowancePath.setFillRule(Qt::OddEvenFill); + m_allowanceFill->setPath(allowancePath); + if (piece.isHideSeamLine()) { - m_seamLine->setPath(QPainterPath()); - } - else - { - m_seamLine->setPath(m_mainPath); + this->setPath(QPainterPath()); } } else { m_cutLine->setPath(QPainterPath()); + m_allowanceFill->setPath(QPainterPath()); } + m_notches->setPath(piece.getNotchesPath(this->getData(), seamAllowancePoints)); + m_pieceRect = path.boundingRect(); this->setPos(piece.GetMx(), piece.GetMy()); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); diff --git a/src/libs/vtools/tools/pattern_piece_tool.h b/src/libs/vtools/tools/pattern_piece_tool.h index 17bc2e76631e..037561a269bd 100644 --- a/src/libs/vtools/tools/pattern_piece_tool.h +++ b/src/libs/vtools/tools/pattern_piece_tool.h @@ -174,17 +174,17 @@ protected slots: private: Q_DISABLE_COPY(PatternPieceTool) - QPainterPath m_mainPath; // Must be first to prevent crash - QRectF m_pieceRect; - QPainterPath m_cutPath; - VMainGraphicsScene *m_pieceScene; /** @brief pieceScene pointer to the scene. */ - QString m_blockName; + QPainterPath m_mainPath; // Must be first to prevent crash + QRectF m_pieceRect; + QPainterPath m_cutPath; + VMainGraphicsScene *m_pieceScene; /// @brief pieceScene pointer to the scene. */ + QString m_blockName; NonScalingFillPathItem *m_cutLine; - NonScalingFillPathItem *m_seamLine; - VTextGraphicsItem *m_dataLabel; - VTextGraphicsItem *m_patternInfo; - VGrainlineItem *m_grainLine; - QGraphicsPathItem *m_notches; + NonScalingFillPathItem *m_allowanceFill; + VTextGraphicsItem *m_dataLabel; + VTextGraphicsItem *m_patternInfo; + VGrainlineItem *m_grainLine; + QGraphicsPathItem *m_notches; PatternPieceTool(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, diff --git a/src/libs/vwidgets/lineweight_combobox.cpp b/src/libs/vwidgets/lineweight_combobox.cpp index 14e6fde26b41..a35c2834032a 100644 --- a/src/libs/vwidgets/lineweight_combobox.cpp +++ b/src/libs/vwidgets/lineweight_combobox.cpp @@ -101,7 +101,8 @@ void LineWeightComboBox::init() addItem(createIcon(7.00), "1.58mm", 1.58); addItem(createIcon(8.00), "2.00mm (ISO)", 2.00); addItem(createIcon(8.00), "2.11mm", 2.11); - setMaxVisibleItems(24); + addItem(createIcon(9.00), "3.00mm", 3.00); + setMaxVisibleItems(25); this->blockSignals(false); connect(this, QOverload::of(&QComboBox::currentIndexChanged), this, &LineWeightComboBox::updateLineWeight);