mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-10 15:25:09 -06:00
Fix typing.
part CURA-6600
This commit is contained in:
parent
83146a71a9
commit
745390e51f
10 changed files with 48 additions and 23 deletions
|
@ -77,6 +77,9 @@ class MachineNode(ContainerNode):
|
|||
# Create the quality group for each available type.
|
||||
quality_groups = {}
|
||||
for quality_type, global_quality_node in self.global_qualities.items():
|
||||
if not global_quality_node.container:
|
||||
Logger.log("w", "Node {0} doesn't have a container.".format(global_quality_node.container_id))
|
||||
continue
|
||||
quality_groups[quality_type] = QualityGroup(name = global_quality_node.container.getMetaDataEntry("name", "Unnamed profile"), quality_type = quality_type)
|
||||
quality_groups[quality_type].node_for_global = global_quality_node
|
||||
for extruder, qualities_per_type in enumerate(qualities_per_type_per_extruder):
|
||||
|
@ -116,7 +119,7 @@ class MachineNode(ContainerNode):
|
|||
def getQualityChangesGroups(self, variant_names: List[str], material_bases: List[str], extruder_enabled: List[bool]) -> List[QualityChangesGroup]:
|
||||
machine_quality_changes = ContainerRegistry.getInstance().findContainersMetadata(type = "quality_changes", definition = self.quality_definition) # All quality changes for each extruder.
|
||||
|
||||
groups_by_name = {} # Group quality changes profiles by their display name. The display name must be unique for quality changes. This finds profiles that belong together in a group.
|
||||
groups_by_name = {} #type: Dict[str, QualityChangesGroup] # Group quality changes profiles by their display name. The display name must be unique for quality changes. This finds profiles that belong together in a group.
|
||||
for quality_changes in machine_quality_changes:
|
||||
name = quality_changes["name"]
|
||||
if name not in groups_by_name:
|
||||
|
@ -143,7 +146,7 @@ class MachineNode(ContainerNode):
|
|||
# quality is taken.
|
||||
# If there are no global qualities, an empty quality is returned.
|
||||
def preferredGlobalQuality(self) -> QualityNode:
|
||||
return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities)))
|
||||
return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))
|
||||
|
||||
## (Re)loads all variants under this printer.
|
||||
def _loadAll(self):
|
||||
|
|
|
@ -132,7 +132,7 @@ class MaterialManager(QObject):
|
|||
# Fetch the available materials (ContainerNode) for the current active machine and extruder setup.
|
||||
materials = self.getAvailableMaterials(machine.definition.getId(), nozzle_name)
|
||||
compatible_material_diameter = str(round(extruder_stack.getCompatibleMaterialDiameter()))
|
||||
result = {key: material for key, material in materials.items() if material.container.getMetaDataEntry("approximate_diameter") == compatible_material_diameter}
|
||||
result = {key: material for key, material in materials.items() if material.container and material.container.getMetaDataEntry("approximate_diameter") == compatible_material_diameter}
|
||||
return result
|
||||
|
||||
#
|
||||
|
@ -268,6 +268,8 @@ class MaterialManager(QObject):
|
|||
|
||||
@pyqtSlot("QVariant", str)
|
||||
def setMaterialName(self, material_node: "MaterialNode", name: str) -> None:
|
||||
if material_node.container is None:
|
||||
return
|
||||
root_material_id = material_node.container.getMetaDataEntry("base_file")
|
||||
if root_material_id is None:
|
||||
return
|
||||
|
@ -279,6 +281,8 @@ class MaterialManager(QObject):
|
|||
|
||||
@pyqtSlot("QVariant")
|
||||
def removeMaterial(self, material_node: "MaterialNode") -> None:
|
||||
if material_node.container is None:
|
||||
return
|
||||
root_material_id = material_node.container.getMetaDataEntry("base_file")
|
||||
if root_material_id is not None:
|
||||
self.removeMaterialByRootId(root_material_id)
|
||||
|
@ -343,6 +347,9 @@ class MaterialManager(QObject):
|
|||
#
|
||||
@pyqtSlot("QVariant", result = str)
|
||||
def duplicateMaterial(self, material_node: MaterialNode, new_base_id: Optional[str] = None, new_metadata: Dict[str, Any] = None) -> Optional[str]:
|
||||
if material_node.container is None:
|
||||
Logger.log("e", "Material node {0} doesn't have container.".format(material_node.container_id))
|
||||
return "ERROR"
|
||||
root_material_id = cast(str, material_node.container.getMetaDataEntry("base_file", ""))
|
||||
return self.duplicateMaterialByRootId(root_material_id, new_base_id, new_metadata)
|
||||
|
||||
|
@ -359,7 +366,11 @@ class MaterialManager(QObject):
|
|||
machine_manager = application.getMachineManager()
|
||||
extruder_stack = machine_manager.activeStack
|
||||
|
||||
machine_definition = application.getGlobalContainerStack().definition
|
||||
global_stack = application.getGlobalContainerStack()
|
||||
if global_stack is None:
|
||||
Logger.log("e", "Global stack not present!")
|
||||
return "ERROR"
|
||||
machine_definition = global_stack.definition
|
||||
root_material_id = machine_definition.getMetaDataEntry("preferred_material", default = "generic_pla")
|
||||
|
||||
approximate_diameter = str(extruder_stack.approximateMaterialDiameter)
|
||||
|
|
|
@ -106,7 +106,10 @@ class BaseMaterialsModel(ListModel):
|
|||
def _materialsListChanged(self, material: MaterialNode) -> None:
|
||||
if material.variant.container_id != self._extruder_stack.variant.getId():
|
||||
return
|
||||
if material.variant.machine.container_id != cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack().definition.getId():
|
||||
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
|
||||
if not global_stack:
|
||||
return
|
||||
if material.variant.machine.container_id != global_stack.definition.getId():
|
||||
return
|
||||
self._update()
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class QualityChangesGroup(QObject):
|
|||
self.quality_type = quality_type
|
||||
self.intent_category = intent_category
|
||||
self.is_available = False
|
||||
self.metadata_for_global = None # type: Optional[str]
|
||||
self.metadata_for_global = {} # type: Dict[str, Any]
|
||||
self.metadata_per_extruder = {} # type: Dict[int, Dict[str, Any]]
|
||||
|
||||
def __str__(self) -> str:
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import Dict, Optional, List, Set
|
|||
|
||||
from PyQt5.QtCore import QObject, pyqtSlot
|
||||
|
||||
from UM.Logger import Logger
|
||||
from UM.Util import parseBool
|
||||
|
||||
from cura.Machines.ContainerNode import ContainerNode
|
||||
|
@ -60,6 +61,9 @@ class QualityGroup(QObject):
|
|||
self.node_for_global = node
|
||||
|
||||
# Update is_experimental flag
|
||||
if not node.container:
|
||||
Logger.log("w", "Node {0} doesn't have a container.".format(node.container_id))
|
||||
return
|
||||
is_experimental = parseBool(node.container.getMetaDataEntry("is_experimental", False))
|
||||
self.is_experimental |= is_experimental
|
||||
|
||||
|
@ -67,5 +71,8 @@ class QualityGroup(QObject):
|
|||
self.nodes_for_extruders[position] = node
|
||||
|
||||
# Update is_experimental flag
|
||||
if not node.container:
|
||||
Logger.log("w", "Node {0} doesn't have a container.".format(node.container_id))
|
||||
return
|
||||
is_experimental = parseBool(node.container.getMetaDataEntry("is_experimental", False))
|
||||
self.is_experimental |= is_experimental
|
||||
|
|
|
@ -112,12 +112,10 @@ class QualityManager(QObject):
|
|||
# Iterate over all quality_types in the machine node
|
||||
quality_group_dict = dict()
|
||||
for node in nodes_to_check:
|
||||
if node and node.quality_type_map:
|
||||
for quality_type, quality_node in node.quality_type_map.items():
|
||||
quality_group = QualityGroup(quality_node.getMetaDataEntry("name", ""), quality_type)
|
||||
quality_group.setGlobalNode(quality_node)
|
||||
quality_group_dict[quality_type] = quality_group
|
||||
break
|
||||
if node and node.quality_type:
|
||||
quality_group = QualityGroup(node.getMetaDataEntry("name", ""), node.quality_type)
|
||||
quality_group.setGlobalNode(node)
|
||||
quality_group_dict[node.quality_type] = quality_group
|
||||
|
||||
return quality_group_dict
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue