mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-05 23:04:30 +08:00
Refactor user profiles model to always use extruder stack - CURA-4482
This commit is contained in:
parent
59580c0ade
commit
62cb5a48cb
@ -22,47 +22,23 @@ class UserProfilesModel(ProfilesModel):
|
||||
|
||||
# Fetch the list of quality changes.
|
||||
quality_manager = QualityManager.getInstance()
|
||||
machine_definition = quality_manager.getParentMachineDefinition(global_container_stack.getBottom())
|
||||
machine_definition = quality_manager.getParentMachineDefinition(global_container_stack.definition)
|
||||
quality_changes_list = quality_manager.findAllQualityChangesForMachine(machine_definition)
|
||||
|
||||
# Detecting if the machine has multiple extrusion
|
||||
multiple_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1
|
||||
# Get the list of extruders and place the selected extruder at the front of the list.
|
||||
extruder_manager = ExtruderManager.getInstance()
|
||||
active_extruder = extruder_manager.getActiveExtruderStack()
|
||||
extruder_stacks = extruder_manager.getActiveExtruderStacks()
|
||||
if multiple_extrusion:
|
||||
# Place the active extruder at the front of the list.
|
||||
# This is a workaround checking if there is an active_extruder or not before moving it to the front of the list.
|
||||
# Actually, when a printer has multiple extruders, should exist always an active_extruder. However, in some
|
||||
# cases the active_extruder is still None.
|
||||
if active_extruder in extruder_stacks:
|
||||
extruder_stacks.remove(active_extruder)
|
||||
new_extruder_stacks = []
|
||||
if active_extruder is not None:
|
||||
new_extruder_stacks = [active_extruder]
|
||||
else:
|
||||
# if there is no active extruder, use the first one in the active extruder stacks
|
||||
active_extruder = extruder_stacks[0]
|
||||
extruder_stacks = new_extruder_stacks + extruder_stacks
|
||||
extruder_stacks = self._getOrderedExtruderStacksList()
|
||||
|
||||
# Fetch the list of useable qualities across all extruders.
|
||||
# Fetch the list of usable qualities across all extruders.
|
||||
# The actual list of quality profiles come from the first extruder in the extruder list.
|
||||
quality_list = quality_manager.findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
||||
extruder_stacks)
|
||||
quality_list = quality_manager.findAllUsableQualitiesForMachineAndExtruders(global_container_stack, extruder_stacks)
|
||||
|
||||
# Filter the quality_change by the list of available quality_types
|
||||
quality_type_set = set([x.getMetaDataEntry("quality_type") for x in quality_list])
|
||||
|
||||
if multiple_extrusion:
|
||||
# If the printer has multiple extruders then quality changes related to the current extruder are kept
|
||||
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
|
||||
qc.getMetaDataEntry("extruder") is not None and
|
||||
(qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
|
||||
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())]
|
||||
else:
|
||||
# If not, the quality changes of the global stack are selected
|
||||
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
|
||||
qc.getMetaDataEntry("extruder") is None]
|
||||
filtered_quality_changes = [qc for qc in quality_changes_list if
|
||||
qc.getMetaDataEntry("quality_type") in quality_type_set and
|
||||
qc.getMetaDataEntry("extruder") is not None and
|
||||
(qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
|
||||
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())]
|
||||
|
||||
return filtered_quality_changes
|
||||
|
Loading…
x
Reference in New Issue
Block a user