Fix and simplify bgcolor logic
This commit is contained in:
parent
31c5e1aad9
commit
84dd10a2dc
@ -77,19 +77,15 @@ def gv_node_component(
|
|||||||
line_notes,
|
line_notes,
|
||||||
]
|
]
|
||||||
|
|
||||||
tbl = nested_table(lines)
|
if component.bgcolor:
|
||||||
|
tbl_bgcolor = translate_color(component.bgcolor, "HEX")
|
||||||
tbl.update_attribs(bgcolor=translate_color(component.bgcolor, "HEX"))
|
elif isinstance(component, Connector) and harness_options.bgcolor_connector:
|
||||||
|
tbl_bgcolor = translate_color(harness_options.bgcolor_connector, "HEX")
|
||||||
if isinstance(component, Connector) and harness_options.bgcolor_connector:
|
|
||||||
tbl.update_attribs(
|
|
||||||
bgcolor=translate_color(harness_options.bgcolor_connector, "HEX")
|
|
||||||
)
|
|
||||||
elif isinstance(component, Cable) and harness_options.bgcolor_cable:
|
elif isinstance(component, Cable) and harness_options.bgcolor_cable:
|
||||||
tbl.update_attribs(
|
tbl_bgcolor = translate_color(harness_options.bgcolor_cable, "HEX")
|
||||||
bgcolor=translate_color(harness_options.bgcolor_cable, "HEX")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
tbl = nested_table(lines)
|
||||||
|
tbl.update_attribs(bgcolor=tbl_bgcolor)
|
||||||
return tbl
|
return tbl
|
||||||
|
|
||||||
|
|
||||||
@ -111,6 +107,7 @@ def make_list_of_cells(inp) -> List[Td]:
|
|||||||
def nested_table(lines: List[Td]) -> Table:
|
def nested_table(lines: List[Td]) -> Table:
|
||||||
cell_lists = [make_list_of_cells(line) for line in lines]
|
cell_lists = [make_list_of_cells(line) for line in lines]
|
||||||
rows = []
|
rows = []
|
||||||
|
|
||||||
for lst in cell_lists:
|
for lst in cell_lists:
|
||||||
if len(lst) == 0:
|
if len(lst) == 0:
|
||||||
continue # no cells in list
|
continue # no cells in list
|
||||||
@ -132,10 +129,10 @@ def nested_table(lines: List[Td]) -> Table:
|
|||||||
Tr(cells), border=0, cellspacing=0, cellpadding=3, cellborder=1
|
Tr(cells), border=0, cellspacing=0, cellpadding=3, cellborder=1
|
||||||
)
|
)
|
||||||
rows.append(Tr(Td(inner_table)))
|
rows.append(Tr(Td(inner_table)))
|
||||||
|
|
||||||
if len(rows) == 0: # create dummy row to avoid GraphViz errors due to empty <table>
|
if len(rows) == 0: # create dummy row to avoid GraphViz errors due to empty <table>
|
||||||
rows = Tr(Td(""))
|
rows = Tr(Td(""))
|
||||||
tbl = Table(rows, border=0, cellspacing=0, cellpadding=0)
|
tbl = Table(rows, border=0, cellspacing=0, cellpadding=0)
|
||||||
|
|
||||||
return tbl
|
return tbl
|
||||||
|
|
||||||
|
|
||||||
@ -152,8 +149,8 @@ def gv_pin_table(component) -> Table:
|
|||||||
pin_rows.append(
|
pin_rows.append(
|
||||||
gv_pin_row(pinindex, pinname, pinlabel, pincolor, component)
|
gv_pin_row(pinindex, pinname, pinlabel, pincolor, component)
|
||||||
)
|
)
|
||||||
|
tbl = Table(pin_rows, border=0, cellspacing=0, cellpadding=3, cellborder=1)
|
||||||
return Table(pin_rows, border=0, cellspacing=0, cellpadding=3, cellborder=1)
|
return tbl
|
||||||
|
|
||||||
|
|
||||||
def gv_pin_row(pin_index, pin_name, pin_label, pin_color, connector) -> Tr:
|
def gv_pin_row(pin_index, pin_name, pin_label, pin_color, connector) -> Tr:
|
||||||
@ -187,9 +184,8 @@ def gv_connector_loops(connector: Connector) -> List:
|
|||||||
|
|
||||||
|
|
||||||
def gv_conductor_table(cable, harness_options) -> Table:
|
def gv_conductor_table(cable, harness_options) -> Table:
|
||||||
|
|
||||||
rows = []
|
rows = []
|
||||||
rows.append(Tr(Td(" ")))
|
rows.append(Tr(Td(" "))) # spacer row on top
|
||||||
|
|
||||||
for i, (connection_color, wirelabel) in enumerate(
|
for i, (connection_color, wirelabel) in enumerate(
|
||||||
zip_longest(cable.colors, cable.wirelabels), 1
|
zip_longest(cable.colors, cable.wirelabels), 1
|
||||||
@ -215,10 +211,11 @@ def gv_conductor_table(cable, harness_options) -> Table:
|
|||||||
# the wire itself
|
# the wire itself
|
||||||
rows.append(Tr(gv_wire_cell(i, connection_color, harness_options._pad)))
|
rows.append(Tr(gv_wire_cell(i, connection_color, harness_options._pad)))
|
||||||
|
|
||||||
rows.append(Tr(Td(" ")))
|
# row below the wire
|
||||||
|
# TODO: PN stuff for bundles
|
||||||
|
|
||||||
|
rows.append(Tr(Td(" "))) # spacer row on bottom
|
||||||
tbl = Table(rows, border=0, cellspacing=0, cellborder=0)
|
tbl = Table(rows, border=0, cellspacing=0, cellborder=0)
|
||||||
|
|
||||||
return tbl
|
return tbl
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user