Fall back to different quality depending on stack

Falling back to normal.inst.cfg isn't enough. That profile may be filtered out by the machine, variant and material. We need to fall back to a different quality profile depending on the machine, variant and material.

Contributes to issue CURA-844.
This commit is contained in:
Ghostkeeper 2016-09-08 18:50:19 +02:00
parent 263105c3e7
commit e35bc595b6
No known key found for this signature in database
GPG key ID: 701948C5954A7385
2 changed files with 68 additions and 1 deletions

View file

@ -137,6 +137,54 @@ _setting_name_translations = {
"support_roof_pattern": "support_interface_pattern"
}
## Custom profiles become quality_changes. This dictates which quality to base
# the quality_changes profile on.
#
# Which quality profile to base the quality_changes on depends on the machine,
# material and nozzle.
#
# If a current configuration is missing, fall back to "normal".
_quality_fallbacks = {
"ultimaker2_plus": {
"ultimaker2_plus_0.25": {
"generic_abs": "um2p_abs_0.25_normal",
"generic_cpe": "um2p_cpe_0.25_normal",
#No CPE+.
"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",
#No TPU.
}
}
}
## How to translate variants of specific machines from the old version to the
# new.
_variant_translations = {
@ -196,6 +244,25 @@ class VersionUpgrade21to22(VersionUpgrade):
parser.read_string(serialised)
return int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
## Gets the fallback quality to use for a specific machine-variant-material
# combination.
#
# For custom profiles we fall back onto this quality profile, since we
# don't know which quality profile it was based on.
#
# \param machine The machine ID of the user's configuration in 2.2.
# \param variant The variant ID of the user's configuration in 2.2.
# \param material The material ID of the user's configuration in 2.2.
@staticmethod
def getQualityFallback(machine, variant, material):
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]
## Gets the set of built-in profile names in Cura 2.1.
#
# This is required to test if profiles should be converted to a quality