mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 12:47:49 -06:00
Use new MachineNode.getQualityChangesGroups instead of quality manager
I hope that the machine node doesn't become a collection of functions that don't fit anywhere else, but this isn't contributing to that hope. However I still think that this is particular to a certain printer, so it's within the object-oriented programming paradigm. And it's also within the scope of the class, which is getting the available profiles. So it still sort of fits. Contributes to issue CURA-6600.
This commit is contained in:
parent
b1ce9b64d4
commit
51710c2868
2 changed files with 15 additions and 31 deletions
|
@ -4,15 +4,12 @@
|
|||
from UM.Logger import Logger
|
||||
|
||||
import cura.CuraApplication # Imported this way to prevent circular references.
|
||||
from cura.Machines.ContainerTree import ContainerTree
|
||||
from cura.Machines.Models.QualityProfilesDropDownMenuModel import QualityProfilesDropDownMenuModel
|
||||
from cura.Machines.QualityManager import QualityManager
|
||||
|
||||
|
||||
#
|
||||
# This model is used for the custom profile items in the profile drop down menu.
|
||||
#
|
||||
## This model is used for the custom profile items in the profile drop down
|
||||
# menu.
|
||||
class CustomQualityProfilesDropDownMenuModel(QualityProfilesDropDownMenuModel):
|
||||
|
||||
def _update(self):
|
||||
Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
|
||||
|
||||
|
@ -22,12 +19,14 @@ class CustomQualityProfilesDropDownMenuModel(QualityProfilesDropDownMenuModel):
|
|||
Logger.log("d", "No active GlobalStack, set %s as empty.", self.__class__.__name__)
|
||||
return
|
||||
|
||||
quality_changes_group_dict = QualityManager.getInstance().getQualityChangesGroups(active_global_stack)
|
||||
variant_names = [extruder.variant.getName() for extruder in active_global_stack.extruders.values()]
|
||||
material_bases = [extruder.material.getMetaDataEntry("base_file") for extruder in active_global_stack.extruders.values()]
|
||||
extruder_enabled = [extruder.isEnabled for extruder in active_global_stack.extruders.values()]
|
||||
machine_node = ContainerTree.getInstance().machines[active_global_stack.definition.getId()]
|
||||
quality_changes_list = machine_node.getQualityChangesGroups(variant_names, material_bases, extruder_enabled)
|
||||
|
||||
item_list = []
|
||||
for key in sorted(quality_changes_group_dict, key = lambda name: name.upper()):
|
||||
quality_changes_group = quality_changes_group_dict[key]
|
||||
|
||||
for quality_changes_group in sorted(quality_changes_list, key = lambda qgc: qgc.name.lower()):
|
||||
item = {"name": quality_changes_group.name,
|
||||
"layer_height": "",
|
||||
"layer_height_without_unit": "",
|
||||
|
|
|
@ -76,26 +76,11 @@ class QualityManager(QObject):
|
|||
|
||||
# Returns a dict of "custom profile name" -> QualityChangesGroup
|
||||
def getQualityChangesGroups(self, machine: "GlobalStack") -> dict:
|
||||
machine_definition_id = getMachineDefinitionIDForQualitySearch(machine.definition)
|
||||
|
||||
machine_node = self._machine_quality_type_to_quality_changes_dict.get(machine_definition_id)
|
||||
if not machine_node:
|
||||
Logger.log("i", "Cannot find node for machine def [%s] in QualityChanges lookup table", machine_definition_id)
|
||||
return dict()
|
||||
|
||||
# Update availability for each QualityChangesGroup:
|
||||
# A custom profile is always available as long as the quality_type it's based on is available
|
||||
quality_group_dict = self.getQualityGroups(machine)
|
||||
available_quality_type_list = [qt for qt, qg in quality_group_dict.items() if qg.is_available]
|
||||
|
||||
# Iterate over all quality_types in the machine node
|
||||
quality_changes_group_dict = dict()
|
||||
for quality_type, quality_changes_node in machine_node.quality_type_map.items():
|
||||
for quality_changes_name, quality_changes_group in quality_changes_node.children_map.items():
|
||||
quality_changes_group_dict[quality_changes_name] = quality_changes_group
|
||||
quality_changes_group.is_available = quality_type in available_quality_type_list
|
||||
|
||||
return quality_changes_group_dict
|
||||
variant_names = [extruder.variant.getName() for extruder in machine.extruders.values()]
|
||||
material_bases = [extruder.material.getMetaDataEntry("base_file") for extruder in machine.extruders.values()]
|
||||
extruder_enabled = [extruder.isEnabled for extruder in machine.extruders.values()]
|
||||
machine_node = ContainerTree.getInstance().machines[machine.definition.getId()]
|
||||
return machine_node.getQualityChangesGroups(variant_names, material_bases, extruder_enabled)
|
||||
|
||||
## Gets the quality groups for the current printer.
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue