From 2d52e155a58740cde9fc9aea5ec860b37c04d5e9 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 26 Feb 2021 13:56:51 +0100 Subject: [PATCH] Follow-up of 86d7e1fb907d9841a1d0cf516415fea84e8b5280 -> Fixed update after editing custom g-code in settings tabs --- src/slic3r/GUI/Tab.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 947c058a4e..cf1879bb16 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1732,10 +1732,10 @@ bool Tab::validate_custom_gcode(const wxString& title, const std::string& gcode) return !invalid; } -static void validate_custom_gcode_cb(Tab* tab, ConfigOptionsGroupShp opt_group, const boost::any& value) { +static void validate_custom_gcode_cb(Tab* tab, ConfigOptionsGroupShp opt_group, const t_config_option_key& opt_key, const boost::any& value) { Tab::validate_custom_gcode(opt_group->title, boost::any_cast(value)); tab->update_dirty(); - tab->update(); + tab->on_value_change(opt_key, value); } #endif // ENABLE_VALIDATE_CUSTOM_GCODE @@ -1964,7 +1964,7 @@ void TabFilament::build() optgroup = page->new_optgroup(L("Start G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, value); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("start_filament_gcode"); @@ -1976,7 +1976,7 @@ void TabFilament::build() optgroup = page->new_optgroup(L("End G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, value); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("end_filament_gcode"); @@ -2273,17 +2273,11 @@ void TabPrinter::build_fff() const int gcode_field_height = 15; // 150 const int notes_field_height = 25; // 250 -#if ENABLE_VALIDATE_CUSTOM_GCODE - // WARNING !! - // if you are going to change any of the following optgroup/option titles - // or to add/remove optgroups/options - // update also TabPrinter::validate_custom_gcodes() -#endif // ENABLE_VALIDATE_CUSTOM_GCODE page = add_options_page(L("Custom G-code"), "cog"); optgroup = page->new_optgroup(L("Start G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("start_gcode"); @@ -2295,7 +2289,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("End G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("end_gcode"); @@ -2307,7 +2301,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("Before layer change G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("before_layer_gcode"); @@ -2319,7 +2313,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("After layer change G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("layer_gcode"); @@ -2331,7 +2325,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("Tool change G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("toolchange_gcode"); @@ -2343,7 +2337,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("Between objects G-code (for sequential printing)"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("between_objects_gcode"); @@ -2355,7 +2349,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("Color Change G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("color_change_gcode"); @@ -2366,7 +2360,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("Pause Print G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("pause_print_gcode"); @@ -2377,7 +2371,7 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("Template Custom G-code"), 0); #if ENABLE_VALIDATE_CUSTOM_GCODE optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { - validate_custom_gcode_cb(this, optgroup, boost::any_cast(value)); + validate_custom_gcode_cb(this, optgroup, opt_key, value); }; #endif // ENABLE_VALIDATE_CUSTOM_GCODE option = optgroup->get_option("template_custom_gcode");