From aa0bf2f6ba92f59ff6626d5e6d2333c65ad2ccd9 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 20 Jun 2019 15:27:07 +0200 Subject: [PATCH] Implement selectIntent Selects a certain intent profile, applying it to the stack. Contributes to issue CURA-6091. --- cura/Settings/IntentManager.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cura/Settings/IntentManager.py b/cura/Settings/IntentManager.py index 528a060380..876d41a1b4 100644 --- a/cura/Settings/IntentManager.py +++ b/cura/Settings/IntentManager.py @@ -101,10 +101,21 @@ class IntentManager: def defaultIntent(self) -> InstanceContainer: return CuraApplication.getInstance().empty_intent_container - def selectIntent(self, intent_category, quality_type): - for extruder in all_extruders: - extruder_stack.intent = ContainerRegistry.getInstance().findContainers(type = "intent", definition = current_definition_id, variant = extruder_nozzle_id, material = extruder_material_id)[0] - extruder_stack.quality = ContainerRegistry.getInstance().findContainers(type = "quality", quality_type = quality_type) + ## Apply intent on the stacks. + def selectIntent(self, intent_category, quality_type) -> None: + application = CuraApplication.getInstance() + global_stack = application.getGlobalContainerStack() + current_definition_id = global_stack.definition.getMetaDataEntry("id") + for extruder_stack in ExtruderManager.getInstance().getUsedExtruderStacks(): + nozzle_name = extruder_stack.variant.getMetaDataEntry("name") + material_id = extruder_stack.material.getMetaDataEntry("base_file") + intent = ContainerRegistry.getInstance().findContainers(definition = current_definition_id, variant = nozzle_name, material = material_id, quality_type = quality_type, intent_category = intent_category) + if intent: + extruder_stack.intent = intent[0] + else: + extruder_stack.intent = self.defaultIntent() + + application.getMachineManager().setQualityGroupByQualityType(quality_type) def selectDefaultIntent(self) -> None: category, quality_type = self.defaultIntent()