diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py
index 1cc1ec6..c2639a2 100644
--- a/src/wireviz/Harness.py
+++ b/src/wireviz/Harness.py
@@ -188,117 +188,49 @@ class Harness:
# style=style,
# fillcolor=translate_color(bgcolor, "HEX"),
)
- continue
# TODO: connection edges
- html = []
- wirehtml = []
- # conductor table
- wirehtml.append('
')
- wirehtml.append(" | |
")
+ # # for bundles, individual wires can have part information
+ # if cable.category == "bundle":
+ # # create a list of wire parameters
+ # wireidentification = []
+ # if isinstance(cable.pn, list):
+ # wireidentification.append(
+ # pn_info_string(
+ # HEADER_PN, None, remove_links(cable.pn[i - 1])
+ # )
+ # )
+ # manufacturer_info = pn_info_string(
+ # HEADER_MPN,
+ # cable.manufacturer[i - 1]
+ # if isinstance(cable.manufacturer, list)
+ # else None,
+ # cable.mpn[i - 1] if isinstance(cable.mpn, list) else None,
+ # )
+ # supplier_info = pn_info_string(
+ # HEADER_SPN,
+ # cable.supplier[i - 1]
+ # if isinstance(cable.supplier, list)
+ # else None,
+ # cable.spn[i - 1] if isinstance(cable.spn, list) else None,
+ # )
+ # if manufacturer_info:
+ # wireidentification.append(html_line_breaks(manufacturer_info))
+ # if supplier_info:
+ # wireidentification.append(html_line_breaks(supplier_info))
+ # # print parameters into a table row under the wire
+ # if len(wireidentification) > 0:
+ # # fmt: off
+ # wirehtml.append(' ')
+ # wirehtml.append(' ')
+ # for attrib in wireidentification:
+ # wirehtml.append(f" | {attrib} | ")
+ # wirehtml.append(" ")
+ # wirehtml.append(" |
")
+ # # fmt: on
- for i, (connection_color, wirelabel) in enumerate(
- zip_longest(cable.colors, cable.wirelabels), 1
- ):
- wirehtml.append(" ")
- wirehtml.append(f" | ")
- wirehtml.append(f" ")
-
- wireinfo = []
- if cable.show_wirenumbers:
- wireinfo.append(str(i))
- colorstr = wv_colors.translate_color(
- connection_color, self.options.color_mode
- )
- if colorstr:
- wireinfo.append(colorstr)
- if cable.wirelabels:
- wireinfo.append(wirelabel if wirelabel is not None else "")
- wirehtml.append(f' {":".join(wireinfo)}')
-
- wirehtml.append(f" | ")
- wirehtml.append(f" | ")
- wirehtml.append("
")
-
- # fmt: off
- bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000']
- wirehtml.append(f" ")
- 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(" ")
- wirehtml.append(" | ")
- wirehtml.append("
")
- # fmt: on
-
- # for bundles, individual wires can have part information
- if cable.category == "bundle":
- # create a list of wire parameters
- wireidentification = []
- if isinstance(cable.pn, list):
- wireidentification.append(
- pn_info_string(
- HEADER_PN, None, remove_links(cable.pn[i - 1])
- )
- )
- manufacturer_info = pn_info_string(
- HEADER_MPN,
- cable.manufacturer[i - 1]
- if isinstance(cable.manufacturer, list)
- else None,
- cable.mpn[i - 1] if isinstance(cable.mpn, list) else None,
- )
- supplier_info = pn_info_string(
- HEADER_SPN,
- cable.supplier[i - 1]
- if isinstance(cable.supplier, list)
- else None,
- cable.spn[i - 1] if isinstance(cable.spn, list) else None,
- )
- if manufacturer_info:
- wireidentification.append(html_line_breaks(manufacturer_info))
- if supplier_info:
- wireidentification.append(html_line_breaks(supplier_info))
- # print parameters into a table row under the wire
- if len(wireidentification) > 0:
- # fmt: off
- wirehtml.append(' ')
- wirehtml.append(' ')
- for attrib in wireidentification:
- wirehtml.append(f" | {attrib} | ")
- wirehtml.append(" ")
- wirehtml.append(" |
")
- # fmt: on
-
- if cable.shield:
- wirehtml.append(" | |
") # spacer
- wirehtml.append(" ")
- wirehtml.append(" | ")
- wirehtml.append(" Shield | ")
- wirehtml.append(" | ")
- wirehtml.append("
")
- 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"'
- # fmt: off
- wirehtml.append(f' |
')
- # fmt: on
-
- wirehtml.append(" | |
")
- wirehtml.append("
")
-
- html = [
- row.replace("", "\n".join(wirehtml)) for row in html
- ]
# connections
for connection in cable.connections:
@@ -316,11 +248,14 @@ class Harness:
)
else: # it's a shield connection
# shield is shown with specified color and black borders, or as a thin black wire otherwise
+ if isinstance(cable.shield, str):
+ shield_color_hex = wv_colors.get_color_hex(cable.shield)[0]
+ shield_color_str = ":".join(["#000000", shield_color_hex, "#000000"])
+ else:
+ shield_color_str = "#000000"
dot.attr(
"edge",
- color=":".join(["#000000", shield_color_hex, "#000000"])
- if isinstance(cable.shield, str)
- else "#000000",
+ color=shield_color_str,
)
if connection.from_pin is not None: # connect to left
from_connector = self.connectors[connection.from_name]
@@ -345,10 +280,10 @@ class Harness:
from_string = ":".join(from_info)
else:
from_string = ""
- html = [
- row.replace(f"", from_string)
- for row in html
- ]
+ # html = [
+ # row.replace(f"", from_string)
+ # for row in html
+ # ]
if connection.to_pin is not None: # connect to right
to_connector = self.connectors[connection.to_name]
to_pin_index = to_connector.pins.index(connection.to_pin)
@@ -367,24 +302,24 @@ class Harness:
to_string = ":".join(to_info)
else:
to_string = ""
- html = [
- row.replace(f"", to_string)
- for row in html
- ]
+ # html = [
+ # row.replace(f"", to_string)
+ # for row in html
+ # ]
style, bgcolor = (
("filled,dashed", self.options.bgcolor_bundle)
if cable.category == "bundle"
else ("filled", self.options.bgcolor_cable)
)
- html = "\n".join(html)
- dot.node(
- cable.name,
- label=f"<\n{html}\n>",
- shape="box",
- style=style,
- fillcolor=translate_color(bgcolor, "HEX"),
- )
+ # html = "\n".join(html)
+ # dot.node(
+ # cable.name,
+ # label=f"<\n{html}\n>",
+ # shape="box",
+ # style=style,
+ # fillcolor=translate_color(bgcolor, "HEX"),
+ # )
apply_dot_tweaks(dot, self.tweak)
diff --git a/src/wireviz/wv_gv_html.py b/src/wireviz/wv_gv_html.py
index c7cd6ec..ff8c77f 100644
--- a/src/wireviz/wv_gv_html.py
+++ b/src/wireviz/wv_gv_html.py
@@ -209,20 +209,36 @@ def gv_conductor_table(cable, harness_options) -> Table:
rows.append(Tr(cells_above))
# the wire itself
- rows.append(Tr(gv_wire_cell(i, connection_color, harness_options._pad)))
+ color_list = ["#000000"] + get_color_hex(connection_color, pad=harness_options._pad) + ["#000000"]
+ rows.append(Tr(gv_wire_cell(i, color_list)))
# row below the wire
# TODO: PN stuff for bundles
+ if cable.shield:
+ rows.append(Tr(Td(" "))) # spacer between wires and shield
+ # row above the shield
+ cells_above = [
+ Td(""),
+ Td("Shield"),
+ Td(""),
+ ]
+ rows.append(Tr(cells_above))
+ # thw shield itself
+ if isinstance(cable.shield, str):
+ color_list = ["#000000"] + get_color_hex(cable.shield) + ["#000000"]
+ else:
+ color_list = ["#000000"]
+ rows.append(Tr(gv_wire_cell("s", color_list)))
+
rows.append(Tr(Td(" "))) # spacer row on bottom
tbl = Table(rows, border=0, cellspacing=0, cellborder=0)
return tbl
-def gv_wire_cell(index, color, pad) -> Td:
- bgcolors = ["#000000"] + get_color_hex(color, pad=pad) + ["#000000"]
+def gv_wire_cell(index, color_list) -> Td:
wire_inner_rows = []
- for j, bgcolor in enumerate(bgcolors[::-1]):
+ for j, bgcolor in enumerate(color_list[::-1]):
wire_inner_cell_attribs = {
"colspan": 3,
"cellpadding": 0,
@@ -237,7 +253,7 @@ def gv_wire_cell(index, color, pad) -> Td:
"border": 0,
"cellspacing": 0,
"port": f"w{index}",
- "height": 2 * len(bgcolors),
+ "height": 2 * len(color_list),
}
wire_outer_cell = Td(wire_inner_table, **wire_outer_cell_attribs)