mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 03:04:23 +08:00

Among the machines, variants, materials, qualities and intents, only machines and materials can ever be added during runtime. For the rest, we don't need to listen to these signals. Contributes to issue CURA-6600.
32 lines
1.5 KiB
Python
32 lines
1.5 KiB
Python
# Copyright (c) 2019 Ultimaker B.V.
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
from typing import Union, TYPE_CHECKING
|
|
|
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
|
from cura.Machines.ContainerNode import ContainerNode
|
|
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, parent: Union["MaterialNode", "MachineNode"]) -> None:
|
|
super().__init__(container_id)
|
|
self.parent = parent
|
|
self.intents = {} # type: Dict[str, IntentNode]
|
|
self._loadAll()
|
|
|
|
def _loadAll(self) -> None:
|
|
container_registry = ContainerRegistry.getInstance()
|
|
# Find all intent profiles that fit the current configuration.
|
|
from cura.Machines.MachineNode import MachineNode
|
|
if not isinstance(self.parent, MachineNode): # 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. |