Skip to content

Commit

Permalink
wip: Add context
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Dec 15, 2023
1 parent 41f29a4 commit d120b72
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions capellambse_context_diagrams/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def _create_diagram(self, params: dict[str, t.Any]) -> cdiagram.Diagram:
)
data, legend = tree_view.collector(self, params)
params["elkdata"] = data
add_context(data)
class_diagram = super()._create_diagram(params)
width, height = class_diagram.viewport.size
axis: t.Literal["x", "y"]
Expand All @@ -379,6 +380,21 @@ def _create_diagram(self, params: dict[str, t.Any]) -> cdiagram.Diagram:
return class_diagram


def add_context(data: _elkjs.ELKInputData) -> None:
ids: set[str] = set()

def get_ids(obj: _elkjs.ELKInputChild):
ids.add(obj["id"])
for cobj in obj.get("children", []):
get_ids(cobj)

for child in data["children"]:
get_ids(child)

for child in data["children"] + data["edges"]:
child["context"] = list(ids)


def stack_diagrams(
first: cdiagram.Diagram,
second: cdiagram.Diagram,
Expand Down

0 comments on commit d120b72

Please sign in to comment.