Skip to content

Commit

Permalink
fix config rework for linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Dec 23, 2023
1 parent b672a1a commit 123f4a3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ class ConfigOptionPercentsTempl : public ConfigOptionFloatsTempl<NULLABLE>
if (&v != &this->values.front())
ss << ",";
this->serialize_single_value(ss, v);
if (! (std::isnan(v) || v == NIL_VALUE()))
if (!(std::isnan(v) || v == ConfigOptionFloatsTempl<NULLABLE>::NIL_VALUE()))
ss << "%";
}
std::string str = ss.str();
Expand All @@ -1214,7 +1214,7 @@ class ConfigOptionPercentsTempl : public ConfigOptionFloatsTempl<NULLABLE>
for (const double v : this->values) {
std::ostringstream ss;
this->serialize_single_value(ss, v);
if (! (std::isnan(v) || v == NIL_VALUE()))
if (!(std::isnan(v) || v == ConfigOptionFloatsTempl<NULLABLE>::NIL_VALUE()))
ss << "%";
vv.push_back(ss.str());
}
Expand Down
1 change: 0 additions & 1 deletion src/libslic3r/GCode/SeamPlacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "libslic3r/Utils.hpp"

//#define DEBUG_FILES
#pragma optimize("", off)
#ifdef DEBUG_FILES
#include <boost/nowide/cstdio.hpp>
#include <SVG.hpp>
Expand Down
50 changes: 36 additions & 14 deletions src/slic3r/GUI/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,13 @@ std::pair<wxString, bool> any_to_wxstring(const boost::any &value, const ConfigO
};
// first, easy convert-to one-string
switch (opt.type) {
case coFloats:
case coFloats: {
if (opt_idx < 0) {
deserialize(ConfigOptionFloats{});
break;
}
case coPercents:
}
case coPercents: {
if (opt_idx < 0) {
deserialize(ConfigOptionPercents{});
break;
Expand All @@ -400,23 +401,31 @@ std::pair<wxString, bool> any_to_wxstring(const boost::any &value, const ConfigO
has_nil = true;
break;
}
}
case coFloat:
case coPercent: text_value = double_to_string(boost::any_cast<double>(value), opt.precision); break;
case coStrings:
case coPercent: {
text_value = double_to_string(boost::any_cast<double>(value), opt.precision);
break;
}
case coStrings: {
if (opt_idx < 0) {
//custom for strings, as we don't need the serialized form, the normal one with ';' in-between is enough
// custom for strings, as we don't need the serialized form, the normal one with ';' in-between is enough
ConfigOptionStrings reader;
reader.set_any(value, opt_idx);
std::string good_str;
for (std::string s : reader.values) good_str += s + ";";
if(!good_str.empty())
if (!good_str.empty())
good_str.pop_back();
text_value = good_str;
break;
}
// can't be nullable
case coString: text_value = boost::any_cast<std::string>(value); break;
case coFloatsOrPercents:
}
case coString: {
text_value = boost::any_cast<std::string>(value);
break;
}
case coFloatsOrPercents: {
if (opt_idx < 0) {
deserialize(ConfigOptionFloatsOrPercents{});
break;
Expand All @@ -427,13 +436,15 @@ std::pair<wxString, bool> any_to_wxstring(const boost::any &value, const ConfigO
has_nil = true;
break;
}
case coFloatOrPercent:
}
case coFloatOrPercent: {
FloatOrPercent fl_or_per = boost::any_cast<FloatOrPercent>(value);
text_value = double_to_string(fl_or_per.value);
if (fl_or_per.percent)
text_value.append("%");
break;
case coBools:
}
case coBools: {
if (opt_idx < 0) {
deserialize(ConfigOptionBools{});
} else {
Expand All @@ -445,12 +456,14 @@ std::pair<wxString, bool> any_to_wxstring(const boost::any &value, const ConfigO
text_value = boost::any_cast<uint8_t>(value) != 0 ? "true" : "false";
}
break;
case coBool:
}
case coBool: {
if (opt.is_script)
text_value = boost::any_cast<uint8_t>(value) != 0 ? "true" : "false";
else
text_value = boost::any_cast<bool>(value) ? "true" : "false";
case coInts:
}
case coInts: {
if (opt_idx < 0) {
deserialize(ConfigOptionInts{});
break;
Expand All @@ -460,14 +473,21 @@ std::pair<wxString, bool> any_to_wxstring(const boost::any &value, const ConfigO
has_nil = true;
break;
}
case coInt: text_value = wxString::Format(_T("%i"), int(boost::any_cast<int>(value))); break;
}
case coInt: {
text_value = wxString::Format(_T("%i"), int(boost::any_cast<int>(value)));
break;
}
case coPoints:
if (opt_idx < 0) {
deserialize(ConfigOptionPoints{});
assert(text_value == get_points_string(boost::any_cast<std::vector<Vec2d>>(value)));
break;
}
case coPoint: text_value = get_points_string({boost::any_cast<Vec2d>(value)});
case coPoint: {
text_value = get_points_string({boost::any_cast<Vec2d>(value)});
break;
}
}
return {text_value, has_nil};
}
Expand Down Expand Up @@ -2308,6 +2328,8 @@ boost::any &SliderCtrl::get_value()
} else if (m_opt.type == coInt) {
return m_value = int32_t(m_slider->GetValue() / m_scale);
}
assert(false);
return m_value;
}

} // GUI
Expand Down

0 comments on commit 123f4a3

Please sign in to comment.