From fc679758ef22031ab532a6461aaf9984d812dd1a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 17 Sep 2019 16:57:16 +0200 Subject: [PATCH] Optimise getting intent categories It's in the container tree, so there's no need for separate queries to the container registry. Contributes to issue CURA-6600. --- cura/Settings/IntentManager.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cura/Settings/IntentManager.py b/cura/Settings/IntentManager.py index 8de660145e..89df530f6a 100644 --- a/cura/Settings/IntentManager.py +++ b/cura/Settings/IntentManager.py @@ -37,12 +37,16 @@ class IntentManager(QObject): # # \param definition_id ID of the printer. # \param nozzle_name Name of the nozzle. - # \param material_id ID of the material. + # \param material_base_file The base_file of the material. # \return A list of metadata dictionaries matching the search criteria, or # an empty list if nothing was found. def intentMetadatas(self, definition_id: str, nozzle_name: str, material_base_file: str) -> List[Dict[str, Any]]: - registry = cura.CuraApplication.CuraApplication.getInstance().getContainerRegistry() - return registry.findContainersMetadata(type = "intent", definition = definition_id, variant = nozzle_name, material = material_base_file) + material_node = ContainerTree.getInstance().machines[definition_id].variants[nozzle_name].materials[material_base_file] + intent_metadatas = [] + for quality_node in material_node.qualities.values(): + for intent_node in quality_node.intents.values(): + intent_metadatas.append(intent_node.getMetadata()) + return intent_metadatas ## Collects and returns all intent categories available for the given # parameters. Note that the 'default' category is always available.