Add color attribute to cables

This commit is contained in:
Daniel Rojas 2020-07-30 08:06:50 +02:00
parent 2639c77360
commit 43f85aedb2
2 changed files with 7 additions and 1 deletions

View File

@ -88,6 +88,7 @@ class Cable:
gauge_unit: Optional[str] = None gauge_unit: Optional[str] = None
show_equiv: bool = False show_equiv: bool = False
length: float = 0 length: float = 0
color: Optional[str] = None
wirecount: Optional[int] = None wirecount: Optional[int] = None
shield: bool = False shield: bool = False
notes: Optional[str] = None notes: Optional[str] = None

View File

@ -163,11 +163,16 @@ class Harness:
f'{len(cable.colors)}x' if cable.show_wirecount else None, f'{len(cable.colors)}x' if cable.show_wirecount else None,
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None, f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None,
'+ S' if cable.shield else None, '+ S' if cable.shield else None,
f'{cable.length} m' if cable.length > 0 else None], f'{cable.length} m' if cable.length > 0 else None,
cable.color, '<!-- colorbar -->' if cable.color else None],
'<!-- wire table -->', '<!-- wire table -->',
[html_line_breaks(cable.notes)]] [html_line_breaks(cable.notes)]]
html = nested_html_table(rows) html = nested_html_table(rows)
if cable.color: # add color bar next to color info, if present
colorbar = f' bgcolor="{wv_colors.translate_color(cable.color, "HEX")}" width="4"></td>' # leave out '<td' from string to preserve any existing attributes of the <td> tag
html = html.replace('><!-- colorbar --></td>', colorbar)
wirehtml = '<table border="0" cellspacing="0" cellborder="0">' # conductor table wirehtml = '<table border="0" cellspacing="0" cellborder="0">' # conductor table
wirehtml = f'{wirehtml}<tr><td>&nbsp;</td></tr>' wirehtml = f'{wirehtml}<tr><td>&nbsp;</td></tr>'