Skip to content

Commit

Permalink
fixes linux
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Aug 1, 2024
1 parent fa06a25 commit f1ee53e
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 65 deletions.
59 changes: 32 additions & 27 deletions src/slic3r/GUI/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,8 +1158,8 @@ bool TextCtrl::value_was_changed()
case coPoints:
if (m_opt_idx < 0) {
return boost::any_cast<std::vector<Vec2d>>(m_value) != boost::any_cast<std::vector<Vec2d>>(val);
} else if (boost::any_cast<std::vector<Vec2d>>(m_value).size() > m_opt_idx
&& boost::any_cast<std::vector<Vec2d>>(val).size() > m_opt_idx) {
} else if (int(boost::any_cast<std::vector<Vec2d>>(m_value).size()) > m_opt_idx
&& int(boost::any_cast<std::vector<Vec2d>>(val).size()) > m_opt_idx) {
return boost::any_cast<std::vector<Vec2d>>(m_value)[m_opt_idx] != boost::any_cast<std::vector<Vec2d>>(val)[m_opt_idx];
}
case coPoint:
Expand Down Expand Up @@ -1363,7 +1363,7 @@ void CheckBox::Rescale(wxWindow* win)
}
#ifdef __WXGTK2__
if (wxToggleButton* chk = dynamic_cast<wxToggleButton*>(win))
chk->Rescale();
chk->Update();
#endif
}

Expand Down Expand Up @@ -1402,12 +1402,14 @@ void CheckBox::BUILD() {
#ifdef __WXGTK2__
//gtk2 can't resize checkboxes, so we are using togglable buttons instead
window->Bind(wxEVT_TOGGLEBUTTON, ([this](wxCommandEvent e) {
m_is_na_val = false;
if (static_cast<wxToggleButton*>(window)->GetValue())
static_cast<wxToggleButton*>(window)->SetLabel("X");
else
static_cast<wxToggleButton*>(window)->SetLabel("");
on_change_field();
if (wxToggleButton* chk = dynamic_cast<wxToggleButton*>(window)) {
m_is_na_val = false;
if (chk->GetValue())
chk->SetLabel("X");
else
chk->SetLabel("");
on_change_field();
}
}), window->GetId());
#else
window->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent e) {
Expand Down Expand Up @@ -1870,18 +1872,19 @@ void Choice::set_selection()
field->SetSelection(*opt);
else
field->SetValue(text_value);
}
}
}

void Choice::set_text_value(const std::string &value, bool change_event) //! Redundant?
{
m_disable_change_event = !change_event;
choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
if (auto opt = m_opt.enum_def->value_to_index(value); opt.has_value())
if (auto opt = m_opt.enum_def->value_to_index(value); opt.has_value()) {
// This enum has a value field of the same content as text_value. Select it.
field->SetSelection(*opt);
else
} else {
field->SetValue(value);
}
m_disable_change_event = false;
}

Expand Down Expand Up @@ -2011,19 +2014,20 @@ boost::any& Choice::get_value()
else if (m_opt.gui_type == ConfigOptionDef::GUIType::f_enum_open || m_opt.gui_type == ConfigOptionDef::GUIType::i_enum_open) {
// Open enum: The combo box item index returned by the field
const int ret_enum = field->GetSelection();
if (m_opt.enum_def->has_values() && (m_opt.type == coString || m_opt.type == coStrings) && ret_enum >=0 && ret_enum < m_opt.enum_def->values().size()) {
if (m_opt.enum_def->has_values() && (m_opt.type == coString || m_opt.type == coStrings) && ret_enum >=0 && ret_enum < int(m_opt.enum_def->values().size())) {
m_value = m_opt.enum_def->value(ret_enum);
} else if (ret_enum < 0 || !m_opt.enum_def->has_values() || m_opt.type == coStrings ||
(into_u8(ret_str) != m_opt.enum_def->value(ret_enum) && ret_str != _(m_opt.enum_def->label(ret_enum))))
(into_u8(ret_str) != m_opt.enum_def->value(ret_enum) && ret_str != _(m_opt.enum_def->label(ret_enum)))) {
// modifies ret_string!
get_value_by_opt_type(ret_str);
else if (m_opt.type == coFloatOrPercent) {
} else if (m_opt.type == coFloatOrPercent) {
m_value = FloatOrPercent{string_to_double_decimal_point(m_opt.enum_def->value(ret_enum)),
(m_opt.enum_def->value(ret_enum).find('%') != std::string::npos)};
} else if (m_opt.type == coInt)
} else if (m_opt.type == coInt) {
m_value = atoi(m_opt.enum_def->value(ret_enum).c_str());
else
} else {
m_value = string_to_double_decimal_point(m_opt.enum_def->value(ret_enum));
}
}
else
// modifies ret_string!
Expand Down Expand Up @@ -2095,16 +2099,15 @@ void ColourPicker::BUILD()
// Validate the color
wxColour clr = wxTransparentColour;
if (m_opt.type == coStrings)
clr = wxColour{wxString{ m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx) }};
clr = wxColour{wxString{m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx)}};
if (m_opt.type == coString)
clr = wxColour{ wxString{ m_opt.get_default_value<ConfigOptionString>()->value } };
clr = wxColour{wxString{m_opt.get_default_value<ConfigOptionString>()->value}};
if (m_opt.type == coInts)
clr = wxColour{ (unsigned long)m_opt.get_default_value<ConfigOptionInts>()->get_at(m_opt_idx) };
clr = wxColour{(unsigned long) m_opt.get_default_value<ConfigOptionInts>()->get_at(m_opt_idx)};
if (m_opt.type == coInt)
clr = wxColour{ (unsigned long)m_opt.get_default_value<ConfigOptionInt>()->value };
if (!clr.IsOk()) {
clr = wxTransparentColour;
}
clr = wxColour{(unsigned long) m_opt.get_default_value<ConfigOptionInt>()->value};
if (!clr.IsOk())
clr = wxTransparentColour;

