Skip to content

Commit

Permalink
fix(context): Fix default render styles
Browse files Browse the repository at this point in the history
Merge pull request #71 from DSD-DBS/fix-default-renderstylers
  • Loading branch information
ewuerger authored Feb 7, 2024
2 parents a8a39a4 + 5c79388 commit 17f7be9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
47 changes: 35 additions & 12 deletions capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from capellambse.model.layers import ctx, la, oa, pa
from capellambse.model.modeltypes import DiagramType

from . import context
from . import context, styling

try:
__version__ = metadata.version("capellambse-context-diagrams")
Expand All @@ -38,7 +38,7 @@
del metadata

DefaultRenderParams = dict[str, t.Any]
ClassPair = tuple[
SupportedClass = tuple[
type[common.GenericElement], DiagramType, DefaultRenderParams
]
logger = logging.getLogger(__name__)
Expand All @@ -58,7 +58,7 @@ def init() -> None:

def register_classes() -> None:
"""Add the `context_diagram` property to the relevant model objects."""
supported_classes: list[ClassPair] = [
supported_classes: list[SupportedClass] = [
(oa.Entity, DiagramType.OAB, {}),
(oa.OperationalActivity, DiagramType.OAIB, {}),
(oa.OperationalCapability, DiagramType.OCB, {}),
Expand All @@ -67,13 +67,36 @@ def register_classes() -> None:
(
ctx.SystemComponent,
DiagramType.SAB,
{"display_symbols_as_boxes": True},
{
"display_symbols_as_boxes": True,
"render_styles": styling.BLUE_ACTOR_FNCS,
},
),
(
ctx.SystemFunction,
DiagramType.SDFB,
{"render_styles": styling.BLUE_ACTOR_FNCS},
),
(
la.LogicalComponent,
DiagramType.LAB,
{"render_styles": styling.BLUE_ACTOR_FNCS},
),
(
la.LogicalFunction,
DiagramType.LDFB,
{"render_styles": styling.BLUE_ACTOR_FNCS},
),
(
pa.PhysicalComponent,
DiagramType.PAB,
{"render_styles": styling.BLUE_ACTOR_FNCS},
),
(
pa.PhysicalFunction,
DiagramType.PDFB,
{"render_styles": styling.BLUE_ACTOR_FNCS},
),
(ctx.SystemFunction, DiagramType.SDFB, {}),
(la.LogicalComponent, DiagramType.LAB, {}),
(la.LogicalFunction, DiagramType.LDFB, {}),
(pa.PhysicalComponent, DiagramType.PAB, {}),
(pa.PhysicalFunction, DiagramType.PDFB, {}),
]
patch_styles(supported_classes)
class_: type[common.GenericElement]
Expand All @@ -82,7 +105,7 @@ def register_classes() -> None:
common.set_accessor(class_, ATTR_NAME, accessor)


def patch_styles(classes: cabc.Iterable[ClassPair]) -> None:
def patch_styles(classes: cabc.Iterable[SupportedClass]) -> None:
"""Add missing default styling to default styles.
See Also
Expand Down Expand Up @@ -174,7 +197,7 @@ def register_realization_view() -> None:
Adds ``realization_view`` to Activities, Functions and Components
of all layers.
"""
supported_classes: list[ClassPair] = [
supported_classes: list[SupportedClass] = [
(oa.Entity, DiagramType.OAB, {}),
(oa.OperationalActivity, DiagramType.OAIB, {}),
(ctx.SystemComponent, DiagramType.SAB, {}),
Expand Down Expand Up @@ -205,7 +228,7 @@ def register_realization_view() -> None:


def register_data_flow_view() -> None:
supported_classes: list[ClassPair] = [
supported_classes: list[SupportedClass] = [
(oa.OperationalCapability, DiagramType.OAIB, {}), # portless
(ctx.Capability, DiagramType.SDFB, {}), # default
]
Expand Down
4 changes: 2 additions & 2 deletions capellambse_context_diagrams/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(
self._default_render_params = render_params or {}

@t.overload
def __get__(self, obj: None, objtype=None) -> common.Accessor:
def __get__(self, obj: None, objtype: type[t.Any]) -> ContextAccessor:
...

@t.overload
Expand Down Expand Up @@ -260,7 +260,7 @@ def __init__(
self.target = obj
self.styleclass = class_

self.render_styles = render_styles or styling.BLUE_ACTOR_FNCS
self.render_styles = render_styles or {}
self.serializer = serializers.DiagramSerializer(self)
self.__filters: cabc.MutableSet[str] = self.FilterSet(self)
self.display_symbols_as_boxes = display_symbols_as_boxes
Expand Down

0 comments on commit 17f7be9

Please sign in to comment.