123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- import configparser
- from typing import Dict, Iterable, List, Optional, Set, Tuple
- from UM.VersionUpgrade import VersionUpgrade
- from . import MachineInstance
- from . import Preferences
- from . import Profile
- _machines_with_machine_quality = {
- "ultimaker2plus": {
- "materials": { "generic_abs", "generic_cpe", "generic_pla", "generic_pva", "generic_cpe_plus", "generic_nylon", "generic_pc", "generic_tpu" },
- "variants": { "0.25 mm", "0.4 mm", "0.6 mm", "0.8 mm" }
- },
- "ultimaker2_extended_plus": {
- "materials": { "generic_abs", "generic_cpe", "generic_pla", "generic_pva", "generic_cpe_plus", "generic_nylon", "generic_pc", "generic_tpu" },
- "variants": { "0.25 mm", "0.4 mm", "0.6 mm", "0.8 mm" }
- }
- }
- _material_translations = {
- "PLA": "generic_pla",
- "ABS": "generic_abs",
- "CPE": "generic_cpe",
- "CPE+": "generic_cpe_plus",
- "Nylon": "generic_nylon",
- "PC": "generic_pc",
- "TPU": "generic_tpu",
- }
- _material_translations_profiles = {
- "PLA": "pla",
- "ABS": "abs",
- "CPE": "cpe",
- "CPE+": "cpep",
- "Nylon": "nylon",
- "PC": "pc",
- "TPU": "tpu",
- }
- _printer_translations = {
- "ultimaker2plus": "ultimaker2_plus"
- }
- _printer_translations_profiles = {
- "ultimaker2plus": "um2p",
- "ultimaker2_extended_plus": "um2ep"
- }
- _profile_translations = {
- "Low Quality": "low",
- "Normal Quality": "normal",
- "High Quality": "high",
- "Ulti Quality": "high",
- "abs_0.25_normal": "um2p_abs_0.25_normal",
- "abs_0.4_fast": "um2p_abs_0.4_fast",
- "abs_0.4_high": "um2p_abs_0.4_high",
- "abs_0.4_normal": "um2p_abs_0.4_normal",
- "abs_0.6_normal": "um2p_abs_0.6_normal",
- "abs_0.8_normal": "um2p_abs_0.8_normal",
- "cpe_0.25_normal": "um2p_cpe_0.25_normal",
- "cpe_0.4_fast": "um2p_cpe_0.4_fast",
- "cpe_0.4_high": "um2p_cpe_0.4_high",
- "cpe_0.4_normal": "um2p_cpe_0.4_normal",
- "cpe_0.6_normal": "um2p_cpe_0.6_normal",
- "cpe_0.8_normal": "um2p_cpe_0.8_normal",
- "cpep_0.4_draft": "um2p_cpep_0.4_draft",
- "cpep_0.4_normal": "um2p_cpep_0.4_normal",
- "cpep_0.6_draft": "um2p_cpep_0.6_draft",
- "cpep_0.6_normal": "um2p_cpep_0.6_normal",
- "cpep_0.8_draft": "um2p_cpep_0.8_draft",
- "cpep_0.8_normal": "um2p_cpep_0.8_normal",
- "nylon_0.25_high": "um2p_nylon_0.25_high",
- "nylon_0.25_normal": "um2p_nylon_0.25_normal",
- "nylon_0.4_fast": "um2p_nylon_0.4_fast",
- "nylon_0.4_normal": "um2p_nylon_0.4_normal",
- "nylon_0.6_fast": "um2p_nylon_0.6_fast",
- "nylon_0.6_normal": "um2p_nylon_0.6_normal",
- "nylon_0.8_draft": "um2p_nylon_0.8_draft",
- "nylon_0.8_normal": "um2p_nylon_0.8_normal",
- "pc_0.25_high": "um2p_pc_0.25_high",
- "pc_0.25_normal": "um2p_pc_0.25_normal",
- "pc_0.4_fast": "um2p_pc_0.4_fast",
- "pc_0.4_normal": "um2p_pc_0.4_normal",
- "pc_0.6_fast": "um2p_pc_0.6_fast",
- "pc_0.6_normal": "um2p_pc_0.6_normal",
- "pc_0.8_draft": "um2p_pc_0.8_draft",
- "pc_0.8_normal": "um2p_pc_0.8_normal",
- "pla_0.25_normal": "pla_0.25_normal",
- "pla_0.4_fast": "pla_0.4_fast",
- "pla_0.4_high": "pla_0.4_high",
- "pla_0.4_normal": "pla_0.4_normal",
- "pla_0.6_normal": "pla_0.6_normal",
- "pla_0.8_normal": "pla_0.8_normal",
- "tpu_0.25_high": "um2p_tpu_0.25_high",
- "tpu_0.4_normal": "um2p_tpu_0.4_normal",
- "tpu_0.6_fast": "um2p_tpu_0.6_fast"
- }
- _removed_settings = {
- "fill_perimeter_gaps",
- "support_area_smoothing"
- }
- _setting_name_translations = {
- "remove_overlapping_walls_0_enabled": "travel_compensate_overlapping_walls_0_enabled",
- "remove_overlapping_walls_enabled": "travel_compensate_overlapping_walls_enabled",
- "remove_overlapping_walls_x_enabled": "travel_compensate_overlapping_walls_x_enabled",
- "retraction_hop": "retraction_hop_enabled",
- "skin_overlap": "infill_overlap",
- "skirt_line_width": "skirt_brim_line_width",
- "skirt_minimal_length": "skirt_brim_minimal_length",
- "skirt_speed": "skirt_brim_speed",
- "speed_support_lines": "speed_support_infill",
- "speed_support_roof": "speed_support_interface",
- "support_roof_density": "support_interface_density",
- "support_roof_enable": "support_interface_enable",
- "support_roof_extruder_nr": "support_interface_extruder_nr",
- "support_roof_line_distance": "support_interface_line_distance",
- "support_roof_line_width": "support_interface_line_width",
- "support_roof_pattern": "support_interface_pattern"
- }
- _quality_fallbacks = {
- "ultimaker2_plus": {
- "ultimaker2_plus_0.25": {
- "generic_abs": "um2p_abs_0.25_normal",
- "generic_cpe": "um2p_cpe_0.25_normal",
-
- "generic_nylon": "um2p_nylon_0.25_normal",
- "generic_pc": "um2p_pc_0.25_normal",
- "generic_pla": "pla_0.25_normal",
- "generic_tpu": "um2p_tpu_0.25_high"
- },
- "ultimaker2_plus_0.4": {
- "generic_abs": "um2p_abs_0.4_normal",
- "generic_cpe": "um2p_cpe_0.4_normal",
- "generic_cpep": "um2p_cpep_0.4_normal",
- "generic_nylon": "um2p_nylon_0.4_normal",
- "generic_pc": "um2p_pc_0.4_normal",
- "generic_pla": "pla_0.4_normal",
- "generic_tpu": "um2p_tpu_0.4_normal"
- },
- "ultimaker2_plus_0.6": {
- "generic_abs": "um2p_abs_0.6_normal",
- "generic_cpe": "um2p_cpe_0.6_normal",
- "generic_cpep": "um2p_cpep_0.6_normal",
- "generic_nylon": "um2p_nylon_0.6_normal",
- "generic_pc": "um2p_pc_0.6_normal",
- "generic_pla": "pla_0.6_normal",
- "generic_tpu": "um2p_tpu_0.6_fast",
- },
- "ultimaker2_plus_0.8": {
- "generic_abs": "um2p_abs_0.8_normal",
- "generic_cpe": "um2p_cpe_0.8_normal",
- "generic_cpep": "um2p_cpep_0.8_normal",
- "generic_nylon": "um2p_nylon_0.8_normal",
- "generic_pc": "um2p_pc_0.8_normal",
- "generic_pla": "pla_0.8_normal",
-
- }
- }
- }
- _variant_translations = {
- "ultimaker2_plus": {
- "0.25 mm": "ultimaker2_plus_0.25",
- "0.4 mm": "ultimaker2_plus_0.4",
- "0.6 mm": "ultimaker2_plus_0.6",
- "0.8 mm": "ultimaker2_plus_0.8"
- },
- "ultimaker2_extended_plus": {
- "0.25 mm": "ultimaker2_extended_plus_0.25",
- "0.4 mm": "ultimaker2_extended_plus_0.4",
- "0.6 mm": "ultimaker2_extended_plus_0.6",
- "0.8 mm": "ultimaker2_extended_plus_0.8"
- }
- }
- _variant_translations_profiles = {
- "0.25 mm": "0.25",
- "0.4 mm": "0.4",
- "0.6 mm": "0.6",
- "0.8 mm": "0.8"
- }
- _variant_translations_materials = {
- "ultimaker2_plus": {
- "0.25 mm": "ultimaker2_plus_0.25_mm",
- "0.4 mm": "ultimaker2_plus_0.4_mm",
- "0.6 mm": "ultimaker2_plus_0.6_mm",
- "0.8 mm": "ultimaker2_plus_0.8_mm"
- },
- "ultimaker2_extended_plus": {
- "0.25 mm": "ultimaker2_plus_0.25_mm",
- "0.4 mm": "ultimaker2_plus_0.4_mm",
- "0.6 mm": "ultimaker2_plus_0.6_mm",
- "0.8 mm": "ultimaker2_plus_0.8_mm"
- }
- }
- class VersionUpgrade21to22(VersionUpgrade):
-
-
-
-
-
-
-
-
-
- @staticmethod
- def getQualityFallback(machine: str, variant: str, material: str) -> str:
- if machine not in _quality_fallbacks:
- return "normal"
- if variant not in _quality_fallbacks[machine]:
- return "normal"
- if material not in _quality_fallbacks[machine][variant]:
- return "normal"
- return _quality_fallbacks[machine][variant][material]
-
-
-
-
- @staticmethod
- def builtInProfiles() -> Iterable[str]:
- return _profile_translations.keys()
-
-
-
- @staticmethod
- def machinesWithMachineQuality() -> Dict[str, Dict[str, Set[str]]]:
- return _machines_with_machine_quality
-
-
-
-
-
-
-
-
- def upgradeMachineInstance(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]:
- machine_instance = MachineInstance.importFrom(serialised, filename)
- if not machine_instance:
- return None
- return machine_instance.export()
-
-
-
-
-
-
-
-
- def upgradePreferences(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]:
- preferences = Preferences.importFrom(serialised, filename)
- if not preferences:
- return None
- return preferences.export()
-
-
-
-
-
-
-
- def upgradeProfile(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]:
- profile = Profile.importFrom(serialised, filename)
- if not profile:
- return None
- return profile.export()
-
-
-
-
- @staticmethod
- def translateMaterial(material: str) -> str:
- if material in _material_translations:
- return _material_translations[material]
- return material
-
-
-
-
-
-
- @staticmethod
- def translateMaterialForProfiles(material: str) -> str:
- if material in _material_translations_profiles:
- return _material_translations_profiles[material]
- return material
-
-
-
-
-
- @staticmethod
- def translatePrinter(printer: str) -> str:
- if printer in _printer_translations:
- return _printer_translations[printer]
- return printer
-
-
-
-
-
- @staticmethod
- def translatePrinterForProfile(printer: str) -> str:
- if printer in _printer_translations_profiles:
- return _printer_translations_profiles[printer]
- return printer
-
-
-
-
-
- @staticmethod
- def translateProfile(profile: str) -> str:
- if profile in _profile_translations:
- return _profile_translations[profile]
- return profile
-
-
-
-
-
-
-
-
- @staticmethod
- def translateSettings(settings: Dict[str, str]) -> Dict[str, str]:
- new_settings = {}
- for key, value in settings.items():
- if key in _removed_settings:
- continue
- if key == "retraction_combing":
- new_settings[key] = "off" if (value == "False") else "all"
- continue
- if key == "cool_fan_full_layer":
- new_settings[key] = str(int(value) + 1)
- continue
- if key in _setting_name_translations:
- new_settings[_setting_name_translations[key]] = value
- continue
- new_settings[key] = value
- return new_settings
-
-
-
-
- @staticmethod
- def translateSettingName(setting: str) -> str:
- if setting in _setting_name_translations:
- return _setting_name_translations[setting]
- return setting
-
-
-
-
-
-
- @staticmethod
- def translateVariant(variant: str, machine: str) -> str:
- if machine in _variant_translations and variant in _variant_translations[machine]:
- return _variant_translations[machine][variant]
- return variant
-
-
-
-
-
-
-
-
- @staticmethod
- def translateVariantForMaterials(variant: str, machine: str) -> str:
- if machine in _variant_translations_materials and variant in _variant_translations_materials[machine]:
- return _variant_translations_materials[machine][variant]
- return variant
-
-
-
-
-
-
- @staticmethod
- def translateVariantForProfiles(variant: str) -> str:
- if variant in _variant_translations_profiles:
- return _variant_translations_profiles[variant]
- return variant
|