diff --git a/examples/ex15.html b/examples/ex15.html
index a9f7e2d..d87404e 100644
--- a/examples/ex15.html
+++ b/examples/ex15.html
@@ -42,7 +42,7 @@
X1
-X1
+X1
Molex KK 254
@@ -51,58 +51,73 @@
7-pin
GND
-
-⬤
-
+
+⬤
+
1
VCC
-
-
-⬤
+
+
+⬤
2
RX
-
-
+
+
3
TX
-
-
+
+
4
GND
-
+
⬤
-
+
5
VCC
-
-
+
+
⬤
6
GND
-
-⬤
-
+
+⬤
+
7
+
+
+X1:c--X1:c
+
+
+
+
+X1:c--X1:c
+
+
+
+
+X1:c--X1:c
+
+
-
+
W1
-W1
+W1
Serial
@@ -113,8 +128,8 @@
+ S
0.2 m
-
-X1:1:GND
+
+X1:1:GND
1:BN
X2:1:GND
@@ -122,45 +137,45 @@
X1:2:VCC
2:RD
-X2:2:VCC
+X2:2:VCC
X1:3:RX
3:OG
-X2:4:TX
+X2:4:TX
X1:4:TX
- 4:YE
-X2:3:RX
+ 4:YE
+X2:3:RX
-
-X1:1:GND
+
+X1:1:GND
Shield
-
+
-
+
X1:e--W1:w
-
+
-
-
-
-
-X1:e--W1:w
-
-
-
+
X1:e--W1:w
+
+
+
+
+
+
+X1:e--W1:w
@@ -168,17 +183,17 @@
X1:e--W1:w
-
+
-
+
-
+
X1:e--W1:w
-
+
X2
@@ -192,78 +207,93 @@
1
-GND
-
-⬤
-
+GND
+
+⬤
+
2
VCC
-
-
-⬤
+
+
+⬤
3
RX
-
-
+
+
4
TX
-
-
+
+
5
-GND
-
+GND
+
⬤
-
+
6
VCC
-
-
+
+
⬤
7
-GND
-
-⬤
-
+GND
+
+⬤
+
-
+
W1:e--X2:w
-
+
-
+
-
+
W1:e--X2:w
-
+
-
+
-
+
W1:e--X2:w
-
+
W1:e--X2:w
-
+
-
+
+
+
+
+X2:c--X2:c
+
+
+
+
+X2:c--X2:c
+
+
+
+
+X2:c--X2:c
+
diff --git a/examples/ex15.png b/examples/ex15.png
index ab7aa04..10b97dd 100644
Binary files a/examples/ex15.png and b/examples/ex15.png differ
diff --git a/examples/ex15.svg b/examples/ex15.svg
index a0c9370..f9511ab 100644
--- a/examples/ex15.svg
+++ b/examples/ex15.svg
@@ -13,7 +13,7 @@
X1
-X1
+X1
Molex KK 254
@@ -22,58 +22,73 @@
7-pin
GND
-
-⬤
-
+
+⬤
+
1
VCC
-
-
-⬤
+
+
+⬤
2
RX
-
-
+
+
3
TX
-
-
+
+
4
GND
-
+
⬤
-
+
5
VCC
-
-
+
+
⬤
6
GND
-
-⬤
-
+
+⬤
+
7
+
+
+X1:c--X1:c
+
+
+
+
+X1:c--X1:c
+
+
+
+
+X1:c--X1:c
+
+
-
+
W1
-W1
+W1
Serial
@@ -84,8 +99,8 @@
+ S
0.2 m
-
-X1:1:GND
+
+X1:1:GND
1:BN
X2:1:GND
@@ -93,45 +108,45 @@
X1:2:VCC
2:RD
-X2:2:VCC
+X2:2:VCC
X1:3:RX
3:OG
-X2:4:TX
+X2:4:TX
X1:4:TX
- 4:YE
-X2:3:RX
+ 4:YE
+X2:3:RX
-
-X1:1:GND
+
+X1:1:GND
Shield
-
+
-
+
X1:e--W1:w
-
+
-
-
-
-
-X1:e--W1:w
-
-
-
+
X1:e--W1:w
+
+
+
+
+
+
+X1:e--W1:w
@@ -139,17 +154,17 @@
X1:e--W1:w
-
+
-
+
-
+
X1:e--W1:w
-
+
X2
@@ -163,78 +178,93 @@
1
-GND
-
-⬤
-
+GND
+
+⬤
+
2
VCC
-
-
-⬤
+
+
+⬤
3
RX
-
-
+
+
4
TX
-
-
+
+
5
-GND
-
+GND
+
⬤
-
+
6
VCC
-
-
+
+
⬤
7
-GND
-
-⬤
-
+GND
+
+⬤
+
-
+
W1:e--X2:w
-
+
-
+
-
+
W1:e--X2:w
-
+
-
+
-
+
W1:e--X2:w
-
+
W1:e--X2:w
-
+
-
+
+
+
+
+X2:c--X2:c
+
+
+
+
+X2:c--X2:c
+
+
+
+
+X2:c--X2:c
+
diff --git a/examples/ex15.tmp b/examples/ex15.tmp
new file mode 100644
index 0000000..c35214b
--- /dev/null
+++ b/examples/ex15.tmp
@@ -0,0 +1,252 @@
+graph {
+// Graph generated by WireViz 0.5-dev
+// https://github.com/formatc1702/WireViz
+ graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
+ node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
+ edge [fontname=arial style=bold]
+ edge [color="#FF66CC" headclip=false style=dashed tailclip=false]
+ X1:p1j:c -- X1:p5j:c [straight=straight]
+ X1:p5j:c -- X1:p7j:c [straight=straight]
+ edge [color="#FF0000" headclip=false style=dashed tailclip=false]
+ X1:p2j:c -- X1:p6j:c [straight=straight]
+ edge [headclip=true style=bold tailclip=true]
+ X1 [label=<
+
+ |
+
+ |
+
+
+ | Molex KK 254 |
+ female |
+ 7-pin |
+
+ |
+
+
+
+ | GND |
+ ⬤ |
+ |
+ 1 |
+
+
+ | VCC |
+ |
+ ⬤ |
+ 2 |
+
+
+ | RX |
+ |
+ |
+ 3 |
+
+
+ | TX |
+ |
+ |
+ 4 |
+
+
+ | GND |
+ ⬤ |
+ |
+ 5 |
+
+
+ | VCC |
+ |
+ ⬤ |
+ 6 |
+
+
+ | GND |
+ ⬤ |
+ |
+ 7 |
+
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+ edge [color="#000000" headclip=false style=dashed tailclip=false]
+ X2:p1j:c -- X2:p5j:c [straight=straight]
+ X2:p5j:c -- X2:p7j:c [straight=straight]
+ edge [color="#000000" headclip=false style=dashed tailclip=false]
+ X2:p2j:c -- X2:p6j:c [straight=straight]
+ edge [headclip=true style=bold tailclip=true]
+ X2 [label=<
+
+ |
+
+ |
+
+
+ | Molex KK 254 |
+ female |
+ 7-pin |
+
+ |
+
+
+
+ | 1 |
+ GND |
+ ⬤ |
+ |
+
+
+ | 2 |
+ VCC |
+ |
+ ⬤ |
+
+
+ | 3 |
+ RX |
+ |
+ |
+
+
+ | 4 |
+ TX |
+ |
+ |
+
+
+ | 5 |
+ GND |
+ ⬤ |
+ |
+
+
+ | 6 |
+ VCC |
+ |
+ ⬤ |
+
+
+ | 7 |
+ GND |
+ ⬤ |
+ |
+
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+ edge [color="#000000:#895956:#000000"]
+ X1:p1r:e -- W1:w1:w
+ W1:w1:e -- X2:p1l:w
+ edge [color="#000000:#ff0000:#000000"]
+ X1:p2r:e -- W1:w2:w
+ W1:w2:e -- X2:p2l:w
+ edge [color="#000000:#ff8000:#000000"]
+ X1:p3r:e -- W1:w3:w
+ W1:w3:e -- X2:p4l:w
+ edge [color="#000000:#ffff00:#000000"]
+ X1:p4r:e -- W1:w4:w
+ W1:w4:e -- X2:p3l:w
+ edge [color="#000000"]
+ X1:p1r:e -- W1:ws:w
+ W1 [label=<
+
+ |
+
+ |
+
+
+ | Serial |
+ 4x |
+ 0.25 mm² (24 AWG) |
+ + S |
+ 0.2 m |
+
+ |
+
+
+ | |
+
+ | X1:1:GND |
+
+ 1:BN
+ |
+ X2:1:GND |
+
+
+ |
+
+ |
+
+
+ | X1:2:VCC |
+
+ 2:RD
+ |
+ X2:2:VCC |
+
+
+ |
+
+ |
+
+
+ | X1:3:RX |
+
+ 3:OG
+ |
+ X2:4:TX |
+
+
+ |
+
+ |
+
+
+ | X1:4:TX |
+
+ 4:YE
+ |
+ X2:3:RX |
+
+
+ |
+
+ |
+
+ | |
+
+ | X1:1:GND |
+ Shield |
+ |
+
+ |
+ | |
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+}
diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py
index 4a76567..346b42b 100644
--- a/src/wireviz/Harness.py
+++ b/src/wireviz/Harness.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
+import os
import re
from collections import Counter
from dataclasses import dataclass
@@ -269,11 +270,17 @@ class Harness:
]
for short, short_color in zip_longest(connector.internal_shorts, connector.internal_shorts_color):
- print("Short_connections: " + str(short) + str(short_color))
if short_color == None:
short_color = "BK"
- # TODO adding dashed Line for Jumpers
+ dot.attr("edge", color=str(wv_colors.translate_color(short_color, "HEX")), headclip="false", tailclip="false", style="dashed")
+ for i in range(1, len(short)):
+ dot.edge(
+ f"{connector.name}:p{short[i - 1]}j:c",
+ f"{connector.name}:p{short[i]}j:c",
+ straight="straight"
+ )
+ dot.attr("edge", headclip="true", tailclip="true", style="bold")
html = "\n".join(html)
dot.node(
@@ -663,6 +670,12 @@ class Harness:
# cache for the GraphViz Graph object
# do not access directly, use self.graph instead
_graph = None
+
+ # 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):
+ 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}")
+ os.remove(f"{filename}_tmp.gv")
@property
def graph(self):
@@ -688,8 +701,6 @@ class Harness:
def output(
self,
filename: (str, Path),
- view: bool = False,
- cleanup: bool = True,
fmt: tuple = ("html", "png", "svg", "tsv"),
) -> None:
# graphical output
@@ -706,7 +717,8 @@ class Harness:
_filename = f"{filename}.tmp" if f == "svg" else filename
# TODO: prevent rendering SVG twice when both SVG and HTML are specified
graph.format = f
- graph.render(filename=_filename, view=view, cleanup=cleanup)
+ # graph.render(filename=_filename) # old rendering methode, befor jumper implementations
+ self.graphRender(f, _filename, graph)
# embed images into SVG output
if "svg" in fmt or "html" in fmt:
embed_svg_images_file(f"{filename}.tmp.svg")
diff --git a/src/wireviz/pin2pin.gvpr b/src/wireviz/pin2pin.gvpr
new file mode 100644
index 0000000..baa0e5c
--- /dev/null
+++ b/src/wireviz/pin2pin.gvpr
@@ -0,0 +1,28 @@
+/*******************************************************************
+
+ see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196
+ input must include pos values (must be output from one of the engines w/ -Tdot)
+
+*******************************************************************/
+BEG_G{
+ string tok[int];
+ int cnt;
+
+/***************************************
+ $G.bb="";
+ $G.nodesep="";
+ $G.ranksep="";
+ $G.splines="true";
+****************************************/
+}
+/********************************************************
+ the weakness is in the head==tail test
+ it would be better to mark every target edge with a new attribute and test for that attribute
+*********************************************************/
+E[straight] {
+ cnt=tokens($.pos,tok," ");
+ $.oldpos=$.pos;
+ pos=tok[0]+" " + tok[0]+" "+tok[cnt-1]+" "+tok[cnt-1];
+ $.label=""; // remove pesky label
+ $.lp=""; // remove peskier label pos
+}
\ No newline at end of file
diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py
index bc974e8..983f174 100755
--- a/src/wireviz/wireviz.py
+++ b/src/wireviz/wireviz.py
@@ -377,7 +377,7 @@ def parse(
harness.add_bom_item(line)
if output_formats:
- harness.output(filename=output_file, fmt=output_formats, view=False)
+ harness.output(filename=output_file, fmt=output_formats)
if return_types:
returns = []
diff --git a/tutorial/tutorial01 b/tutorial/tutorial01
new file mode 100644
index 0000000..b5d32ea
--- /dev/null
+++ b/tutorial/tutorial01
@@ -0,0 +1,166 @@
+graph {
+// Graph generated by WireViz 0.5-dev
+// https://github.com/formatc1702/WireViz
+ graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
+ node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
+ edge [fontname=arial style=bold]
+ edge [headclip=true style=bold tailclip=true]
+ X1 [label=<
+
+ |
+
+ |
+ |
+
+ |
+
+
+
+ | 1 |
+
+
+ | 2 |
+
+
+ | 3 |
+
+
+ | 4 |
+
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+ edge [headclip=true style=bold tailclip=true]
+ X2 [label=<
+
+ |
+
+ |
+ |
+
+ |
+
+
+
+ | 1 |
+
+
+ | 2 |
+
+
+ | 3 |
+
+
+ | 4 |
+
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+ edge [color="#000000:#ffffff:#000000"]
+ X1:p1r:e -- W1:w1:w
+ W1:w1:e -- X2:p1l:w
+ edge [color="#000000:#ffffff:#000000"]
+ X1:p2r:e -- W1:w2:w
+ W1:w2:e -- X2:p2l:w
+ edge [color="#000000:#ffffff:#000000"]
+ X1:p3r:e -- W1:w3:w
+ W1:w3:e -- X2:p3l:w
+ edge [color="#000000:#ffffff:#000000"]
+ X1:p4r:e -- W1:w4:w
+ W1:w4:e -- X2:p4l:w
+ W1 [label=<
+
+ |
+
+ |
+ |
+
+ |
+
+
+ | |
+
+ | X1:1 |
+
+ 1
+ |
+ X2:1 |
+
+
+ |
+
+ |
+
+
+ | X1:2 |
+
+ 2
+ |
+ X2:2 |
+
+
+ |
+
+ |
+
+
+ | X1:3 |
+
+ 3
+ |
+ X2:3 |
+
+
+ |
+
+ |
+
+
+ | X1:4 |
+
+ 4
+ |
+ X2:4 |
+
+
+ |
+
+ |
+
+ | |
+
+ |
+
+> fillcolor="#FFFFFF" shape=box style=filled]
+}
|