mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 11:17:49 -06:00
Add global quality nodes to machine node
This means that the parent of the quality node could be one of two types. A bit confusing. Contributes to issue CURA-6600.
This commit is contained in:
parent
fff26bb021
commit
8f075b644d
3 changed files with 28 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Union, TYPE_CHECKING
|
||||
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
from UM.Settings.Interfaces import ContainerInterface
|
||||
|
@ -11,14 +11,15 @@ from cura.Machines.IntentNode import IntentNode
|
|||
if TYPE_CHECKING:
|
||||
from typing import Dict
|
||||
from cura.Machines.MaterialNode import MaterialNode
|
||||
from cura.Machines.MachineNode import MachineNode
|
||||
|
||||
## Represents a material profile in the container tree.
|
||||
#
|
||||
# Its subcontainers are intent profiles.
|
||||
class QualityNode(ContainerNode):
|
||||
def __init__(self, container_id: str, material: "MaterialNode") -> None:
|
||||
def __init__(self, container_id: str, parent: Union["MaterialNode", "MachineNode"]) -> None:
|
||||
super().__init__(container_id)
|
||||
self.material = material
|
||||
self.parent = parent
|
||||
self.intents = {} # type: Dict[str, IntentNode]
|
||||
ContainerRegistry.getInstance().containerAdded.connect(self._intentAdded)
|
||||
self._loadAll()
|
||||
|
@ -26,17 +27,22 @@ class QualityNode(ContainerNode):
|
|||
def _loadAll(self) -> None:
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
# Find all intent profiles that fit the current configuration.
|
||||
for intent in container_registry.findInstanceContainersMetadata(type = "intent", definition = self.material.variant.machine.quality_definition, variant = self.material.variant.variant_name, material = self.material.base_file):
|
||||
self.intents[intent["id"]] = IntentNode(intent["id"], quality = self)
|
||||
if isinstance(self.parent, MaterialNode): # Not a global profile.
|
||||
for intent in container_registry.findInstanceContainersMetadata(type = "intent", definition = self.parent.variant.machine.quality_definition, variant = self.parent.variant.variant_name, material = self.parent.base_file):
|
||||
self.intents[intent["id"]] = IntentNode(intent["id"], quality = self)
|
||||
# Otherwise, there are no intents for global profiles.
|
||||
|
||||
def _intentAdded(self, container: ContainerInterface) -> None:
|
||||
from cura.Machines.MachineNode import MachineNode # Imported here to prevent circular imports.
|
||||
if container.getMetaDataEntry("type") != "intent":
|
||||
return # Not interested if it's not an intent.
|
||||
if container.getMetaDataEntry("definition") != self.material.variant.machine.quality_definition:
|
||||
if isinstance(self.parent, MachineNode):
|
||||
return # Global profiles don't have intents.
|
||||
if container.getMetaDataEntry("definition") != self.parent.variant.machine.quality_definition:
|
||||
return # Incorrect printer.
|
||||
if container.getMetaDataEntry("variant") != self.material.variant.variant_name:
|
||||
if container.getMetaDataEntry("variant") != self.parent.variant.variant_name:
|
||||
return # Incorrect variant.
|
||||
if container.getMetaDataEntry("material") != self.material.base_file:
|
||||
if container.getMetaDataEntry("material") != self.parent.base_file:
|
||||
return # Incorrect material.
|
||||
container_id = container.getId()
|
||||
if container_id in self.intents:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue