ENH: config: process object config values after printer switch

jira: no-jira
Change-Id: I01532c42c20aa63b1b9621e175a98cad06bdf577
(cherry picked from commit cc86a62d408cb40942c49277a7f239144d7a5567)
This commit is contained in:
lane.wei
2024-11-23 16:59:54 +08:00
committed by Noisyfox
parent b8f8151340
commit 1297857f66
4 changed files with 189 additions and 3 deletions

View File

@@ -4973,14 +4973,17 @@ void Tab::load_current_preset()
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<<boost::format(": enter");
const Preset& preset = m_presets->get_edited_preset();
int previous_extruder_count = 0;
update_btns_enabling();
update();
if (m_type == Slic3r::Preset::TYPE_PRINTER) {
// For the printer profile, generate the extruder pages.
if (preset.printer_technology() == ptFFF)
if (preset.printer_technology() == ptFFF) {
previous_extruder_count = static_cast<TabPrinter*>(this)->m_extruders_count;
on_preset_loaded();
}
else
wxGetApp().obj_list()->update_objects_list_filament_column(1);
}
@@ -5065,6 +5068,39 @@ void Tab::load_current_preset()
dynamic_cast<Notebook*>(wxGetApp().tab_panel())->SetPageImage(wxGetApp().tab_panel()->FindPage(this), printer_technology == ptFFF ? "printer" : "sla_printer");
#endif
}
//update the object config due to extruder count change
DynamicPrintConfig& new_print_config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
int new_extruder_count = wxGetApp().preset_bundle->get_printer_extruder_count();
if (previous_extruder_count != new_extruder_count)
{
//process the object params here
Model& model = wxGetApp().plater()->model();
size_t num_objects = model.objects.size();
for (int i = 0; i < num_objects; ++i) {
ModelObject* object = model.objects[i];
DynamicPrintConfig object_config = object->config.get();
if (!object_config.empty()) {
if (previous_extruder_count < new_extruder_count)
object_config.update_values_from_single_to_multi_2(new_print_config, print_options_with_variant);
else
object_config.update_values_from_multi_to_single_2(print_options_with_variant);
object->config.assign_config(std::move(object_config));
}
for (ModelVolume* v : object->volumes) {
if (v->is_model_part()) {
DynamicPrintConfig volume_config = v->config.get();
if (!volume_config.empty()) {
if (previous_extruder_count < new_extruder_count)
volume_config.update_values_from_single_to_multi_2(new_print_config, print_options_with_variant);
else
volume_config.update_values_from_multi_to_single_2(print_options_with_variant);
v->config.assign_config(std::move(volume_config));
}
}
}
}
}
on_presets_changed();
if (printer_technology == ptFFF) {
static_cast<TabPrinter*>(this)->m_initial_extruders_count = static_cast<const ConfigOptionFloats*>(m_presets->get_selected_preset().config.option("nozzle_diameter"))->values.size(); //static_cast<TabPrinter*>(this)->m_extruders_count;