Skip to content

Commit

Permalink
feat(context-diagram): Include all boxes in parent-relation
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Feb 15, 2024
1 parent 912dcb0 commit e0299f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
34 changes: 24 additions & 10 deletions capellambse_context_diagrams/collectors/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,20 @@ def collector(
except AttributeError:
continue

global_boxes = {centerbox["id"]: centerbox}
if diagram.display_parent_relation:
box = makers.make_box(
diagram.target.parent,
no_symbol=diagram.display_symbols_as_boxes,
)
box["children"] = [centerbox]
del data["children"][0]
global_boxes[diagram.target.parent.uuid] = box

stack_heights: dict[str, float | int] = {
"input": -makers.NEIGHBOR_VMARGIN,
"output": -makers.NEIGHBOR_VMARGIN,
}
global_boxes = {centerbox["id"]: centerbox}
child_boxes: list[_elkjs.ELKInputChild] = []
for i, local_ports, side in port_context_collector(ex_datas, ports):
_, label_height = helpers.get_text_extent(i.name)
Expand All @@ -58,10 +67,10 @@ def collector(
makers.PORT_PADDING
+ (makers.PORT_SIZE + makers.PORT_PADDING) * len(local_ports),
)
if box := global_boxes.get(i.uuid):
if box := global_boxes.get(i.uuid): # type: ignore[assignment]
if box is centerbox:
continue
box["ports"].extend(
box.setdefault("ports", []).extend(
[makers.make_port(j.uuid) for j in local_ports]
)
box["height"] += height
Expand All @@ -72,17 +81,22 @@ def collector(
box["ports"] = [makers.make_port(j.uuid) for j in local_ports]
if i.parent.uuid == centerbox["id"]:
child_boxes.append(box)
elif (
diagram.display_parent_relation and i == diagram.target.parent
):
box["children"] = [centerbox]
else:
global_boxes[i.uuid] = box
del data["children"][0]

if diagram.display_parent_relation:
if i == diagram.target.parent:
_move_edge_to_local_edges(
box, connections, local_ports, diagram, data
)
else:
global_boxes[i.uuid] = box
elif i.parent == diagram.target.parent:
parent_box = global_boxes[i.parent.uuid]
parent_box.setdefault("children", []).append(
global_boxes.pop(i.uuid)
)
_move_edge_to_local_edges(
parent_box, connections, local_ports, diagram, data
)

stack_heights[side] += makers.NEIGHBOR_VMARGIN + height

Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class type that stores all previously named classes.
pos += self.diagram[self._diagram.target.uuid].pos

element = diagram.Circle(
pos,
ref + pos,
5,
uuid=child["id"],
styleclass=self.get_styleclass(uuid),
Expand Down

0 comments on commit e0299f6

Please sign in to comment.