Fix color swatch not updating when a different coloured filament is selected. (#14038)

* Fix color swatch not updating when a different coloured filament is selected.

* Address review comment
This commit is contained in:
Ioannis Giannakas
2026-06-05 21:01:51 +03:00
committed by GitHub
parent 9f1bc75c70
commit 1ec574bcbb
2 changed files with 19 additions and 1 deletions

View File

@@ -9549,6 +9549,12 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
wxGetApp().get_tab(preset_type)->select_preset(preset_name);
}
// ORCA: Always refresh the selected filament combo so its color swatch (clr_picker)
// matches the chosen preset. update_ams_color() (in OnSelect) updates the project
// filament color when the preset defines one; this repaints the swatch to match.
if (preset_type == Preset::TYPE_FILAMENT)
combo->update();
// update plater with new config
q->on_config_change(wxGetApp().preset_bundle->full_config());
if (preset_type == Preset::TYPE_PRINTER) {

View File

@@ -234,7 +234,19 @@ int PresetComboBox::update_ams_color()
std::string ctype;
std::vector<std::string> colors;
if (idx < 0) {
auto name = Preset::remove_suffix_modified(GetValue().ToUTF8().data());
// ORCA: The combo displays the preset alias while
// the stored preset name usually carries a printer suffix. Resolving with the raw display
// value via find_preset() fails for such presets, so this returned early and the
// filament color swatch (clr_picker) kept showing the previous color. Prefer the
// internal preset name stored per item, then fall back to alias resolution.
std::string name;
if (m_last_selected >= 0) {
wxString stored = GetItemAlias(m_last_selected);
if (!stored.empty())
name = Preset::remove_suffix_modified(stored.ToUTF8().data());
}
if (name.empty())
name = m_collection->get_preset_name_by_alias(Preset::remove_suffix_modified(GetValue().ToUTF8().data()));
auto *preset = m_collection->find_preset(name);
if (preset)
color = preset->config.opt_string("default_filament_colour", 0u);