mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Add signals to signal that a material got changed or removed
The material models need to know this. Contributes to issue CURA-6600.
This commit is contained in:
parent
b7213ad020
commit
6c6dd0efad
4 changed files with 22 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
|
|||
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
from UM.Settings.Interfaces import ContainerInterface
|
||||
from UM.Signal import Signal
|
||||
from cura.Machines.ContainerNode import ContainerNode
|
||||
from cura.Machines.MaterialNode import MaterialNode
|
||||
|
||||
|
|
@ -26,6 +27,8 @@ class VariantNode(ContainerNode):
|
|||
super().__init__(container_id)
|
||||
self.machine = machine
|
||||
self.materials = {} # type: Dict[str, MaterialNode] # Mapping material base files to their nodes.
|
||||
self.materialsChanged = Signal()
|
||||
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
self.variant_name = container_registry.findContainersMetadata(id = container_id)[0]["name"] # Store our own name so that we can filter more easily.
|
||||
container_registry.containerAdded.connect(self._materialAdded)
|
||||
|
|
@ -55,6 +58,7 @@ class VariantNode(ContainerNode):
|
|||
base_file = material["base_file"]
|
||||
if base_file not in self.materials:
|
||||
self.materials[base_file] = MaterialNode(material["id"], variant = self)
|
||||
self.materials[base_file].materialChanged.connect(self.materialsChanged)
|
||||
|
||||
## When a material gets added to the set of profiles, we need to update our
|
||||
# tree here.
|
||||
|
|
@ -85,4 +89,5 @@ class VariantNode(ContainerNode):
|
|||
if original_variant != "empty" or container.getMetaDataEntry("variant", "empty") == "empty":
|
||||
return # Original was already specific or just as unspecific as the new one.
|
||||
|
||||
self.materials[base_file] = MaterialNode(container.getId(), variant = self)
|
||||
self.materials[base_file] = MaterialNode(container.getId(), variant = self)
|
||||
self.materials[base_file].materialChanged.connect(self.materialsChanged)
|
||||
Loading…
Add table
Add a link
Reference in a new issue