Merge pull request #8698 from Ultimaker/CURA-7827_Properly_set_print_sequence_when_number_of_enabled_extruder_changes

CURA-7827: Correct print sequence when there are more than one enabled extruders
This commit is contained in:
Jelle Spijker 2020-11-09 19:48:26 +01:00 committed by GitHub
commit 05d98091b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 7 deletions

View File

@ -345,6 +345,9 @@ class ContainerManager(QObject):
# user changes are possibly added to make the current setup match the current enabled extruders # user changes are possibly added to make the current setup match the current enabled extruders
machine_manager.correctExtruderSettings() machine_manager.correctExtruderSettings()
# The Print Sequence should be changed to match the current setup
machine_manager.correctPrintSequence()
for container in send_emits_containers: for container in send_emits_containers:
container.sendPostponedEmits() container.sendPostponedEmits()

View File

@ -128,6 +128,7 @@ class MachineManager(QObject):
self.activeQualityChangesGroupChanged.connect(self.activeQualityDisplayNameChanged) self.activeQualityChangesGroupChanged.connect(self.activeQualityDisplayNameChanged)
self.activeStackValueChanged.connect(self._reCalculateNumUserSettings) self.activeStackValueChanged.connect(self._reCalculateNumUserSettings)
self.numberExtrudersEnabledChanged.connect(self.correctPrintSequence)
activeQualityDisplayNameChanged = pyqtSignal() activeQualityDisplayNameChanged = pyqtSignal()
@ -826,11 +827,6 @@ class MachineManager(QObject):
result = [] # type: List[str] result = [] # type: List[str]
for setting_instance in container.findInstances(): for setting_instance in container.findInstances():
setting_key = setting_instance.definition.key setting_key = setting_instance.definition.key
if setting_key == "print_sequence":
old_value = container.getProperty(setting_key, "value")
Logger.log("d", "Reset setting [%s] in [%s] because its old value [%s] is no longer valid", setting_key, container, old_value)
result.append(setting_key)
continue
if not self._global_container_stack.getProperty(setting_key, "type") in ("extruder", "optional_extruder"): if not self._global_container_stack.getProperty(setting_key, "type") in ("extruder", "optional_extruder"):
continue continue
@ -862,6 +858,41 @@ class MachineManager(QObject):
title = catalog.i18nc("@info:title", "Settings updated")) title = catalog.i18nc("@info:title", "Settings updated"))
caution_message.show() caution_message.show()
def correctPrintSequence(self) -> None:
"""
Sets the Print Sequence setting to "all-at-once" when there are more than one enabled extruders.
This setting has to be explicitly changed whenever we have more than one enabled extruders to make sure that the
Cura UI is properly updated to reset all the UI elements changes that occur due to the one-at-a-time mode (such
as the reduced build volume, the different convex hulls of the objects etc.).
"""
setting_key = "print_sequence"
new_value = "all_at_once"
if self._global_container_stack is None \
or self._global_container_stack.getProperty(setting_key, "value") == new_value \
or self.numberExtrudersEnabled < 2:
return
user_changes_container = self._global_container_stack.userChanges
quality_changes_container = self._global_container_stack.qualityChanges
print_sequence_quality_changes = quality_changes_container.getProperty(setting_key, "value")
print_sequence_user_changes = user_changes_container.getProperty(setting_key, "value")
# If the user changes container has a value and its the incorrect value, then reset the setting in the user
# changes (so that the circular revert-changes arrow will now show up in the interface)
if print_sequence_user_changes and print_sequence_user_changes != new_value:
user_changes_container.removeInstance(setting_key)
Logger.log("d", "Resetting '{}' in container '{}' because there are more than 1 enabled extruders.".format(setting_key, user_changes_container))
# If the print sequence doesn't exist in either the user changes or the quality changes (yet it still has the
# wrong value in the global stack), or it exists in the quality changes and it has the wrong value, then set it
# in the user changes
elif (not print_sequence_quality_changes and not print_sequence_user_changes) \
or (print_sequence_quality_changes and print_sequence_quality_changes != new_value):
user_changes_container.setProperty(setting_key, "value", new_value)
Logger.log("d", "Setting '{}' in '{}' to '{}' because there are more than 1 enabled extruders.".format(setting_key, user_changes_container, new_value))
def setActiveMachineExtruderCount(self, extruder_count: int) -> None: def setActiveMachineExtruderCount(self, extruder_count: int) -> None:
"""Set the amount of extruders on the active machine (global stack) """Set the amount of extruders on the active machine (global stack)

View File

@ -21,7 +21,8 @@ def machine_manager(application, extruder_manager, container_registry, global_st
application.getGlobalContainerStack = MagicMock(return_value = global_stack) application.getGlobalContainerStack = MagicMock(return_value = global_stack)
with patch("cura.Settings.CuraContainerRegistry.CuraContainerRegistry.getInstance", MagicMock(return_value=container_registry)): with patch("cura.Settings.CuraContainerRegistry.CuraContainerRegistry.getInstance", MagicMock(return_value=container_registry)):
manager = MachineManager(application) manager = MachineManager(application)
manager._onGlobalContainerChanged() with patch.object(MachineManager, "updateNumberExtrudersEnabled", return_value = None):
manager._onGlobalContainerChanged()
return manager return manager
@ -253,4 +254,4 @@ def test_isActiveQualityNotSupported(machine_manager):
def test_isActiveQualityNotSupported_noQualityGroup(machine_manager): def test_isActiveQualityNotSupported_noQualityGroup(machine_manager):
machine_manager.activeQualityGroup = MagicMock(return_value=None) machine_manager.activeQualityGroup = MagicMock(return_value=None)
assert not machine_manager.isActiveQualitySupported assert not machine_manager.isActiveQualitySupported