auto temp = new wxColourPickerCtrl(m_parent, wxID_ANY, clr, wxDefaultPosition, size);
if (parent_is_custom_ctrl && m_opt.height < 0)
Expand Down Expand Up @@ -2320,11 +2323,13 @@ void PointCtrl::BUILD()
const wxSize field_size(4 * m_em_unit, -1);

Vec2d default_pt;
if (m_opt.type == coPoint)
if (m_opt.type == coPoint) {
default_pt = m_opt.get_default_value<ConfigOptionPoint>()->value;
else // coPoints
} else { // coPoints
assert(m_opt.type == coPoints);
default_pt = m_opt.get_default_value<ConfigOptionPoints>()->get_at(0);
double val = default_pt(0);
}
double val = default_pt.x();
wxString X = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
val = default_pt(1);
wxString Y = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/)
try {
if (view_params.exact)
pattern = std::wregex(wsearch, std::regex_constants::icase);
} catch (std::regex_error reg_err) {
} catch (std::regex_error) {
// Happens when std::wregex("]") or similar. => no result //TODO: add warning message 'wrong regexp'
fail_pattern = true;
}
Expand Down
5 changes: 5 additions & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4778,6 +4778,11 @@ void Tab::transfer_options(const std::string &name_from, const std::string &name

Preset* preset_from = m_presets->find_preset(name_from);
Preset* preset_to = m_presets->find_preset(name_to);

if (preset_from == nullptr || preset_to == nullptr){
assert(false);
return;
}

if (m_type == Preset::TYPE_PRINTER) {
auto it = std::find(options.begin(), options.end(), "extruders_count");
Expand Down
93 changes: 56 additions & 37 deletions src/slic3r/GUI/UnsavedChangesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ wxString graph_to_string(const GraphData &graph)
case GraphData::GraphType::SQUARE: str = _L("Square") + ":"; break;
case GraphData::GraphType::LINEAR: str = _L("Linear") + ":"; break;
case GraphData::GraphType::SPLINE: str = _L("Spline") + ":"; break;
default: assert(false);
}
for (const Vec2d &pt : graph.data()) { str += format_wxstr(" %1%,%2%", pt.x(), pt.y()); }
return str;
Expand All @@ -1119,17 +1120,18 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
case coInts: {
if (is_nullable) {
auto values = config.opt<ConfigOptionIntsNullable>(opt_key);
if (opt_idx < values->size())
if (opt_idx < values->size()) {
return from_u8((boost::format("%1%") % values->get_at(opt_idx)).str());
else
} else {
return from_u8(values->serialize());
}
else {
}
} else {
auto values = config.opt<ConfigOptionInts>(opt_key);
if (opt_idx < values->size())
if (opt_idx < values->size()) {
return from_u8((boost::format("%1%") % values->get_at(opt_idx)).str());
else
} else {
return from_u8(values->serialize());
}
}
return _L("Undef");
}
Expand All @@ -1138,17 +1140,19 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
case coBools: {
if (is_nullable) {
auto values = config.opt<ConfigOptionBoolsNullable>(opt_key);
if (opt_idx < values->size())
if (opt_idx < values->size()) {
return values->get_at(opt_idx) ? "true" : "false";
else
} else {
return from_u8(values->serialize());
}
}
else {
auto values = config.opt<ConfigOptionBools>(opt_key);
if (opt_idx < values->size())
if (opt_idx < values->size()) {
return values->get_at(opt_idx) ? "true" : "false";
else
} else {
return from_u8(values->serialize());
}
}
return _L("Undef");
}
Expand All @@ -1157,17 +1161,18 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
case coPercents: {
if (is_nullable) {
auto values = config.opt<ConfigOptionPercentsNullable>(opt_key);
if (opt_idx < values->size())
if (opt_idx < values->size()) {
return from_u8((boost::format("%1%%%") % values->get_at(opt_idx)).str());
else
} else {
return from_u8(values->serialize());
}
else {
}
} else {
auto values = config.opt<ConfigOptionPercents>(opt_key);
if (opt_idx < values->size())
if (opt_idx < values->size()) {
return from_u8((boost::format("%1%%%") % values->get_at(opt_idx)).str());
else
} else {
return from_u8(values->serialize());
}
}
return _L("Undef");
}
Expand All @@ -1176,17 +1181,18 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
case coFloats: {
if (is_nullable) {
auto values = config.opt<ConfigOptionFloatsNullable>(opt_key);
if (opt_idx < values->size())
if (opt_idx < values->size()) {
return double_to_string(values->get_at(opt_idx), opt->precision);
else
} else {
return from_u8(values->serialize());
}
else {
}
} else {
auto values = config.opt<ConfigOptionFloats>(opt_key);
if (opt_idx < values->size())
if (opt_idx < values->size()) {
return double_to_string(values->get_at(opt_idx), opt->precision);
else
} else {
return from_u8(values->serialize());
}
}
return _L("Undef");
}
Expand All @@ -1202,27 +1208,33 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
const ConfigOptionStrings* strings = config.opt<ConfigOptionStrings>(opt_key);
if (strings) {
if (opt_key == "compatible_printers" || opt_key == "compatible_prints") {
if (strings->empty())
return _L("All");
for (size_t id = 0; id < strings->size(); id++)
if (strings->empty()) {
return _L("All");
}
for (size_t id = 0; id < strings->size(); id++) {
out += from_u8(strings->get_at(id)) + "\n";
}
out.RemoveLast(1);
return out;
}
if (opt_key == "gcode_substitutions") {
if (!strings->empty())
for (size_t id = 0; id < strings->size(); id += 4)
if (!strings->empty()) {
for (size_t id = 0; id < strings->size(); id += 4) {
out += from_u8(strings->get_at(id)) + ";\t" +
from_u8(strings->get_at(id + 1)) + ";\t" +
from_u8(strings->get_at(id + 2)) + ";\t" +
from_u8(strings->get_at(id + 3)) + ";\n";
}
}
return out;
}
if (!strings->empty())
if (opt_idx < strings->size())
if (!strings->empty()) {
if (opt_idx < strings->size()) {
return from_u8(strings->get_at(opt_idx));
else
} else {
return from_u8(strings->serialize());
}
}
}
break;
}
Expand Down Expand Up @@ -1259,22 +1271,27 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
}

