From 8c69a0030e4f57b89c429d2859c760a812799a96 Mon Sep 17 00:00:00 2001 From: Martin Rieder Date: Sat, 13 Jul 2024 14:28:10 +0200 Subject: [PATCH 1/2] Add simple style to Cable dataclass --- src/wireviz/DataClasses.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index d14e4459..8f7a9087 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -253,6 +253,7 @@ class Cable: spn: Union[MultilineHypertext, List[MultilineHypertext], None] = None pn: Union[Hypertext, List[Hypertext], None] = None category: Optional[str] = None + style: Optional[str] = None type: Optional[MultilineHypertext] = None gauge: Optional[float] = None gauge_unit: Optional[str] = None @@ -362,9 +363,14 @@ def __post_init__(self) -> None: else: raise Exception("lists of part data are only supported for bundles") + if self.show_name is None: - # hide designators for auto-generated cables by default - self.show_name = self.name[0:2] != "__" + # hide designators for simple and for auto-generated cables by default + self.show_name = self.style != "simple" and self.name[0:2] != "__" + + if self.show_wirecount is None: + # hide wirecount for simple (1 pin) connectors by default + self.show_wirecount = self.style != "simple" if self.show_wirenumbers is None: # by default, show wire numbers for cables, hide for bundles From 5e4271df1c22e5f73b81ef2b34f915657d4bbb25 Mon Sep 17 00:00:00 2001 From: Martin Rieder Date: Sat, 13 Jul 2024 16:50:48 +0200 Subject: [PATCH 2/2] Implement show_colorname for cables --- src/wireviz/DataClasses.py | 1 + src/wireviz/Harness.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 8f7a9087..e7172ce0 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -271,6 +271,7 @@ class Cable: show_name: Optional[bool] = None show_wirecount: bool = True show_wirenumbers: Optional[bool] = None + show_colorname: bool = True ignore_in_bom: bool = False additional_components: List[AdditionalComponent] = field(default_factory=list) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index c4af2364..5678e4ac 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -352,7 +352,7 @@ def create_graph(self) -> Graph: colorstr = wv_colors.translate_color( connection_color, self.options.color_mode ) - if colorstr: + if colorstr and cable.show_colorname: wireinfo.append(colorstr) if cable.wirelabels: wireinfo.append(wirelabel if wirelabel is not None else "")