From c9f79655992d447181013b16722fdc2c998d89f1 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 10 May 2019 11:44:21 +0200 Subject: [PATCH] Reverted a change in number text formatting. Fixed some message wording. --- src/slic3r/GUI/Field.cpp | 26 +++++++++++++++++++++++++- src/slic3r/GUI/GLCanvas3D.cpp | 8 ++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index edc65aca0..9443f3658 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -15,7 +15,31 @@ namespace Slic3r { namespace GUI { wxString double_to_string(double const value, const int max_precision /*= 4*/) { - return wxNumberFormatter::ToString(value, max_precision, wxNumberFormatter::Style_NoTrailingZeroes); +// Style_NoTrailingZeroes does not work on OSX. It also does not work correctly with some locales on Windows. +// return wxNumberFormatter::ToString(value, max_precision, wxNumberFormatter::Style_NoTrailingZeroes); + + wxString s = wxNumberFormatter::ToString(value, max_precision, wxNumberFormatter::Style_None); + + // The following code comes from wxNumberFormatter::RemoveTrailingZeroes(wxString& s) + // with the exception that here one sets the decimal separator explicitely to dot. + // If number is in scientific format, trailing zeroes belong to the exponent and cannot be removed. + if (s.find_first_of("eE") == wxString::npos) { + const size_t posDecSep = s.find("."); + // No decimal point => removing trailing zeroes irrelevant for integer number. + if (posDecSep != wxString::npos) { + // Find the last character to keep. + size_t posLastNonZero = s.find_last_not_of("0"); + // If it's the decimal separator itself, don't keep it neither. + if (posLastNonZero == posDecSep) + -- posLastNonZero; + s.erase(posLastNonZero + 1); + // Remove sign from orphaned zero. + if (s.compare("-0") == 0) + s = "0"; + } + } + + return s; } void Field::PostInitialize() diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 80815c8be..084762a80 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -716,12 +716,12 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool std::string text; bool red_colored = false; switch (m_warnings.back()) { - case ObjectOutside : text = L("Detected object outside print volume"); break; - case ToolpathOutside : text = L("Detected toolpath outside print volume"); break; + case ObjectOutside : text = L("An object outside the print area was detected"); break; + case ToolpathOutside : text = L("A toolpath outside the print area was detected"); break; case SomethingNotShown : text = L("Some objects are not visible when editing supports"); break; case ObjectClashed: { - text = L("Detected object outside print volume\n" - "Resolve a clash to continue slicing/export process correctly"); + text = L("An object outside the print area was detected\n" + "Resolve the current problem to continue slicing"); red_colored = true; break; }