From 15788555cafcd37bd2303834548591f7ff810fe7 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Wed, 11 Nov 2020 18:37:20 +0100 Subject: [PATCH] Improve rendering of cable node Display wire number, color and label, as needed --- src/wireviz/Harness.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 9c1e119b..edd72cc5 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -213,23 +213,31 @@ def create_graph(self) -> Graph: wirehtml.append('') # conductor table wirehtml.append(' ') - colspan = 4 if cable.wirelabels else 3 - for i, (connection_color, wirelabel) in enumerate(zip_longest(cable.colors, cable.wirelabels), 1): wirehtml.append(' ') wirehtml.append(f' ') - wirehtml.append(f' ') + wirehtml.append(f' ') + wireinfo.append(wirelabel if wirelabel else '') + wirehtml.append(f' {":".join(wireinfo)}') + + wirehtml.append(f' ') wirehtml.append(f' ') wirehtml.append(' ') bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000'] wirehtml.append(f' ') - wirehtml.append(f' ') wirehtml.append(' ') @@ -245,7 +253,7 @@ def create_graph(self) -> Graph: wireidentification.append(html_line_breaks(manufacturer_info)) # print parameters into a table row under the wire if len(wireidentification) > 0 : - wirehtml.append('
 
{wv_colors.translate_color(connection_color, self.color_mode)}') + + wireinfo = [] + if cable.show_wirenumbers: + wireinfo.append(str(i)) + colorstr = wv_colors.translate_color(connection_color, self.color_mode) + if colorstr: + wireinfo.append(colorstr) if cable.wirelabels: - wirehtml.append(f' [{wirelabel}]
') + wirehtml.append(f' ') wirehtml.append(' ') for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors - wirehtml.append(f' ') + wirehtml.append(f' ') wirehtml.append('
') wirehtml.append('
') + wirehtml.append('
') wirehtml.append(' ') for attrib in wireidentification: wirehtml.append(f' ') @@ -266,7 +274,7 @@ def create_graph(self) -> Graph: else: # shield is shown as a thin black wire attributes = f'height="2" bgcolor="#000000" border="0"' - wirehtml.append(f' ') + wirehtml.append(f' ') wirehtml.append(' ') wirehtml.append('
{attrib}
 
')