123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- # Copyright (c) 2018 Ultimaker B.V.
- # Cura is released under the terms of the LGPLv3 or higher.
- import configparser
- import io
- from UM.VersionUpgrade import VersionUpgrade
- deleted_settings = {"prime_tower_wall_thickness", "dual_pre_wipe", "prime_tower_purge_volume"}
- changed_settings = {'retraction_combing': 'noskin'}
- updated_settings = {'retraction_combing': 'infill'}
- _RENAMED_MATERIAL_PROFILES = {
- "dsm_arnitel2045_175_cartesio_0.25_mm": "dsm_arnitel2045_175_cartesio_0.25mm_thermoplastic_extruder",
- "dsm_arnitel2045_175_cartesio_0.4_mm": "dsm_arnitel2045_175_cartesio_0.4mm_thermoplastic_extruder",
- "dsm_arnitel2045_175_cartesio_0.8_mm": "dsm_arnitel2045_175_cartesio_0.8mm_thermoplastic_extruder",
- "dsm_novamid1070_175_cartesio_0.25_mm": "dsm_novamid1070_175_cartesio_0.25mm_thermoplastic_extruder",
- "dsm_novamid1070_175_cartesio_0.4_mm": "dsm_novamid1070_175_cartesio_0.4mm_thermoplastic_extruder",
- "dsm_novamid1070_175_cartesio_0.8_mm": "dsm_novamid1070_175_cartesio_0.8mm_thermoplastic_extruder",
- "generic_abs_175_cartesio_0.25_mm": "generic_abs_175_cartesio_0.25mm_thermoplastic_extruder",
- "generic_abs_175_cartesio_0.4_mm": "generic_abs_175_cartesio_0.4mm_thermoplastic_extruder",
- "generic_abs_175_cartesio_0.8_mm": "generic_abs_175_cartesio_0.8mm_thermoplastic_extruder",
- "generic_hips_175_cartesio_0.25_mm": "generic_hips_175_cartesio_0.25mm_thermoplastic_extruder",
- "generic_hips_175_cartesio_0.4_mm": "generic_hips_175_cartesio_0.4mm_thermoplastic_extruder",
- "generic_hips_175_cartesio_0.8_mm": "generic_hips_175_cartesio_0.8mm_thermoplastic_extruder",
- "generic_nylon_175_cartesio_0.25_mm": "generic_nylon_175_cartesio_0.25mm_thermoplastic_extruder",
- "generic_nylon_175_cartesio_0.4_mm": "generic_nylon_175_cartesio_0.4mm_thermoplastic_extruder",
- "generic_nylon_175_cartesio_0.8_mm": "generic_nylon_175_cartesio_0.8mm_thermoplastic_extruder",
- "generic_pc_cartesio_0.25_mm": "generic_pc_cartesio_0.25mm_thermoplastic_extruder",
- "generic_pc_cartesio_0.4_mm": "generic_pc_cartesio_0.4mm_thermoplastic_extruder",
- "generic_pc_cartesio_0.8_mm": "generic_pc_cartesio_0.8mm_thermoplastic_extruder",
- "generic_pc_175_cartesio_0.25_mm": "generic_pc_175_cartesio_0.25mm_thermoplastic_extruder",
- "generic_pc_175_cartesio_0.4_mm": "generic_pc_175_cartesio_0.4mm_thermoplastic_extruder",
- "generic_pc_175_cartesio_0.8_mm": "generic_pc_175_cartesio_0.8mm_thermoplastic_extruder",
- "generic_petg_175_cartesio_0.25_mm": "generic_petg_175_cartesio_0.25mm_thermoplastic_extruder",
- "generic_petg_175_cartesio_0.4_mm": "generic_petg_175_cartesio_0.4mm_thermoplastic_extruder",
- "generic_petg_175_cartesio_0.8_mm": "generic_petg_175_cartesio_0.8mm_thermoplastic_extruder",
- "generic_pla_175_cartesio_0.25_mm": "generic_pla_175_cartesio_0.25mm_thermoplastic_extruder",
- "generic_pla_175_cartesio_0.4_mm": "generic_pla_175_cartesio_0.4mm_thermoplastic_extruder",
- "generic_pla_175_cartesio_0.8_mm": "generic_pla_175_cartesio_0.8mm_thermoplastic_extruder",
- "generic_pva_cartesio_0.25_mm": "generic_pva_cartesio_0.25mm_thermoplastic_extruder",
- "generic_pva_cartesio_0.4_mm": "generic_pva_cartesio_0.4mm_thermoplastic_extruder",
- "generic_pva_cartesio_0.8_mm": "generic_pva_cartesio_0.8mm_thermoplastic_extruder",
- "generic_pva_175_cartesio_0.25_mm": "generic_pva_175_cartesio_0.25mm_thermoplastic_extruder",
- "generic_pva_175_cartesio_0.4_mm": "generic_pva_175_cartesio_0.4mm_thermoplastic_extruder",
- "generic_pva_175_cartesio_0.8_mm": "generic_pva_175_cartesio_0.8mm_thermoplastic_extruder",
- "ultimaker_pc_black_cartesio_0.25_mm": "ultimaker_pc_black_cartesio_0.25mm_thermoplastic_extruder",
- "ultimaker_pc_black_cartesio_0.4_mm": "ultimaker_pc_black_cartesio_0.4mm_thermoplastic_extruder",
- "ultimaker_pc_black_cartesio_0.8_mm": "ultimaker_pc_black_cartesio_0.8mm_thermoplastic_extruder",
- "ultimaker_pc_transparent_cartesio_0.25_mm": "ultimaker_pc_transparent_cartesio_0.25mm_thermoplastic_extruder",
- "ultimaker_pc_transparent_cartesio_0.4_mm": "ultimaker_pc_transparent_cartesio_0.4mm_thermoplastic_extruder",
- "ultimaker_pc_transparent_cartesio_0.8_mm": "ultimaker_pc_transparent_cartesio_0.8mm_thermoplastic_extruder",
- "ultimaker_pc_white_cartesio_0.25_mm": "ultimaker_pc_white_cartesio_0.25mm_thermoplastic_extruder",
- "ultimaker_pc_white_cartesio_0.4_mm": "ultimaker_pc_white_cartesio_0.4mm_thermoplastic_extruder",
- "ultimaker_pc_white_cartesio_0.8_mm": "ultimaker_pc_white_cartesio_0.8mm_thermoplastic_extruder",
- "ultimaker_pva_cartesio_0.25_mm": "ultimaker_pva_cartesio_0.25mm_thermoplastic_extruder",
- "ultimaker_pva_cartesio_0.4_mm": "ultimaker_pva_cartesio_0.4mm_thermoplastic_extruder",
- "ultimaker_pva_cartesio_0.8_mm": "ultimaker_pva_cartesio_0.8mm_thermoplastic_extruder"
- }
- ## Upgrades configurations from the state they were in at version 3.4 to the
- # state they should be in at version 3.5.
- class VersionUpgrade34to35(VersionUpgrade):
- ## Gets the version number from a CFG file in Uranium's 3.3 format.
- #
- # Since the format may change, this is implemented for the 3.3 format only
- # and needs to be included in the version upgrade system rather than
- # globally in Uranium.
- #
- # \param serialised The serialised form of a CFG file.
- # \return The version number stored in the CFG file.
- # \raises ValueError The format of the version number in the file is
- # incorrect.
- # \raises KeyError The format of the file is incorrect.
- def getCfgVersion(self, serialised):
- 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
- ## Upgrades Preferences to have the new version number.
- def upgradePreferences(self, serialized, filename):
- parser = configparser.ConfigParser(interpolation = None)
- parser.read_string(serialized)
- # Need to show the data collection agreement again because the data Cura collects has been changed.
- if parser.has_option("info", "asked_send_slice_info"):
- parser.set("info", "asked_send_slice_info", "False")
- if parser.has_option("info", "send_slice_info"):
- parser.set("info", "send_slice_info", "True")
- # Update version number.
- parser["general"]["version"] = "6"
- if "metadata" not in parser:
- parser["metadata"] = {}
- parser["metadata"]["setting_version"] = "5"
- result = io.StringIO()
- parser.write(result)
- return [filename], [result.getvalue()]
- ## Upgrades stacks to have the new version number.
- def upgradeStack(self, serialized, filename):
- parser = configparser.ConfigParser(interpolation = None)
- parser.read_string(serialized)
- # Update version number.
- parser["general"]["version"] = "4"
- parser["metadata"]["setting_version"] = "5"
- #Update the name of the quality profile.
- if parser["containers"]["3"] in _RENAMED_MATERIAL_PROFILES:
- parser["containers"]["3"] = _RENAMED_MATERIAL_PROFILES[parser["containers"]["3"]]
- result = io.StringIO()
- parser.write(result)
- return [filename], [result.getvalue()]
- ## Upgrades instance containers to have the new version
- # number.
- def upgradeInstanceContainer(self, serialized, filename):
- parser = configparser.ConfigParser(interpolation = None)
- parser.read_string(serialized)
- # Update version number.
- parser["general"]["version"] = "4"
- parser["metadata"]["setting_version"] = "5"
- self._resetConcentric3DInfillPattern(parser)
- if "values" in parser:
- for deleted_setting in deleted_settings:
- if deleted_setting not in parser["values"]:
- continue
- del parser["values"][deleted_setting]
- for setting_key in changed_settings:
- if setting_key not in parser["values"]:
- continue
- if parser["values"][setting_key] == changed_settings[setting_key]:
- parser["values"][setting_key] = updated_settings[setting_key]
- result = io.StringIO()
- parser.write(result)
- return [filename], [result.getvalue()]
- def _resetConcentric3DInfillPattern(self, parser):
- if "values" not in parser:
- return
- # Reset the patterns which are concentric 3d
- for key in ("infill_pattern",
- "support_pattern",
- "support_interface_pattern",
- "support_roof_pattern",
- "support_bottom_pattern",
- ):
- if key not in parser["values"]:
- continue
- if parser["values"][key] == "concentric_3d":
- del parser["values"][key]
|