Fix of SPE-1035 (Wrong filament color updating for multi-material print)
This commit is contained in:
parent
4b35ebe6e5
commit
904bbcc006
3 changed files with 35 additions and 0 deletions
|
@ -4842,6 +4842,34 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
|
|||
this->p->schedule_background_process();
|
||||
}
|
||||
|
||||
void Plater::force_filament_colors_update()
|
||||
{
|
||||
bool update_scheduled = false;
|
||||
DynamicPrintConfig* config = p->config;
|
||||
const std::vector<std::string> filament_presets = wxGetApp().preset_bundle->filament_presets;
|
||||
if (filament_presets.size() > 1 &&
|
||||
p->config->option<ConfigOptionStrings>("filament_colour")->values.size() == filament_presets.size())
|
||||
{
|
||||
const PresetCollection& filaments = wxGetApp().preset_bundle->filaments;
|
||||
std::vector<std::string> filament_colors;
|
||||
filament_colors.reserve(filament_presets.size());
|
||||
|
||||
for (const std::string& filament_preset : filament_presets)
|
||||
filament_colors.push_back(filaments.find_preset(filament_preset, true)->config.opt_string("filament_colour", (unsigned)0));
|
||||
|
||||
if (config->option<ConfigOptionStrings>("filament_colour")->values != filament_colors) {
|
||||
config->option<ConfigOptionStrings>("filament_colour")->values = filament_colors;
|
||||
update_scheduled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (update_scheduled)
|
||||
update();
|
||||
|
||||
if (p->main_frame->is_loaded())
|
||||
this->p->schedule_background_process();
|
||||
}
|
||||
|
||||
void Plater::on_activate()
|
||||
{
|
||||
#ifdef __linux__
|
||||
|
|
|
@ -211,6 +211,7 @@ public:
|
|||
|
||||
void on_extruders_change(size_t extruders_count);
|
||||
void on_config_change(const DynamicPrintConfig &config);
|
||||
void force_filament_colors_update();
|
||||
// On activating the parent window.
|
||||
void on_activate();
|
||||
const DynamicPrintConfig* get_plater_config() const;
|
||||
|
|
|
@ -3032,6 +3032,12 @@ void Tab::save_preset(std::string name /*= ""*/)
|
|||
if (m_type == Preset::TYPE_PRINTER)
|
||||
static_cast<TabPrinter*>(this)->m_initial_extruders_count = static_cast<TabPrinter*>(this)->m_extruders_count;
|
||||
update_changed_ui();
|
||||
|
||||
/* If filament preset is saved for multi-material printer preset,
|
||||
* there are cases when filament comboboxs are updated for old (non-modified) colors,
|
||||
* but in full_config a filament_colors option aren't.*/
|
||||
if (m_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1)
|
||||
wxGetApp().plater()->force_filament_colors_update();
|
||||
}
|
||||
|
||||
// Called for a currently selected preset.
|
||||
|
|
Loading…
Reference in a new issue