Skip to content

Commit

Permalink
feat: Change to NETWORK_SIMPLEX placement and add edge straightenin…
Browse files Browse the repository at this point in the history
…g to interfaces
  • Loading branch information
ewuerger committed Jul 18, 2024
1 parent 87c5c23 commit 256866c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 10 additions & 3 deletions capellambse_context_diagrams/_elkjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
"elk.direction": "RIGHT",
"hierarchyHandling": "INCLUDE_CHILDREN",
"layered.edgeLabels.sideSelection": "ALWAYS_DOWN",
"layered.nodePlacement.strategy": "BRANDES_KOEPF",
"layered.considerModelOrder.strategy": "NODES_AND_EDGES",
"layered.nodePlacement.strategy": "NETWORK_SIMPLEX",
"spacing.labelNode": "0.0",
}
"""
Expand Down Expand Up @@ -85,8 +84,14 @@
"widthApproximation.targetWidth": 1, # width / height
"elk.contentAlignment": "V_TOP H_CENTER",
}
LABEL_LAYOUT_OPTIONS = {"nodeLabels.placement": "OUTSIDE, V_BOTTOM, H_CENTER"}
LABEL_LAYOUT_OPTIONS: LayoutOptions = {
"nodeLabels.placement": "OUTSIDE, V_BOTTOM, H_CENTER"
}
"""Options for labels to configure ELK layouting."""
EDGE_STRAIGHTENING_LAYOUT_OPTIONS: LayoutOptions = {
"layered.priority.straightness": "10"
}
"""Options for increasing the edge straightness priority."""


class BaseELKModel(pydantic.BaseModel):
Expand Down Expand Up @@ -147,6 +152,8 @@ class ELKInputEdge(BaseELKModel):
"""Exchange data that can be fed to ELK."""

id: str
layoutOptions: LayoutOptions = pydantic.Field(default_factory=dict)

sources: cabc.MutableSequence[str]
targets: cabc.MutableSequence[str]
labels: cabc.MutableSequence[ELKInputLabel] = pydantic.Field(
Expand Down
5 changes: 5 additions & 0 deletions capellambse_context_diagrams/collectors/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import abc
import copy
import logging
import operator
import typing as t
Expand Down Expand Up @@ -251,6 +252,7 @@ def make_all_owners(
return root.id

def add_interface(self) -> None:
"""Add the ComponentExchange (interface) to the collected data."""
ex_data = generic.ExchangeData(
self.obj,
self.data,
Expand All @@ -259,6 +261,9 @@ def add_interface(self) -> None:
is_hierarchical=False,
)
src, tgt = generic.exchange_data_collector(ex_data)
self.data.edges[-1].layoutOptions = copy.deepcopy(
_elkjs.EDGE_STRAIGHTENING_LAYOUT_OPTIONS
)
assert self.right is not None
assert self.left is not None
self.left.ports.append(makers.make_port(src.uuid))
Expand Down

0 comments on commit 256866c

Please sign in to comment.