Cleand up and added comends, description in the readme
This commit is contained in:
parent
9e54d02e39
commit
e0dd2c1670
@ -148,6 +148,12 @@ To see how to specify the output formats, as well as additional options, run:
|
|||||||
$ wireviz --help
|
$ wireviz --help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For using the .gv output one needs to use the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
dot <filename>.gv | gvpr -q -cf <filename>_pin2pin.gvpr | neato -n2 -T<type> -o <filename>.<type>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### (Re-)Building the example projects
|
### (Re-)Building the example projects
|
||||||
|
|
||||||
|
|||||||
@ -69,7 +69,7 @@ def check_old(node: str, old_attr: dict, args: dict) -> None:
|
|||||||
for attr, descr in old_attr.items():
|
for attr, descr in old_attr.items():
|
||||||
if attr in args:
|
if attr in args:
|
||||||
raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}")
|
raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}")
|
||||||
|
|
||||||
def getAddCompFromRef(reference, part):
|
def getAddCompFromRef(reference, part):
|
||||||
for comp in part.additional_components:
|
for comp in part.additional_components:
|
||||||
if reference in comp.references:
|
if reference in comp.references:
|
||||||
@ -234,7 +234,7 @@ class Harness:
|
|||||||
pinhtml.append(f' <td></td>')
|
pinhtml.append(f' <td></td>')
|
||||||
if connector.pinlabels:
|
if connector.pinlabels:
|
||||||
pinhtml.append(f" <td></td>")
|
pinhtml.append(f" <td></td>")
|
||||||
|
|
||||||
for short in connector.shorts:
|
for short in connector.shorts:
|
||||||
shortName = list(short.keys())[0]
|
shortName = list(short.keys())[0]
|
||||||
pinhtml.append(f' <td>{shortName}</td>')
|
pinhtml.append(f' <td>{shortName}</td>')
|
||||||
@ -242,7 +242,7 @@ class Harness:
|
|||||||
if connector.ports_right:
|
if connector.ports_right:
|
||||||
pinhtml.append(f' <td></td>')
|
pinhtml.append(f' <td></td>')
|
||||||
pinhtml.append(" </tr>")
|
pinhtml.append(" </tr>")
|
||||||
|
|
||||||
|
|
||||||
for pinindex, (pinname, pinlabel, pincolor) in enumerate(
|
for pinindex, (pinname, pinlabel, pincolor) in enumerate(
|
||||||
zip_longest(
|
zip_longest(
|
||||||
@ -272,27 +272,25 @@ class Harness:
|
|||||||
# fmt: on
|
# fmt: on
|
||||||
else:
|
else:
|
||||||
pinhtml.append(' <td colspan="2"></td>')
|
pinhtml.append(' <td colspan="2"></td>')
|
||||||
|
# Add Short columns
|
||||||
for short in connector.shorts:
|
for short in connector.shorts:
|
||||||
shortName = list(short.keys())[0]
|
shortName = list(short.keys())[0]
|
||||||
shortPins = list(short.values())[0]
|
shortPins = list(short.values())[0]
|
||||||
shortComp = getAddCompFromRef(shortName, connector)
|
shortComp = getAddCompFromRef(shortName, connector)
|
||||||
|
|
||||||
shColor = "BK"
|
shColor = "BK"
|
||||||
if shortComp != None and shortComp.color != None:
|
if shortComp != None and shortComp.color != None:
|
||||||
shColor = shortComp.color
|
shColor = shortComp.color
|
||||||
|
|
||||||
if pinindex+1 in shortPins:
|
if pinindex+1 in shortPins:
|
||||||
pinhtml.append(f' <td width="21" port="p{pinindex+1}J"></td>')
|
pinhtml.append(f' <td width="21" port="p{pinindex+1}J"></td>')
|
||||||
|
|
||||||
# pinhtml.append(f' <td port="p{pinindex+1}J"><FONT FACE="Sans" POINT-SIZE="12.0" COLOR="{wv_colors.translate_color(shColor, "HEX")}">⬤</FONT></td>')
|
|
||||||
else:
|
else:
|
||||||
pinhtml.append(f' <td></td>')
|
pinhtml.append(f' <td></td>')
|
||||||
|
|
||||||
|
|
||||||
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>')
|
||||||
|
|
||||||
pinhtml.append(" </tr>")
|
pinhtml.append(" </tr>")
|
||||||
|
|
||||||
pinhtml.append(" </table>")
|
pinhtml.append(" </table>")
|
||||||
@ -301,16 +299,17 @@ class Harness:
|
|||||||
row.replace("<!-- connector table -->", "\n".join(pinhtml))
|
row.replace("<!-- connector table -->", "\n".join(pinhtml))
|
||||||
for row in html
|
for row in html
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Add short connections/vertical lines with dots
|
||||||
for short in connector.shorts:
|
for short in connector.shorts:
|
||||||
shortName = list(short.keys())[0]
|
shortName = list(short.keys())[0]
|
||||||
shortPins = list(short.values())[0]
|
shortPins = list(short.values())[0]
|
||||||
shortComp = getAddCompFromRef(shortName, connector)
|
shortComp = getAddCompFromRef(shortName, connector)
|
||||||
|
|
||||||
shColor = "BK"
|
shColor = "BK"
|
||||||
if shortComp != None and shortComp.color != None:
|
if shortComp != None and shortComp.color != None:
|
||||||
shColor = shortComp.color
|
shColor = shortComp.color
|
||||||
|
|
||||||
dot.attr("edge", color=str(wv_colors.translate_color(shColor, "HEX")), headclip="false", tailclip="false", style="solid,bold")
|
dot.attr("edge", color=str(wv_colors.translate_color(shColor, "HEX")), headclip="false", tailclip="false", style="solid,bold")
|
||||||
for i in range(1, len(shortPins)):
|
for i in range(1, len(shortPins)):
|
||||||
dot.edge(
|
dot.edge(
|
||||||
@ -318,9 +317,9 @@ class Harness:
|
|||||||
f"{connector.name}:p{shortPins[i]}j:c",
|
f"{connector.name}:p{shortPins[i]}j:c",
|
||||||
straight="straight",
|
straight="straight",
|
||||||
addPTS=".18", # Size of the point at the end of the straight line/edge, it also enables the drawing of it
|
addPTS=".18", # Size of the point at the end of the straight line/edge, it also enables the drawing of it
|
||||||
colorPTS=str(wv_colors.translate_color(shColor, "HEX")), # the color of the point at the end of the line, it is requered that the circle is drawin
|
colorPTS=str(wv_colors.translate_color(shColor, "HEX")), # the color of the point at the end of the line, it is required that the circle is drawing
|
||||||
)
|
)
|
||||||
|
|
||||||
dot.attr("edge", headclip="true", tailclip="true", style="bold")
|
dot.attr("edge", headclip="true", tailclip="true", style="bold")
|
||||||
|
|
||||||
html = "\n".join(html)
|
html = "\n".join(html)
|
||||||
@ -332,15 +331,16 @@ class Harness:
|
|||||||
fillcolor=translate_color(self.options.bgcolor_connector, "HEX"),
|
fillcolor=translate_color(self.options.bgcolor_connector, "HEX"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Draw loop connections
|
||||||
for loop in connector.loops:
|
for loop in connector.loops:
|
||||||
loopName = list(loop.keys())[0]
|
loopName = list(loop.keys())[0]
|
||||||
loopPins = list(loop.values())[0]
|
loopPins = list(loop.values())[0]
|
||||||
loopComp = getAddCompFromRef(loopName, connector)
|
loopComp = getAddCompFromRef(loopName, connector)
|
||||||
|
|
||||||
loColor = "BK"
|
loColor = "BK"
|
||||||
if loopComp != None and loopComp.color != None:
|
if loopComp != None and loopComp.color != None:
|
||||||
loColor = loopComp.color
|
loColor = loopComp.color
|
||||||
|
|
||||||
dot.attr("edge", color=f"#000000:{wv_colors.translate_color(loColor, 'HEX')}:#000000")
|
dot.attr("edge", color=f"#000000:{wv_colors.translate_color(loColor, 'HEX')}:#000000")
|
||||||
if connector.ports_left:
|
if connector.ports_left:
|
||||||
loop_side = "l"
|
loop_side = "l"
|
||||||
@ -357,22 +357,6 @@ class Harness:
|
|||||||
label= " ",
|
label= " ",
|
||||||
)
|
)
|
||||||
|
|
||||||
# if len(connector.loops) > 0:
|
|
||||||
# dot.attr("edge", color="#000000:#ffffff:#000000")
|
|
||||||
# if connector.ports_left:
|
|
||||||
# loop_side = "l"
|
|
||||||
# loop_dir = "w"
|
|
||||||
# elif connector.ports_right:
|
|
||||||
# loop_side = "r"
|
|
||||||
# loop_dir = "e"
|
|
||||||
# else:
|
|
||||||
# raise Exception("No side for loops")
|
|
||||||
# for loop in connector.loops:
|
|
||||||
# dot.edge(
|
|
||||||
# f"{connector.name}:p{loop[0]}{loop_side}:{loop_dir}",
|
|
||||||
# f"{connector.name}:p{loop[1]}{loop_side}:{loop_dir}",
|
|
||||||
# )
|
|
||||||
|
|
||||||
# determine if there are double- or triple-colored wires in the harness;
|
# determine if there are double- or triple-colored wires in the harness;
|
||||||
# if so, pad single-color wires to make all wires of equal thickness
|
# if so, pad single-color wires to make all wires of equal thickness
|
||||||
pad = any(
|
pad = any(
|
||||||
@ -606,12 +590,12 @@ class Harness:
|
|||||||
row.replace(f"<!-- {connection.via_port}_out -->", to_string)
|
row.replace(f"<!-- {connection.via_port}_out -->", to_string)
|
||||||
for row in html
|
for row in html
|
||||||
]
|
]
|
||||||
|
|
||||||
# Connection in the Wire
|
# Connection in the Wire
|
||||||
code_left_1 = f"{cable.name}:w{connection.via_port}:w"
|
code_left_1 = f"{cable.name}:w{connection.via_port}:w"
|
||||||
code_left_2 = f"{cable.name}:w{connection.via_port}:e"
|
code_left_2 = f"{cable.name}:w{connection.via_port}:e"
|
||||||
dot.edge(code_left_1,
|
dot.edge(code_left_1,
|
||||||
code_left_2,
|
code_left_2,
|
||||||
straight="straight",
|
straight="straight",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -745,16 +729,21 @@ class Harness:
|
|||||||
# cache for the GraphViz Graph object
|
# cache for the GraphViz Graph object
|
||||||
# do not access directly, use self.graph instead
|
# do not access directly, use self.graph instead
|
||||||
_graph = None
|
_graph = None
|
||||||
|
|
||||||
# This renders the graph with gvpr and neato, this is needed to be able to draw the stright lines for the jumpers
|
# This renders the graph with gvpr and neato, this is needed to be able to draw the stright lines for the jumpers
|
||||||
def graphRender(self, type, filename, graph):
|
def graphRender(self, type, filename, graph):
|
||||||
|
# Chack if the needed commands are existing
|
||||||
if find_executable("dot") and find_executable("gvpr") and find_executable("neato"):
|
if find_executable("dot") and find_executable("gvpr") and find_executable("neato"):
|
||||||
|
# Set enviorments variable to path of this file
|
||||||
os.environ['GVPRPATH'] = str(Path(__file__).parent)
|
os.environ['GVPRPATH'] = str(Path(__file__).parent)
|
||||||
|
# Export the gv output to a temporay file
|
||||||
graph.save(filename=f"{filename}_tmp.gv")
|
graph.save(filename=f"{filename}_tmp.gv")
|
||||||
os.system(f"dot {filename}_tmp.gv | gvpr -q -cf pin2pin.gvpr | neato -n2 -T{type} -o {filename}.{type}")#{':cairo'if type == 'svg' else ''}
|
# Run the vomand and generait the output
|
||||||
|
os.system(f"dot {filename}_tmp.gv | gvpr -q -cf pin2pin.gvpr | neato -n2 -T{type} -o {filename}.{type}")
|
||||||
|
# Remove the temporary file
|
||||||
os.remove(f"{filename}_tmp.gv")
|
os.remove(f"{filename}_tmp.gv")
|
||||||
else:
|
else:
|
||||||
|
print('The "dot", "gvpr" and "neato" comand where not found on the system, use old methode of generaiton, this may lead to not wanted output.')
|
||||||
graph.render(filename=filename) # old rendering methode, befor jumper implementations
|
graph.render(filename=filename) # old rendering methode, befor jumper implementations
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -797,7 +786,6 @@ class Harness:
|
|||||||
_filename = f"{filename}.tmp" if f == "svg" else filename
|
_filename = f"{filename}.tmp" if f == "svg" else filename
|
||||||
# TODO: prevent rendering SVG twice when both SVG and HTML are specified
|
# TODO: prevent rendering SVG twice when both SVG and HTML are specified
|
||||||
graph.format = f
|
graph.format = f
|
||||||
# graph.render(filename=_filename) # old rendering methode, befor jumper implementations
|
|
||||||
self.graphRender(f, _filename, graph)
|
self.graphRender(f, _filename, graph)
|
||||||
# embed images into SVG output
|
# embed images into SVG output
|
||||||
if "svg" in fmt or "html" in fmt:
|
if "svg" in fmt or "html" in fmt:
|
||||||
@ -805,9 +793,10 @@ class Harness:
|
|||||||
# GraphViz output
|
# GraphViz output
|
||||||
if "gv" in fmt:
|
if "gv" in fmt:
|
||||||
graph.save(filename=f"{filename}.gv")
|
graph.save(filename=f"{filename}.gv")
|
||||||
|
# Print the needed comand for generaitong an output
|
||||||
filename_str = str(filename)
|
filename_str = str(filename)
|
||||||
shutil.copyfile(str(Path(__file__).parent).replace('\\', '/') + "/pin2pin.gvpr", filename_str + "_pin2pin.gvpr")
|
shutil.copyfile(str(Path(__file__).parent).replace('\\', '/') + "/pin2pin.gvpr", filename_str + "_pin2pin.gvpr")
|
||||||
print(f"Use: dot {filename_str}_tmp.gv | gvpr -q -cf {filename_str}_pin2pin.gvpr | neato -n2 -T<type> -o {filename_str}.<type>")
|
print(f"Use: dot {filename_str}.gv | gvpr -q -cf {filename_str}_pin2pin.gvpr | neato -n2 -T<type> -o {filename_str}.<type>")
|
||||||
# BOM output
|
# BOM output
|
||||||
bomlist = bom_list(self.bom())
|
bomlist = bom_list(self.bom())
|
||||||
if "tsv" in fmt:
|
if "tsv" in fmt:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user