Resolve issue #895. Improve path validation. Do not allow repeat the same curve
twice. --HG-- branch : develop
This commit is contained in:
parent
9f2959e32e
commit
ead254ab6b
|
@ -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.
|
||||
|
|
|
@ -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; 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)
|
||||
{
|
||||
|
|
|
@ -280,6 +280,7 @@ protected:
|
|||
static int FindNotExcludedNodeUp(QListWidget *listWidget, int candidate);
|
||||
static bool FirstPointEqualLast(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 QString DialogWarningIcon();
|
||||
static QFont NodeFont(QFont font, bool nodeExcluded = false);
|
||||
|
|
|
@ -1428,6 +1428,12 @@ bool DialogPiecePath::PathIsValid() const
|
|||
ui->helpLabel->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 <b>custom seam allowance</b> path must be unique!");
|
||||
|
|
|
@ -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!");
|
||||
|
|
Loading…
Reference in New Issue
Block a user