Fixed wrong preset comboboxes updating on sidebar after preset changing on "Printer Settings" tab
This commit is contained in:
parent
70f1cdaf01
commit
4de0f574fb
3 changed files with 29 additions and 9 deletions
|
@ -783,7 +783,7 @@ void MainFrame::on_presets_changed(SimpleEvent &event)
|
||||||
// Update preset combo boxes(Print settings, Filament, Material, Printer) from their respective tabs.
|
// Update preset combo boxes(Print settings, Filament, Material, Printer) from their respective tabs.
|
||||||
auto presets = tab->get_presets();
|
auto presets = tab->get_presets();
|
||||||
if (m_plater != nullptr && presets != nullptr) {
|
if (m_plater != nullptr && presets != nullptr) {
|
||||||
auto reload_dependent_tabs = tab->get_dependent_tabs();
|
// auto reload_dependent_tabs = tab->get_dependent_tabs();
|
||||||
|
|
||||||
// FIXME: The preset type really should be a property of Tab instead
|
// FIXME: The preset type really should be a property of Tab instead
|
||||||
Slic3r::Preset::Type preset_type = tab->type();
|
Slic3r::Preset::Type preset_type = tab->type();
|
||||||
|
@ -791,7 +791,7 @@ void MainFrame::on_presets_changed(SimpleEvent &event)
|
||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
m_plater->sidebar().update_presets(preset_type);
|
m_plater->sidebar().update_presets(preset_type);
|
||||||
|
|
||||||
if (preset_type == Slic3r::Preset::TYPE_PRINTER) {
|
if (preset_type == Slic3r::Preset::TYPE_PRINTER) {
|
||||||
|
@ -809,7 +809,9 @@ void MainFrame::on_presets_changed(SimpleEvent &event)
|
||||||
cur_tab->load_current_preset();
|
cur_tab->load_current_preset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
m_plater->on_config_change(*tab->get_config());
|
m_plater->on_config_change(*tab->get_config());
|
||||||
|
m_plater->sidebar().update_presets(preset_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,9 +844,13 @@ void MainFrame::update_ui_from_settings()
|
||||||
{
|
{
|
||||||
m_menu_item_reslice_now->Enable(wxGetApp().app_config->get("background_processing") == "1");
|
m_menu_item_reslice_now->Enable(wxGetApp().app_config->get("background_processing") == "1");
|
||||||
// if (m_plater) m_plater->update_ui_from_settings();
|
// if (m_plater) m_plater->update_ui_from_settings();
|
||||||
|
/*
|
||||||
std::vector<std::string> tab_names = { "print", "filament", "printer" };
|
std::vector<std::string> tab_names = { "print", "filament", "printer" };
|
||||||
for (auto tab_name: tab_names)
|
for (auto tab_name: tab_names)
|
||||||
m_options_tabs[tab_name]->update_ui_from_settings();
|
m_options_tabs[tab_name]->update_ui_from_settings();
|
||||||
|
*/
|
||||||
|
for (auto tab: wxGetApp().tabs_list)
|
||||||
|
tab->update_ui_from_settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -759,6 +759,18 @@ void Tab::update_wiping_button_visibility() {
|
||||||
// to uddate number of "filament" selection boxes when the number of extruders change.
|
// to uddate number of "filament" selection boxes when the number of extruders change.
|
||||||
void Tab::on_presets_changed()
|
void Tab::on_presets_changed()
|
||||||
{
|
{
|
||||||
|
if (m_type == Slic3r::Preset::TYPE_PRINTER && !m_dependent_tabs.empty()) {
|
||||||
|
// Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
|
||||||
|
for (auto t: m_dependent_tabs)
|
||||||
|
{
|
||||||
|
// If the printer tells us that the print or filament/sla_material preset has been switched or invalidated,
|
||||||
|
// refresh the print or filament/sla_material tab page.
|
||||||
|
Tab* tab = wxGetApp().get_tab(t);
|
||||||
|
if (tab)
|
||||||
|
tab->load_current_preset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wxCommandEvent event(EVT_TAB_PRESETS_CHANGED);
|
wxCommandEvent event(EVT_TAB_PRESETS_CHANGED);
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
wxPostEvent(this, event);
|
wxPostEvent(this, event);
|
||||||
|
@ -2335,7 +2347,7 @@ void Tab::select_preset(std::string preset_name)
|
||||||
auto current_dirty = m_presets->current_is_dirty();
|
auto current_dirty = m_presets->current_is_dirty();
|
||||||
auto printer_tab = m_presets->name() == "printer";
|
auto printer_tab = m_presets->name() == "printer";
|
||||||
auto canceled = false;
|
auto canceled = false;
|
||||||
m_reload_dependent_tabs = {};
|
m_dependent_tabs = {};
|
||||||
if (current_dirty && !may_discard_current_dirty_preset()) {
|
if (current_dirty && !may_discard_current_dirty_preset()) {
|
||||||
canceled = true;
|
canceled = true;
|
||||||
} else if (printer_tab) {
|
} else if (printer_tab) {
|
||||||
|
@ -2350,16 +2362,16 @@ void Tab::select_preset(std::string preset_name)
|
||||||
PrinterTechnology old_printer_technology = m_presets->get_edited_preset().printer_technology();
|
PrinterTechnology old_printer_technology = m_presets->get_edited_preset().printer_technology();
|
||||||
PrinterTechnology new_printer_technology = new_printer_preset.printer_technology();
|
PrinterTechnology new_printer_technology = new_printer_preset.printer_technology();
|
||||||
struct PresetUpdate {
|
struct PresetUpdate {
|
||||||
std::string name;
|
Preset::Type tab_type;
|
||||||
PresetCollection *presets;
|
PresetCollection *presets;
|
||||||
PrinterTechnology technology;
|
PrinterTechnology technology;
|
||||||
bool old_preset_dirty;
|
bool old_preset_dirty;
|
||||||
bool new_preset_compatible;
|
bool new_preset_compatible;
|
||||||
};
|
};
|
||||||
std::vector<PresetUpdate> updates = {
|
std::vector<PresetUpdate> updates = {
|
||||||
{ "print", &m_preset_bundle->prints, ptFFF },
|
{ Preset::Type::TYPE_PRINT, &m_preset_bundle->prints, ptFFF },
|
||||||
{ "filament", &m_preset_bundle->filaments, ptFFF },
|
{ Preset::Type::TYPE_FILAMENT, &m_preset_bundle->filaments, ptFFF },
|
||||||
{ "sla_material", &m_preset_bundle->sla_materials, ptSLA }
|
{ Preset::Type::TYPE_SLA_MATERIAL,&m_preset_bundle->sla_materials, ptSLA }
|
||||||
};
|
};
|
||||||
for (PresetUpdate &pu : updates) {
|
for (PresetUpdate &pu : updates) {
|
||||||
pu.old_preset_dirty = (old_printer_technology == pu.technology) && pu.presets->current_is_dirty();
|
pu.old_preset_dirty = (old_printer_technology == pu.technology) && pu.presets->current_is_dirty();
|
||||||
|
@ -2371,7 +2383,7 @@ void Tab::select_preset(std::string preset_name)
|
||||||
for (PresetUpdate &pu : updates) {
|
for (PresetUpdate &pu : updates) {
|
||||||
// The preset will be switched to a different, compatible preset, or the '-- default --'.
|
// The preset will be switched to a different, compatible preset, or the '-- default --'.
|
||||||
if (pu.technology == new_printer_technology)
|
if (pu.technology == new_printer_technology)
|
||||||
m_reload_dependent_tabs.emplace_back(pu.name);
|
m_dependent_tabs.emplace_back(pu.tab_type);
|
||||||
if (pu.old_preset_dirty)
|
if (pu.old_preset_dirty)
|
||||||
pu.presets->discard_current_changes();
|
pu.presets->discard_current_changes();
|
||||||
}
|
}
|
||||||
|
@ -2597,6 +2609,7 @@ void Tab::update_ui_from_settings()
|
||||||
// in application preferences.
|
// in application preferences.
|
||||||
m_show_btn_incompatible_presets = wxGetApp().app_config->get("show_incompatible_presets")[0] == '1' ? true : false;
|
m_show_btn_incompatible_presets = wxGetApp().app_config->get("show_incompatible_presets")[0] == '1' ? true : false;
|
||||||
bool show = m_show_btn_incompatible_presets && m_presets->name().compare("printer") != 0;
|
bool show = m_show_btn_incompatible_presets && m_presets->name().compare("printer") != 0;
|
||||||
|
Layout();
|
||||||
show ? m_btn_hide_incompatible_presets->Show() : m_btn_hide_incompatible_presets->Hide();
|
show ? m_btn_hide_incompatible_presets->Show() : m_btn_hide_incompatible_presets->Hide();
|
||||||
// If the 'show / hide presets' button is hidden, hide the incompatible presets.
|
// If the 'show / hide presets' button is hidden, hide the incompatible presets.
|
||||||
if (show) {
|
if (show) {
|
||||||
|
|
|
@ -175,6 +175,7 @@ protected:
|
||||||
bool m_show_incompatible_presets;
|
bool m_show_incompatible_presets;
|
||||||
|
|
||||||
std::vector<std::string> m_reload_dependent_tabs = {};
|
std::vector<std::string> m_reload_dependent_tabs = {};
|
||||||
|
std::vector<Preset::Type> m_dependent_tabs = {};
|
||||||
enum OptStatus { osSystemValue = 1, osInitValue = 2 };
|
enum OptStatus { osSystemValue = 1, osInitValue = 2 };
|
||||||
std::map<std::string, int> m_options_list;
|
std::map<std::string, int> m_options_list;
|
||||||
int m_opt_status_value = 0;
|
int m_opt_status_value = 0;
|
||||||
|
|
Loading…
Reference in a new issue