Forcing a print bed update after config or config bundle is loaded.

The solution is hackish, but a major refactoring would be needed
to avoid multiple refreshes of the print bed, and to avoid
expensive checks at Plater::on_config_change() every time
a config value changes at a parameter tab.
This commit is contained in:
bubnikv 2020-01-24 15:16:28 +01:00
parent fd11dcd44b
commit d937ac1ed3
4 changed files with 13 additions and 9 deletions

View file

@ -960,8 +960,11 @@ void GUI_App::load_current_presets()
this->plater()->set_printer_technology(printer_technology); this->plater()->set_printer_technology(printer_technology);
for (Tab *tab : tabs_list) for (Tab *tab : tabs_list)
if (tab->supports_printer_technology(printer_technology)) { if (tab->supports_printer_technology(printer_technology)) {
if (tab->type() == Preset::TYPE_PRINTER) if (tab->type() == Preset::TYPE_PRINTER) {
static_cast<TabPrinter*>(tab)->update_pages(); static_cast<TabPrinter*>(tab)->update_pages();
// Mark the plater to update print bed by tab->load_current_preset() from Plater::on_config_change().
this->plater()->force_print_bed_update();
}
tab->load_current_preset(); tab->load_current_preset();
} }
} }

View file

@ -5376,6 +5376,13 @@ void Plater::force_filament_colors_update()
this->p->schedule_background_process(); this->p->schedule_background_process();
} }
void Plater::force_print_bed_update()
{
// Fill in the printer model key with something which cannot possibly be valid, so that Plater::on_config_change() will update the print bed
// once a new Printer profile config is loaded.
p->config->opt_string("printer_model", true) = "\x01\x00\x01";
}
void Plater::on_activate() void Plater::on_activate()
{ {
#ifdef __linux__ #ifdef __linux__
@ -5392,11 +5399,6 @@ void Plater::on_activate()
this->p->show_delayed_error_message(); this->p->show_delayed_error_message();
} }
const DynamicPrintConfig* Plater::get_plater_config() const
{
return p->config;
}
// Get vector of extruder colors considering filament color, if extruder color is undefined. // Get vector of extruder colors considering filament color, if extruder color is undefined.
std::vector<std::string> Plater::get_extruder_colors_from_plater_config() const std::vector<std::string> Plater::get_extruder_colors_from_plater_config() const
{ {

View file

@ -227,9 +227,9 @@ public:
void on_extruders_change(size_t extruders_count); void on_extruders_change(size_t extruders_count);
void on_config_change(const DynamicPrintConfig &config); void on_config_change(const DynamicPrintConfig &config);
void force_filament_colors_update(); void force_filament_colors_update();
void force_print_bed_update();
// On activating the parent window. // On activating the parent window.
void on_activate(); void on_activate();
const DynamicPrintConfig* get_plater_config() const;
std::vector<std::string> get_extruder_colors_from_plater_config() const; std::vector<std::string> get_extruder_colors_from_plater_config() const;
std::vector<std::string> get_colors_for_color_print() const; std::vector<std::string> get_colors_for_color_print() const;

View file

@ -54,8 +54,7 @@ public:
// There will be an entry for each system profile loaded, // There will be an entry for each system profile loaded,
// and the system profiles will point to the VendorProfile instances owned by PresetBundle::vendors. // and the system profiles will point to the VendorProfile instances owned by PresetBundle::vendors.
// std::set<VendorProfile> vendors; VendorMap vendors;
VendorMap vendors;
struct ObsoletePresets { struct ObsoletePresets {
std::vector<std::string> prints; std::vector<std::string> prints;