From 2c23e254975d29476a84d46ec6099f02ea6a7b6b Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 26 Mar 2021 13:32:47 +0100 Subject: [PATCH 1/4] DoubleSlider: fix for 1c2d26457092f0d0e92bf0d40e6c7796505b6eb0 --- src/slic3r/GUI/DoubleSlider.cpp | 23 +++++++++++++---------- src/slic3r/GUI/DoubleSlider.hpp | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 80b74c437..94cfedbd4 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -329,7 +329,7 @@ double Control::get_double_value(const SelectedSlider& selection) int Control::get_tick_from_value(double value) { std::vector::iterator it; - if (m_is_smart_wipe_tower) + if (m_is_wipe_tower) it = std::find_if(m_values.begin(), m_values.end(), [value](const double & val) { return fabs(value - val) <= epsilon(); }); else @@ -400,8 +400,7 @@ void Control::SetLayersTimes(const std::vector& layers_times, float total // Erase duplicates values from m_values and save it to the m_layers_values // They will be used for show the correct estimated time for MM print, when "No sparce layer" is enabled // See https://github.com/prusa3d/PrusaSlicer/issues/6232 - m_is_smart_wipe_tower = m_values.size() != m_layers_times.size(); - if (m_is_smart_wipe_tower) { + if (m_is_wipe_tower && m_values.size() != m_layers_times.size()) { m_layers_values = m_values; sort(m_layers_values.begin(), m_layers_values.end()); m_layers_values.erase(unique(m_layers_values.begin(), m_layers_values.end()), m_layers_values.end()); @@ -411,12 +410,14 @@ void Control::SetLayersTimes(const std::vector& layers_times, float total if (m_layers_values.size() != m_layers_times.size()) for (size_t i = m_layers_times.size(); i < m_layers_values.size(); i++) m_layers_times.push_back(total_time); + Refresh(); + Update(); } } void Control::SetLayersTimes(const std::vector& layers_times) { - m_is_smart_wipe_tower = false; + m_is_wipe_tower = false; m_layers_times = layers_times; for (size_t i = 1; i < m_layers_times.size(); i++) m_layers_times[i] += m_layers_times[i - 1]; @@ -439,6 +440,8 @@ void Control::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, c m_only_extruder = only_extruder; UseDefaultColors(m_mode == SingleExtruder); + + m_is_wipe_tower = m_mode != SingleExtruder; } void Control::SetExtruderColors( const std::vector& extruder_colors) @@ -535,7 +538,7 @@ void Control::render() bool Control::is_wipe_tower_layer(int tick) const { - if (!m_is_smart_wipe_tower || tick >= (int)m_values.size()) + if (!m_is_wipe_tower || tick >= (int)m_values.size()) return false; if (tick == 0 || (tick == (int)m_values.size() - 1 && m_values[tick] > m_values[tick - 1])) return false; @@ -723,9 +726,9 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer it = std::lower_bound(m_values.begin(), m_values.end(), layer_print_z - epsilon()); if (it == m_values.end()) return size_t(-1); - return m_layers_values.size(); + return size_t(value + 1); } - return size_t(it - m_layers_values.begin()); + return size_t(it - m_layers_values.begin()+1); }; #if ENABLE_GCODE_LINES_ID_IN_H_SLIDER @@ -740,7 +743,7 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer #endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER else { if (label_type == ltEstimatedTime) { - if (m_is_smart_wipe_tower) { + if (m_is_wipe_tower) { size_t layer_number = get_layer_number(value); return layer_number == size_t(-1) ? "" : short_and_splitted_time(get_time_dhms(m_layers_times[layer_number])); } @@ -752,7 +755,7 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer if (label_type == ltHeight) return str; if (label_type == ltHeightWithLayer) { - size_t layer_number = m_is_smart_wipe_tower ? get_layer_number(value) : (m_values.empty() ? value : value + 1); + size_t layer_number = m_is_wipe_tower ? get_layer_number(value) : (m_values.empty() ? value : value + 1); return format_wxstr("%1%\n(%2%)", str, layer_number); } } @@ -1498,7 +1501,7 @@ void Control::OnMotion(wxMouseEvent& event) m_focus = fiHigherThumb; else { tick = get_tick_near_point(pos); - if (tick < 0 && m_is_smart_wipe_tower) { + if (tick < 0 && m_is_wipe_tower) { tick = get_value_from_position(pos); m_focus = tick > 0 && is_wipe_tower_layer(tick) && (tick == m_lower_value || tick == m_higher_value) ? fiSmartWipeTower : fiTick; diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp index 24199b7ff..439b03a50 100644 --- a/src/slic3r/GUI/DoubleSlider.hpp +++ b/src/slic3r/GUI/DoubleSlider.hpp @@ -370,7 +370,7 @@ private: bool m_is_focused = false; bool m_force_mode_apply = true; bool m_enable_action_icon = true; - bool m_is_smart_wipe_tower = false; //This flag indicates that for current print is used "smart" wipe tower (Print Settings->Multiple Extruders->No sparse layer is enabled) + bool m_is_wipe_tower = false; //This flag indicates that there is multiple extruder print with wipe tower DrawMode m_draw_mode = dmRegular; From 45ac53efa1917fa960f297fe26afa782f6bce920 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 26 Mar 2021 19:01:10 +0100 Subject: [PATCH 2/4] Code refactoring to reduce switch statements on ConfigOptionEnum<> templates --- src/slic3r/GUI/Field.cpp | 72 ++++++++-------------------------------- src/slic3r/GUI/GUI.cpp | 35 +------------------ 2 files changed, 15 insertions(+), 92 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 8e3fff06d..1fe28eb34 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1112,28 +1112,17 @@ void Choice::set_value(const boost::any& value, bool change_event) int val = boost::any_cast(value); if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "fill_pattern") { - if (!m_opt.enum_values.empty()) { - std::string key; - t_config_enum_values map_names = ConfigOptionEnum::get_enum_values(); - for (auto it : map_names) { - if (val == it.second) { - key = it.first; - break; - } + std::string key; + const t_config_enum_values& map_names = ConfigOptionEnum::get_enum_values(); + for (auto it : map_names) + if (val == it.second) { + key = it.first; + break; } - size_t idx = 0; - for (auto el : m_opt.enum_values) - { - if (el == key) - break; - ++idx; - } - - val = idx == m_opt.enum_values.size() ? 0 : idx; - } - else - val = 0; + const std::vector& values = m_opt.enum_values; + auto it = std::find(values.begin(), values.end(), key); + val = it == values.end() ? 0 : it - values.begin(); } field->SetSelection(val); break; @@ -1199,45 +1188,12 @@ boost::any& Choice::get_value() if (m_opt.type == coEnum) { - int ret_enum = field->GetSelection(); - if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "fill_pattern") - { - if (!m_opt.enum_values.empty()) { - std::string key = m_opt.enum_values[ret_enum]; - t_config_enum_values map_names = ConfigOptionEnum::get_enum_values(); - int value = map_names.at(key); - - m_value = static_cast(value); - } - else - m_value = static_cast(0); + if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "fill_pattern") { + const std::string& key = m_opt.enum_values[field->GetSelection()]; + m_value = int(ConfigOptionEnum::get_enum_values().at(key)); } - else if (m_opt_id.compare("ironing_type") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("fuzzy_skin") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("gcode_flavor") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("machine_limits_usage") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("support_material_pattern") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("support_material_interface_pattern") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("support_material_style") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("seam_position") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("host_type") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("display_orientation") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id.compare("support_pillar_connection_mode") == 0) - m_value = static_cast(ret_enum); - else if (m_opt_id == "printhost_authorization_type") - m_value = static_cast(ret_enum); - else if (m_opt_id == "brim_type") - m_value = static_cast(ret_enum); + else + m_value = field->GetSelection(); } else if (m_opt.gui_type == ConfigOptionDef::GUIType::f_enum_open || m_opt.gui_type == ConfigOptionDef::GUIType::i_enum_open) { const int ret_enum = field->GetSelection(); diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 1d3a85dc0..f3a8f6ba1 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -177,43 +177,10 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt } break; case coEnum:{ -#if 0 auto *opt = opt_def->default_value.get()->clone(); - opt->setInt(0); + opt->setInt(boost::any_cast(value)); config.set_key_value(opt_key, opt); -#else - if (opt_key == "top_fill_pattern" || - opt_key == "bottom_fill_pattern" || - opt_key == "fill_pattern") - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("ironing_type") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("fuzzy_skin") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("gcode_flavor") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("machine_limits_usage") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("support_material_pattern") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("support_material_interface_pattern") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("support_material_style") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("seam_position") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("host_type") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if (opt_key.compare("display_orientation") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if(opt_key.compare("support_pillar_connection_mode") == 0) - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if(opt_key == "printhost_authorization_type") - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); - else if(opt_key == "brim_type") - config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); } -#endif break; case coPoints:{ if (opt_key == "bed_shape" || opt_key == "thumbnails") { From 507ba46ecc36a2b32f80c07593400216e1d09e54 Mon Sep 17 00:00:00 2001 From: rtyr <36745189+rtyr@users.noreply.github.com> Date: Mon, 29 Mar 2021 09:38:01 +0200 Subject: [PATCH 3/4] updated min_slic3r_version to 2.4.0-alpha0 --- resources/profiles/Artillery.idx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/profiles/Artillery.idx b/resources/profiles/Artillery.idx index eca18b8b4..1fa68f82b 100644 --- a/resources/profiles/Artillery.idx +++ b/resources/profiles/Artillery.idx @@ -1,2 +1,2 @@ -min_slic3r_version = 2.3.0 +min_slic3r_version = 2.4.0-alpha0 0.0.1 Initial Artillery bundle From 525f05c97583c32c86f3d893ba56673f7b6aa12f Mon Sep 17 00:00:00 2001 From: rtyr <36745189+rtyr@users.noreply.github.com> Date: Mon, 29 Mar 2021 09:38:59 +0200 Subject: [PATCH 4/4] updated min_slic3r_version to 2.4.0-alpha0 --- resources/profiles/INAT.idx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/profiles/INAT.idx b/resources/profiles/INAT.idx index ff2873c12..e682f4ed2 100644 --- a/resources/profiles/INAT.idx +++ b/resources/profiles/INAT.idx @@ -1,2 +1,2 @@ -min_slic3r_version = 2.3.0 +min_slic3r_version = 2.4.0-alpha0 0.0.1 Initial version