Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Matena <lukasmatena@seznam.cz>2021-05-10 09:13:23 +0300
committerLukas Matena <lukasmatena@seznam.cz>2021-05-24 13:20:29 +0300
commitc5c6f51ae0802bf39ef4fe2cf3bd324967e30cb1 (patch)
tree9e4ada63600191259051c8d55f19b227d6963771 /src
parentfef385cd6b948cccb2aa75cb77d0abeb4fcac355 (diff)
Fixed third batch of locale-dependent calls
Diffstat (limited to 'src')
-rw-r--r--src/libslic3r/AppConfig.cpp15
-rw-r--r--src/libslic3r/AppConfig.hpp2
-rw-r--r--src/libslic3r/Config.cpp4
-rw-r--r--src/libslic3r/Config.hpp8
-rw-r--r--src/libslic3r/Format/SL1.cpp1
-rw-r--r--src/libslic3r/LocalesUtils.cpp8
-rw-r--r--src/libslic3r/LocalesUtils.hpp2
-rw-r--r--src/libslic3r/Point.hpp10
-rw-r--r--src/libslic3r/SLAPrintSteps.cpp4
-rw-r--r--src/slic3r/GUI/BitmapCache.cpp2
-rw-r--r--src/slic3r/GUI/GLCanvas3D.cpp4
11 files changed, 34 insertions, 26 deletions
diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp
index d9301d1f3..cf532160d 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 <utility>
#include <vector>
#include <stdexcept>
@@ -376,7 +378,8 @@ void AppConfig::set_recent_projects(const std::vector<std::string>& 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<std::string, std::map<std::string, std::string>>::value_type(key, std::map<std::string, std::string>())).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 c8ccd18cd..03924175d 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 5db1d8179..bd396243c 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 <assert.h>
#include <fstream>
#include <iostream>
@@ -462,7 +464,7 @@ void ConfigBase::set(const std::string &opt_key, double value, bool create)
switch (opt->type()) {
case coFloat: static_cast<ConfigOptionFloat*>(opt)->value = value; break;
case coFloatOrPercent: static_cast<ConfigOptionFloatOrPercent*>(opt)->value = value; static_cast<ConfigOptionFloatOrPercent*>(opt)->percent = false; break;
- case coString: static_cast<ConfigOptionString*>(opt)->value = std::to_string(value); break;
+ case coString: static_cast<ConfigOptionString*>(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 adda2654e..e67b6b781 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 4038cb046..1809c3e4f 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 5ee6ac58e..116078a25 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 c74c8b1ac..113cfa04b 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 12870b713..e5ce68420 100644
--- a/src/libslic3r/Point.hpp
+++ b/src/libslic3r/Point.hpp
@@ -11,6 +11,8 @@
#include <Eigen/Geometry>
+#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<d
inline Vec3d unscale(const Vec3crd &pt) { return Vec3d(unscale<double>(pt(0)), unscale<double>(pt(1)), unscale<double>(pt(2))); }
inline Vec3d unscale(const Vec3d &pt) { return Vec3d(unscale<double>(pt(0)), unscale<double>(pt(1)), unscale<double>(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<Vec3f> transform(const std::vector<Vec3f>& 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 46064c55b..51e2430aa 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 0a6f3e4f9..2c756c3b9 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 734bc24aa..455eb8a78 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;
}