const ConfigOptionPoints* opt_pts = config.opt<ConfigOptionPoints>(opt_key);
if (!opt_pts->empty())
if (opt_idx < opt_pts->size())
return from_u8((boost::format("[%1%]") % ConfigOptionPoint(opt_pts->get_at(opt_idx)).serialize()).str());
else
if (!opt_pts->empty()) {
if (opt_idx < opt_pts->size()) {
return from_u8(
(boost::format("[%1%]") % ConfigOptionPoint(opt_pts->get_at(opt_idx)).serialize()).str());
} else {
return from_u8(opt_pts->serialize());
}
}
}
case coGraph: {
return graph_to_string(config.option<ConfigOptionGraph>(opt_key)->value);
}
case coGraphs: {
const ConfigOptionGraphs* opt_graphs = config.opt<ConfigOptionGraphs>(opt_key);
if (!opt_graphs->empty())
if (opt_idx < opt_graphs->size())
if (!opt_graphs->empty()) {
if (opt_idx < opt_graphs->size()) {
return graph_to_string(opt_graphs->get_at(opt_idx));
else
} else {
return from_u8(opt_graphs->serialize());
}
}
}
default:
break;
Expand Down Expand Up @@ -2154,6 +2171,7 @@ std::string DiffPresetDialog::get_left_preset_name(Preset::Type type)
return Preset::remove_suffix_modified(get_selection(preset_combos.presets_left));
}
}
return "";
}

std::string DiffPresetDialog::get_right_preset_name(Preset::Type type)
Expand All @@ -2163,6 +2181,7 @@ std::string DiffPresetDialog::get_right_preset_name(Preset::Type type)
return Preset::remove_suffix_modified(get_selection(preset_combos.presets_right));
}
}
return "";
}

}
Expand Down

2 comments on commit f1ee53e

@mirlang
Copy link

@mirlang mirlang commented on f1ee53e Aug 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still doesn't build on linux for me :(

Circle.hpp:346:97: error: ‘Line’ does not name a type

could you have a look at this, please?

also, while grepping around, i noticed a (supposed) typo:

./src/libslic3r/Geometry/Circle.cpp: Line segmemt(points[index - 1], points[index]);
./src/libslic3r/Geometry/Circle.cpp: if ((index != 1 && ray_intersects_segment(test_arc.center, start_norm, segmemt)) ||
./src/libslic3r/Geometry/Circle.cpp: (index != point_count - 1 && ray_intersects_segment(test_arc.center, end_norm, segmemt)))

(segmemt instead of segment)

@supermerill
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently working on fixes on linux, has a working build last night.

Please sign in to comment.