def _loadAll(self) -> None: container_registry = ContainerRegistry.getInstance() # Find all quality profiles that fit on this material. if not self.variant.machine.has_machine_quality: # Need to find the global qualities. qualities = container_registry.findInstanceContainersMetadata(type = "quality", definition = "fdmprinter") elif not self.variant.machine.has_materials: qualities = container_registry.findInstanceContainersMetadata(type = "quality", definition = self.variant.machine.quality_definition) else: if self.variant.machine.has_variants: # Need to find the qualities that specify a material profile with the same material type. qualities = container_registry.findInstanceContainersMetadata(type = "quality", definition = self.variant.machine.quality_definition, variant = self.variant.variant_name, material = self.base_file) # First try by exact material ID. # CURA-7070 # The quality profiles only reference a material with the material_root_id. They will never state something # such as "generic_pla_ultimaker_s5_AA_0.4". So we search with the "base_file" which is the material_root_id. else: qualities = container_registry.findInstanceContainersMetadata(type = "quality", definition = self.variant.machine.quality_definition, material = self.base_file) if not qualities: my_material_type = self.material_type if self.variant.machine.has_variants: qualities_any_material = container_registry.findInstanceContainersMetadata(type = "quality", definition = self.variant.machine.quality_definition, variant = self.variant.variant_name) else: qualities_any_material = container_registry.findInstanceContainersMetadata(type = "quality", definition = self.variant.machine.quality_definition) for material_metadata in container_registry.findInstanceContainersMetadata(type = "material", material = my_material_type): qualities.extend((quality for quality in qualities_any_material if quality.get("material") == material_metadata["base_file"])) if not qualities: # No quality profiles found. Go by GUID then. my_guid = self.guid for material_metadata in container_registry.findInstanceContainersMetadata(type = "material", guid = my_guid): qualities.extend((quality for quality in qualities_any_material if quality["material"] == material_metadata["base_file"])) if not qualities: # There are still some machines that should use global profiles in the extruder, so do that now. # These are mostly older machines that haven't received updates (so single extruder machines without specific qualities # but that do have materials and profiles specific to that machine) qualities.extend([quality for quality in qualities_any_material if quality.get("global_quality", "False") != "False"]) for quality in qualities: quality_id = quality["id"] if quality_id not in self.qualities: self.qualities[quality_id] = QualityNode(quality_id, parent = self) if not self.qualities: self.qualities["empty_quality"] = QualityNode("empty_quality", parent = self)
def _loadAll(self) -> None: container_registry = ContainerRegistry.getInstance() if not self.has_variants: self.variants["empty"] = VariantNode("empty_variant", machine=self) else: # Find all the variants for this definition ID. variants = container_registry.findInstanceContainersMetadata( type="variant", definition=self.container_id, hardware_type="nozzle") for variant in variants: variant_name = variant["name"] if variant_name not in self.variants: self.variants[variant_name] = VariantNode(variant["id"], machine=self) self.variants[variant_name].materialsChanged.connect( self.materialsChanged) if not self.variants: self.variants["empty"] = VariantNode("empty_variant", machine=self) # Find the global qualities for this printer. global_qualities = container_registry.findInstanceContainersMetadata( type="quality", definition=self.quality_definition, global_quality="True") # First try specific to this printer. if len(global_qualities ) == 0: # This printer doesn't override the global qualities. global_qualities = container_registry.findInstanceContainersMetadata( type="quality", definition="fdmprinter", global_quality="True" ) # Otherwise pick the global global qualities. for global_quality in global_qualities: self.global_qualities[ global_quality["quality_type"]] = QualityNode( global_quality["id"], parent=self)
def _loadAll(self) -> None: """(Re)loads all variants under this printer.""" container_registry = ContainerRegistry.getInstance() if not self.has_variants: self.variants["empty"] = VariantNode("empty_variant", machine = self) self.variants["empty"].materialsChanged.connect(self.materialsChanged) else: # Find all the variants for this definition ID. variants = container_registry.findInstanceContainersMetadata(type = "variant", definition = self.container_id, hardware_type = "nozzle") for variant in variants: variant_name = variant["name"] if variant_name not in self.variants: self.variants[variant_name] = VariantNode(variant["id"], machine = self) self.variants[variant_name].materialsChanged.connect(self.materialsChanged) else: # Force reloading the materials if the variant already exists or else materals won't be loaded # when the G-Code flavor changes --> CURA-7354 self.variants[variant_name]._loadAll() if not self.variants: self.variants["empty"] = VariantNode("empty_variant", machine = self) # Find the global qualities for this printer. global_qualities = container_registry.findInstanceContainersMetadata(type = "quality", definition = self.quality_definition, global_quality = "True") # First try specific to this printer. if not global_qualities: # This printer doesn't override the global qualities. global_qualities = container_registry.findInstanceContainersMetadata(type = "quality", definition = "fdmprinter", global_quality = "True") # Otherwise pick the global global qualities. if not global_qualities: # There are no global qualities either?! Something went very wrong, but we'll not crash and properly fill the tree. global_qualities = [cura.CuraApplication.CuraApplication.getInstance().empty_quality_container.getMetaData()] for global_quality in global_qualities: self.global_qualities[global_quality["quality_type"]] = QualityNode(global_quality["id"], parent = self)
def test_qualityNode_machine_1(container_registry): material_node = MagicMock() material_node.variant.machine.quality_definition = "correct_definition" material_node.variant.variant_name = "correct_variant" with patch("cura.Machines.QualityNode.IntentNode"): with patch( "UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)): node = QualityNode("quality_1", material_node) assert len(node.intents) == 3 assert "matching_intent" in node.intents assert "matching_intent_2" in node.intents assert "empty_intent" in node.intents