Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2020-01-02 18:40:32 +0300
committerbubnikv <bubnikv@gmail.com>2020-01-02 18:40:32 +0300
commit0d9022c5f6bc05154819617a72fae884776eada0 (patch)
treebd1aef91295195a11d2a1825a7d34e8a2622035e /src/slic3r/GUI/Preset.cpp
parentbb569889164ca87526096f29a92e94eff2666cf1 (diff)
Implemented "renamed_from" attribute of a system profile,
so that references from user profiles and .3mfs / .amfs to system profiles are not being lost. If a system profile has no "renamed_from" profile name assigned, and the system profile name contains "@", then a profile name with the "@" is implicitely assumed to be the name, from which this profile has been renamed.
Diffstat (limited to 'src/slic3r/GUI/Preset.cpp')
-rw-r--r--src/slic3r/GUI/Preset.cpp55
1 files changed, 40 insertions, 15 deletions
diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp
index 1c848b60f..c2439b26f 100644
--- a/src/slic3r/GUI/Preset.cpp
+++ b/src/slic3r/GUI/Preset.cpp
@@ -590,6 +590,7 @@ void PresetCollection::reset(bool delete_files)
m_presets.erase(m_presets.begin() + m_num_default_presets, m_presets.end());
this->select_preset(0);
}
+ m_map_system_profile_renamed.clear();
}
void PresetCollection::add_default_preset(const std::vector<std::string> &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &preset_name)
@@ -703,6 +704,11 @@ Preset& PresetCollection::load_external_preset(
// Is there a preset already loaded with the name stored inside the config?
std::deque<Preset>::iterator it = this->find_preset_internal(original_name);
bool found = it != m_presets.end() && it->name == original_name;
+ if (! found) {
+ // Try to match the original_name against the "renamed_from" profile names of loaded system profiles.
+ it = this->find_preset_renamed(original_name);
+ found = it != m_presets.end();
+ }
if (found && profile_print_params_same(it->config, cfg)) {
// The preset exists and it matches the values stored inside config.
if (select)
@@ -872,24 +878,27 @@ const Preset* PresetCollection::get_selected_preset_parent() const
if (this->get_selected_idx() == -1)
// This preset collection has no preset activated yet. Only the get_edited_preset() is valid.
return nullptr;
-// const std::string &inherits = this->get_edited_preset().inherits();
-// if (inherits.empty())
-// return this->get_selected_preset().is_system ? &this->get_selected_preset() : nullptr;
- std::string inherits = this->get_edited_preset().inherits();
- if (inherits.empty())
- {
- if (this->get_selected_preset().is_system || this->get_selected_preset().is_default)
- return &this->get_selected_preset();
- if (this->get_selected_preset().is_external)
- return nullptr;
+ const Preset &selected_preset = this->get_selected_preset();
+ if (selected_preset.is_system || selected_preset.is_default)
+ return &selected_preset;
- inherits = m_type != Preset::Type::TYPE_PRINTER ? "- default -" :
- this->get_edited_preset().printer_technology() == ptFFF ?
- "- default FFF -" : "- default SLA -" ;
+ const Preset &edited_preset = this->get_edited_preset();
+ const std::string &inherits = edited_preset.inherits();
+ const Preset *preset = nullptr;
+ if (inherits.empty()) {
+ if (selected_preset.is_external)
+ return nullptr;
+ preset = &this->default_preset(m_type == Preset::Type::TYPE_PRINTER && edited_preset.printer_technology() == ptSLA ? 1 : 0);
+ } else
+ preset = this->find_preset(inherits, false);
+ if (preset == nullptr) {
+ // Resolve the "renamed_from" field.
+ assert(! inherits.empty());
+ auto it = this->find_preset_renamed(inherits);
+ if (it != m_presets.end())
+ preset = &(*it);
}
-
- const Preset* preset = this->find_preset(inherits, false);
return (preset == nullptr/* || preset->is_default*/ || preset->is_external) ? nullptr : preset;
}
@@ -900,6 +909,11 @@ const Preset* PresetCollection::get_preset_parent(const Preset& child) const
// return this->get_selected_preset().is_system ? &this->get_selected_preset() : nullptr;
return nullptr;
const Preset* preset = this->find_preset(inherits, false);
+ if (preset == nullptr) {
+ auto it = this->find_preset_renamed(inherits);
+ if (it != m_presets.end())
+ preset = &(*it);
+ }
return (preset == nullptr/* || preset->is_default */|| preset->is_external) ? nullptr : preset;
}
@@ -1402,6 +1416,17 @@ std::vector<std::string> PresetCollection::merge_presets(PresetCollection &&othe
return duplicates;
}
+void PresetCollection::update_map_system_profile_renamed()
+{
+ m_map_system_profile_renamed.clear();
+ for (Preset &preset : m_presets)
+ for (const std::string &renamed_from : preset.renamed_from) {
+ const auto [it, success] = m_map_system_profile_renamed.insert(std::pair<std::string, std::string>(renamed_from, preset.name));
+ if (! success)
+ BOOST_LOG_TRIVIAL(error) << boost::format("Preset name \"%1%\" was marked as renamed from \"%2%\", though preset name \"%3%\" was marked as renamed from \"%2%\" as well.") % preset.name % renamed_from % it->second;
+ }
+}
+
std::string PresetCollection::name() const
{
switch (this->type()) {