Parsing of obsolete presets from Config Bundle to remove them

from user's profile when upgrading to a new configuration structure.
This commit is contained in:
bubnikv 2018-05-16 16:34:07 +02:00
parent 6d98c2b1ce
commit 687c91d6e9
3 changed files with 35 additions and 1 deletions

View file

@ -1030,3 +1030,8 @@ max_print_height = 210
start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif} start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif}
printer_model = MK3 printer_model = MK3
default_print_profile = 0.15mm OPTIMAL 0.6 nozzle MK3 default_print_profile = 0.15mm OPTIMAL 0.6 nozzle MK3
# The obsolete presets will be removed when upgrading from the legacy configuration structure (up to Slic3r 1.39.2) to 1.40.0 and newer.
[obsolete_presets]
print="0.05mm DETAIL 0.25 nozzle";"0.05mm DETAIL MK3";"0.05mm DETAIL";"0.20mm NORMAL MK3";"0.35mm FAST MK3"
filament="ColorFabb Brass Bronze 1.75mm";"ColorFabb HT 1.75mm";"ColorFabb nGen 1.75mm";"ColorFabb Woodfil 1.75mm";"ColorFabb XT 1.75mm";"ColorFabb XT-CF20 1.75mm";"E3D PC-ABS 1.75mm";"Fillamentum ABS 1.75mm";"Fillamentum ASA 1.75mm";"Generic ABS 1.75mm";"Generic PET 1.75mm";"Generic PLA 1.75mm";"Prusa ABS 1.75mm";"Prusa HIPS 1.75mm";"Prusa PET 1.75mm";"Prusa PLA 1.75mm";"Taulman Bridge 1.75mm";"Taulman T-Glase 1.75mm"

View file

@ -104,6 +104,9 @@ void PresetBundle::reset(bool delete_files)
this->printers .reset(delete_files); this->printers .reset(delete_files);
this->filament_presets.clear(); this->filament_presets.clear();
this->filament_presets.emplace_back(this->filaments.get_selected_preset().name); this->filament_presets.emplace_back(this->filaments.get_selected_preset().name);
this->obsolete_presets.prints.clear();
this->obsolete_presets.filaments.clear();
this->obsolete_presets.printers.clear();
} }
void PresetBundle::setup_directories() void PresetBundle::setup_directories()
@ -224,6 +227,9 @@ std::vector<std::string> PresetBundle::merge_presets(PresetBundle &&other)
std::vector<std::string> duplicate_prints = this->prints .merge_presets(std::move(other.prints), this->vendors); 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_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); std::vector<std::string> duplicate_printers = this->printers .merge_presets(std::move(other.printers), this->vendors);
append(this->obsolete_presets.prints, std::move(other.obsolete_presets.prints));
append(this->obsolete_presets.filaments, std::move(other.obsolete_presets.filaments));
append(this->obsolete_presets.printers, std::move(other.obsolete_presets.printers));
append(duplicate_prints, std::move(duplicate_filaments)); append(duplicate_prints, std::move(duplicate_filaments));
append(duplicate_prints, std::move(duplicate_printers)); append(duplicate_prints, std::move(duplicate_printers));
return duplicate_prints; return duplicate_prints;
@ -365,6 +371,7 @@ DynamicPrintConfig PresetBundle::full_config() const
} else { } else {
// Retrieve filament presets and build a single config object for them. // Retrieve filament presets and build a single config object for them.
// First collect the filament configurations based on the user selection of this->filament_presets. // First collect the filament configurations based on the user selection of this->filament_presets.
// Here this->filaments.find_preset() and this->filaments.first_visible() return the edited copy of the preset if active.
std::vector<const DynamicPrintConfig*> filament_configs; std::vector<const DynamicPrintConfig*> filament_configs;
for (const std::string &filament_preset_name : this->filament_presets) for (const std::string &filament_preset_name : this->filament_presets)
filament_configs.emplace_back(&this->filaments.find_preset(filament_preset_name, true)->config); filament_configs.emplace_back(&this->filaments.find_preset(filament_preset_name, true)->config);
@ -760,6 +767,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
flatten_configbundle_hierarchy(tree); flatten_configbundle_hierarchy(tree);
// 2) Parse the property_tree, extract the active preset names and the profiles, save them into local config files. // 2) Parse the property_tree, extract the active preset names and the profiles, save them into local config files.
// Parse the obsolete preset names, to be deleted when upgrading from the old configuration structure.
std::vector<std::string> loaded_prints; std::vector<std::string> loaded_prints;
std::vector<std::string> loaded_filaments; std::vector<std::string> loaded_filaments;
std::vector<std::string> loaded_printers; std::vector<std::string> loaded_printers;
@ -799,6 +807,20 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
active_printer = kvp.second.data(); active_printer = kvp.second.data();
} }
} }
} else if (section.first == "obsolete_presets") {
// Parse the names of obsolete presets. These presets will be deleted from user's
// profile directory on installation of this vendor preset.
for (auto &kvp : section.second) {
std::vector<std::string> *dst = nullptr;
if (kvp.first == "print")
dst = &this->obsolete_presets.prints;
else if (kvp.first == "filament")
dst = &this->obsolete_presets.filaments;
else if (kvp.first == "printer")
dst = &this->obsolete_presets.printers;
if (dst)
unescape_strings_cstyle(kvp.second.data(), *dst);
}
} else if (section.first == "settings") { } else if (section.first == "settings") {
// Load the settings. // Load the settings.
for (auto &kvp : section.second) { for (auto &kvp : section.second) {

View file

@ -54,6 +54,13 @@ public:
// 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; std::set<VendorProfile> vendors;
struct ObsoletePresets {
std::vector<std::string> prints;
std::vector<std::string> filaments;
std::vector<std::string> printers;
};
ObsoletePresets obsolete_presets;
bool has_defauls_only() const bool has_defauls_only() const
{ return prints.size() <= 1 && filaments.size() <= 1 && printers.size() <= 1; } { return prints.size() <= 1 && filaments.size() <= 1 && printers.size() <= 1; }