Add debugging functionality to visualise the container tree

Could be useful for later, don't you think?

Contributes to issue CURA-6831.
This commit is contained in:
Ghostkeeper 2019-10-01 16:58:44 +02:00
parent b245be6970
commit c8be172343
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -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)