Check if all points in a path are unique.
Because in some valid cases the same geometric point can be included in a path several times we must force user to create unique point for each case. This happens because we determine each point by point id. --HG-- branch : feature
This commit is contained in:
parent
50a5119960
commit
ad23a75d7a
|
@ -889,6 +889,12 @@ bool DialogPiecePath::PathIsValid() const
|
|||
ui->helpLabel->setText(url);
|
||||
return false;
|
||||
}
|
||||
else if (not EachPointLabelIsUnique(ui->listWidget))
|
||||
{
|
||||
url += tr("Each point in the path must be unique!");
|
||||
ui->helpLabel->setText(url);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (not m_showMode && ui->comboBoxPiece->count() <= 0)
|
||||
|
|
|
@ -522,6 +522,27 @@ bool DialogTool::DoublePoints(QListWidget *listWidget)
|
|||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogTool::EachPointLabelIsUnique(QListWidget *listWidget)
|
||||
{
|
||||
SCASSERT(listWidget != nullptr);
|
||||
QSet<quint32> pointLabels;
|
||||
int countPoints = 0;
|
||||
for (int i=0; i < listWidget->count(); ++i)
|
||||
{
|
||||
const QListWidgetItem *rowItem = listWidget->item(i);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
const VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
if (rowNode.GetTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
++countPoints;
|
||||
pointLabels.insert(rowNode.GetId());
|
||||
}
|
||||
}
|
||||
|
||||
return countPoints == pointLabels.size();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogTool::DialogWarningIcon()
|
||||
{
|
||||
|
|
|
@ -270,6 +270,7 @@ protected:
|
|||
static int FindNotExcludedNodeUp(QListWidget *listWidget, int candidate);
|
||||
static bool FirstPointEqualLast(QListWidget *listWidget);
|
||||
static bool DoublePoints(QListWidget *listWidget);
|
||||
static bool EachPointLabelIsUnique(QListWidget *listWidget);
|
||||
static QString DialogWarningIcon();
|
||||
static QFont NodeFont(bool nodeExcluded);
|
||||
|
||||
|
|
|
@ -2029,6 +2029,12 @@ bool DialogSeamAllowance::MainPathIsValid() const
|
|||
uiTabPaths->helpLabel->setText(url);
|
||||
valid = false;
|
||||
}
|
||||
else if (not EachPointLabelIsUnique(uiTabPaths->listWidgetMainPath))
|
||||
{
|
||||
url += tr("Each point in the path must be unique!");
|
||||
uiTabPaths->helpLabel->setText(url);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
|
|
Loading…
Reference in New Issue
Block a user