Resolve issue #895. Improve path validation. Do not allow repeat the same curve

twice.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-10-22 15:43:58 +03:00
parent 9f2959e32e
commit ead254ab6b
5 changed files with 48 additions and 0 deletions

View File

@ -1,6 +1,7 @@
# Version 0.7.0 (unreleased) # Version 0.7.0 (unreleased)
- [#892] Show tooltip for piece node point. - [#892] Show tooltip for piece node point.
- [#894] Quick way to disable a passmark. - [#894] Quick way to disable a passmark.
- [#895] Improve path validation. Do not allow repeat the same curve twice.
# Version 0.6.1 (unreleased) # Version 0.6.1 (unreleased)
- [#885] Regression. Broken support for multi size measurements. - [#885] Regression. Broken support for multi size measurements.

View File

@ -129,6 +129,22 @@ bool DoublePoint(const VPieceNode &firstNode, const VPieceNode &secondNode, cons
return false; 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; return false;
} }
//---------------------------------------------------------------------------------------------------------------------
bool DialogTool::DoubleCurves(QListWidget *listWidget, const VContainer *data)
{
SCASSERT(listWidget != nullptr);
for (int i=0, sz = listWidget->count()-1; i<sz; ++i)
{
const int firstIndex = FindNotExcludedNodeDown(listWidget, i);
const VPieceNode firstNode = RowNode(listWidget, firstIndex);
const VPieceNode secondNode = RowNode(listWidget, FindNotExcludedNodeDown(listWidget, firstIndex+1));
if (DoubleCurve(firstNode, secondNode, data))
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogTool::EachPointLabelIsUnique(QListWidget *listWidget) bool DialogTool::EachPointLabelIsUnique(QListWidget *listWidget)
{ {

View File

@ -280,6 +280,7 @@ protected:
static int FindNotExcludedNodeUp(QListWidget *listWidget, int candidate); static int FindNotExcludedNodeUp(QListWidget *listWidget, int candidate);
static bool FirstPointEqualLast(QListWidget *listWidget, const VContainer *data); static bool FirstPointEqualLast(QListWidget *listWidget, const VContainer *data);
static bool DoublePoints(QListWidget *listWidget, const VContainer *data); static bool DoublePoints(QListWidget *listWidget, const VContainer *data);
static bool DoubleCurves(QListWidget *listWidget, const VContainer *data);
static bool EachPointLabelIsUnique(QListWidget *listWidget); static bool EachPointLabelIsUnique(QListWidget *listWidget);
static QString DialogWarningIcon(); static QString DialogWarningIcon();
static QFont NodeFont(QFont font, bool nodeExcluded = false); static QFont NodeFont(QFont font, bool nodeExcluded = false);

View File

@ -1428,6 +1428,12 @@ bool DialogPiecePath::PathIsValid() const
ui->helpLabel->setText(url); ui->helpLabel->setText(url);
return false; 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)) else if (GetType() == PiecePathType::CustomSeamAllowance && not EachPointLabelIsUnique(ui->listWidget))
{ {
url += tr("Each point in the <b>custom seam allowance</b> path must be unique!"); url += tr("Each point in the <b>custom seam allowance</b> path must be unique!");

View File

@ -2420,6 +2420,12 @@ bool DialogSeamAllowance::MainPathIsValid() const
uiTabPaths->helpLabel->setText(url); uiTabPaths->helpLabel->setText(url);
valid = false; 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)) else if (not EachPointLabelIsUnique(uiTabPaths->listWidgetMainPath))
{ {
url += tr("Each point in the path must be unique!"); url += tr("Each point in the path must be unique!");