diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index d9301d1f3d..cf532160dc 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -2,8 +2,10 @@ #include "libslic3r/Utils.hpp" #include "AppConfig.hpp" #include "Exception.hpp" +#include "LocalesUtils.hpp" #include "Thread.hpp" + #include #include #include @@ -376,7 +378,8 @@ void AppConfig::set_recent_projects(const std::vector& recent_proje } } -void AppConfig::set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz) +void AppConfig::set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, + float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz) { std::string key = std::string("mouse_device:") + name; auto it = m_storage.find(key); @@ -384,11 +387,11 @@ void AppConfig::set_mouse_device(const std::string& name, double translation_spe it = m_storage.insert(std::map>::value_type(key, std::map())).first; it->second.clear(); - it->second["translation_speed"] = std::to_string(translation_speed); - it->second["translation_deadzone"] = std::to_string(translation_deadzone); - it->second["rotation_speed"] = std::to_string(rotation_speed); - it->second["rotation_deadzone"] = std::to_string(rotation_deadzone); - it->second["zoom_speed"] = std::to_string(zoom_speed); + it->second["translation_speed"] = float_to_string_decimal_point(translation_speed); + it->second["translation_deadzone"] = float_to_string_decimal_point(translation_deadzone); + it->second["rotation_speed"] = float_to_string_decimal_point(rotation_speed); + it->second["rotation_deadzone"] = float_to_string_decimal_point(rotation_deadzone); + it->second["zoom_speed"] = float_to_string_decimal_point(zoom_speed); it->second["swap_yz"] = swap_yz ? "1" : "0"; } diff --git a/src/libslic3r/AppConfig.hpp b/src/libslic3r/AppConfig.hpp index c8ccd18cd8..03924175d8 100644 --- a/src/libslic3r/AppConfig.hpp +++ b/src/libslic3r/AppConfig.hpp @@ -196,6 +196,6 @@ private: bool m_legacy_datadir; }; -}; // namespace Slic3r +} // namespace Slic3r #endif /* slic3r_AppConfig_hpp_ */ diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 5db1d8179b..bd396243c0 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -1,6 +1,8 @@ #include "Config.hpp" #include "format.hpp" #include "Utils.hpp" +#include "LocalesUtils.hpp" + #include #include #include @@ -462,7 +464,7 @@ void ConfigBase::set(const std::string &opt_key, double value, bool create) switch (opt->type()) { case coFloat: static_cast(opt)->value = value; break; case coFloatOrPercent: static_cast(opt)->value = value; static_cast(opt)->percent = false; break; - case coString: static_cast(opt)->value = std::to_string(value); break; + case coString: static_cast(opt)->value = float_to_string_decimal_point(value); break; default: throw BadOptionTypeException("Configbase::set() - conversion from float not possible"); } } diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index adda2654ed..e67b6b781f 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -1819,10 +1819,10 @@ public: SetDeserializeItem(const std::string &opt_key, const bool value, bool append = false) : opt_key(opt_key), opt_value(value ? "1" : "0"), append(append) {} SetDeserializeItem(const char *opt_key, const int value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {} SetDeserializeItem(const std::string &opt_key, const int value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {} - SetDeserializeItem(const char *opt_key, const float value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {} - SetDeserializeItem(const std::string &opt_key, const float value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {} - SetDeserializeItem(const char *opt_key, const double value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {} - SetDeserializeItem(const std::string &opt_key, const double value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {} + SetDeserializeItem(const char *opt_key, const float value, bool append = false) : opt_key(opt_key), opt_value(float_to_string_decimal_point(value)), append(append) {} + SetDeserializeItem(const std::string &opt_key, const float value, bool append = false) : opt_key(opt_key), opt_value(float_to_string_decimal_point(value)), append(append) {} + SetDeserializeItem(const char *opt_key, const double value, bool append = false) : opt_key(opt_key), opt_value(float_to_string_decimal_point(value)), append(append) {} + SetDeserializeItem(const std::string &opt_key, const double value, bool append = false) : opt_key(opt_key), opt_value(float_to_string_decimal_point(value)), append(append) {} std::string opt_key; std::string opt_value; bool append = false; }; // May throw BadOptionTypeException() if the operation fails. diff --git a/src/libslic3r/Format/SL1.cpp b/src/libslic3r/Format/SL1.cpp index 4038cb0467..1809c3e4f3 100644 --- a/src/libslic3r/Format/SL1.cpp +++ b/src/libslic3r/Format/SL1.cpp @@ -345,6 +345,7 @@ std::string get_cfg_value(const DynamicPrintConfig &cfg, const std::string &key) void fill_iniconf(ConfMap &m, const SLAPrint &print) { + CNumericLocalesSetter locales_setter; // for to_string auto &cfg = print.full_print_config(); m["layerHeight"] = get_cfg_value(cfg, "layer_height"); m["expTime"] = get_cfg_value(cfg, "exposure_time"); diff --git a/src/libslic3r/LocalesUtils.cpp b/src/libslic3r/LocalesUtils.cpp index 5ee6ac58ea..116078a25b 100644 --- a/src/libslic3r/LocalesUtils.cpp +++ b/src/libslic3r/LocalesUtils.cpp @@ -66,10 +66,10 @@ std::string float_to_string_decimal_point(double value, int precision/* = -1*/) return buf.str(); } -std::string float_to_string_decimal_point(float value, int precision/* = -1*/) -{ - return float_to_string_decimal_point(double(value), precision); -} +//std::string float_to_string_decimal_point(float value, int precision/* = -1*/) +//{ +// return float_to_string_decimal_point(double(value), precision); +//} } // namespace Slic3r diff --git a/src/libslic3r/LocalesUtils.hpp b/src/libslic3r/LocalesUtils.hpp index c74c8b1ac7..113cfa04b0 100644 --- a/src/libslic3r/LocalesUtils.hpp +++ b/src/libslic3r/LocalesUtils.hpp @@ -39,7 +39,7 @@ bool is_decimal_separator_point(); // to be sure that decimal point is used as a separator. // (We use user C locales and "C" C++ locales in most of the code.) std::string float_to_string_decimal_point(double value, int precision = -1); -std::string float_to_string_decimal_point(float value, int precision = -1); +//std::string float_to_string_decimal_point(float value, int precision = -1); double string_to_double_decimal_point(const std::string& str, size_t* pos = nullptr); } // namespace Slic3r diff --git a/src/libslic3r/Point.hpp b/src/libslic3r/Point.hpp index 12870b7132..e5ce68420e 100644 --- a/src/libslic3r/Point.hpp +++ b/src/libslic3r/Point.hpp @@ -11,6 +11,8 @@ #include +#include "LocalesUtils.hpp" + namespace Slic3r { class BoundingBox; @@ -88,10 +90,10 @@ inline Vec3d unscale(coord_t x, coord_t y, coord_t z) { return Vec3d(unscale(pt(0)), unscale(pt(1)), unscale(pt(2))); } inline Vec3d unscale(const Vec3d &pt) { return Vec3d(unscale(pt(0)), unscale(pt(1)), unscale(pt(2))); } -inline std::string to_string(const Vec2crd &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + "]"; } -inline std::string to_string(const Vec2d &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + "]"; } -inline std::string to_string(const Vec3crd &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + ", " + std::to_string(pt(2)) + "]"; } -inline std::string to_string(const Vec3d &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + ", " + std::to_string(pt(2)) + "]"; } +inline std::string to_string(const Vec2crd &pt) { return std::string("[") + float_to_string_decimal_point(pt(0)) + ", " + float_to_string_decimal_point(pt(1)) + "]"; } +inline std::string to_string(const Vec2d &pt) { return std::string("[") + float_to_string_decimal_point(pt(0)) + ", " + float_to_string_decimal_point(pt(1)) + "]"; } +inline std::string to_string(const Vec3crd &pt) { return std::string("[") + float_to_string_decimal_point(pt(0)) + ", " + float_to_string_decimal_point(pt(1)) + ", " + float_to_string_decimal_point(pt(2)) + "]"; } +inline std::string to_string(const Vec3d &pt) { return std::string("[") + float_to_string_decimal_point(pt(0)) + ", " + float_to_string_decimal_point(pt(1)) + ", " + float_to_string_decimal_point(pt(2)) + "]"; } std::vector transform(const std::vector& points, const Transform3f& t); Pointf3s transform(const Pointf3s& points, const Transform3d& t); diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index 46064c55b8..51e2430aae 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -166,8 +166,8 @@ struct FaceHash { Vec<3, int64_t> c = a.cross(b) + (pts[0] + pts[1] + pts[2]) / 3; // Return a concatenated string representation of the coordinates - return std::to_string(c(0)) + std::to_string(c(1)) + std::to_string(c(2)); - }; + return float_to_string_decimal_point(c(0)) + float_to_string_decimal_point(c(1)) + float_to_string_decimal_point(c(2)); + } FaceHash(const indexed_triangle_set &its) { diff --git a/src/slic3r/GUI/BitmapCache.cpp b/src/slic3r/GUI/BitmapCache.cpp index 0a6f3e4f9f..2c756c3b95 100644 --- a/src/slic3r/GUI/BitmapCache.cpp +++ b/src/slic3r/GUI/BitmapCache.cpp @@ -266,7 +266,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_ std::string bitmap_key = bitmap_name + ( target_height !=0 ? "-h" + std::to_string(target_height) : "-w" + std::to_string(target_width)) - + (m_scale != 1.0f ? "-s" + std::to_string(m_scale) : "") + + (m_scale != 1.0f ? "-s" + float_to_string_decimal_point(m_scale) : "") + (grayscale ? "-gs" : ""); /* For the Dark mode of any platform, we should draw icons in respect to OS background diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 734bc24aa6..455eb8a781 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3800,7 +3800,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) if (imgui->slider_float(_L("Spacing"), &settings.distance, dist_min, 100.0f, "%5.2f") || dist_min > settings.distance) { settings.distance = std::max(dist_min, settings.distance); settings_out.distance = settings.distance; - appcfg->set("arrange", dist_key.c_str(), std::to_string(settings_out.distance)); + appcfg->set("arrange", dist_key.c_str(), float_to_string_decimal_point(settings_out.distance)); settings_changed = true; } @@ -3815,7 +3815,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) if (imgui->button(_L("Reset"))) { settings_out = ArrangeSettings{}; settings_out.distance = std::max(dist_min, settings_out.distance); - appcfg->set("arrange", dist_key.c_str(), std::to_string(settings_out.distance)); + appcfg->set("arrange", dist_key.c_str(), float_to_string_decimal_point(settings_out.distance)); appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0"); settings_changed = true; }