Fix bug Tool seam allowance. The tool returned to previous position after

selecting Apply or Ok buttons in the tool's dialog.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-12 15:41:15 +02:00
parent 878fdb6156
commit 585bfec12f
3 changed files with 22 additions and 14 deletions

View File

@ -38,8 +38,9 @@
DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent), : DialogTool(data, toolId, parent),
ui(new Ui::DialogSeamAllowance), ui(new Ui::DialogSeamAllowance),
m_piece(), applyAllowed(false),// By default disabled
applyAllowed(false)// By default disabled m_mx(0),
m_my(0)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -110,22 +111,24 @@ void DialogSeamAllowance::EnableApply(bool enable)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiece DialogSeamAllowance::GetPiece() const VPiece DialogSeamAllowance::GetPiece() const
{ {
return m_piece; return CreatePiece();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetPiece(const VPiece &piece) void DialogSeamAllowance::SetPiece(const VPiece &piece)
{ {
m_piece = piece;
ui->listWidget->clear(); ui->listWidget->clear();
for (int i = 0; i < m_piece.CountNodes(); ++i) for (int i = 0; i < piece.CountNodes(); ++i)
{ {
NewItem(m_piece.at(i)); NewItem(piece.at(i));
} }
ui->checkBoxForbidFlipping->setChecked(m_piece.IsForbidFlipping()); ui->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping());
ui->doubleSpinBoxSeams->setValue(m_piece.GetSAWidth()); ui->doubleSpinBoxSeams->setValue(piece.GetSAWidth());
ui->checkBoxSeams->setChecked(m_piece.IsSeamAllowance()); ui->checkBoxSeams->setChecked(piece.IsSeamAllowance());
m_mx = piece.GetMx();
m_my = piece.GetMy();
ValidObjects(MainPathIsValid()); ValidObjects(MainPathIsValid());
@ -217,10 +220,7 @@ void DialogSeamAllowance::ShowDialog(bool click)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SaveData() void DialogSeamAllowance::SaveData()
{ {}
m_piece.Clear();
m_piece = CreatePiece();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CheckState() void DialogSeamAllowance::CheckState()
@ -397,6 +397,8 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked()); piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked());
piece.SetSeamAllowance(ui->checkBoxSeams->isChecked()); piece.SetSeamAllowance(ui->checkBoxSeams->isChecked());
piece.SetSAWidth(ui->doubleSpinBoxSeams->value()); piece.SetSAWidth(ui->doubleSpinBoxSeams->value());
piece.SetMx(m_mx);
piece.SetMy(m_my);
return piece; return piece;
} }

View File

@ -73,8 +73,9 @@ private:
Q_DISABLE_COPY(DialogSeamAllowance) Q_DISABLE_COPY(DialogSeamAllowance)
Ui::DialogSeamAllowance *ui; Ui::DialogSeamAllowance *ui;
VPiece m_piece;
bool applyAllowed; bool applyAllowed;
qreal m_mx;
qreal m_my;
VPiece CreatePiece() const; VPiece CreatePiece() const;

View File

@ -437,6 +437,11 @@ QVariant VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change
} }
} }
// Don't forget to update geometry, because first change never call full parse // Don't forget to update geometry, because first change never call full parse
VPiece detail = VAbstractTool::data.GetPiece(id);
detail.SetMx(newPos.x());
detail.SetMy(newPos.y());
VAbstractTool::data.UpdatePiece(id, detail);
RefreshGeometry(); RefreshGeometry();
changeFinished = true; changeFinished = true;
} }