Skip to content

Commit f19fafb

Browse files
committed
Fix @kvid's suggestions:
- Rename image alignment to position - Rename under to below - Display the above positioned images right above the pins list Fixes #418
1 parent 00716d0 commit f19fafb

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/wireviz/DataClasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length']
2424
)
2525
ImageScale = PlainText # = Literal['false', 'true', 'width', 'height', 'both']
26-
ImageAlignment = PlainText # = Literal['under', 'above', 'left', 'right']
26+
ImagePosition = PlainText # = Literal['below', 'above', 'left', 'right']
2727

2828
# Type combinations
2929
Pin = Union[int, PlainText] # Pin identifier
@@ -87,7 +87,7 @@ class Image:
8787
height: Optional[int] = None
8888
fixedsize: Optional[bool] = None
8989
bgcolor: Optional[Color] = None
90-
alignment: Optional[ImageAlignment] = None
90+
position: Optional[ImagePosition] = None
9191
# Contents of the text cell <td> just below the image cell:
9292
caption: Optional[MultilineHypertext] = None
9393
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html

src/wireviz/Harness.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def create_graph(self) -> Graph:
193193
html = []
194194

195195
image_rows = []
196-
if connector.image:
196+
if connector.image and connector.image.position != 'above':
197197
image_rows = [[html_image(connector.image)],
198198
[html_caption(connector.image)]]
199199

@@ -205,17 +205,17 @@ def create_graph(self) -> Graph:
205205
html_line_breaks(pn_info_string(HEADER_SPN, connector.supplier, connector.spn))],
206206
[html_line_breaks(connector.type),
207207
html_line_breaks(connector.subtype),
208-
f'{connector.pincount}-pin' if connector.show_pincount else None,
208+
f'{connector.pincount}-pin' if connector.show_pincount else None],
209+
[html_caption(connector.image) if connector.image and connector.image.position == 'above' else None,
210+
html_image(connector.image) if connector.image and connector.image.position == 'above' else None,
209211
translate_color(connector.color, self.options.color_mode) if connector.color else None,
210212
html_colorbar(connector.color)],
211213
'<!-- connector table -->' if connector.style != 'simple' else None]
212214
# fmt: on
213215
imagetable=''
214216
if connector.image:
215-
if connector.image.alignment == 'under' or connector.image.alignment is None:
217+
if connector.image.position == 'below' or connector.image.position is None:
216218
rows += image_rows
217-
elif connector.image.alignment == 'above':
218-
rows = image_rows + rows
219219
else:
220220
imagetable = ''.join(nested_html_table(image_rows, html_bgcolor_attr(connector.bgcolor)))
221221

@@ -248,7 +248,7 @@ def create_graph(self) -> Graph:
248248

249249
pinhtml.append(" <tr>")
250250

251-
if firstpin and connector.image and connector.image.alignment == 'left':
251+
if firstpin and connector.image and connector.image.position == 'left':
252252
firstpin = False
253253
pinhtml.append(f'<td rowspan="{pincount}">{imagetable}</td>')
254254

@@ -272,7 +272,7 @@ def create_graph(self) -> Graph:
272272
if connector.ports_right:
273273
pinhtml.append(f' <td port="p{pinindex+1}r">{pinname}</td>')
274274

275-
if firstpin and connector.image and connector.image.alignment == 'right':
275+
if firstpin and connector.image and connector.image.position == 'right':
276276
firstpin = False
277277
pinhtml.append(
278278
f'<td rowspan="{pincount}">{imagetable}</td>')
@@ -741,3 +741,4 @@ def bom(self):
741741
if not self._bom:
742742
self._bom = generate_bom(self)
743743
return self._bom
744+

0 commit comments

Comments
 (0)