Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node rendering for cables with hidden name and/or no visible attributes #104

Merged
merged 2 commits into from
Jul 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,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