diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 83de577aa..a49124f87 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -418,7 +418,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = L("This is only used in the Slic3r interface as a visual help."); def->cli = "filament-color=s@"; def->gui_type = "color"; - def->default_value = new ConfigOptionStrings { "#29b2b2" }; + def->default_value = new ConfigOptionStrings { "#29B2B2" }; def = this->add("filament_notes", coStrings); def->label = L("Filament notes"); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 52b7ea94e..7cb3491f6 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -62,9 +62,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_undo_to_sys_btn->SetBackgroundColour(color); } m_undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); - m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ })); + m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); })); m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG)); - m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ })); + m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); })); m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 0, wxBOTTOM, 3); @@ -442,6 +442,51 @@ void Tab::update_undo_buttons() m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(undo_to_sys_icon)), wxBITMAP_TYPE_PNG)); } +void Tab::on_back_to_initial_value() +{ + if (!m_is_modified_values) return; + + auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); + for (auto page : m_pages) + if (page->title() == selection) { + for (auto group : page->m_optgroups){ + if (group->title == _("Capabilities")){ + if (find(m_dirty_options.begin(), m_dirty_options.end(), "extruders_count") != m_dirty_options.end()) + group->back_to_initial_value("extruders_count"); + } + for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { + const std::string& opt_key = it->first; + if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) != m_dirty_options.end()) + group->back_to_initial_value(opt_key); + } + } + break; + } + +} + +void Tab::on_back_to_sys_value() +{ + if (!m_is_nonsys_values) return; + + auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); + for (auto page : m_pages) + if (page->title() == selection) { + for (auto group : page->m_optgroups) { + if (group->title == _("Capabilities")){ + if (find(m_sys_options.begin(), m_sys_options.end(), "extruders_count") == m_sys_options.end()) + group->back_to_sys_value("extruders_count"); + } + for (t_opt_map::iterator it = group->m_opt_map.begin(); it != group->m_opt_map.end(); ++it) { + const std::string& opt_key = it->first; + if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) + group->back_to_sys_value(opt_key); + } + } + break; + } +} + // Update the combo box label of the selected preset based on its "dirty" state, // comparing the selected preset config with $self->{config}. void Tab::update_dirty(){ diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index fbc65745c..eaf188df4 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -163,6 +163,9 @@ public: void update_changed_tree_ui(); void update_undo_buttons(); + void on_back_to_initial_value(); + void on_back_to_sys_value(); + PageShp add_options_page(wxString title, std::string icon, bool is_extruder_pages = false); virtual void OnActivate(){}