diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp
index 9e08bdd31..fb3690b68 100644
--- a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp
@@ -127,26 +127,36 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
{
reverse = true;
}
- switch (type)
+ if (id != GetLastId())
{
- case SceneObject::Arc:
- NewItem(VPieceNode(id, Tool::NodeArc, reverse));
- break;
- case SceneObject::Point:
- NewItem(VPieceNode(id, Tool::NodePoint));
- break;
- case SceneObject::Spline:
- NewItem(VPieceNode(id, Tool::NodeSpline, reverse));
- break;
- case SceneObject::SplinePath:
- NewItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
- break;
- case (SceneObject::Line):
- case (SceneObject::Detail):
- case (SceneObject::Unknown):
- default:
- qDebug() << "Got wrong scene object. Ignore.";
- break;
+ switch (type)
+ {
+ case SceneObject::Arc:
+ NewItem(VPieceNode(id, Tool::NodeArc, reverse));
+ break;
+ case SceneObject::Point:
+ NewItem(VPieceNode(id, Tool::NodePoint));
+ break;
+ case SceneObject::Spline:
+ NewItem(VPieceNode(id, Tool::NodeSpline, reverse));
+ break;
+ case SceneObject::SplinePath:
+ NewItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
+ break;
+ case (SceneObject::Line):
+ case (SceneObject::Detail):
+ case (SceneObject::Unknown):
+ default:
+ qDebug() << "Got wrong scene object. Ignore.";
+ break;
+ }
+ }
+ else
+ {
+ if (ui->listWidget->count() > 1)
+ {
+ delete GetItemById(id);
+ }
}
ValidObjects(PathIsValid());
@@ -163,7 +173,14 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
emit ToolTip(tr("Select main path objects, Shift - reverse direction curve, "
"Enter - finish creation"));
- visPath->VisualMode(NULL_ID);
+ if (not qApp->getCurrentScene()->items().contains(visPath))
+ {
+ visPath->VisualMode(NULL_ID);
+ }
+ else
+ {
+ visPath->RefreshGeometry();
+ }
}
else
{
@@ -545,6 +562,22 @@ QListWidgetItem *DialogPiecePath::GetItemById(quint32 id)
return nullptr;
}
+//---------------------------------------------------------------------------------------------------------------------
+quint32 DialogPiecePath::GetLastId() const
+{
+ const int count = ui->listWidget->count();
+ if (count > 0)
+ {
+ QListWidgetItem *item = ui->listWidget->item(count-1);
+ const VPieceNode node = qvariant_cast(item->data(Qt::UserRole));
+ return node.GetId();
+ }
+ else
+ {
+ return NULL_ID;
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetCurrentSABefore(qreal value)
{
diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/dialogpiecepath.h
index 75c51429f..c1f06c163 100644
--- a/src/libs/vtools/dialogs/tools/dialogpiecepath.h
+++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.h
@@ -99,6 +99,8 @@ private:
QListWidgetItem *GetItemById(quint32 id);
+ quint32 GetLastId() const;
+
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
};
diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp
index 7a9b62e7b..9407993e9 100644
--- a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp
@@ -202,26 +202,36 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
{
reverse = true;
}
- switch (type)
+ if (id != GetLastId())
{
- case SceneObject::Arc:
- NewMainPathItem(VPieceNode(id, Tool::NodeArc, reverse));
- break;
- case SceneObject::Point:
- NewMainPathItem(VPieceNode(id, Tool::NodePoint));
- break;
- case SceneObject::Spline:
- NewMainPathItem(VPieceNode(id, Tool::NodeSpline, reverse));
- break;
- case SceneObject::SplinePath:
- NewMainPathItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
- break;
- case (SceneObject::Line):
- case (SceneObject::Detail):
- case (SceneObject::Unknown):
- default:
- qDebug() << "Got wrong scene object. Ignore.";
- break;
+ switch (type)
+ {
+ case SceneObject::Arc:
+ NewMainPathItem(VPieceNode(id, Tool::NodeArc, reverse));
+ break;
+ case SceneObject::Point:
+ NewMainPathItem(VPieceNode(id, Tool::NodePoint));
+ break;
+ case SceneObject::Spline:
+ NewMainPathItem(VPieceNode(id, Tool::NodeSpline, reverse));
+ break;
+ case SceneObject::SplinePath:
+ NewMainPathItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
+ break;
+ case (SceneObject::Line):
+ case (SceneObject::Detail):
+ case (SceneObject::Unknown):
+ default:
+ qDebug() << "Got wrong scene object. Ignore.";
+ break;
+ }
+ }
+ else
+ {
+ if (ui->listWidgetMainPath->count() > 1)
+ {
+ delete GetItemById(id);
+ }
}
ValidObjects(MainPathIsValid());
@@ -238,7 +248,14 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
emit ToolTip(tr("Select main path objects clockwise, Shift - reverse direction curve, "
"Enter - finish creation"));
- visPath->VisualMode(NULL_ID);
+ if (not qApp->getCurrentScene()->items().contains(visPath))
+ {
+ visPath->VisualMode(NULL_ID);
+ }
+ else
+ {
+ visPath->RefreshGeometry();
+ }
}
else
{
@@ -925,6 +942,22 @@ QListWidgetItem *DialogSeamAllowance::GetItemById(quint32 id)
return nullptr;
}
+//---------------------------------------------------------------------------------------------------------------------
+quint32 DialogSeamAllowance::GetLastId() const
+{
+ const int count = ui->listWidgetMainPath->count();
+ if (count > 0)
+ {
+ QListWidgetItem *item = ui->listWidgetMainPath->item(count-1);
+ const VPieceNode node = qvariant_cast(item->data(Qt::UserRole));
+ return node.GetId();
+ }
+ else
+ {
+ return NULL_ID;
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetCurrentSABefore(qreal value)
{
diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/dialogseamallowance.h
index c761f8d76..2890ea3f4 100644
--- a/src/libs/vtools/dialogs/tools/dialogseamallowance.h
+++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.h
@@ -105,6 +105,8 @@ private:
QListWidgetItem *GetItemById(quint32 id);
+ quint32 GetLastId() const;
+
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
};