mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 13:49:02 +08:00
Read only position from metadata
We now determine whether this is a global or an extruder profile based on whether the position metadata field is present, instead of whether the extruder metadata field is present. Contributes to issue CURA-5054.
This commit is contained in:
parent
5d2e98cdd4
commit
b797ac1a15
@ -15,41 +15,16 @@ class QualityChangesGroup(QualityGroup):
|
|||||||
self._container_registry = Application.getInstance().getContainerRegistry()
|
self._container_registry = Application.getInstance().getContainerRegistry()
|
||||||
|
|
||||||
def addNode(self, node: "QualityNode"):
|
def addNode(self, node: "QualityNode"):
|
||||||
# TODO: in 3.2 and earlier, a quality_changes container may have a field called "extruder" which contains the
|
extruder_position = node.metadata.get("position")
|
||||||
# extruder definition ID it belongs to. But, in fact, we only need to know the following things:
|
if not extruder_position: #Then we're a global quality changes profile.
|
||||||
# 1. which machine a custom profile is suitable for,
|
if self.node_for_global is not None:
|
||||||
# 2. if this profile is for the GlobalStack,
|
raise RuntimeError("{group} tries to overwrite the existing node_for_global {original_global} with {new_global}".format(group = self, original_global = self.node_for_global, new_global = node))
|
||||||
# 3. if this profile is for an ExtruderStack and which one (the position).
|
self.node_for_global = node
|
||||||
#
|
else: #This is an extruder's quality changes profile.
|
||||||
# So, it is preferred to have a field like this:
|
|
||||||
# extruder_position = 1
|
|
||||||
# instead of this:
|
|
||||||
# extruder = custom_extruder_1
|
|
||||||
#
|
|
||||||
# An upgrade needs to be done if we want to do it this way. Before that, we use the extruder's definition
|
|
||||||
# to figure out its position.
|
|
||||||
#
|
|
||||||
extruder_definition_id = node.metadata.get("extruder")
|
|
||||||
if extruder_definition_id:
|
|
||||||
metadata_list = self._container_registry.findDefinitionContainersMetadata(id = extruder_definition_id)
|
|
||||||
if not metadata_list:
|
|
||||||
raise RuntimeError("%s cannot get metadata for extruder definition [%s]" %
|
|
||||||
(self, extruder_definition_id))
|
|
||||||
extruder_definition_metadata = metadata_list[0]
|
|
||||||
extruder_position = str(extruder_definition_metadata["position"])
|
|
||||||
|
|
||||||
if extruder_position in self.nodes_for_extruders:
|
if extruder_position in self.nodes_for_extruders:
|
||||||
raise RuntimeError("%s tries to overwrite the existing nodes_for_extruders position [%s] %s with %s" %
|
raise RuntimeError("%s tries to overwrite the existing nodes_for_extruders position [%s] %s with %s" %
|
||||||
(self, extruder_position, self.node_for_global, node))
|
(self, extruder_position, self.node_for_global, node))
|
||||||
|
|
||||||
self.nodes_for_extruders[extruder_position] = node
|
self.nodes_for_extruders[extruder_position] = node
|
||||||
|
|
||||||
else:
|
|
||||||
# This is a quality_changes for the GlobalStack
|
|
||||||
if self.node_for_global is not None:
|
|
||||||
raise RuntimeError("%s tries to overwrite the existing node_for_global %s with %s" %
|
|
||||||
(self, self.node_for_global, node))
|
|
||||||
self.node_for_global = node
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return "%s[<%s>, available = %s]" % (self.__class__.__name__, self.name, self.is_available)
|
return "%s[<%s>, available = %s]" % (self.__class__.__name__, self.name, self.is_available)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user