Fix quality lookup logic for extruders

CURA-5694

 - Add convenience functions into GlobalStack
 - Use "has_variants" and "has_materials" instead of
 "has_variant_materials"
 - Remove "has_variant_materials"
 - For extruder qualities, skip global qualities if the machine has
   variants or materials
This commit is contained in:
Lipu Fei 2018-09-06 08:10:53 +02:00
parent d3356cdba6
commit 9aea0e5109
6 changed files with 13 additions and 7 deletions

View file

@ -200,7 +200,9 @@ class QualityManager(QObject):
machine_definition_id = getMachineDefinitionIDForQualitySearch(machine.definition) machine_definition_id = getMachineDefinitionIDForQualitySearch(machine.definition)
# This determines if we should only get the global qualities for the global stack and skip the global qualities for the extruder stacks # This determines if we should only get the global qualities for the global stack and skip the global qualities for the extruder stacks
has_variant_materials = parseBool(machine.getMetaDataEntry("has_variant_materials", False)) has_variants = machine.getHasVariants()
has_materials = machine.getHasMaterials()
has_variants_or_materials = has_variants or has_materials
# To find the quality container for the GlobalStack, check in the following fall-back manner: # To find the quality container for the GlobalStack, check in the following fall-back manner:
# (1) the machine-specific node # (1) the machine-specific node
@ -214,7 +216,7 @@ class QualityManager(QObject):
for node in nodes_to_check: for node in nodes_to_check:
if node and node.quality_type_map: if node and node.quality_type_map:
# Only include global qualities # Only include global qualities
if has_variant_materials: if has_variants_or_materials:
quality_node = list(node.quality_type_map.values())[0] quality_node = list(node.quality_type_map.values())[0]
is_global_quality = parseBool(quality_node.metadata.get("global_quality", False)) is_global_quality = parseBool(quality_node.metadata.get("global_quality", False))
if not is_global_quality: if not is_global_quality:
@ -302,7 +304,7 @@ class QualityManager(QObject):
for node in nodes_to_check: for node in nodes_to_check:
if node and node.quality_type_map: if node and node.quality_type_map:
if has_variant_materials: if has_variants_or_materials:
# Only include variant qualities; skip non global qualities # Only include variant qualities; skip non global qualities
quality_node = list(node.quality_type_map.values())[0] quality_node = list(node.quality_type_map.values())[0]
is_global_quality = parseBool(quality_node.metadata.get("global_quality", False)) is_global_quality = parseBool(quality_node.metadata.get("global_quality", False))

View file

@ -13,6 +13,8 @@ from UM.Settings.SettingInstance import InstanceState
from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Settings.Interfaces import PropertyEvaluationContext from UM.Settings.Interfaces import PropertyEvaluationContext
from UM.Logger import Logger from UM.Logger import Logger
from UM.Util import parseBool
import cura.CuraApplication import cura.CuraApplication
from . import Exceptions from . import Exceptions
@ -188,6 +190,12 @@ class GlobalStack(CuraContainerStack):
def getHeadAndFansCoordinates(self): def getHeadAndFansCoordinates(self):
return self.getProperty("machine_head_with_fans_polygon", "value") return self.getProperty("machine_head_with_fans_polygon", "value")
def getHasMaterials(self) -> bool:
return parseBool(self.getMetaDataEntry("has_materials", False))
def getHasVariants(self) -> bool:
return parseBool(self.getMetaDataEntry("has_variants", False))
## private: ## private:
global_stack_mime = MimeType( global_stack_mime = MimeType(

View file

@ -11,7 +11,6 @@
"has_machine_quality": true, "has_machine_quality": true,
"has_materials": true, "has_materials": true,
"has_machine_materials": true, "has_machine_materials": true,
"has_variant_materials": true,
"has_variants": true, "has_variants": true,
"variants_name": "Tool", "variants_name": "Tool",

View file

@ -13,7 +13,6 @@
"has_machine_quality": true, "has_machine_quality": true,
"has_materials": true, "has_materials": true,
"has_machine_materials": true, "has_machine_materials": true,
"has_variant_materials": true,
"has_variants": true, "has_variants": true,
"preferred_variant_name": "AA 0.4", "preferred_variant_name": "AA 0.4",
"preferred_quality_type": "normal", "preferred_quality_type": "normal",

View file

@ -13,7 +13,6 @@
"platform_offset": [0, 0, 0], "platform_offset": [0, 0, 0],
"has_machine_quality": true, "has_machine_quality": true,
"has_machine_materials": true, "has_machine_materials": true,
"has_variant_materials": true,
"has_materials": true, "has_materials": true,
"has_variants": true, "has_variants": true,
"preferred_variant_name": "AA 0.4", "preferred_variant_name": "AA 0.4",

View file

@ -15,7 +15,6 @@
"has_machine_quality": true, "has_machine_quality": true,
"has_materials": true, "has_materials": true,
"has_machine_materials": true, "has_machine_materials": true,
"has_variant_materials": true,
"has_variant_buildplates": true, "has_variant_buildplates": true,
"has_variants": true, "has_variants": true,
"preferred_variant_name": "AA 0.4", "preferred_variant_name": "AA 0.4",