From 6abddfd24052ca31523810b9f90e725f3689374c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 10 May 2021 16:39:17 +0300 Subject: [PATCH] Standard passmarks length for all pieces. Closes #124 --- ChangeLog.txt | 1 + .../dialogs/dialogpatternproperties.cpp | 84 ++++++++++-- .../dialogs/dialogpatternproperties.h | 27 ++-- .../dialogs/dialogpatternproperties.ui | 34 ++--- src/app/valentina/mainwindow.cpp | 2 + src/app/valentina/xml/vpattern.cpp | 8 +- src/app/valentina/xml/vpattern.h | 5 +- src/libs/ifc/schema/pattern/v0.8.11.xsd | 1 + src/libs/ifc/xml/vabstractpattern.cpp | 25 ++++ src/libs/ifc/xml/vabstractpattern.h | 3 + src/libs/vlayout/vabstractpiece.cpp | 6 +- src/libs/vpatterndb/vpassmark.cpp | 120 ++++++++++-------- src/libs/vpatterndb/vpassmark.h | 2 +- src/libs/vpatterndb/vpatterndb.pro | 2 +- src/libs/vpatterndb/vpiece.cpp | 35 +++++ src/libs/vpatterndb/vpiece.h | 2 + src/libs/vtest/abstracttest.cpp | 5 + src/libs/vtools/tools/vtoolseamallowance.cpp | 8 ++ src/libs/vtools/tools/vtoolseamallowance.h | 1 + src/libs/vwidgets/vmaingraphicsscene.cpp | 6 + src/libs/vwidgets/vmaingraphicsscene.h | 2 + src/test/CollectionTest/CollectionTest.pro | 2 +- .../TranslationsTest/TranslationsTest.pro | 2 +- 23 files changed, 281 insertions(+), 102 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 760b1a585..e194e4812 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -12,6 +12,7 @@ - Fix regression. Incorrect data caching. - Improve tool tooltip. Show segment names and aliases. - Alias support for tools Point of intersection curve and axis and Point of intersection curves. +- [smart-pattern/valentina#124] Standard passmarks length for all pieces. # Version 0.7.46 Mar 31, 2021 - Fix incorrect calculation of value for multisize measurements in Valentina. diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 30e261af4..df7eabf17 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "../xml/vpattern.h" #include "../vpatterndb/vcontainer.h" @@ -42,22 +43,14 @@ #include "../vtools/dialogs/support/dialogeditlabel.h" #include "dialogknownmaterials.h" #include "../vmisc/vsettings.h" +#include "../qmuparser/qmudef.h" //--------------------------------------------------------------------------------------------------------------------- DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) : QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), - pattern(pattern), - data(QMap()), - descriptionChanged(false), - gradationChanged(false), - defaultChanged(false), - securityChanged(false), - deleteAction(nullptr), - changeImageAction(nullptr), - saveImageAction(nullptr), - showImageAction(nullptr) + pattern(pattern) { ui->setupUi(this); @@ -137,8 +130,27 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat ui->checkBoxPatternReadOnly->setDisabled(true); } + //----------------------- Passmark length + m_variables = pattern->DataMeasurements().keys() + pattern->DataIncrements().keys(); + m_completer = new QCompleter(m_variables, this); + m_completer->setCompletionMode(QCompleter::PopupCompletion); + m_completer->setModelSorting(QCompleter::UnsortedModel); + m_completer->setFilterMode(Qt::MatchStartsWith); + m_completer->setCaseSensitivity(Qt::CaseSensitive); + + ui->lineEditPassmarkLength->setCompleter(m_completer); + connect(ui->lineEditPassmarkLength, &QLineEdit::textEdited, this, [this]() + { + ValidatePassmarkLength(); + DescEdited(); + }); + + ui->lineEditPassmarkLength->installEventFilter(this); + m_oldPassmarkLength = doc->GetPassmarkLengthVariable(); + ui->lineEditPassmarkLength->setText(m_oldPassmarkLength); + ValidatePassmarkLength(); + //Initialization change value. Set to default value after initialization - gradationChanged = false; defaultChanged = false; securityChanged = false; } @@ -149,6 +161,27 @@ DialogPatternProperties::~DialogPatternProperties() delete ui; } +//--------------------------------------------------------------------------------------------------------------------- +auto DialogPatternProperties::eventFilter(QObject *object, QEvent *event) -> bool +{ + if (ui->lineEditPassmarkLength == qobject_cast(object)) + { + if (event->type() == QEvent::KeyPress) + { + auto *keyEvent = static_cast(event); + if ((keyEvent->key() == Qt::Key_Space) && ((keyEvent->modifiers() & Qt::ControlModifier) != 0U)) + { + m_completer->complete(); + return true; + } + } + + return false; + } + + return QDialog::eventFilter(object, event); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::Apply() { @@ -188,8 +221,16 @@ void DialogPatternProperties::SaveDescription() doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); doc->SetLabelPrefix(qvariant_cast(ui->comboBoxLabelLanguage->currentData())); + doc->SetPassmarkLengthVariable(ui->lineEditPassmarkLength->text()); + + if (m_oldPassmarkLength != ui->lineEditPassmarkLength->text()) + { + emit UpddatePieces(); + m_oldPassmarkLength = ui->lineEditPassmarkLength->text(); + } descriptionChanged = false; + emit doc->patternChanged(false); } } @@ -219,6 +260,27 @@ QImage DialogPatternProperties::GetImage() return image; } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::ValidatePassmarkLength() const +{ + const QString text = ui->lineEditPassmarkLength->text(); + QPalette palette = ui->lineEditPassmarkLength->palette(); + const QPalette::ColorRole foregroundRole = ui->lineEditPassmarkLength->foregroundRole(); + + QRegularExpression rx(NameRegExp()); + if (not text.isEmpty()) + { + palette.setColor(foregroundRole, + rx.match(text).hasMatch() && m_variables.contains(text) ? Qt::black : Qt::red); + } + else + { + palette.setColor(foregroundRole, Qt::black); + } + + ui->lineEditPassmarkLength->setPalette(palette); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::InitImage() { diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index 188d3008d..ac756ef16 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -38,6 +38,7 @@ class VPattern; class VContainer; class QCheckBox; +class QCompleter; namespace Ui { @@ -50,6 +51,10 @@ class DialogPatternProperties : public QDialog public: explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr); virtual ~DialogPatternProperties() override; +signals: + void UpddatePieces(); +protected: + virtual bool eventFilter(QObject *object, QEvent *event) override; private slots: void Apply(); void Ok(); @@ -61,21 +66,25 @@ private: Ui::DialogPatternProperties *ui; VPattern *doc; VContainer *pattern; - QMap data; - bool descriptionChanged; - bool gradationChanged; - bool defaultChanged; - bool securityChanged; - QAction *deleteAction; - QAction *changeImageAction; - QAction *saveImageAction; - QAction *showImageAction; + QMap data{}; + bool descriptionChanged{false}; + bool defaultChanged{false}; + bool securityChanged{false}; + QAction *deleteAction{nullptr}; + QAction *changeImageAction{nullptr}; + QAction *saveImageAction{nullptr}; + QAction *showImageAction{nullptr}; + QCompleter *m_completer{nullptr}; + QStringList m_variables{}; + QString m_oldPassmarkLength{}; void SaveDescription(); void SaveReadOnlyState(); void InitImage(); QImage GetImage(); + + void ValidatePassmarkLength() const; }; #endif // DIALOGPATTERNPROPERTIES_H diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index d28f9a1aa..e282095e7 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -6,8 +6,8 @@ 0 0 - 571 - 491 + 493 + 582 @@ -81,8 +81,11 @@ - - + + + QFormLayout::ExpandingFieldsGrow + + @@ -95,7 +98,7 @@ - + @@ -105,18 +108,19 @@ - - - - Qt::Horizontal + + + + Passmark length: - - - 40 - 20 - + + + + + + true - + diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 943114667..cd1595834 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -4923,6 +4923,8 @@ void MainWindow::CreateActions() connect(ui->actionPattern_properties, &QAction::triggered, this, [this]() { DialogPatternProperties proper(doc, pattern, this); + connect(&proper, &DialogPatternProperties::UpddatePieces, sceneDetails, + &VMainGraphicsScene::UpdatePiecePassmarks); proper.exec(); }); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 89f590e97..550bbc3ba 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -3700,21 +3700,21 @@ void VPattern::RefreshPieceGeometry() VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView()); }); - if (VApplication::VApp()->IsGUIMode() && m_parsing) + if (VApplication::IsGUIMode() && m_parsing) { return; } for(auto pieceId : qAsConst(updatePieces)) { - if (VApplication::VApp()->IsGUIMode() && m_parsing) + if (VApplication::IsGUIMode() && m_parsing) { return; } try { - if (VToolSeamAllowance *piece = qobject_cast(VAbstractPattern::getTool(pieceId))) + if (auto *piece = qobject_cast(VAbstractPattern::getTool(pieceId))) { piece->RefreshGeometry(); } @@ -3726,7 +3726,7 @@ void VPattern::RefreshPieceGeometry() QApplication::processEvents(); - if (VApplication::VApp()->IsGUIMode() && m_parsing) + if (VApplication::IsGUIMode() && m_parsing) { return; } diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 97c182852..c99c393f0 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -119,12 +119,11 @@ signals: public slots: virtual void LiteParseTree(const Document &parse) override; + void RefreshPieceGeometry(); + protected: virtual void customEvent(QEvent * event) override; -private slots: - void RefreshPieceGeometry(); - private: Q_DISABLE_COPY(VPattern) diff --git a/src/libs/ifc/schema/pattern/v0.8.11.xsd b/src/libs/ifc/schema/pattern/v0.8.11.xsd index b82690505..ea5ac8902 100644 --- a/src/libs/ifc/schema/pattern/v0.8.11.xsd +++ b/src/libs/ifc/schema/pattern/v0.8.11.xsd @@ -762,6 +762,7 @@ + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 1507381da..68688fffb 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1200,6 +1200,31 @@ bool VAbstractPattern::GetPatternWasChanged() const return patternLabelWasChanged; } +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::GetPassmarkLengthVariable() const +{ + const QDomElement pattern = documentElement(); + + if (pattern.isNull()) + { + return {}; + } + + return GetParametrEmptyString(pattern, AttrPassmarkLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetPassmarkLengthVariable(const QString &name) +{ + QDomElement pattern = documentElement(); + + if (not pattern.isNull()) + { + SetAttribute(pattern, AttrPassmarkLength, name); + modified = true; + } +} + //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetImage() const { diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 5b580d732..581407873 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -192,6 +192,9 @@ public: void SetPatternWasChanged(bool changed); bool GetPatternWasChanged() const; + QString GetPassmarkLengthVariable() const; + void SetPassmarkLengthVariable(const QString &name); + QString GetImage() const; QString GetImageExtension() const; void SetImage(const QString &text, const QString &extension); diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index d90df91a8..462dfeac4 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1646,10 +1646,8 @@ qreal VSAPoint::PassmarkLength(qreal width) const passmarkLength = qMin(passmarkLength, maxPassmarkLength); return passmarkLength; } - else - { - return m_passmarkLength; - } + + return m_passmarkLength; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpassmark.cpp b/src/libs/vpatterndb/vpassmark.cpp index 7e552e790..f7135acde 100644 --- a/src/libs/vpatterndb/vpassmark.cpp +++ b/src/libs/vpatterndb/vpassmark.cpp @@ -537,6 +537,43 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType return passmarksLines; } +//--------------------------------------------------------------------------------------------------------------------- +auto PassmarkLength(const VPiecePassmarkData &passmarkData, qreal width, bool &ok) -> qreal +{ + qreal length = 0; + if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength()) + { + if (passmarkData.globalPassmarkLength > accuracyPointOnLine) + { + ok = true; + return passmarkData.globalPassmarkLength; + } + + length = qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength); + + if (length <= accuracyPointOnLine) + { + const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " + "than minimal allowed.") + .arg(passmarkData.nodeName, passmarkData.pieceName); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + + ok = false; + return length; + } + + ok = true; + return length; + } + + length = passmarkData.passmarkSAPoint.GetPasskmarkLength(); + + ok = true; + return length; +} + //--------------------------------------------------------------------------------------------------------------------- QVector PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const VPiecePassmarkData &passmarkData, const QPointF &seamPassmarkSAPoint, const QVector &seamAllowance) @@ -572,14 +609,11 @@ QVector PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const return QVector(); } - const qreal length = passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth); - if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + bool ok = false; + const qreal length = PassmarkLength(passmarkData, passmarkData.passmarkSAPoint.MaxLocalSA(passmarkData.saWidth), + ok); + if (not ok) { - const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " - "than minimal allowed.") - .arg(passmarkData.nodeName, passmarkData.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QVector(); } @@ -624,6 +658,7 @@ QJsonObject VPiecePassmarkData::toJson() const {"isShowSecondPassmark", isShowSecondPassmark}, {"passmarkIndex", passmarkIndex}, {"id", static_cast(id)}, + {"globalPassmarkLength", static_cast(globalPassmarkLength)}, }; return dataObject; @@ -781,15 +816,11 @@ QVector VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const qreal length = 0; if (not piece.IsSeamAllowanceBuiltIn()) { - length = m_data.passmarkSAPoint.PassmarkLength(m_data.saWidth); - if (not m_data.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + bool ok = false; + length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok); + if (not ok) { - const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " - "than minimal allowed.") - .arg(m_data.nodeName, m_data.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; - return QVector(); + return {}; } } else @@ -888,34 +919,23 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa if (intersections.last() != m_data.passmarkSAPoint) { line = QLineF(intersections.last(), m_data.passmarkSAPoint); - if (not m_data.passmarkSAPoint.IsManualPasskmarkLength()) + + bool ok = false; + const qreal length = PassmarkLength(m_data, width, ok); + if (not ok) { - const qreal length = qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength); - if (length <= accuracyPointOnLine) - { - const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is " - "less than minimal allowed.") - .arg(m_data.nodeName, m_data.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; - return QLineF(); - } - line.setLength(length); - } - else - { - line.setLength(m_data.passmarkSAPoint.GetPasskmarkLength()); + return QLineF(); } + line.setLength(length); + return line; } - else - { - const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch " - "collapse.") - .arg(m_data.nodeName, m_data.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; - } + + const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch " + "collapse.") + .arg(m_data.nodeName, m_data.pieceName); + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } else { @@ -931,21 +951,17 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward) { - const qreal length = m_data.passmarkSAPoint.PassmarkLength(m_data.saWidth); - if (not m_data.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + bool ok = false; + const qreal length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok); + + if (not ok) { - const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " - "than minimal allowed.") - .arg(m_data.nodeName, m_data.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; - } - else - { - QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint); - line.setLength(length); - return QVector({line}); + return {}; } + + QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint); + line.setLength(length); + return {line}; } else if (m_data.passmarkAngleType == PassmarkAngleType::Bisector) { diff --git a/src/libs/vpatterndb/vpassmark.h b/src/libs/vpatterndb/vpassmark.h index f4cf693e2..648b7e34f 100644 --- a/src/libs/vpatterndb/vpassmark.h +++ b/src/libs/vpatterndb/vpassmark.h @@ -61,6 +61,7 @@ struct VPiecePassmarkData bool isShowSecondPassmark{true}; int passmarkIndex{-1}; vidtype id{NULL_ID}; + qreal globalPassmarkLength{0}; QJsonObject toJson() const; }; @@ -102,7 +103,6 @@ private: bool m_null{true}; QVector MakeSAPassmark(const QVector &seamAllowance, PassmarkSide side) const; - }; #endif // VPASSMARK_H diff --git a/src/libs/vpatterndb/vpatterndb.pro b/src/libs/vpatterndb/vpatterndb.pro index 49c48e227..d6bc37df4 100644 --- a/src/libs/vpatterndb/vpatterndb.pro +++ b/src/libs/vpatterndb/vpatterndb.pro @@ -7,7 +7,7 @@ # File with common stuff for whole project include(../../../common.pri) -QT += core widgets printsupport +QT += core widgets printsupport xmlpatterns concurrent # Name of the library TARGET = vpatterndb diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 959cca32f..8d1eba71a 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -38,6 +38,7 @@ #include "../vmisc/compatibility.h" #include "../ifc/exception/vexceptioninvalidnotch.h" #include "../vlayout/testpath.h" +#include "../ifc/xml/vabstractpattern.h" #include #include @@ -1106,6 +1107,7 @@ VPassmark VPiece::CreatePassmark(const QVector &path, int previousIn passmarkData.isShowSecondPassmark = path.at(passmarkIndex).IsShowSecondPassmark(); passmarkData.passmarkIndex = passmarkIndex; passmarkData.id = path.at(passmarkIndex).GetId(); + passmarkData.globalPassmarkLength = ToPixel(GlobalPassmarkLength(data), *data->GetPatternUnit()); return VPassmark(passmarkData); } @@ -1170,6 +1172,39 @@ QJsonObject VPiece::DBToJson(const VContainer *data) const return dbObject; } +//--------------------------------------------------------------------------------------------------------------------- +auto VPiece::GlobalPassmarkLength(const VContainer *data) const -> qreal +{ + qreal length = 0; + QString passmarkLengthVariable = VAbstractValApplication::VApp()->getCurrentDocument()->GetPassmarkLengthVariable(); + if (passmarkLengthVariable.isEmpty()) + { + return 0; + } + + try + { + QSharedPointer var = data->GetVariable(passmarkLengthVariable); + length = *var->GetValue(); + + if (length <= accuracyPointOnLine) + { + const QString errorMsg = QObject::tr("Invalid global value for a passmark length. Piece '%1'. Length is " + "less than minimal allowed.") + .arg(GetName()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + } + } + catch (const VExceptionBadId &) + { + length = 0; + } + + return length; +} + //--------------------------------------------------------------------------------------------------------------------- void VPiece::DumpPiece(const VPiece &piece, const VContainer *data) { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 9edb23976..674baecb0 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -158,6 +158,8 @@ private: QJsonObject MainPathToJson() const; QJsonObject DBToJson(const VContainer *data) const; + + qreal GlobalPassmarkLength(const VContainer *data) const; }; Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE); diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index 4e814f445..13cf270b0 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -266,6 +266,11 @@ void AbstractTest::PassmarkDataFromJson(const QString &json, VPiecePassmarkData vidtype id; AbstractTest::ReadDoubleValue(passmarkData, QStringLiteral("id"), id, QString::number(NULL_ID)); data.id = id; + + qreal globalPassmarkLength; + AbstractTest::ReadDoubleValue(passmarkData, QStringLiteral("globalPassmarkLength"), globalPassmarkLength, + QString::number(NULL_ID)); + data.globalPassmarkLength = globalPassmarkLength; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index feed82212..25aedee20 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -710,6 +710,13 @@ void VToolSeamAllowance::UpdatePatternInfo() } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::UpdatePassmarks() +{ + const VPiece detail = VAbstractTool::data.GetPiece(m_id); + m_passmarks->setPath(detail.PassmarksPath(getData())); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VToolDetail::UpdateGrainline updates the grain line item @@ -1293,6 +1300,7 @@ VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initDat connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem); connect(m_sceneDetails, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove); connect(m_sceneDetails, &VMainGraphicsScene::ItemSelection, this, &VToolSeamAllowance::ToolSelectionType); + connect(m_sceneDetails, &VMainGraphicsScene::UpdatePassmarks, this, &VToolSeamAllowance::UpdatePassmarks); ConnectOutsideSignals(); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 4c0fd8219..a481c40b6 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -133,6 +133,7 @@ public slots: void Highlight(quint32 id); void UpdateDetailLabel(); void UpdatePatternInfo(); + void UpdatePassmarks(); void ShowOptions(); void DeleteFromMenu(); protected slots: diff --git a/src/libs/vwidgets/vmaingraphicsscene.cpp b/src/libs/vwidgets/vmaingraphicsscene.cpp index 4e0dbf058..8e43d0c26 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.cpp +++ b/src/libs/vwidgets/vmaingraphicsscene.cpp @@ -319,6 +319,12 @@ void VMainGraphicsScene::HighlightItem(quint32 id) emit HighlightDetail(id); } +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::UpdatePiecePassmarks() +{ + emit UpdatePassmarks(); +} + //--------------------------------------------------------------------------------------------------------------------- void VMainGraphicsScene::ToggleLabelSelection(bool enabled) { diff --git a/src/libs/vwidgets/vmaingraphicsscene.h b/src/libs/vwidgets/vmaingraphicsscene.h index 8179cacbd..aced01546 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.h +++ b/src/libs/vwidgets/vmaingraphicsscene.h @@ -74,6 +74,7 @@ public slots: void EnableDetailsMode(bool mode); void ItemsSelection(const SelectionType &type); void HighlightItem(quint32 id); + void UpdatePiecePassmarks(); void ToggleLabelSelection(bool enabled); void TogglePointSelection(bool enabled); @@ -123,6 +124,7 @@ signals: void CurveDetailsMode(bool mode); void ItemSelection(const SelectionType &type); void HighlightDetail(quint32 id); + void UpdatePassmarks(); void EnableLabelItemSelection(bool enable); void EnablePointItemSelection(bool enable); diff --git a/src/test/CollectionTest/CollectionTest.pro b/src/test/CollectionTest/CollectionTest.pro index dbde17e42..109207bd0 100644 --- a/src/test/CollectionTest/CollectionTest.pro +++ b/src/test/CollectionTest/CollectionTest.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += testlib widgets printsupport concurrent xml +QT += testlib widgets printsupport concurrent xml xmlpatterns QT -= gui diff --git a/src/test/TranslationsTest/TranslationsTest.pro b/src/test/TranslationsTest/TranslationsTest.pro index 919ae2f77..d3c4b34ee 100644 --- a/src/test/TranslationsTest/TranslationsTest.pro +++ b/src/test/TranslationsTest/TranslationsTest.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += testlib widgets xml printsupport +QT += testlib widgets xml printsupport concurrent xmlpatterns QT -= gui