Undo selection of last object if was selected twice.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-12-03 19:18:58 +02:00
parent 0a11ec59fb
commit c2da41bbf0
4 changed files with 110 additions and 40 deletions

View File

@ -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, <b>Shift</b> - reverse direction curve, "
"<b>Enter</b> - 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<VPieceNode>(item->data(Qt::UserRole));
return node.GetId();
}
else
{
return NULL_ID;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetCurrentSABefore(qreal value)
{

View File

@ -99,6 +99,8 @@ private:
QListWidgetItem *GetItemById(quint32 id);
quint32 GetLastId() const;
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
};

View File

@ -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, <b>Shift</b> - reverse direction curve, "
"<b>Enter</b> - 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<VPieceNode>(item->data(Qt::UserRole));
return node.GetId();
}
else
{
return NULL_ID;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetCurrentSABefore(qreal value)
{

View File

@ -105,6 +105,8 @@ private:
QListWidgetItem *GetItemById(quint32 id);
quint32 GetLastId() const;
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
};