From 5de0644c7bcd256cc44acaaa935b98bd8d7f878e Mon Sep 17 00:00:00 2001 From: leozide Date: Wed, 26 Jul 2017 17:34:25 -0700 Subject: [PATCH] Save positions with 4 digits and rotations with 6. --- common/lc_model.cpp | 2 +- common/piece.cpp | 4 ++-- qt/lc_qutils.cpp | 4 ++-- qt/lc_qutils.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 8a5d1f37..41147aa2 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -385,7 +385,7 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly) const float Numbers[13] = { FloatMatrix[12], -FloatMatrix[14], FloatMatrix[13], FloatMatrix[0], -FloatMatrix[8], FloatMatrix[4], -FloatMatrix[2], FloatMatrix[10], -FloatMatrix[6], FloatMatrix[1], -FloatMatrix[9], FloatMatrix[5], ControlPoint.Scale }; for (int NumberIdx = 0; NumberIdx < 13; NumberIdx++) - Stream << ' ' << lcFormatValue(Numbers[NumberIdx]); + Stream << ' ' << lcFormatValue(Numbers[NumberIdx], NumberIdx < 3 ? 4 : 6); Stream << LineEnding; } diff --git a/common/piece.cpp b/common/piece.cpp index 48b97fdc..76821fa4 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -118,7 +118,7 @@ void lcPiece::SaveLDraw(QTextStream& Stream) const Stream << QLatin1String("0 !LEOCAD PIECE PIVOT "); for (int NumberIdx = 0; NumberIdx < 12; NumberIdx++) - Stream << ' ' << lcFormatValue(PivotNumbers[NumberIdx]); + Stream << ' ' << lcFormatValue(PivotNumbers[NumberIdx], NumberIdx < 3 ? 4 : 6); Stream << LineEnding; } @@ -135,7 +135,7 @@ void lcPiece::SaveLDraw(QTextStream& Stream) const float Numbers[12] = { Matrix[12], -Matrix[14], Matrix[13], Matrix[0], -Matrix[8], Matrix[4], -Matrix[2], Matrix[10], -Matrix[6], Matrix[1], -Matrix[9], Matrix[5] }; for (int NumberIdx = 0; NumberIdx < 12; NumberIdx++) - Stream << lcFormatValue(Numbers[NumberIdx]) << ' '; + Stream << lcFormatValue(Numbers[NumberIdx], NumberIdx < 3 ? 4 : 6) << ' '; Stream << mID << LineEnding; } diff --git a/qt/lc_qutils.cpp b/qt/lc_qutils.cpp index 82b8c97e..ffce15f0 100644 --- a/qt/lc_qutils.cpp +++ b/qt/lc_qutils.cpp @@ -4,9 +4,9 @@ #include "lc_library.h" #include "pieceinf.h" -QString lcFormatValue(float Value) +QString lcFormatValue(float Value, int Precision) { - QString String = QString::number(Value, 'f', 4); + QString String = QString::number(Value, 'f', Precision); int Dot = String.indexOf('.'); if (Dot != -1) diff --git a/qt/lc_qutils.h b/qt/lc_qutils.h index 1cd27baf..c7d5a9c6 100644 --- a/qt/lc_qutils.h +++ b/qt/lc_qutils.h @@ -2,7 +2,7 @@ #include -QString lcFormatValue(float Value); +QString lcFormatValue(float Value, int Precision); QString lcFormatValueLocalized(float Value); float lcParseValueLocalized(const QString& Value);