diff --git a/capellambse_context_diagrams/__init__.py b/capellambse_context_diagrams/__init__.py index 460c356..5a307e2 100644 --- a/capellambse_context_diagrams/__init__.py +++ b/capellambse_context_diagrams/__init__.py @@ -329,12 +329,21 @@ def register_cable_tree_view() -> None: def register_custom_diagram() -> None: """Add the `custom_diagram` attribute to `ModelObject`s.""" supported_classes: list[tuple[type[m.ModelElement], DiagramType]] = [ + (oa.Entity, DiagramType.OAB), + (oa.OperationalActivity, DiagramType.OAB), + (oa.OperationalCapability, DiagramType.OCB), + (oa.CommunicationMean, DiagramType.OAB), + (sa.Mission, DiagramType.MCB), + (sa.Capability, DiagramType.MCB), + (sa.SystemComponent, DiagramType.SAB), (sa.SystemFunction, DiagramType.SAB), - (cs.PhysicalLink, DiagramType.PAB), + (la.LogicalComponent, DiagramType.LAB), (la.LogicalFunction, DiagramType.LAB), + (pa.PhysicalComponent, DiagramType.PAB), (pa.PhysicalFunction, DiagramType.PAB), - (fa.ComponentExchange, DiagramType.SAB), + (cs.PhysicalLink, DiagramType.PAB), (cs.PhysicalPort, DiagramType.PAB), + (fa.ComponentExchange, DiagramType.SAB), ] for class_, dgcls in supported_classes: m.set_accessor( diff --git a/capellambse_context_diagrams/collectors/custom.py b/capellambse_context_diagrams/collectors/custom.py index ffbc576..f7ddf9f 100644 --- a/capellambse_context_diagrams/collectors/custom.py +++ b/capellambse_context_diagrams/collectors/custom.py @@ -89,6 +89,7 @@ def __call__(self) -> _elkjs.ELKInputData: and getattr(current, "owner", None) is not None and not isinstance(current.owner, generic.PackageTypes) ): + self.common_owners.discard(current.uuid) current = self._make_owner_box(current) self.common_owners.discard(current.uuid) for edge_uuid, box_uuid in self.edge_owners.items(): @@ -224,6 +225,10 @@ def _make_owner_box( break else: children.append(obj_box) + obj_box.width = max( + obj_box.width, + parent_box.width, + ) for label in parent_box.labels: label.layoutOptions = makers.DEFAULT_LABEL_LAYOUT_OPTIONS self.boxes_to_delete.add(obj.uuid) diff --git a/docs/custom_diagram.md b/docs/custom_diagram.md index 62ffdb3..3c175a1 100644 --- a/docs/custom_diagram.md +++ b/docs/custom_diagram.md @@ -74,18 +74,9 @@ my_model = capellambse.MelodyModel(...) my_element = my_model.by_uuid(...) my_yaml = "..." -my_element.custom_diagram(collect=yaml.safe_load(my_yaml)).render("svgdiagram").save(pretty=True) +my_element.custom_diagram.render("svgdiagram", collect=yaml.safe_load(my_yaml)).save(pretty=True) ``` -## Supported Elements - -- [`sa.SystemFunction`][capellambse.metamodel.sa.SystemFunction] -- [`cs.PhysicalLink`][capellambse.metamodel.cs.PhysicalFunction] -- [`la.LogicalFunction`][capellambse.metamodel.la.LogicalFunction] -- [`pa.PhysicalFunction`][capellambse.metamodel.pa.PhysicalFunction] -- [`fa.ComponentExchange`][capellambse.metamodel.fa.ComponentExchange] -- [`cs.PhysicalPort`][capellambse.metamodel.cs.PhysicalPort] - ## Check out the code To understand the collection have a look into the