diff options
author | Nino van Hooff <ninovanhooff@gmail.com> | 2020-05-28 18:31:24 +0300 |
---|---|---|
committer | Nino van Hooff <ninovanhooff@gmail.com> | 2020-05-28 18:31:24 +0300 |
commit | 58ffc9dcae0020d7dd4f3c32b41922dfdbef37d3 (patch) | |
tree | 54902883427fa76a9dffb5068afd99532563cb4b /plugins/VersionUpgrade | |
parent | c2c96faf5fcbad942f8cf257e75c94a623ac5eaa (diff) | |
parent | 2a70813d030c678181b5c37fc82cb513d689187b (diff) |
Merge remote-tracking branch 'origin/master' into doxygen_to_restructuredtext_comments
# Conflicts:
# cura/API/__init__.py
# cura/Settings/CuraContainerRegistry.py
# cura/Settings/ExtruderManager.py
# plugins/PostProcessingPlugin/scripts/PauseAtHeight.py
# plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py
# plugins/UM3NetworkPrinting/src/Cloud/ToolPathUploader.py
# plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py
Diffstat (limited to 'plugins/VersionUpgrade')
3 files changed, 179 insertions, 7 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade460to462/VersionUpgrade460to462.py b/plugins/VersionUpgrade/VersionUpgrade460to462/VersionUpgrade460to462.py index c447f9f25d..1aa5e1b2da 100644 --- a/plugins/VersionUpgrade/VersionUpgrade460to462/VersionUpgrade460to462.py +++ b/plugins/VersionUpgrade/VersionUpgrade460to462/VersionUpgrade460to462.py @@ -2,11 +2,44 @@ # Cura is released under the terms of the LGPLv3 or higher. import configparser +import copy # To split up files. from typing import Tuple, List import io from UM.VersionUpgrade import VersionUpgrade + +renamed_nozzles = { + "deltacomb_025_e3d": "deltacomb_dc20_fbe025", + "deltacomb_040_e3d": "deltacomb_dc20_fbe040", + "deltacomb_080_e3d": "deltacomb_dc20_vfbe080" +} +default_qualities_per_nozzle_and_material = { + # Can't define defaults for user-defined materials, since we only have the material ID. Those will get reset to empty quality :( + "deltacomb_dc20_fbe025": { + "generic_pla_175": "deltacomb_FBE0.25_PLA_C", + "generic_abs_175": "deltacomb_FBE0.25_ABS_C" + }, + "deltacomb_dc20_fbe040": { + "generic_pla_175": "deltacomb_FBE0.40_PLA_C", + "generic_abs_175": "deltacomb_FBE0.40_ABS_C", + "generic_petg_175": "deltacomb_FBE0.40_PETG_C", + "generic_tpu_175": "deltacomb_FBE0.40_TPU_C" + }, + "deltacomb_dc20_vfbe080": { + "generic_pla_175": "deltacomb_VFBE0.80_PLA_D", + "generic_abs_175": "deltacomb_VFBE0.80_ABS_D" + } +} + + class VersionUpgrade460to462(VersionUpgrade): + def getCfgVersion(self, serialised: str) -> int: + parser = configparser.ConfigParser(interpolation = None) + parser.read_string(serialised) + format_version = int(parser.get("general", "version")) # Explicitly give an exception when this fails. That means that the file format is not recognised. + setting_version = int(parser.get("metadata", "setting_version", fallback = "0")) + return format_version * 1000000 + setting_version + def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: """ Upgrades preferences to have the new version number. @@ -25,6 +58,66 @@ class VersionUpgrade460to462(VersionUpgrade): parser.write(result) return [filename], [result.getvalue()] + def upgradeExtruderInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: + """ + Upgrades per-extruder instance containers to the new version number. + + This applies all of the changes that are applied in other instance + containers as well. + + In the case of Deltacomb printers, it splits the 2 extruders into 4 and + changes the definition. + :param serialized: The original contents of the instance container. + :param filename: The original file name of the instance container. + :return: A list of new file names, and a list of the new contents for + those files. + """ + parser = configparser.ConfigParser(interpolation = None, comment_prefixes = ()) + parser.read_string(serialized) + results = [(parser, filename)] + + if "general" in parser and "definition" in parser["general"]: + if parser["general"]["definition"] == "deltacomb_extruder_0": + parser["general"]["definition"] = "deltacomb_base_extruder_0" + elif parser["general"]["definition"] == "deltacomb_extruder_1": # Split up the second Deltacomb extruder into 3, creating an extra two extruders. + parser_e2 = configparser.ConfigParser(interpolation = None) + parser_e3 = configparser.ConfigParser(interpolation = None) + parser_e2.read_dict(parser) + parser_e3.read_dict(parser) + + parser["general"]["definition"] = "deltacomb_base_extruder_1" + parser_e2["general"]["definition"] = "deltacomb_base_extruder_2" + parser_e3["general"]["definition"] = "deltacomb_base_extruder_3" + results.append((parser_e2, filename + "_e2_upgrade")) # Hopefully not already taken. + results.append((parser_e3, filename + "_e3_upgrade")) + elif parser["general"]["definition"] == "deltacomb": # On the global stack, the per-extruder user container OR the per-extruder quality changes container. + parser["general"]["definition"] = "deltacomb_dc20" + + if "metadata" in parser and ("extruder" in parser["metadata"] or "position" in parser["metadata"]): # Per-extruder user container or quality changes container. + parser_e2 = configparser.ConfigParser(interpolation = None) + parser_e3 = configparser.ConfigParser(interpolation = None) + parser_e2.read_dict(parser) + parser_e3.read_dict(parser) + if "extruder" in parser["metadata"]: + parser_e2["metadata"]["extruder"] += "_e2_upgrade" + parser_e3["metadata"]["extruder"] += "_e3_upgrade" + results.append((parser_e2, filename + "_e2_upgrade")) + results.append((parser_e3, filename + "_e3_upgrade")) + + # Now go upgrade with the generic instance container method. + final_serialized = [] # type: List[str] + final_filenames = [] # type: List[str] + for result_parser, result_filename in results: + result_ss = io.StringIO() + result_parser.write(result_ss) + result_serialized = result_ss.getvalue() + # The upgrade function itself might also return multiple files, so we need to append all of those into the final list. + this_filenames_upgraded, this_serialized_upgraded = self.upgradeInstanceContainer(result_serialized, result_filename) + final_serialized += this_serialized_upgraded + final_filenames += this_filenames_upgraded + + return final_filenames, final_serialized + def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: """ Upgrades instance containers to have the new version number. @@ -62,6 +155,9 @@ class VersionUpgrade460to462(VersionUpgrade): def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: """ Upgrades stacks to have the new version number. + + This upgrades Deltacomb printers to their new profile structure, and + gives them 4 extruders. :param serialized: The original contents of the stack. :param filename: The original file name of the stack. :return: A list of new file names, and a list of the new contents for @@ -69,12 +165,56 @@ class VersionUpgrade460to462(VersionUpgrade): """ parser = configparser.ConfigParser(interpolation = None) parser.read_string(serialized) + results = [(parser, filename)] # Update version number. if "metadata" not in parser: parser["metadata"] = {} parser["metadata"]["setting_version"] = "14" - result = io.StringIO() - parser.write(result) - return [filename], [result.getvalue()] + if "containers" in parser and "7" in parser["containers"]: + if parser["containers"]["7"] == "deltacomb_extruder_0" or parser["containers"]["7"] == "deltacomb_extruder_1": # Extruder stack. + if "5" in parser["containers"]: + parser["containers"]["5"] = renamed_nozzles.get(parser["containers"]["5"], parser["containers"]["5"]) + if "3" in parser["containers"] and "4" in parser["containers"] and parser["containers"]["3"] == "empty_quality": + parser["containers"]["3"] = default_qualities_per_nozzle_and_material[parser["containers"]["5"]].get(parser["containers"]["4"], "empty_quality") + if parser["containers"]["7"] == "deltacomb_extruder_0": + parser["containers"]["7"] = "deltacomb_base_extruder_0" + else: + parser["containers"]["7"] = "deltacomb_base_extruder_1" + # Copy this extruder to extruder 3 and 4. + extruder3 = configparser.ConfigParser(interpolation=None) + extruder4 = configparser.ConfigParser(interpolation=None) + extruder3.read_dict(parser) + extruder4.read_dict(parser) + + extruder3["general"]["id"] += "_e2_upgrade" + extruder3["metadata"]["position"] = "2" + extruder3["containers"]["0"] += "_e2_upgrade" + if extruder3["containers"]["1"] != "empty_quality_changes": + extruder3["containers"]["1"] += "_e2_upgrade" + extruder3["containers"]["6"] += "_e2_upgrade" + extruder3["containers"]["7"] = "deltacomb_base_extruder_2" + results.append((extruder3, filename + "_e2_upgrade")) + + extruder4["general"]["id"] += "_e3_upgrade" + extruder4["metadata"]["position"] = "3" + extruder4["containers"]["0"] += "_e3_upgrade" + if extruder4["containers"]["1"] != "empty_quality_changes": + extruder4["containers"]["1"] += "_e3_upgrade" + extruder4["containers"]["6"] += "_e3_upgrade" + extruder4["containers"]["7"] = "deltacomb_base_extruder_3" + results.append((extruder4, filename + "_e3_upgrade")) + elif parser["containers"]["7"] == "deltacomb": # Global stack. + parser["containers"]["7"] = "deltacomb_dc20" + parser["containers"]["3"] = "deltacomb_global_C" + + result_serialized = [] + result_filenames = [] + for result_parser, result_filename in results: + result_ss = io.StringIO() + result_parser.write(result_ss) + result_serialized.append(result_ss.getvalue()) + result_filenames.append(result_filename) + + return result_filenames, result_serialized diff --git a/plugins/VersionUpgrade/VersionUpgrade460to462/__init__.py b/plugins/VersionUpgrade/VersionUpgrade460to462/__init__.py index 33732dc9e2..5f096545b2 100644 --- a/plugins/VersionUpgrade/VersionUpgrade460to462/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade460to462/__init__.py @@ -17,10 +17,10 @@ def getMetaData() -> Dict[str, Any]: ("preferences", 6000013): ("preferences", 6000014, upgrade.upgradePreferences), ("machine_stack", 4000013): ("machine_stack", 4000014, upgrade.upgradeStack), ("extruder_train", 4000013): ("extruder_train", 4000014, upgrade.upgradeStack), - ("definition_changes", 4000013): ("definition_changes", 4000014, upgrade.upgradeInstanceContainer), - ("quality_changes", 4000013): ("quality_changes", 4000014, upgrade.upgradeInstanceContainer), - ("quality", 4000013): ("quality", 4000014, upgrade.upgradeInstanceContainer), - ("user", 4000013): ("user", 4000014, upgrade.upgradeInstanceContainer), + ("definition_changes", 4000013): ("definition_changes", 4000014, upgrade.upgradeExtruderInstanceContainer), + ("quality_changes", 4000013): ("quality_changes", 4000014, upgrade.upgradeExtruderInstanceContainer), + ("quality", 4000013): ("quality", 4000014, upgrade.upgradeExtruderInstanceContainer), + ("user", 4000013): ("user", 4000014, upgrade.upgradeExtruderInstanceContainer), }, "sources": { "preferences": { diff --git a/plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py b/plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py index c340fd0c72..70de42ab3b 100644 --- a/plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py +++ b/plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py @@ -58,6 +58,19 @@ class VersionUpgrade462to47(VersionUpgrade): maximum_deviation = "=(" + maximum_deviation + ") / 2" parser["values"]["meshfix_maximum_deviation"] = maximum_deviation + # Ironing inset is now based on the flow-compensated line width to make the setting have a more logical UX. + # Adjust so that the actual print result remains the same. + if "ironing_inset" in parser["values"]: + ironing_inset = parser["values"]["ironing_inset"] + if ironing_inset.startswith("="): + ironing_inset = ironing_inset[1:] + if "ironing_pattern" in parser["values"] and parser["values"]["ironing_pattern"] == "concentric": + correction = " + ironing_line_spacing - skin_line_width * (1.0 + ironing_flow / 100) / 2" + else: # If ironing_pattern doesn't exist, it means the default (zigzag) is selected + correction = " + skin_line_width * (1.0 - ironing_flow / 100) / 2" + ironing_inset = "=(" + ironing_inset + ")" + correction + parser["values"]["ironing_inset"] = ironing_inset + result = io.StringIO() parser.write(result) return [filename], [result.getvalue()] @@ -88,6 +101,25 @@ class VersionUpgrade462to47(VersionUpgrade): script_parser = configparser.ConfigParser(interpolation=None) script_parser.optionxform = str # type: ignore # Don't transform the setting keys as they are case-sensitive. script_parser.read_string(script_str) + + # Unify all Pause at Height + script_id = script_parser.sections()[0] + if script_id in ["BQ_PauseAtHeight", "PauseAtHeightRepRapFirmwareDuet", "PauseAtHeightforRepetier"]: + script_settings = script_parser.items(script_id) + script_settings.append(("pause_method", { + "BQ_PauseAtHeight": "bq", + "PauseAtHeightforRepetier": "repetier", + "PauseAtHeightRepRapFirmwareDuet": "reprap" + }[script_id])) + + # Since we cannot rename a section, we remove the original section and create a new section with the new script id. + script_parser.remove_section(script_id) + script_id = "PauseAtHeight" + script_parser.add_section(script_id) + for setting_tuple in script_settings: + script_parser.set(script_id, setting_tuple[0], setting_tuple[1]) + + # Update redo_layers to redo_layer if "PauseAtHeight" in script_parser: if "redo_layers" in script_parser["PauseAtHeight"]: script_parser["PauseAtHeight"]["redo_layer"] = str(int(script_parser["PauseAtHeight"]["redo_layers"]) > 0) |