+ Added update for plater config option "filament_colour", when we have multiple extruder print.
This commit is contained in:
YuSanka 2019-08-19 17:19:21 +02:00
parent 6780e74521
commit 7706a5be3e
2 changed files with 24 additions and 18 deletions

View file

@ -4602,6 +4602,30 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
bool update_scheduled = false;
bool bed_shape_changed = false;
for (auto opt_key : p->config->diff(config)) {
if (opt_key == "filament_colour")
{
update_scheduled = true; // update should be scheduled (for update 3DScene) #2738
/* There is a case, when we use filament_color instead of extruder_color (when extruder_color == "").
* Thus plater config option "filament_colour" should be filled with filament_presets values.
* Otherwise, on 3dScene will be used last edited filament color for all volumes with extruder_color == "".
*/
const std::vector<std::string> filament_presets = wxGetApp().preset_bundle->filament_presets;
if (filament_presets.size() > 1 &&
p->config->option<ConfigOptionStrings>(opt_key)->values.size() != config.option<ConfigOptionStrings>(opt_key)->values.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));
p->config->option<ConfigOptionStrings>(opt_key)->values = filament_colors;
continue;
}
}
p->config->set_key_value(opt_key, config.option(opt_key)->clone());
if (opt_key == "printer_technology")
this->set_printer_technology(config.opt_enum<PrinterTechnology>(opt_key));

View file

@ -1621,24 +1621,6 @@ void TabFilament::build()
optgroup->append_single_option_line("filament_density");
optgroup->append_single_option_line("filament_cost");
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
this->update_dirty();
this->on_value_change(opt_key, value);
if (opt_key == "filament_colour")
{
const Preset& printer_preset = m_preset_bundle->printers.get_edited_preset();
const std::vector<std::string>& colors = static_cast<const ConfigOptionStrings*>(
printer_preset.config.option("extruder_colour"))->values;
for (const std::string& color : colors)
if (color.empty()) {
// update scene
wxGetApp().plater()->update();
break;
}
}
};
optgroup = page->new_optgroup(_(L("Temperature")) + wxString(" °C", wxConvUTF8));
Line line = { _(L("Extruder")), "" };
line.append_option(optgroup->get_option("first_layer_temperature"));