Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat custom diagram #159

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a584e6f
feat: Implement custom_diagram
huyenngn Nov 9, 2024
c65647a
fix: Diagram target dictates unified edge direction
huyenngn Nov 9, 2024
cf6fdca
feat(custom_diagram): Add recursion option
huyenngn Nov 10, 2024
40c009c
fix: Move edges to owners
huyenngn Nov 11, 2024
bfa43bc
docs: Add docs for custom diagram
huyenngn Nov 11, 2024
be8a5b8
feat(custom_diagram): Add nested recursion and recursion depth
huyenngn Nov 12, 2024
810ca66
docs: Add expamles for custom_diagram
huyenngn Nov 12, 2024
8e6baea
fix: Fix recursion depth
huyenngn Nov 18, 2024
d7e94b9
fix: Straighten target edge
huyenngn Nov 18, 2024
d6592a0
feat(context-diagram): Add support for PhysicalPorts
huyenngn Nov 19, 2024
261ea06
docs: Add PhysicalPort to docs
huyenngn Nov 19, 2024
2a5f966
fix: Apply code review suggestions
huyenngn Nov 25, 2024
6305008
fix: Apply suggestions from code review
huyenngn Nov 25, 2024
e4dfd0d
fix: Fix minimum size calculation of boxes
huyenngn Nov 26, 2024
f091a65
refactor: Implement generic make_owner_boxes function
huyenngn Nov 26, 2024
bed6a30
fix: Fix mutability bug
huyenngn Nov 27, 2024
c744a6b
feat: Add support for python lambda filter
huyenngn Nov 27, 2024
3f99c27
fix: Add custom_diagram attribute to Class elements
huyenngn Dec 2, 2024
5398b91
refactor: Add generic make_owner_box method
huyenngn Dec 9, 2024
ad39f99
refactor(custom_diagram): Take iterable as collection
huyenngn Dec 9, 2024
d2162d4
docs(custom_diagram): Add example to docs
huyenngn Dec 9, 2024
51772a8
docs: Update custom_diagram docs
huyenngn Dec 16, 2024
fd3b4b1
fix: Remove duplicates from port context
ewuerger Jan 6, 2025
e492ffe
fix: Change custom diagram names
huyenngn Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ def init() -> None:
"""Initialize the extension."""
register_classes()
register_interface_context()
register_physical_port_context()
register_tree_view()
register_realization_view()
register_data_flow_view()
register_cable_tree_view()
register_custom_diagram()
# register_functional_context() XXX: Future


Expand Down Expand Up @@ -247,6 +249,15 @@ def register_functional_context() -> None:
)


def register_physical_port_context() -> None:
"""Add the `context_diagram` attribute to `PhysicalPort`s."""
m.set_accessor(
cs.PhysicalPort,
ATTR_NAME,
context.PhysicalPortContextAccessor(DiagramType.PAB.value, {}),
)


def register_tree_view() -> None:
"""Add the ``tree_view`` attribute to ``Class``es."""
m.set_accessor(
Expand Down Expand Up @@ -313,3 +324,31 @@ 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),
(la.LogicalComponent, DiagramType.LAB),
(la.LogicalFunction, DiagramType.LAB),
(pa.PhysicalComponent, DiagramType.PAB),
(pa.PhysicalFunction, DiagramType.PAB),
(cs.PhysicalLink, DiagramType.PAB),
(cs.PhysicalPort, DiagramType.PAB),
(fa.ComponentExchange, DiagramType.SAB),
(information.Class, DiagramType.CDB),
]
for class_, dgcls in supported_classes:
m.set_accessor(
class_,
"custom_diagram",
context.CustomContextAccessor(dgcls.value, {}),
)
Loading
Loading