Tree View Diagram🔗
With release v0.5.35
of py-capellambse you can access the
.tree_view
on Class
objects. A tree view diagram shows a tree made from all properties of the
parent class.
Tree view of Root
import capellambse
model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
diag = model.by_uuid("b7c7f442-377f-492c-90bf-331e66988bda").tree_view
diag.render("svgdiagram").save(pretty=True)
Additional rendering parameters enable the control over the layout computed by ELK. The available options are:
- edgeRouting - Controls the style of the edges.
- POLYLINE (default)
- ORTHOGONAL
- SPLINE
- algorithm - Controls the algorithm for the diagram layout.
- layered (default)
- mr.tree
- ... Have a look for all available ELK algorithms.
- direction - The flow direction for the ELK Layered algortihm.
- DOWN (default)
- UP
- RIGHT
- LEFT
- partitioning - Enable partitioning. Each recursion level for collecting the
classes is its own partition.
- True (default)
- False
- edgeLabelSide - Controls edge label placement.
- SMART_DOWN (default)
- SMART_UP
- ALWAYS_UP
- ALWAYS_DOWN
- DIRECTION_UP
- DIRECTION_DOWN
Additionally the following render parameters are offered:
- depth - The depth of the computed tree. Defaults to
None
such that the whole tree is computed.depth=1
means that only first level properties and generalizations are collected. - super - Generalizations from the
super
attribute, can be set to- ALL
- ROOT
- sub - Generalizations from the
sub
attribute, can be set to- ALL
- ROOT
Here is an example that shows how convenient these parameters can be passed before rendering:
Tree View of Root
import capellambse
model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
diag = model.by_uuid("b7c7f442-377f-492c-90bf-331e66988bda").tree_view
diag.render(
"svgdiagram",
edgeRouting="ORTHOGONAL",
direction="Right",
# partitioning=False,
# edgeLabelsSide="ALWAYS_DOWN",
).save(pretty=True)
They are optional and don't need to be set all together.
Check out the code🔗
To understand the collection have a look into the
class_tree
module.