Skip to content

Commit

Permalink
fix(tree-view): Fix direction of Generalization edges
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Feb 22, 2024
1 parent 793e71c commit e91ef8d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 5 additions & 5 deletions capellambse_context_diagrams/collectors/tree_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def process_class(self, cls, params):
self.data["edges"].append(
{
"id": edge.uuid,
"sources": [cls.generalizes.uuid],
"targets": [cls.source.uuid],
"sources": [cls.source.uuid],
"targets": [cls.generalizes.uuid],
}
)

Expand Down Expand Up @@ -122,9 +122,9 @@ def collector(
"""Return the class tree data for ELK."""
assert isinstance(diagram.target, information.Class)
data = generic.collector(diagram, no_symbol=True)
all_associations: cabc.Iterable[information.Association] = (
diagram._model.search("Association")
)
all_associations: cabc.Iterable[
information.Association
] = diagram._model.search("Association")
_set_layout_options(data, params)
processor = ClassProcessor(data, all_associations)
processor._set_data_types_and_labels(data["children"][0], diagram.target)
Expand Down
16 changes: 16 additions & 0 deletions capellambse_context_diagrams/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""
from __future__ import annotations

import collections.abc as cabc
import logging
import typing as t

Expand Down Expand Up @@ -149,6 +150,8 @@ class type that stores all previously named classes.
elif child["type"] == "edge":
styleclass = child.get("styleclass", styleclass) # type: ignore[assignment]
styleclass = REMAP_STYLECLASS.get(styleclass, styleclass) # type: ignore[arg-type]
EDGE_HANDLER.get(styleclass, lambda c: c)(child)

if child["routingPoints"]:
refpoints = [
ref + (point["x"], point["y"])
Expand Down Expand Up @@ -315,3 +318,16 @@ def route_shortest_connection(
line_end, source=line_start, style=diagram.RoutingStyle.OBLIQUE
)
return [source_intersection, target_intersection]


def reverse_edge_refpoints(child: _elkjs.ELKOutputEdge) -> None:
source = child["sourceId"]
target = child["targetId"]
child["targetId"] = source
child["sourceId"] = target
child["routingPoints"] = child["routingPoints"][::-1]


EDGE_HANDLER: dict[str, cabc.Callable[[_elkjs.ELKOutputEdge], None]] = {
"Generalization": reverse_edge_refpoints
}

0 comments on commit e91ef8d

Please sign in to comment.