mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-30 15:31:59 +08:00
Moved trim_zeroes to libslic3r utils.
This commit is contained in:
parent
ee71f8b8f8
commit
49f123ca20
@ -148,14 +148,7 @@ 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())); }
|
||||
|
||||
|
@ -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<Settings> ui_settings;
|
||||
|
||||
std::string trim_zeroes(std::string in);
|
||||
wxString trim_zeroes(wxString in);
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -9,5 +9,6 @@
|
||||
/// Separate a string based on some regular expression string.
|
||||
std::vector<std::string>
|
||||
split_at_regex(const std::string& input, const std::string& regex);
|
||||
std::string trim_zeroes(std::string in);
|
||||
|
||||
#endif // UTILS_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user