From a5a25f676e7b19bd262c6e77ad264d1d48e8346e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 24 Apr 2024 13:15:21 +0200 Subject: [PATCH] Improve currentIntentCategory logic CURA-11854 --- .../Models/ActiveIntentQualitiesModel.py | 1 - cura/Settings/IntentManager.py | 22 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cura/Machines/Models/ActiveIntentQualitiesModel.py b/cura/Machines/Models/ActiveIntentQualitiesModel.py index 906662d133e..f9acb9a970c 100644 --- a/cura/Machines/Models/ActiveIntentQualitiesModel.py +++ b/cura/Machines/Models/ActiveIntentQualitiesModel.py @@ -55,7 +55,6 @@ def _onChanged(self, container: ContainerStack) -> None: def _update(self): self._intent_category = IntentManager.getInstance().currentIntentCategory - new_items: List[Dict[str, Any]] = [] global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() if not global_stack: diff --git a/cura/Settings/IntentManager.py b/cura/Settings/IntentManager.py index 7d3e2659bfc..df8c1dc9e14 100644 --- a/cura/Settings/IntentManager.py +++ b/cura/Settings/IntentManager.py @@ -145,10 +145,24 @@ def getDefaultIntent(self) -> "InstanceContainer": @pyqtProperty(str, notify = intentCategoryChanged) def currentIntentCategory(self) -> str: application = cura.CuraApplication.CuraApplication.getInstance() - active_extruder_stack = application.getMachineManager().activeStack - if active_extruder_stack is None: - return "" - return active_extruder_stack.intent.getMetaDataEntry("intent_category", "") + global_stack = application.getGlobalContainerStack() + + active_intent = "default" + if global_stack is None: + return active_intent + + # Loop over all active extruders and check if they have an intent that isn't default. + # The logic behind this is that support materials (for instance, PVA) don't have intents, but they should be + # combinable with all other intents. So if one extruder has "engineering" as an intent and the other has + # "default" the 'dominant' intent is "engineering" + for extruder_stack in global_stack.extruderList: + if not extruder_stack.isEnabled: # Ignore disabled stacks + continue + extruder_intent = extruder_stack.intent.getMetaDataEntry("intent_category", "") + if extruder_intent != "default": + active_intent = extruder_intent + + return active_intent @pyqtSlot(str, str) def selectIntent(self, intent_category: str, quality_type: str) -> None: