From 49f123ca20a8e358a845398f53e4f76470f9987e Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 15 Jul 2018 10:10:42 -0500 Subject: [PATCH] Moved trim_zeroes to libslic3r utils. --- src/GUI/misc_ui.cpp | 9 +-------- src/GUI/misc_ui.hpp | 1 - xs/src/libslic3r/utils.cpp | 8 ++++++++ xs/src/libslic3r/utils.hpp | 1 + 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/GUI/misc_ui.cpp b/src/GUI/misc_ui.cpp index b05d3698e..f7ac27bca 100644 --- a/src/GUI/misc_ui.cpp +++ b/src/GUI/misc_ui.cpp @@ -148,14 +148,7 @@ std::vector open_model(wxWindow* parent, wxWindow* top) { return tmp; } -/// Remove extra zeroes generated from std::to_string on doubles -std::string trim_zeroes(std::string in) { - std::string result {""}; - std::regex strip_zeroes("(0*)$"); - std::regex_replace (std::back_inserter(result), in.begin(), in.end(), strip_zeroes, ""); - if (result.back() == '.') result.append("0"); - return result; -} + wxString trim_zeroes(wxString in) { return wxString(trim_zeroes(in.ToStdString())); } diff --git a/src/GUI/misc_ui.hpp b/src/GUI/misc_ui.hpp index 7bcc2bd82..fc207a3ff 100644 --- a/src/GUI/misc_ui.hpp +++ b/src/GUI/misc_ui.hpp @@ -155,7 +155,6 @@ inline Slic3r::Point new_scale(const wxPoint& p) { return Slic3r::Point::new_sca /// Singleton for UI settings. extern std::unique_ptr ui_settings; -std::string trim_zeroes(std::string in); wxString trim_zeroes(wxString in); diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp index 4275f06f8..ee1c9d7f4 100644 --- a/xs/src/libslic3r/utils.cpp +++ b/xs/src/libslic3r/utils.cpp @@ -50,3 +50,11 @@ split_at_regex(const std::string& input, const std::string& regex) { last; return {first, last}; } +/// Remove extra zeroes generated from std::to_string on doubles +std::string trim_zeroes(std::string in) { + std::string result {""}; + std::regex strip_zeroes("(0*)$"); + std::regex_replace (std::back_inserter(result), in.begin(), in.end(), strip_zeroes, ""); + if (result.back() == '.') result.append("0"); + return result; +} diff --git a/xs/src/libslic3r/utils.hpp b/xs/src/libslic3r/utils.hpp index 382ca53b2..8a21e1bc6 100644 --- a/xs/src/libslic3r/utils.hpp +++ b/xs/src/libslic3r/utils.hpp @@ -9,5 +9,6 @@ /// Separate a string based on some regular expression string. std::vector split_at_regex(const std::string& input, const std::string& regex); +std::string trim_zeroes(std::string in); #endif // UTILS_HPP