Fix of #5450 - Wrong printer preset after loading 3mf project file when having multiple presets for one physical printer

This commit is contained in:
YuSanka 2020-12-15 12:09:03 +01:00
parent 82fe571cdc
commit 43581059ff
3 changed files with 10 additions and 2 deletions

View File

@ -1849,6 +1849,13 @@ void PhysicalPrinterCollection::select_printer(const std::string& full_name)
m_selected_preset = it->get_preset_name(full_name);
}
void PhysicalPrinterCollection::select_printer(const std::string& printer_name, const std::string& preset_name)
{
if (preset_name.empty())
return select_printer(printer_name);
return select_printer(printer_name + PhysicalPrinter::separator() + preset_name);
}
void PhysicalPrinterCollection::select_printer(const PhysicalPrinter& printer)
{
return select_printer(printer.name);

View File

@ -701,6 +701,7 @@ public:
// If full_name doesn't contain name of selected preset, then select first preset in the list for this printer
void select_printer(const std::string& full_name);
void select_printer(const PhysicalPrinter& printer);
void select_printer(const std::string& printer_name, const std::string& preset_name);
bool has_selection() const;
void unselect_printer() ;
bool is_selected(ConstIterator it, const std::string &preset_name) const;

View File

@ -876,7 +876,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// Activate the physical printer profile if possible.
PhysicalPrinter *pp = this->physical_printers.find_printer(physical_printer, true);
if (pp != nullptr && std::find(pp->preset_names.begin(), pp->preset_names.end(), this->printers.get_edited_preset().name) != pp->preset_names.end())
this->physical_printers.select_printer(*pp);
this->physical_printers.select_printer(pp->name, this->printers.get_edited_preset().name);
else
this->physical_printers.unselect_printer();
}
@ -1396,7 +1396,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
if (! active_printer.empty())
printers.select_preset_by_name(active_printer, true);
if (! active_physical_printer.empty())
physical_printers.select_printer(active_physical_printer +" * " + active_printer);
physical_printers.select_printer(active_physical_printer, active_printer);
// Activate the first filament preset.
if (! active_filaments.empty() && ! active_filaments.front().empty())
filaments.select_preset_by_name(active_filaments.front(), true);