From ead254ab6b9694f2ac4f5ca41f06aada0c6f0b9b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 22 Oct 2018 15:43:58 +0300 Subject: [PATCH] Resolve issue #895. Improve path validation. Do not allow repeat the same curve twice. --HG-- branch : develop --- ChangeLog.txt | 1 + src/libs/vtools/dialogs/tools/dialogtool.cpp | 34 +++++++++++++++++++ src/libs/vtools/dialogs/tools/dialogtool.h | 1 + .../dialogs/tools/piece/dialogpiecepath.cpp | 6 ++++ .../tools/piece/dialogseamallowance.cpp | 6 ++++ 5 files changed, 48 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 2aae3c440..f84ef6a54 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ # Version 0.7.0 (unreleased) - [#892] Show tooltip for piece node point. - [#894] Quick way to disable a passmark. +- [#895] Improve path validation. Do not allow repeat the same curve twice. # Version 0.6.1 (unreleased) - [#885] Regression. Broken support for multi size measurements. diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 39e64daa1..dadfdf279 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -129,6 +129,22 @@ bool DoublePoint(const VPieceNode &firstNode, const VPieceNode &secondNode, cons return false; } + +//--------------------------------------------------------------------------------------------------------------------- +bool DoubleCurve(const VPieceNode &firstNode, const VPieceNode &secondNode, const VContainer *data) +{ + if (firstNode.GetTypeTool() != Tool::NodePoint && not (firstNode.GetId() == NULL_ID) + && secondNode.GetTypeTool() != Tool::NodePoint && not (secondNode.GetId() == NULL_ID)) + { + // don't ignore the same curve twice + if (data->GetGObject(firstNode.GetId())->getIdObject() == data->GetGObject(secondNode.GetId())->getIdObject()) + { + return true; + } + } + + return false; +} } //--------------------------------------------------------------------------------------------------------------------- @@ -579,6 +595,24 @@ bool DialogTool::DoublePoints(QListWidget *listWidget, const VContainer *data) return false; } +//--------------------------------------------------------------------------------------------------------------------- +bool DialogTool::DoubleCurves(QListWidget *listWidget, const VContainer *data) +{ + SCASSERT(listWidget != nullptr); + for (int i=0, sz = listWidget->count()-1; ihelpLabel->setText(url); return false; } + else if (DoubleCurves(ui->listWidget, data)) + { + url += tr("The same curve repeats twice!"); + ui->helpLabel->setText(url); + return false; + } else if (GetType() == PiecePathType::CustomSeamAllowance && not EachPointLabelIsUnique(ui->listWidget)) { url += tr("Each point in the custom seam allowance path must be unique!"); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index c698a8b18..4f2183c1c 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -2420,6 +2420,12 @@ bool DialogSeamAllowance::MainPathIsValid() const uiTabPaths->helpLabel->setText(url); valid = false; } + else if (DoubleCurves(uiTabPaths->listWidgetMainPath, data)) + { + url += tr("The same curve repeats twice!"); + uiTabPaths->helpLabel->setText(url); + valid = false; + } else if (not EachPointLabelIsUnique(uiTabPaths->listWidgetMainPath)) { url += tr("Each point in the path must be unique!");