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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2018-04-18 14:35:51 +0300
committerbubnikv <bubnikv@gmail.com>2018-04-18 14:35:51 +0300
commitfa97a867519ef5dc91bf7fab4c7c5d3a104f0c50 (patch)
tree06f616037162f08c1941c41a2d0371c5976839aa /xs/src/slic3r/GUI/PresetBundle.cpp
parent0711f84ea0277dd503abe49cf0b58ddeb2d030f2 (diff)
Implemented merging of system profiles from various vendors.
Diffstat (limited to 'xs/src/slic3r/GUI/PresetBundle.cpp')
-rw-r--r--xs/src/slic3r/GUI/PresetBundle.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp
index 6f0754a03..717e7a6f0 100644
--- a/xs/src/slic3r/GUI/PresetBundle.cpp
+++ b/xs/src/slic3r/GUI/PresetBundle.cpp
@@ -178,6 +178,7 @@ std::string PresetBundle::load_system_presets()
// Here the vendor specific read only Config Bundles are stored.
boost::filesystem::path dir = (boost::filesystem::path(data_dir()) / "vendor").make_preferred();
std::string errors_cummulative;
+ bool first = true;
for (auto &dir_entry : boost::filesystem::directory_iterator(dir))
if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini")) {
std::string name = dir_entry.path().filename().string();
@@ -185,7 +186,25 @@ std::string PresetBundle::load_system_presets()
name.erase(name.size() - 4);
try {
// Load the config bundle, flatten it.
- this->load_configbundle(dir_entry.path().string(), LOAD_CFGBNDLE_SYSTEM);
+ if (first) {
+ // Reset this PresetBundle and load the first vendor config.
+ this->load_configbundle(dir_entry.path().string(), LOAD_CFGBNDLE_SYSTEM);
+ first = false;
+ } else {
+ // Load the other vendor configs, merge them with this PresetBundle.
+ // Report duplicate profiles.
+ PresetBundle other;
+ other.load_configbundle(dir_entry.path().string(), LOAD_CFGBNDLE_SYSTEM);
+ std::vector<std::string> duplicates = this->merge_presets(std::move(other));
+ if (! duplicates.empty()) {
+ errors_cummulative += "Vendor configuration file " + name + " contains the following presets with names used by other vendors: ";
+ for (size_t i = 0; i < duplicates.size(); ++ i) {
+ if (i > 0)
+ errors_cummulative += ", ";
+ errors_cummulative += duplicates[i];
+ }
+ }
+ }
} catch (const std::runtime_error &err) {
errors_cummulative += err.what();
errors_cummulative += "\n";
@@ -194,6 +213,18 @@ std::string PresetBundle::load_system_presets()
return errors_cummulative;
}
+// Merge one vendor's presets with the other vendor's presets, report duplicates.
+std::vector<std::string> PresetBundle::merge_presets(PresetBundle &&other)
+{
+ this->vendors.insert(other.vendors.begin(), other.vendors.end());
+ std::vector<std::string> duplicate_prints = this->prints .merge_presets(std::move(other.prints), this->vendors);
+ std::vector<std::string> duplicate_filaments = this->filaments.merge_presets(std::move(other.filaments), this->vendors);
+ std::vector<std::string> duplicate_printers = this->printers .merge_presets(std::move(other.printers), this->vendors);
+ append(duplicate_prints, std::move(duplicate_filaments));
+ append(duplicate_prints, std::move(duplicate_printers));
+ return duplicate_prints;
+}
+
static inline std::string remove_ini_suffix(const std::string &name)
{
std::string out = name;