mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-21 13:47:51 -06:00
CURA-4870 Add function to set the configuration from the printer back to
Cura. Change the hash function to compare by GUID instead of type. Show the material name instead of type in the list.
This commit is contained in:
parent
d11d850f7c
commit
f625fa8a90
8 changed files with 66 additions and 14 deletions
|
@ -87,6 +87,7 @@ class MaterialManager(QObject):
|
|||
root_material_id = material_metadata.get("base_file")
|
||||
if root_material_id not in self._material_group_map:
|
||||
self._material_group_map[root_material_id] = MaterialGroup(root_material_id)
|
||||
self._material_group_map[root_material_id].is_read_only = self._container_registry.isReadOnly(root_material_id)
|
||||
group = self._material_group_map[root_material_id]
|
||||
|
||||
# We only add root materials here
|
||||
|
@ -325,6 +326,35 @@ class MaterialManager(QObject):
|
|||
|
||||
return material_node
|
||||
|
||||
#
|
||||
# Gets MaterialNode for the given extruder and machine with the given material type.
|
||||
# Returns None if:
|
||||
# 1. the given machine doesn't have materials;
|
||||
# 2. cannot find any material InstanceContainers with the given settings.
|
||||
#
|
||||
def getMaterialNodeByType(self, global_stack: "GlobalStack", extruder_variant_name: str, material_guid: str) -> Optional["MaterialNode"]:
|
||||
node = None
|
||||
machine_definition = global_stack.definition
|
||||
if parseBool(machine_definition.getMetaDataEntry("has_materials", False)):
|
||||
material_diameter = machine_definition.getProperty("material_diameter", "value")
|
||||
if isinstance(material_diameter, SettingFunction):
|
||||
material_diameter = material_diameter(global_stack)
|
||||
|
||||
# Look at the guid to material dictionary
|
||||
root_material_id = None
|
||||
for material_group in self._guid_material_groups_map[material_guid]:
|
||||
if material_group.is_read_only:
|
||||
root_material_id = material_group.root_material_node.metadata["id"]
|
||||
break
|
||||
|
||||
if not root_material_id:
|
||||
Logger.log("i", "Cannot find materials with guid [%s] ", material_guid)
|
||||
return None
|
||||
|
||||
node = self.getMaterialNode(machine_definition.getId(), extruder_variant_name,
|
||||
material_diameter, root_material_id)
|
||||
return node
|
||||
|
||||
#
|
||||
# Used by QualityManager. Built-in quality profiles may be based on generic material IDs such as "generic_pla".
|
||||
# For materials such as ultimaker_pla_orange, no quality profiles may be found, so we should fall back to use
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue