Skip to content

diagram_view

Collector for the DiagramView.

Collects all model elements from a Capella diagram.

Collector 🔗

Collector(diagram: ELKDiagram)

Collects model elements from a diagram.

Source code in src/capellambse_context_diagrams/collectors/diagram_view.py
34
35
36
def __init__(self, diagram: context.ELKDiagram):
    self.diagram = diagram
    self._diagram = diagram.target

collect 🔗

collect() -> DiagramElements

Collect all relevant elements from the diagram.

Source code in src/capellambse_context_diagrams/collectors/diagram_view.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def collect(self) -> DiagramElements:
    """Collect all relevant elements from the diagram."""
    elements = DiagramElements()

    for node in self._diagram.nodes:
        if helpers.is_function(node):
            elements.functions.append(node)
        elif helpers.is_part(node):
            elements.components.append(node.type)
        elif helpers.is_allocation(node):
            elements.port_allocations.append(node)
        elif helpers.is_exchange(node):
            elements.exchanges.append(node)
        elif helpers.is_port(node):
            elements.ports.append(node)

    return elements

DiagramElements dataclass 🔗

DiagramElements(
    components: list[ModelElement] = list(),
    functions: list[ModelElement] = list(),
    exchanges: list[ModelElement] = list(),
    ports: list[ModelElement] = list(),
    port_allocations: list[ModelElement] = list(),
)

Collected elements from a diagram.