From 3359f2a7201f606067c1ead0efb9f982ae98020f Mon Sep 17 00:00:00 2001 From: ewuerger Date: Tue, 13 Feb 2024 12:05:14 +0100 Subject: [PATCH] fix(tree-view): Duplicated box in diagram The legend and tree shouldn't overlap with boxes. --- capellambse_context_diagrams/collectors/tree_view.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/capellambse_context_diagrams/collectors/tree_view.py b/capellambse_context_diagrams/collectors/tree_view.py index bfe88472..a7821747 100644 --- a/capellambse_context_diagrams/collectors/tree_view.py +++ b/capellambse_context_diagrams/collectors/tree_view.py @@ -40,6 +40,10 @@ def __init__( self.legend_boxes: list[_elkjs.ELKInputChild] = [] self.all_associations = all_associations + def __contains__(self, uuid: str) -> bool: + objects = self.data["children"] + self.data["edges"] # type: ignore[operator] + return uuid in {obj["id"] for obj in objects} + def process_class(self, cls, params): self._process_box(cls.source, cls.partition, params) @@ -108,7 +112,9 @@ def _set_data_types_and_labels( box["width"], box["height"] = makers.calculate_height_and_width( list(box["labels"]) ) - self.legend_boxes.extend(legends) + for legend in legends: + if legend["id"] not in self: + self.legend_boxes.append(legend) def collector(