mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 01:15:57 +08:00
Add a MachineNode once a definition for it gets loaded
This means that we've added this machine. We need to pre-load all of the containers for that printer then. Contributes to issue CURA-6600.
This commit is contained in:
parent
9fda7bd0b9
commit
e84a75094a
@ -1,6 +1,9 @@
|
||||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry # To listen to containers being added.
|
||||
from UM.Settings.DefinitionContainer import DefinitionContainer
|
||||
from UM.Settings.Interfaces import ContainerInterface
|
||||
from cura.Machines.MachineNode import MachineNode
|
||||
|
||||
from typing import Dict
|
||||
@ -12,4 +15,15 @@ from typing import Dict
|
||||
# there will be one machine node here.
|
||||
class ContainerTree:
|
||||
def __init__(self) -> None:
|
||||
self.machines = {} # type: Dict[str, MachineNode] # Mapping from definition ID to machine nodes.
|
||||
self.machines = {} # type: Dict[str, MachineNode] # Mapping from definition ID to machine nodes.
|
||||
ContainerRegistry.getInstance().containerAdded.connect(self.machineAdded)
|
||||
|
||||
## When a printer gets added, we need to build up the tree for that container.
|
||||
def machineAdded(self, definition_container: ContainerInterface):
|
||||
if not isinstance(definition_container, DefinitionContainer):
|
||||
return # Not our concern.
|
||||
definition_id = definition_container.getId()
|
||||
if definition_id in self.machines:
|
||||
return # Already have this definition ID.
|
||||
|
||||
self.machines[definition_id] = MachineNode(definition_id)
|
Loading…
x
Reference in New Issue
Block a user