Move trim_zeroes to misc_ui

This commit is contained in:
Joseph Lenox 2018-07-04 16:32:39 -05:00 committed by Joseph Lenox
parent e66cda51bf
commit 9dc4343029
3 changed files with 16 additions and 8 deletions

View File

@ -342,15 +342,7 @@ private:
void _set_value(Slic3r::Pointf3 value);
void _set_value(std::string value);
/// 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())); }

View File

@ -5,6 +5,7 @@
#include <exception>
#include <stdexcept>
#include <regex>
namespace Slic3r { namespace GUI {
@ -147,5 +148,16 @@ std::vector<wxString> 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())); }
}} // namespace Slic3r::GUI

View File

@ -155,6 +155,10 @@ inline Slic3r::Point new_scale(const wxPoint& p) { return Slic3r::Point::new_sca
/// Singleton for UI settings.
extern std::unique_ptr<Settings> ui_settings;
std::string trim_zeroes(std::string in);
wxString trim_zeroes(wxString in);
}} // namespace Slic3r::GUI
#endif // MISC_UI_HPP