Added alignment option to the connector images
This commit is contained in:
parent
1c4fd68a2e
commit
00716d0c61
@ -23,6 +23,7 @@ CableMultiplier = (
|
|||||||
PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length']
|
PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length']
|
||||||
)
|
)
|
||||||
ImageScale = PlainText # = Literal['false', 'true', 'width', 'height', 'both']
|
ImageScale = PlainText # = Literal['false', 'true', 'width', 'height', 'both']
|
||||||
|
ImageAlignment = PlainText # = Literal['under', 'above', 'left', 'right']
|
||||||
|
|
||||||
# Type combinations
|
# Type combinations
|
||||||
Pin = Union[int, PlainText] # Pin identifier
|
Pin = Union[int, PlainText] # Pin identifier
|
||||||
@ -86,6 +87,7 @@ class Image:
|
|||||||
height: Optional[int] = None
|
height: Optional[int] = None
|
||||||
fixedsize: Optional[bool] = None
|
fixedsize: Optional[bool] = None
|
||||||
bgcolor: Optional[Color] = None
|
bgcolor: Optional[Color] = None
|
||||||
|
alignment: Optional[ImageAlignment] = None
|
||||||
# Contents of the text cell <td> just below the image cell:
|
# Contents of the text cell <td> just below the image cell:
|
||||||
caption: Optional[MultilineHypertext] = None
|
caption: Optional[MultilineHypertext] = None
|
||||||
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
|
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
|
||||||
|
|||||||
@ -191,6 +191,12 @@ class Harness:
|
|||||||
connector.ports_left = True # Use left side pins.
|
connector.ports_left = True # Use left side pins.
|
||||||
|
|
||||||
html = []
|
html = []
|
||||||
|
|
||||||
|
image_rows = []
|
||||||
|
if connector.image:
|
||||||
|
image_rows = [[html_image(connector.image)],
|
||||||
|
[html_caption(connector.image)]]
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
rows = [[f'{html_bgcolor(connector.bgcolor_title)}{remove_links(connector.name)}'
|
rows = [[f'{html_bgcolor(connector.bgcolor_title)}{remove_links(connector.name)}'
|
||||||
if connector.show_name else None],
|
if connector.show_name else None],
|
||||||
@ -202,13 +208,20 @@ class Harness:
|
|||||||
f'{connector.pincount}-pin' if connector.show_pincount else None,
|
f'{connector.pincount}-pin' if connector.show_pincount else None,
|
||||||
translate_color(connector.color, self.options.color_mode) if connector.color else None,
|
translate_color(connector.color, self.options.color_mode) if connector.color else None,
|
||||||
html_colorbar(connector.color)],
|
html_colorbar(connector.color)],
|
||||||
'<!-- connector table -->' if connector.style != 'simple' else None,
|
'<!-- connector table -->' if connector.style != 'simple' else None]
|
||||||
[html_image(connector.image)],
|
|
||||||
[html_caption(connector.image)]]
|
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
imagetable=''
|
||||||
|
if connector.image:
|
||||||
|
if connector.image.alignment == 'under' or connector.image.alignment is None:
|
||||||
|
rows += image_rows
|
||||||
|
elif connector.image.alignment == 'above':
|
||||||
|
rows = image_rows + rows
|
||||||
|
else:
|
||||||
|
imagetable = ''.join(nested_html_table(image_rows, html_bgcolor_attr(connector.bgcolor)))
|
||||||
|
|
||||||
rows.extend(get_additional_component_table(self, connector))
|
rows.extend(get_additional_component_table(self, connector))
|
||||||
rows.append([html_line_breaks(connector.notes)])
|
rows.append([html_line_breaks(connector.notes)])
|
||||||
|
|
||||||
html.extend(nested_html_table(rows, html_bgcolor_attr(connector.bgcolor)))
|
html.extend(nested_html_table(rows, html_bgcolor_attr(connector.bgcolor)))
|
||||||
|
|
||||||
if connector.style != "simple":
|
if connector.style != "simple":
|
||||||
@ -217,11 +230,16 @@ class Harness:
|
|||||||
'<table border="0" cellspacing="0" cellpadding="3" cellborder="1">'
|
'<table border="0" cellspacing="0" cellpadding="3" cellborder="1">'
|
||||||
)
|
)
|
||||||
|
|
||||||
for pinindex, (pinname, pinlabel, pincolor) in enumerate(
|
firstpin = True
|
||||||
zip_longest(
|
pincount = len(connector.pins)
|
||||||
|
if len(connector.pinlabels) > pincount:
|
||||||
|
pincount = len(connector.pinlabels)
|
||||||
|
if len(connector.pincolors) > pincount:
|
||||||
|
pincount = len(connector.pincolors)
|
||||||
|
|
||||||
|
for pinindex, (pinname, pinlabel, pincolor) in enumerate(zip_longest(
|
||||||
connector.pins, connector.pinlabels, connector.pincolors
|
connector.pins, connector.pinlabels, connector.pincolors
|
||||||
)
|
)):
|
||||||
):
|
|
||||||
if (
|
if (
|
||||||
connector.hide_disconnected_pins
|
connector.hide_disconnected_pins
|
||||||
and not connector.visible_pins.get(pinname, False)
|
and not connector.visible_pins.get(pinname, False)
|
||||||
@ -229,6 +247,11 @@ class Harness:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
pinhtml.append(" <tr>")
|
pinhtml.append(" <tr>")
|
||||||
|
|
||||||
|
if firstpin and connector.image and connector.image.alignment == 'left':
|
||||||
|
firstpin = False
|
||||||
|
pinhtml.append(f'<td rowspan="{pincount}">{imagetable}</td>')
|
||||||
|
|
||||||
if connector.ports_left:
|
if connector.ports_left:
|
||||||
pinhtml.append(f' <td port="p{pinindex+1}l">{pinname}</td>')
|
pinhtml.append(f' <td port="p{pinindex+1}l">{pinname}</td>')
|
||||||
if pinlabel:
|
if pinlabel:
|
||||||
@ -248,6 +271,11 @@ class Harness:
|
|||||||
|
|
||||||
if connector.ports_right:
|
if connector.ports_right:
|
||||||
pinhtml.append(f' <td port="p{pinindex+1}r">{pinname}</td>')
|
pinhtml.append(f' <td port="p{pinindex+1}r">{pinname}</td>')
|
||||||
|
|
||||||
|
if firstpin and connector.image and connector.image.alignment == 'right':
|
||||||
|
firstpin = False
|
||||||
|
pinhtml.append(
|
||||||
|
f'<td rowspan="{pincount}">{imagetable}</td>')
|
||||||
pinhtml.append(" </tr>")
|
pinhtml.append(" </tr>")
|
||||||
|
|
||||||
pinhtml.append(" </table>")
|
pinhtml.append(" </table>")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user