From f185038a0fcbb3b8682a8854a33c388fd4eb16cb Mon Sep 17 00:00:00 2001 From: KV Date: Sun, 26 Jul 2020 00:47:47 +0200 Subject: [PATCH] Make each shield wire uniform and allow cable.shield color As the spline shield wires were rendered as tinned wires with black borders, and the shield wires in cable nodes were rendered as a single (bottom) border, they didn't fit well together. Each shield wire is now rendered equally along the spline sections and in cable nodes. If cable.shield is true, they are rendered as thin black wires in the same way as with version 0.1. The new feature is that cable.shield is allowed to contain a two-letter color code to specify a colored shield wire with black borders. The shield wire thickness is not increased, even if the cable has some multi-colored wires that makes all other wires to increase. This fixes bug #125. --- src/wireviz/Harness.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 0c15b49d..5952e0e9 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -230,7 +230,14 @@ def create_graph(self) -> Graph: for bla in p: html = html + f'{bla}' html = f'{html}' - html = f'{html}' + if isinstance(cable.shield, str): + # shield is shown with specified color and black borders + shield_color_hex = wv_colors.get_color_hex(cable.shield)[0] + attributes = f'height="6" bgcolor="{shield_color_hex}" border="2" sides="tb"' + else: + # shield is shown as a thin black wire + attributes = f'height="2" bgcolor="#000000" border="0"' + html = f'{html}' html = f'{html} ' # spacer at the end @@ -248,8 +255,8 @@ def create_graph(self) -> Graph: if isinstance(connection_color.via_port, int): # check if it's an actual wire and not a shield dot.attr('edge', color=':'.join(['#000000'] + wv_colors.get_color_hex(cable.colors[connection_color.via_port - 1], pad=pad) + ['#000000'])) else: # it's a shield connection - # shield is shown as a thin tinned wire - dot.attr('edge', color=':'.join(['#000000', wv_colors.get_color_hex('SN', pad=False)[0], '#000000'])) + # shield is shown with specified color and black borders, or as a thin black wire otherwise + dot.attr('edge', color=':'.join(['#000000', shield_color_hex, '#000000']) if isinstance(cable.shield, str) else '#000000') if connection_color.from_port is not None: # connect to left from_port = f':p{connection_color.from_port}r' if self.connectors[connection_color.from_name].style != 'simple' else '' code_left_1 = f'{connection_color.from_name}{from_port}:e'