From 27560e62075d7419d5387af353303bc1009e4ec2 Mon Sep 17 00:00:00 2001 From: ewuerger Date: Tue, 31 Oct 2023 15:27:53 +0100 Subject: [PATCH] feat: Add missing attributes and default styling --- capellambse/diagram/_styleclass.py | 2 ++ capellambse/diagram/capstyle.py | 20 +++++++++++++++++++ capellambse/model/crosslayer/capellacore.py | 2 ++ .../model/crosslayer/information/__init__.py | 6 ++++++ capellambse/svg/decorations.py | 9 +++++++-- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/capellambse/diagram/_styleclass.py b/capellambse/diagram/_styleclass.py index 8c0d23062..0ec28b30a 100644 --- a/capellambse/diagram/_styleclass.py +++ b/capellambse/diagram/_styleclass.py @@ -30,6 +30,8 @@ def get_styleclass(obj: model.ModelObject) -> str: def _default(obj: model.ModelObject) -> str: + if isinstance(obj, model.GenericElement): + return obj.xtype.split(":")[-1] return type(obj).__name__ diff --git a/capellambse/diagram/capstyle.py b/capellambse/diagram/capstyle.py index dc600f298..69eb25853 100644 --- a/capellambse/diagram/capstyle.py +++ b/capellambse/diagram/capstyle.py @@ -341,6 +341,26 @@ class in the form:: "stroke": COLORS["_CAP_Datatype_Border_Gray"], "text_fill": COLORS["black"], }, + "Box.BooleanType": { + "fill": COLORS["_CAP_Class_Brown"], + "stroke": COLORS["_CAP_Datatype_Border_Gray"], + "text_fill": COLORS["black"], + }, + "Box.NumericType": { + "fill": COLORS["_CAP_Class_Brown"], + "stroke": COLORS["_CAP_Datatype_Border_Gray"], + "text_fill": COLORS["black"], + }, + "Box.PhysicalQuantity": { + "fill": COLORS["_CAP_Class_Brown"], + "stroke": COLORS["_CAP_Datatype_Border_Gray"], + "text_fill": COLORS["black"], + }, + "Box.StringType": { + "fill": COLORS["_CAP_Class_Brown"], + "stroke": COLORS["_CAP_Datatype_Border_Gray"], + "text_fill": COLORS["black"], + }, "Box.ExchangeItem": { # DT_ExchangeItem "fill": COLORS["_CAP_ExchangeItem_Pinkkish"], "stroke": COLORS["_CAP_Interface_Border_Reddish"], diff --git a/capellambse/model/crosslayer/capellacore.py b/capellambse/model/crosslayer/capellacore.py index f07f12c2e..068ff6e45 100644 --- a/capellambse/model/crosslayer/capellacore.py +++ b/capellambse/model/crosslayer/capellacore.py @@ -26,6 +26,8 @@ class Generalization(c.GenericElement): _xmltag = "ownedGeneralizations" + super: c.Accessor + @c.xtype_handler(None) class EnumerationPropertyLiteral(c.GenericElement): diff --git a/capellambse/model/crosslayer/information/__init__.py b/capellambse/model/crosslayer/information/__init__.py index 89fdedc1f..3bb5918e5 100644 --- a/capellambse/model/crosslayer/information/__init__.py +++ b/capellambse/model/crosslayer/information/__init__.py @@ -122,6 +122,9 @@ class Class(c.GenericElement): capellacommon.StateMachine, aslist=c.ElementList ) owned_properties = c.DirectProxyAccessor(Property, aslist=c.ElementList) + generalizations = c.DirectProxyAccessor( + capellacore.Generalization, aslist=c.ElementList + ) @property def properties(self) -> c.ElementList[Property]: @@ -207,6 +210,9 @@ class ExchangeItem(c.GenericElement): exchanges: c.Accessor[c.GenericElement] +c.set_accessor( + capellacore.Generalization, "super", c.AttrProxyAccessor(None, "super") +) for cls in [Class, Union, datatype.Enumeration, Collection]: c.set_accessor( cls, diff --git a/capellambse/svg/decorations.py b/capellambse/svg/decorations.py index 204858236..ae8ff6ad0 100644 --- a/capellambse/svg/decorations.py +++ b/capellambse/svg/decorations.py @@ -32,15 +32,20 @@ DiagramClass = str FaultyClass = str PatchClass = str -always_top_label = { +needs_feature_line = { + "BooleanType", "Class", "Enumeration", + "NumericType", + "PhysicalQuantity", + "StringType", +} +always_top_label = needs_feature_line | { "Note", "RepresentationLink", "OperationalActivity", "PhysicalComponent", } -needs_feature_line = {"Class", "Enumeration"} class DecoFactories(t.Dict[str, cabc.Callable]):