Skip to content

Commit

Permalink
refactor: Rename to exchange item relation view
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Aug 21, 2024
1 parent 84ebc9a commit 70c3669
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
14 changes: 7 additions & 7 deletions capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def init() -> None:
register_tree_view()
register_realization_view()
register_data_flow_view()
register_exchange_item_class_tree_view()
register_exchange_item_relation_view()
# register_functional_context() XXX: Future


Expand Down Expand Up @@ -275,7 +275,7 @@ def register_data_flow_view() -> None:
common.set_accessor(class_, "data_flow_view", accessor)


def register_exchange_item_class_tree_view() -> None:
def register_exchange_item_relation_view() -> None:

supported_classes: list[
tuple[type[common.GenericElement], set[DiagramType], dict[str, t.Any]]
Expand All @@ -292,15 +292,15 @@ def register_exchange_item_class_tree_view() -> None:
for _class, _diagclasses, render_params in supported_classes:
common.set_accessor(
_class,
"exchange_item_class_tree_view",
context.ExchangeItemClassTreeAccessor(
"ExchangeItemClassTreeView Diagram", render_params
"exchange_item_relation_view",
context.ExchangeItemRelationAccessor(
"ExchangeItemRelationView Diagram", render_params
),
)
for dgcls in _diagclasses:
styles.update(capstyle.STYLES.get(dgcls.value, {}))

capstyle.STYLES["ExchangeItemClassTreeView Diagram"] = styles
capstyle.STYLES["ExchangeItemClassTreeView Diagram"].update(
capstyle.STYLES["ExchangeItemRelationView Diagram"] = styles
capstyle.STYLES["ExchangeItemRelationView Diagram"].update(
capstyle.STYLES["Class Diagram Blank"]
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
}


class ExchangeItemClassTreeCollector:
class ExchangeItemRelationCollector:
def __init__(
self,
diagram: context.ExchangeItemClassTreeViewDiagram,
diagram: context.ExchangeItemRelationViewDiagram,
*,
params: dict[str, t.Any] | None = None,
) -> None:
Expand Down Expand Up @@ -172,7 +172,7 @@ def _make_class_box(self, cls: information.Class) -> _elkjs.ELKInputChild:


def collector(
diagram: context.ExchangeItemClassTreeViewDiagram, params: dict[str, t.Any]
diagram: context.ExchangeItemRelationViewDiagram, params: dict[str, t.Any]
) -> _elkjs.ELKInputData:
"""Return ExchangeElement data for ELK."""
return ExchangeItemClassTreeCollector(diagram, params=params)()
return ExchangeItemRelationCollector(diagram, params=params)()
18 changes: 9 additions & 9 deletions capellambse_context_diagrams/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from . import _elkjs, filters, serializers, styling
from .collectors import (
dataflow_view,
exchange_item_class_tree_view,
exchange_item_relation_view,
exchanges,
get_elkdata,
realization_view,
Expand Down Expand Up @@ -189,18 +189,18 @@ def __get__( # type: ignore
return self._get(obj, DataFlowViewDiagram)


class ExchangeItemClassTreeAccessor(ContextAccessor):
class ExchangeItemRelationAccessor(ContextAccessor):
def __get__( # type: ignore
self,
obj: common.T | None,
objtype: type | None = None,
) -> common.Accessor | ContextDiagram:
"""Make a ExchangeItemClassTreeViewDiagram for the given model object."""
"""Make a ExchangeItemRelationViewDiagram for the given model object."""
del objtype
if obj is None: # pragma: no cover
return self
assert isinstance(obj, common.GenericElement)
return self._get(obj, ExchangeItemClassTreeViewDiagram)
return self._get(obj, ExchangeItemRelationViewDiagram)


class ContextDiagram(diagram.AbstractDiagram):
Expand Down Expand Up @@ -690,20 +690,20 @@ def _create_diagram(self, params: dict[str, t.Any]) -> cdiagram.Diagram:
return super()._create_diagram(params)


class ExchangeItemClassTreeViewDiagram(ContextDiagram):
"""An automatically generated ExchangeItemClassTreeViewDiagram."""
class ExchangeItemRelationViewDiagram(ContextDiagram):
"""An automatically generated ExchangeItemRelationViewDiagram."""

@property
def uuid(self) -> str: # type: ignore
"""Returns the UUID of the diagram."""
return f"{self.target.uuid}_exchange_item_class_tree_view"
return f"{self.target.uuid}_exchange_item_relation_view"

@property
def name(self) -> str: # type: ignore
return f"Exchange Item Class Tree View of {self.target.name}"
return f"Exchange Item Relation View of {self.target.name}"

def _create_diagram(self, params: dict[str, t.Any]) -> cdiagram.Diagram:
data = exchange_item_class_tree_view.collector(self, params)
data = exchange_item_relation_view.collector(self, params)
layout = try_to_layout(data)
return self.serializer.make_diagram(
layout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
~ SPDX-License-Identifier: Apache-2.0
-->

# Exchange Item Class Tree View
# Exchange Item Relation View

The `ExchangeItemClassTreeView` visualizes the hierarchical structure of exchange items and the relationships between their associated classes in a tree view. You can access `.exchange_item_class_tree_view` on any `fa.ComponentExchange`. Data collection starts on the allocated exchange items and collects the associated classes through their exchange item elements.
The `ExchangeItemRelationView` visualizes the hierarchical structure of exchange items and the relationships between their associated classes in a tree view. You can access `.exchange_item_relation_view` on any `fa.ComponentExchange`. Data collection starts on the allocated exchange items and collects the associated classes through their exchange item elements.

??? example "Exchange Item Class Tree View of C 28"
??? example "Exchange Item Relation View of C 28"

``` py
import capellambse

model = capellambse.MelodyModel("tests/data/ContextDiagram.aird")
diag = model.by_uuid("0ab202d7-6497-4b78-9d13-fd7c9a75486c").exchange_item_class_tree_view
diag = model.by_uuid("0ab202d7-6497-4b78-9d13-fd7c9a75486c").exchange_item_relation_view
diag.render("svgdiagram").save(pretty=True)
```
<figure markdown>
<img src="../assets/images/Exchange Item Class Tree View of C 28.svg">
<figcaption>[LAB] Exchange Item Class Tree View of C 28</figcaption>
<img src="../assets/images/Exchange Item Relation View of C 28.svg">
<figcaption>[LAB] Exchange Item Relation View of C 28</figcaption>
</figure>

## Known Issues
Expand All @@ -30,5 +30,5 @@ This issue could potentially be resolved when Libavoid for ELK becomes publicly
## Check out the code

To understand the collection have a look into the
[`exchange_item_class_tree_view`][capellambse_context_diagrams.collectors.exchange_item_class_tree_view]
[`exchange_item_relation_view`][capellambse_context_diagrams.collectors.exchange_item_relation_view]
module.
2 changes: 1 addition & 1 deletion docs/gen_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def generate_interface_with_hide_interface_image():

def generate_exchange_item_class_tree_images() -> None:
obj = model.by_uuid(exchange_item_class_tree_uuid)
diag = obj.exchange_item_class_tree_view
diag = obj.exchange_item_relation_view
with mkdocs_gen_files.open(f"{str(dest / diag.name)}.svg", "w") as fd:
print(diag.render("svg", transparent_background=False), file=fd)

Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ nav:
- Overview: realization_view.md
- DataFlow View:
- Overview: data_flow_view.md
- Exchange Item Class Tree View:
- Overview: exchange_item_class_tree_view.md
- Exchange Item Relation View:
- Overview: exchange_item_relation_view.md
- Extras:
- Filters: extras/filters.md
- Styling: extras/styling.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

@pytest.mark.parametrize("uuid", ["0ab202d7-6497-4b78-9d13-fd7c9a75486c"])
@pytest.mark.parametrize("fmt", ["svgdiagram", "svg", None])
def test_exchange_item_class_tree_views(
def test_exchange_item_relation_views(
model: capellambse.MelodyModel, uuid: str, fmt: str
) -> None:
obj = model.by_uuid(uuid)

diag = obj.exchange_item_class_tree_view
diag = obj.exchange_item_relation_view

assert diag.render(fmt)

0 comments on commit 70c3669

Please sign in to comment.