Fix incorrect saving grainline angle and length.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-02-27 14:28:22 +02:00
parent 93a59b9371
commit 38740f7ef8
5 changed files with 36 additions and 10 deletions

View File

@ -238,16 +238,12 @@ void VLayoutPiece::SetGrainline(const VGrainlineData& geom, const VContainer& rP
try try
{ {
QString qsFormula = geom.GetRotation().replace("\n", " ");
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
Calculator cal1; Calculator cal1;
dAng = cal1.EvalFormula(rPattern.PlainVariables(), qsFormula); dAng = cal1.EvalFormula(rPattern.PlainVariables(), geom.GetRotation());
dAng = qDegreesToRadians(dAng); dAng = qDegreesToRadians(dAng);
qsFormula = geom.GetLength().replace("\n", " ");
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
Calculator cal2; Calculator cal2;
dLen = cal2.EvalFormula(rPattern.PlainVariables(), qsFormula); dLen = cal2.EvalFormula(rPattern.PlainVariables(), geom.GetLength());
dLen = ToPixel(dLen, *rPattern.GetPatternUnit()); dLen = ToPixel(dLen, *rPattern.GetPatternUnit());
} }
catch(qmu::QmuParserError &e) catch(qmu::QmuParserError &e)

View File

@ -213,8 +213,8 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
UpdateList(); UpdateList();
ui->groupBoxGrainline->setChecked(piece.GetGrainlineGeometry().IsVisible()); ui->groupBoxGrainline->setChecked(piece.GetGrainlineGeometry().IsVisible());
ui->lineEditRotFormula->setPlainText(piece.GetGrainlineGeometry().GetRotation()); SetGrainlineAngle(piece.GetGrainlineGeometry());
ui->lineEditLenFormula->setPlainText(piece.GetGrainlineGeometry().GetLength()); SetGrainlineLength(piece.GetGrainlineGeometry());
ui->comboBoxArrow->setCurrentIndex(int(piece.GetGrainlineGeometry().GetArrowType())); ui->comboBoxArrow->setCurrentIndex(int(piece.GetGrainlineGeometry().GetArrowType()));
m_oldData = piece.GetPatternPieceData(); m_oldData = piece.GetPatternPieceData();
@ -1989,3 +1989,31 @@ QVector<T> DialogSeamAllowance::GetPieceInternals(const QListWidget *list) const
} }
return internals; return internals;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetGrainlineAngle(const VGrainlineData &data)
{
const QString formula = qApp->TrVars()->FormulaToUser(data.GetRotation(), qApp->Settings()->GetOsSeparator());
// increase height if needed.
if (formula.length() > 80)
{
this->DeployRotation();
}
ui->lineEditRotFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditRotFormula);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetGrainlineLength(const VGrainlineData &data)
{
const QString formula = qApp->TrVars()->FormulaToUser(data.GetLength(), qApp->Settings()->GetOsSeparator());
// increase height if needed.
if (formula.length() > 80)
{
this->DeployLength();
}
ui->lineEditLenFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditLenFormula);
}

View File

@ -198,6 +198,8 @@ private:
template <typename T> template <typename T>
QVector<T> GetPieceInternals(const QListWidget *list) const; QVector<T> GetPieceInternals(const QListWidget *list) const;
void SetGrainlineAngle(const VGrainlineData &data);
void SetGrainlineLength(const VGrainlineData &data);
}; };
#endif // DIALOGSEAMALLOWANCE_H #endif // DIALOGSEAMALLOWANCE_H

View File

@ -353,7 +353,7 @@ void DialogTool::ChangeCurrentData(QComboBox *box, const QVariant &value) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit) void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit) const
{ {
SCASSERT(plainTextEdit != nullptr) SCASSERT(plainTextEdit != nullptr)
QTextCursor cursor = plainTextEdit->textCursor(); QTextCursor cursor = plainTextEdit->textCursor();

View File

@ -262,7 +262,7 @@ protected:
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables
*/ */
virtual void SaveData() {} virtual void SaveData() {}
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit); void MoveCursorToEnd(QPlainTextEdit *plainTextEdit) const;
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
quint32 DNumber(const QString &baseName) const; quint32 DNumber(const QString &baseName) const;