mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-09 23:05:01 -06:00
Merge branch 'master' into feature_sync_button
This commit is contained in:
commit
85d6919ce6
478 changed files with 1284 additions and 1365 deletions
|
@ -387,10 +387,10 @@ class MaterialManager(QObject):
|
|||
else:
|
||||
return None
|
||||
|
||||
def getDefaultMaterial(self, global_stack: "GlobalStack", extruder_variant_name: str) -> Optional["MaterialNode"]:
|
||||
def getDefaultMaterial(self, global_stack: "GlobalStack", extruder_variant_name: Optional[str]) -> Optional["MaterialNode"]:
|
||||
node = None
|
||||
machine_definition = global_stack.definition
|
||||
if parseBool(machine_definition.getMetaDataEntry("has_materials", False)):
|
||||
if parseBool(global_stack.getMetaDataEntry("has_materials", False)):
|
||||
material_diameter = machine_definition.getProperty("material_diameter", "value")
|
||||
if isinstance(material_diameter, SettingFunction):
|
||||
material_diameter = material_diameter(global_stack)
|
||||
|
|
|
@ -122,17 +122,17 @@ class BrandMaterialsModel(ListModel):
|
|||
material_type_item["colors"].clear()
|
||||
|
||||
# Sort materials by name
|
||||
material_list = sorted(material_list, key = lambda x: x["name"])
|
||||
material_list = sorted(material_list, key = lambda x: x["name"].upper())
|
||||
material_type_item["colors"].setItems(material_list)
|
||||
|
||||
material_type_item_list.append(material_type_item)
|
||||
|
||||
# Sort material type by name
|
||||
material_type_item_list = sorted(material_type_item_list, key = lambda x: x["name"])
|
||||
material_type_item_list = sorted(material_type_item_list, key = lambda x: x["name"].upper())
|
||||
brand_item["materials"].setItems(material_type_item_list)
|
||||
|
||||
brand_item_list.append(brand_item)
|
||||
|
||||
# Sort brand by name
|
||||
brand_item_list = sorted(brand_item_list, key = lambda x: x["name"])
|
||||
brand_item_list = sorted(brand_item_list, key = lambda x: x["name"].upper())
|
||||
self.setItems(brand_item_list)
|
||||
|
|
|
@ -23,7 +23,7 @@ class CustomQualityProfilesDropDownMenuModel(QualityProfilesDropDownMenuModel):
|
|||
quality_changes_group_dict = self._quality_manager.getQualityChangesGroups(active_global_stack)
|
||||
|
||||
item_list = []
|
||||
for key in sorted(quality_changes_group_dict):
|
||||
for key in sorted(quality_changes_group_dict, key = lambda name: name.upper()):
|
||||
quality_changes_group = quality_changes_group_dict[key]
|
||||
|
||||
item = {"name": quality_changes_group.name,
|
||||
|
|
|
@ -55,6 +55,6 @@ class GenericMaterialsModel(BaseMaterialsModel):
|
|||
item_list.append(item)
|
||||
|
||||
# Sort the item list by material name alphabetically
|
||||
item_list = sorted(item_list, key = lambda d: d["name"])
|
||||
item_list = sorted(item_list, key = lambda d: d["name"].upper())
|
||||
|
||||
self.setItems(item_list)
|
||||
|
|
|
@ -97,5 +97,5 @@ class MaterialManagementModel(ListModel):
|
|||
|
||||
material_list.append(item)
|
||||
|
||||
material_list = sorted(material_list, key = lambda k: (k["brand"].lower(), k["name"]))
|
||||
material_list = sorted(material_list, key = lambda k: (k["brand"].upper(), k["name"].upper()))
|
||||
self.setItems(material_list)
|
||||
|
|
|
@ -45,7 +45,7 @@ class NozzleModel(ListModel):
|
|||
return
|
||||
|
||||
item_list = []
|
||||
for hotend_name, container_node in sorted(variant_node_dict.items(), key = lambda i: i[0]):
|
||||
for hotend_name, container_node in sorted(variant_node_dict.items(), key = lambda i: i[0].upper()):
|
||||
item = {"id": hotend_name,
|
||||
"hotend_name": hotend_name,
|
||||
"container_node": container_node
|
||||
|
|
|
@ -59,7 +59,7 @@ class QualityManagementModel(ListModel):
|
|||
"quality_changes_group": None}
|
||||
item_list.append(item)
|
||||
# Sort by quality names
|
||||
item_list = sorted(item_list, key = lambda x: x["name"])
|
||||
item_list = sorted(item_list, key = lambda x: x["name"].upper())
|
||||
|
||||
# Create quality_changes group items
|
||||
quality_changes_item_list = []
|
||||
|
@ -74,7 +74,7 @@ class QualityManagementModel(ListModel):
|
|||
quality_changes_item_list.append(item)
|
||||
|
||||
# Sort quality_changes items by names and append to the item list
|
||||
quality_changes_item_list = sorted(quality_changes_item_list, key = lambda x: x["name"])
|
||||
quality_changes_item_list = sorted(quality_changes_item_list, key = lambda x: x["name"].upper())
|
||||
item_list += quality_changes_item_list
|
||||
|
||||
self.setItems(item_list)
|
||||
|
|
|
@ -69,7 +69,7 @@ class QualitySettingsModel(ListModel):
|
|||
return self._selected_quality_item
|
||||
|
||||
def _update(self):
|
||||
if self._selected_quality_item is None:
|
||||
if not self._selected_quality_item:
|
||||
self.setItems([])
|
||||
return
|
||||
|
||||
|
|
|
@ -7,47 +7,21 @@ from .QualityGroup import QualityGroup
|
|||
|
||||
|
||||
class QualityChangesGroup(QualityGroup):
|
||||
|
||||
def __init__(self, name: str, quality_type: str, parent = None):
|
||||
super().__init__(name, quality_type, parent)
|
||||
self._container_registry = Application.getInstance().getContainerRegistry()
|
||||
|
||||
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 definition ID it belongs to. But, in fact, we only need to know the following things:
|
||||
# 1. which machine a custom profile is suitable for,
|
||||
# 2. if this profile is for the GlobalStack,
|
||||
# 3. if this profile is for an ExtruderStack and which one (the position).
|
||||
#
|
||||
# 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"])
|
||||
|
||||
extruder_position = node.metadata.get("position")
|
||||
if extruder_position is None: #Then we're a global quality changes profile.
|
||||
if self.node_for_global is not None:
|
||||
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))
|
||||
self.node_for_global = node
|
||||
else: #This is an extruder's quality changes profile.
|
||||
if extruder_position in self.nodes_for_extruders:
|
||||
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.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:
|
||||
return "%s[<%s>, available = %s]" % (self.__class__.__name__, self.name, self.is_available)
|
||||
|
|
|
@ -428,11 +428,11 @@ class QualityManager(QObject):
|
|||
Logger.log("w", "No quality or quality changes container found in stack %s, ignoring it", stack.getId())
|
||||
continue
|
||||
|
||||
extruder_definition_id = None
|
||||
if isinstance(stack, ExtruderStack):
|
||||
extruder_definition_id = stack.definition.getId()
|
||||
quality_type = quality_container.getMetaDataEntry("quality_type")
|
||||
new_changes = self._createQualityChanges(quality_type, unique_name, global_stack, extruder_definition_id)
|
||||
extruder_stack = None
|
||||
if isinstance(stack, ExtruderStack):
|
||||
extruder_stack = stack
|
||||
new_changes = self._createQualityChanges(quality_type, unique_name, global_stack, extruder_stack)
|
||||
from cura.Settings.ContainerManager import ContainerManager
|
||||
ContainerManager.getInstance()._performMerge(new_changes, quality_changes_container, clear_settings = False)
|
||||
ContainerManager.getInstance()._performMerge(new_changes, user_container)
|
||||
|
@ -443,8 +443,8 @@ class QualityManager(QObject):
|
|||
# Create a quality changes container with the given setup.
|
||||
#
|
||||
def _createQualityChanges(self, quality_type: str, new_name: str, machine: "GlobalStack",
|
||||
extruder_id: Optional[str]) -> "InstanceContainer":
|
||||
base_id = machine.definition.getId() if extruder_id is None else extruder_id
|
||||
extruder_stack: Optional["ExtruderStack"]) -> "InstanceContainer":
|
||||
base_id = machine.definition.getId() if extruder_stack is None else extruder_stack.getId()
|
||||
new_id = base_id + "_" + new_name
|
||||
new_id = new_id.lower().replace(" ", "_")
|
||||
new_id = self._container_registry.uniqueName(new_id)
|
||||
|
@ -456,8 +456,8 @@ class QualityManager(QObject):
|
|||
quality_changes.addMetaDataEntry("quality_type", quality_type)
|
||||
|
||||
# If we are creating a container for an extruder, ensure we add that to the container
|
||||
if extruder_id is not None:
|
||||
quality_changes.addMetaDataEntry("extruder", extruder_id)
|
||||
if extruder_stack is not None:
|
||||
quality_changes.addMetaDataEntry("position", extruder_stack.getMetaDataEntry("position"))
|
||||
|
||||
# If the machine specifies qualities should be filtered, ensure we match the current criteria.
|
||||
machine_definition_id = getMachineDefinitionIDForQualitySearch(machine)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue