ENH: Synchronize the modification of parameters to another extruder.

Change-Id: Ieac8dce3f4edec310a51d8e3af90df81a2abcbdb
Jira: none
(cherry picked from commit a1491f432ea617d799e5dd5a135b39da45aeeca9)
This commit is contained in:
chunmao.guo
2024-07-15 14:38:13 +08:00
committed by Noisyfox
parent 5458e0ea6c
commit e546a9188e
6 changed files with 42 additions and 33 deletions

View File

@@ -42,14 +42,14 @@ void ConfigManipulation::toggle_field(const std::string &opt_key, const bool tog
cb_toggle_field(opt_key, toggle, opt_index); cb_toggle_field(opt_key, toggle, opt_index);
} }
void ConfigManipulation::toggle_line(const std::string& opt_key, const bool toggle) void ConfigManipulation::toggle_line(const std::string& opt_key, const bool toggle, int opt_index)
{ {
if (local_config) { if (local_config) {
if (local_config->option(opt_key) == nullptr) if (local_config->option(opt_key) == nullptr)
return; return;
} }
if (cb_toggle_line) if (cb_toggle_line)
cb_toggle_line(opt_key, toggle); cb_toggle_line(opt_key, toggle, opt_index);
} }
void ConfigManipulation::check_nozzle_recommended_temperature_range(DynamicPrintConfig *config) { void ConfigManipulation::check_nozzle_recommended_temperature_range(DynamicPrintConfig *config) {

View File

@@ -28,7 +28,7 @@ class ConfigManipulation
// function to loading of changed configuration // function to loading of changed configuration
std::function<void()> load_config = nullptr; std::function<void()> load_config = nullptr;
std::function<void (const std::string&, bool toggle, int opt_index)> cb_toggle_field = nullptr; std::function<void (const std::string&, bool toggle, int opt_index)> cb_toggle_field = nullptr;
std::function<void (const std::string&, bool toggle)> cb_toggle_line = nullptr; std::function<void(const std::string &, bool toggle, int opt_index)> cb_toggle_line = nullptr;
// callback to propagation of changed value, if needed // callback to propagation of changed value, if needed
std::function<void(const std::string&, const boost::any&)> cb_value_change = nullptr; std::function<void(const std::string&, const boost::any&)> cb_value_change = nullptr;
//BBS: change local config to const DynamicPrintConfig //BBS: change local config to const DynamicPrintConfig
@@ -41,7 +41,7 @@ class ConfigManipulation
public: public:
ConfigManipulation(std::function<void()> load_config, ConfigManipulation(std::function<void()> load_config,
std::function<void(const std::string&, bool toggle, int opt_index)> cb_toggle_field, std::function<void(const std::string&, bool toggle, int opt_index)> cb_toggle_field,
std::function<void(const std::string&, bool toggle)> cb_toggle_line, std::function<void(const std::string&, bool toggle, int opt_index)> cb_toggle_line,
std::function<void(const std::string&, const boost::any&)> cb_value_change, std::function<void(const std::string&, const boost::any&)> cb_value_change,
//BBS: change local config to DynamicPrintConfig //BBS: change local config to DynamicPrintConfig
const DynamicPrintConfig* local_config = nullptr, const DynamicPrintConfig* local_config = nullptr,
@@ -66,7 +66,7 @@ public:
void apply(DynamicPrintConfig* config, DynamicPrintConfig* new_config); void apply(DynamicPrintConfig* config, DynamicPrintConfig* new_config);
t_config_option_keys const &applying_keys() const; t_config_option_keys const &applying_keys() const;
void toggle_field(const std::string& field_key, const bool toggle, int opt_index = -1); void toggle_field(const std::string& field_key, const bool toggle, int opt_index = -1);
void toggle_line(const std::string& field_key, const bool toggle); void toggle_line(const std::string& field_key, const bool toggle, int opt_index = -1);
// FFF print // FFF print
void update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config = false, const bool is_plate_config = false); void update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config = false, const bool is_plate_config = false);

View File

@@ -290,7 +290,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
if (field) if (field)
field->toggle(toggle); field->toggle(toggle);
}; };
auto toggle_line = [this, optgroup](const t_config_option_key & opt_key, bool toggle) auto toggle_line = [this, optgroup](const t_config_option_key &opt_key, bool toggle, int opt_index)
{ {
Line* line = optgroup->get_line(opt_key); Line* line = optgroup->get_line(opt_key);
if (line) line->toggle_visible = toggle; if (line) line->toggle_visible = toggle;
@@ -392,7 +392,7 @@ void ObjectTableSettings::update_config_values(bool is_object, ModelObject* obje
if (field) if (field)
field->toggle(toggle); field->toggle(toggle);
}; };
auto toggle_line = [this](const t_config_option_key &opt_key, bool toggle) { auto toggle_line = [this](const t_config_option_key &opt_key, bool toggle, int opt_index) {
for (auto og : m_og_settings) { for (auto og : m_og_settings) {
Line *line = og->get_line(opt_key); Line *line = og->get_line(opt_key);
if (line) { line->toggle_visible = toggle; break; } if (line) { line->toggle_visible = toggle; break; }

View File

@@ -1243,17 +1243,11 @@ boost::any ConfigOptionsGroup::get_config_value2(const DynamicPrintConfig& confi
Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int opt_index) Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int opt_index)
{ {
Field* field = get_field(opt_key); Field *field = get_field(opt_key);
if (field != nullptr) if (field != nullptr)
return field; return field;
std::string opt_id = ""; std::string opt_id = opt_key + '#' + std::to_string(opt_index);
for (t_opt_map::iterator it = m_opt_map.begin(); it != m_opt_map.end(); ++it) { return get_field(opt_id);
if (opt_key == m_opt_map.at(it->first).first && opt_index == m_opt_map.at(it->first).second) {
opt_id = it->first;
break;
}
}
return opt_id.empty() ? nullptr : get_field(opt_id);
} }
std::pair<OG_CustomCtrl*, bool*> ConfigOptionsGroup::get_custom_ctrl_with_blinking_ptr(const t_config_option_key& opt_key, int opt_index/* = -1*/) std::pair<OG_CustomCtrl*, bool*> ConfigOptionsGroup::get_custom_ctrl_with_blinking_ptr(const t_config_option_key& opt_key, int opt_index/* = -1*/)

View File

@@ -1398,10 +1398,10 @@ void Tab::toggle_option(const std::string& opt_key, bool toggle, int opt_index/*
field->toggle(toggle); field->toggle(toggle);
} }
void Tab::toggle_line(const std::string &opt_key, bool toggle) void Tab::toggle_line(const std::string &opt_key, bool toggle, int opt_index)
{ {
if (!m_active_page) return; if (!m_active_page) return;
Line *line = m_active_page->get_line(opt_key); Line *line = m_active_page->get_line(opt_key, opt_index);
if (line) line->toggle_visible = toggle; if (line) line->toggle_visible = toggle;
}; };
@@ -6577,7 +6577,8 @@ void Tab::update_extruder_variants(int extruder_id)
} }
m_extruder_switch->SetLabels(wxString::Format(_L("Left: %s"), left), wxString::Format(_L("Right: %s"), right)); m_extruder_switch->SetLabels(wxString::Format(_L("Left: %s"), left), wxString::Format(_L("Right: %s"), right));
m_extruder_switch->SetValue(extruder_id == 1); m_extruder_switch->SetValue(extruder_id == 1);
m_extruder_switch->Enable(); m_extruder_switch->Enable(true);
assert(m_extruder_switch->IsEnabled());
} else { } else {
m_extruder_switch->Enable(false); m_extruder_switch->Enable(false);
m_main_sizer->Show(m_extruder_switch, false); m_main_sizer->Show(m_extruder_switch, false);
@@ -6810,19 +6811,33 @@ void Page::refresh()
Field *Page::get_field(const t_config_option_key &opt_key, int opt_index /*= -1*/) const Field *Page::get_field(const t_config_option_key &opt_key, int opt_index /*= -1*/) const
{ {
Field *field = nullptr; Field *field = nullptr;
auto opt_key2 = opt_key;
if (opt_index >= 256) {
auto iter = m_opt_id_map.find(opt_key + '#' + std::to_string(opt_index - 256));
if (iter != m_opt_id_map.end())
opt_key2 = iter->second;
}
for (auto opt : m_optgroups) { for (auto opt : m_optgroups) {
field = opt->get_fieldc(opt_key, opt_index); field = opt->get_fieldc(opt_key2, opt_index);
if (field != nullptr) return field; if (field != nullptr) return field;
} }
return field; return field;
} }
Line *Page::get_line(const t_config_option_key &opt_key) Line *Page::get_line(const t_config_option_key &opt_key, int opt_index)
{ {
for (auto opt : m_optgroups) Line *line = nullptr;
if (Line* line = opt->get_line(opt_key)) auto opt_key2 = opt_key;
return line; if (opt_index >= 256) {
return nullptr; auto iter = m_opt_id_map.find(opt_key + '#' + std::to_string(opt_index - 256));
if (iter != m_opt_id_map.end())
opt_key2 = iter->second;
}
for (auto opt : m_optgroups) {
line = opt->get_line(opt_key2);
if (line != nullptr) return line;
}
return line;
} }
bool Page::set_value(const t_config_option_key &opt_key, const boost::any &value) bool Page::set_value(const t_config_option_key &opt_key, const boost::any &value)
@@ -7206,11 +7221,11 @@ ConfigManipulation Tab::get_config_manipulation()
}; };
auto cb_toggle_field = [this](const t_config_option_key& opt_key, bool toggle, int opt_index) { auto cb_toggle_field = [this](const t_config_option_key& opt_key, bool toggle, int opt_index) {
return toggle_option(opt_key, toggle, opt_index); return toggle_option(opt_key, toggle, opt_index >= 0 ? opt_index + 256 : opt_index);
}; };
auto cb_toggle_line = [this](const t_config_option_key& opt_key, bool toggle) { auto cb_toggle_line = [this](const t_config_option_key &opt_key, bool toggle, int opt_index) {
return toggle_line(opt_key, toggle); return toggle_line(opt_key, toggle, opt_index >= 0 ? opt_index + 256 : opt_index);
}; };
auto cb_value_change = [this](const std::string& opt_key, const boost::any& value) { auto cb_value_change = [this](const std::string& opt_key, const boost::any& value) {

View File

@@ -96,7 +96,7 @@ public:
void sys_color_changed(); void sys_color_changed();
void refresh(); void refresh();
Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const;
Line * get_line(const t_config_option_key &opt_key); Line * get_line(const t_config_option_key &opt_key, int opt_index = -1);
bool set_value(const t_config_option_key& opt_key, const boost::any& value); bool set_value(const t_config_option_key& opt_key, const boost::any& value);
// BBS. Add is_extruder_og parameter. // BBS. Add is_extruder_og parameter.
ConfigOptionsGroupShp new_optgroup(const wxString& title, const wxString& icon = wxEmptyString, int noncommon_label_width = -1, bool is_extruder_og = false); ConfigOptionsGroupShp new_optgroup(const wxString& title, const wxString& icon = wxEmptyString, int noncommon_label_width = -1, bool is_extruder_og = false);
@@ -388,7 +388,7 @@ public:
Field* get_field(const t_config_option_key &opt_key, Page** selected_page, int opt_index = -1); Field* get_field(const t_config_option_key &opt_key, Page** selected_page, int opt_index = -1);
void toggle_option(const std::string &opt_key, bool toggle, int opt_index = -1); void toggle_option(const std::string &opt_key, bool toggle, int opt_index = -1);
void toggle_line(const std::string &opt_key, bool toggle); // BBS: hide some line void toggle_line(const std::string &opt_key, bool toggle, int opt_index = -1); // BBS: hide some line
wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText, wxString text = wxEmptyString); wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText, wxString text = wxEmptyString);
bool current_preset_is_dirty() const; bool current_preset_is_dirty() const;
bool saved_preset_is_dirty() const; bool saved_preset_is_dirty() const;