mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 06:09:00 +08:00
CURA-4606 fix material names for 1.75mm materials
This commit is contained in:
parent
6dc53eb741
commit
8275e506ce
@ -38,11 +38,17 @@ class MaterialManager(QObject):
|
||||
self._fallback_materials_map = dict() # material_type -> generic material metadata
|
||||
self._material_group_map = dict() # root_material_id -> MaterialGroup
|
||||
self._diameter_machine_variant_material_map = dict() # diameter -> dict(machine_definition_id -> MaterialNode)
|
||||
|
||||
# We're using these two maps to convert between the specific diameter material id and the generic material id
|
||||
# because the generic material ids are used in qualities and definitions, while the specific diameter material is meant
|
||||
# i.e. generic_pla -> generic_pla_175
|
||||
self._material_diameter_map = defaultdict() # root_material_id -> diameter -> root_material_id for that diameter
|
||||
self._diameter_material_map = dict() # material id including diameter (generic_pla_175) -> material root id (generic_pla)
|
||||
|
||||
# The machine definition ID for the non-machine-specific materials.
|
||||
# This is used as the last fallback option if the given machine-specific material(s) cannot be found.
|
||||
self._default_machine_definition_id = "fdmprinter"
|
||||
self._default_approximate_diameter_for_quality_search = "3"
|
||||
|
||||
self._update_timer = QTimer(self)
|
||||
self._update_timer.setInterval(300)
|
||||
@ -99,6 +105,7 @@ class MaterialManager(QObject):
|
||||
# be for either "generic_pla" or "generic_pla_175", but not both. This map helps to get the correct material ID
|
||||
# for quality search.
|
||||
self._material_diameter_map = defaultdict(defaultdict)
|
||||
self._diameter_material_map = dict()
|
||||
|
||||
# Group the material IDs by the same name, material, brand, and color but with different diameters.
|
||||
material_group_dict = dict()
|
||||
@ -116,10 +123,17 @@ class MaterialManager(QObject):
|
||||
approximate_diameter = root_material_metadata.get("approximate_diameter")
|
||||
material_group_dict[key_data][approximate_diameter] = root_material_metadata["id"]
|
||||
|
||||
# Map [root_material_id][diameter] -> root_material_id for this diameter
|
||||
for data_dict in material_group_dict.values():
|
||||
for rmid1 in data_dict.values():
|
||||
for ad2, rmid2 in data_dict.items():
|
||||
self._material_diameter_map[rmid1][ad2] = rmid2
|
||||
for root_material_id1 in data_dict.values():
|
||||
for approximate_diameter2, root_material_id2 in data_dict.items():
|
||||
self._material_diameter_map[root_material_id1][approximate_diameter2] = root_material_id2
|
||||
|
||||
default_root_material_id = data_dict.get(self._default_approximate_diameter_for_quality_search)
|
||||
if default_root_material_id is None:
|
||||
default_root_material_id = list(data_dict.values())[0] # no default diameter present, just take "the" only one
|
||||
for root_material_id in data_dict.values():
|
||||
self._diameter_material_map[root_material_id] = default_root_material_id
|
||||
|
||||
# Map #4
|
||||
# "machine" -> "variant_name" -> "root material ID" -> specific material InstanceContainer
|
||||
@ -181,6 +195,9 @@ class MaterialManager(QObject):
|
||||
def getRootMaterialIDForDiameter(self, root_material_id: str, approximate_diameter: str) -> str:
|
||||
return self._material_diameter_map.get(root_material_id).get(approximate_diameter, root_material_id)
|
||||
|
||||
def getRootMaterialIDWithoutDiameter(self, root_material_id: str) -> str:
|
||||
return self._diameter_material_map.get(root_material_id)
|
||||
|
||||
#
|
||||
# Return a dict with all root material IDs (k) and ContainerNodes (v) that's suitable for the given setup.
|
||||
#
|
||||
@ -264,8 +281,12 @@ class MaterialManager(QObject):
|
||||
# This function returns the generic root material ID for the given material type, where material types are "PLA",
|
||||
# "ABS", etc.
|
||||
#
|
||||
def getFallbackMaterialForType(self, material_type: str) -> dict:
|
||||
def getFallbackMaterialId(self, material_type: str) -> str:
|
||||
# For safety
|
||||
if material_type not in self._fallback_materials_map:
|
||||
raise RuntimeError("Material type [%s] is not in the fallback materials table." % material_type)
|
||||
return self._fallback_materials_map[material_type]
|
||||
fallback_material = self._fallback_materials_map[material_type]
|
||||
if fallback_material:
|
||||
return self.getRootMaterialIDWithoutDiameter(fallback_material["id"])
|
||||
else:
|
||||
return None
|
||||
|
@ -286,13 +286,15 @@ class QualityManager(QObject):
|
||||
if extruder.material.getId() != "empty_material":
|
||||
has_material = True
|
||||
root_material_id = extruder.material.getMetaDataEntry("base_file")
|
||||
# Convert possible generic_pla_175 -> generic_pla
|
||||
root_material_id = self._material_manager.getRootMaterialIDWithoutDiameter(root_material_id)
|
||||
root_material_id_list.append(root_material_id)
|
||||
|
||||
# Also try to get the fallback material
|
||||
material_type = extruder.material.getMetaDataEntry("material")
|
||||
fallback_root_material_metadata = self._material_manager.getFallbackMaterialForType(material_type)
|
||||
if fallback_root_material_metadata:
|
||||
root_material_id_list.append(fallback_root_material_metadata["id"])
|
||||
fallback_root_material_id = self._material_manager.getFallbackMaterialId(material_type)
|
||||
if fallback_root_material_id:
|
||||
root_material_id_list.append(fallback_root_material_id)
|
||||
|
||||
nodes_to_check = []
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
"category": "Other",
|
||||
"file_formats": "text/x-gcode",
|
||||
"platform": "gmax_1-5_xt-plus_s3d_full model_150707.stl",
|
||||
"has_machine_quality": true,
|
||||
"has_variants": true,
|
||||
"variants_name": "Hotend",
|
||||
"preferred_variant_name": "0.5mm E3D (Default)"
|
||||
|
@ -11,6 +11,7 @@
|
||||
"file_formats": "text/x-gcode",
|
||||
"platform": "gmax_1-5_xt-plus_s3d_full model_150707.stl",
|
||||
"has_variants": true,
|
||||
"has_machine_quality": true,
|
||||
"variants_name": "Hotend",
|
||||
"preferred_variant_name": "0.5mm E3D (Default)",
|
||||
"machine_extruder_trains": {
|
||||
|
@ -8,7 +8,6 @@ setting_version = 4
|
||||
type = quality
|
||||
quality_type = normal
|
||||
weight = -1
|
||||
global_quality = True
|
||||
|
||||
[values]
|
||||
layer_height = 0.2
|
||||
|
@ -8,7 +8,6 @@ setting_version = 4
|
||||
type = quality
|
||||
quality_type = course
|
||||
weight = -2
|
||||
global_quality = True
|
||||
|
||||
[values]
|
||||
layer_height = 0.28
|
||||
|
@ -8,7 +8,6 @@ setting_version = 4
|
||||
type = quality
|
||||
quality_type = high
|
||||
weight = 0
|
||||
global_quality = True
|
||||
|
||||
[values]
|
||||
layer_height = 0.16
|
||||
|
@ -8,7 +8,6 @@ setting_version = 4
|
||||
type = quality
|
||||
quality_type = extra_course
|
||||
weight = -3
|
||||
global_quality = True
|
||||
|
||||
[values]
|
||||
layer_height = 0.32
|
||||
|
@ -8,7 +8,6 @@ setting_version = 4
|
||||
type = quality
|
||||
quality_type = normal
|
||||
weight = -1
|
||||
global_quality = True
|
||||
|
||||
[values]
|
||||
layer_height = 0.2
|
||||
|
@ -8,7 +8,6 @@ setting_version = 4
|
||||
type = quality
|
||||
quality_type = course
|
||||
weight = -2
|
||||
global_quality = True
|
||||
|
||||
[values]
|
||||
layer_height = 0.28
|
||||
|
@ -8,7 +8,6 @@ setting_version = 4
|
||||
type = quality
|
||||
quality_type = high
|
||||
weight = 0
|
||||
global_quality = True
|
||||
|
||||
[values]
|
||||
layer_height = 0.16
|
||||
|
@ -8,7 +8,6 @@ setting_version = 4
|
||||
type = quality
|
||||
quality_type = extra_course
|
||||
weight = -3
|
||||
global_quality = True
|
||||
|
||||
[values]
|
||||
layer_height = 0.32
|
||||
|
Loading…
x
Reference in New Issue
Block a user