From 6548a6d525108ae1c694239ba0bbce83eb97cc19 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 15 Mar 2019 14:21:32 +0100 Subject: [PATCH] Fixed preset selection after ConfigWizard running --- src/slic3r/GUI/GUI.cpp | 3 --- src/slic3r/GUI/Preset.cpp | 4 +++- src/slic3r/GUI/Tab.cpp | 24 +++++++++++++++++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 11e94f2ca..4a3ccc356 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -148,9 +148,6 @@ void config_wizard(int reason) _(L("Please check and fix your object list.")), _(L("Attention!"))); } - - // Load the currently selected preset into the GUI, update the preset selection box. - // wxGetApp().load_current_presets(); // #ys_FIXME_to_delete presets are loaded now in select_preset function } // opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element) diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 86fdde44b..bb70b8f47 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -952,7 +952,9 @@ void PresetCollection::update_platter_ui(GUI::PresetComboBox *ui) ui->SetToolTip(ui->GetString(selected_preset_item)); ui->Thaw(); - ui->selected_preset_name = this->get_selected_preset().name; + // For printer preset it's important to update preset list every time because of ConfigWizard + // So, don't save selected preset name + ui->selected_preset_name = type()==Preset::TYPE_PRINTER ? "" : this->get_selected_preset().name; } size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompatible) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index ae33443c3..b23becaae 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2594,7 +2594,7 @@ void Tab::select_preset(std::string preset_name) } else { if (current_dirty) m_presets->discard_current_changes(); - m_presets->select_preset_by_name(preset_name, false); + const bool is_selected = m_presets->select_preset_by_name(preset_name, false); // Mark the print & filament enabled if they are compatible with the currently selected preset. // The following method should not discard changes of current print or filament presets on change of a printer profile, // if they are compatible with the current printer. @@ -2603,6 +2603,28 @@ void Tab::select_preset(std::string preset_name) // Initialize the UI from the current preset. if (printer_tab) static_cast(this)->update_pages(); + + if (!is_selected && printer_tab) + { + /* There is a case, when : + * after Config Wizard applying we try to select previously selected preset, but + * in a current configuration this one: + * 1. doesn't exist now, + * 2. have another printer_technology + * So, it is necessary to update list of dependent tabs + * to the corresponding printer_technology + */ + const PrinterTechnology printer_technology = m_presets->get_edited_preset().printer_technology(); + if (printer_technology == ptFFF && m_dependent_tabs.front() != Preset::Type::TYPE_PRINT || + printer_technology == ptSLA && m_dependent_tabs.front() != Preset::Type::TYPE_SLA_PRINT ) + { + m_dependent_tabs.clear(); + if (printer_technology == ptFFF) + m_dependent_tabs = { Preset::Type::TYPE_PRINT, Preset::Type::TYPE_FILAMENT }; + else + m_dependent_tabs = { Preset::Type::TYPE_SLA_PRINT, Preset::Type::TYPE_SLA_MATERIAL }; + } + } load_current_preset(); } }