From c8be1723432e1c6d3f310ed7273f36d660963467 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 1 Oct 2019 16:58:44 +0200 Subject: [PATCH] Add debugging functionality to visualise the container tree Could be useful for later, don't you think? Contributes to issue CURA-6831. --- cura/Machines/ContainerTree.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cura/Machines/ContainerTree.py b/cura/Machines/ContainerTree.py index b5d91ca8c1..ce4c43e1d3 100644 --- a/cura/Machines/ContainerTree.py +++ b/cura/Machines/ContainerTree.py @@ -108,3 +108,19 @@ class ContainerTree: if not isinstance(container_stack, GlobalStack): return # Not our concern. self.addMachineNodeByDefinitionId(container_stack.definition.getId()) + + ## For debugging purposes, visualise the entire container tree as it stands + # now. + def _visualise_tree(self) -> str: + lines = ["% CONTAINER TREE"] # Start with array and then combine into string, for performance. + for machine in self.machines.values(): + lines.append(" # " + machine.container_id) + for variant in machine.variants.values(): + lines.append(" * " + variant.container_id) + for material in variant.materials.values(): + lines.append(" + " + material.container_id) + for quality in material.qualities.values(): + lines.append(" - " + quality.container_id) + for intent in quality.intents.values(): + lines.append(" . " + intent.container_id) + return "\n".join(lines) \ No newline at end of file