Skip to content

Commit

Permalink
Fix node rendering for cables with hidden name and/or no visible attr…
Browse files Browse the repository at this point in the history
…ibutes (#104)

Closes #69.
  • Loading branch information
formatc1702 committed Jul 20, 2020
1 parent a418005 commit b028e7a
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,25 @@ def create_graph(self) -> Graph:
f'{cable.length} m' if cable.length > 0 else '']
attributes = list(filter(None, attributes))

html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td>' # main table

html = f'{html}<table border="0" cellspacing="0" cellpadding="3" cellborder="1">' # name+attributes table
if cable.show_name:
html = f'{html}<tr><td colspan="{len(attributes)}">{cable.name}</td></tr>'
if(len(identification) > 0): # print an identification row if values specified
html = f'{html}<tr><td colspan="{len(attributes)}" cellpadding="0"><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>'
for attrib in identification[0:-1]:
html = f'{html}<td sides="R">{attrib}</td>' # all columns except last have a border on the right (sides="R")
if len(identification) > 0:
html = f'{html}<td border="0">{identification[-1]}</td>' # last column has no border on the right because the enclosing table borders it
html = f'{html}</tr></table></td></tr>' # end identification row
html = f'{html}<tr>' # attribute row
for attrib in attributes:
html = f'{html}<td balign="left">{attrib}</td>'
html = f'{html}</tr>' # attribute row
html = f'{html}</table></td></tr>' # name+attributes table
html = '<table border="0" cellspacing="0" cellpadding="0">' # main table

if cable.show_name or len(attributes) > 0:
html = f'{html}<tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1">' # name+attributes table
if cable.show_name:
html = f'{html}<tr><td colspan="{max(len(attributes), 1)}">{cable.name}</td></tr>'
if(len(identification) > 0): # print an identification row if values specified
html = f'{html}<tr><td colspan="{len(attributes)}" cellpadding="0"><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>'
for attrib in identification[0:-1]:
html = f'{html}<td sides="R">{attrib}</td>' # all columns except last have a border on the right (sides="R")
if len(identification) > 0:
html = f'{html}<td border="0">{identification[-1]}</td>' # last column has no border on the right because the enclosing table borders it
html = f'{html}</tr></table></td></tr>' # end identification row
if(len(attributes) > 0):
html = f'{html}<tr>' # attribute row
for attrib in attributes:
html = f'{html}<td balign="left">{attrib}</td>'
html = f'{html}</tr>' # attribute row
html = f'{html}</table></td></tr>' # name+attributes table

html = f'{html}<tr><td>&nbsp;</td></tr>' # spacer between attributes and wires

Expand Down

0 comments on commit b028e7a

Please sign in to comment.