From 43581059ff3a03a40f74407bee3ea7062a4077b3 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 15 Dec 2020 12:09:03 +0100 Subject: [PATCH] Fix of #5450 - Wrong printer preset after loading 3mf project file when having multiple presets for one physical printer --- src/libslic3r/Preset.cpp | 7 +++++++ src/libslic3r/Preset.hpp | 1 + src/libslic3r/PresetBundle.cpp | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 63e417379..af6b50215 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -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); diff --git a/src/libslic3r/Preset.hpp b/src/libslic3r/Preset.hpp index 2e0e94467..b6d44d58f 100644 --- a/src/libslic3r/Preset.hpp +++ b/src/libslic3r/Preset.hpp @@ -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; diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 39d1f11c0..ae6a77139 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -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);