diff --git a/.gitattributes b/.gitattributes index deb5a71..11fb9d8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,8 +2,8 @@ docs/* linguist-documentation examples/* linguist-documentation tutorial/* linguist-documentation -**/*.bom.tsv linguist-generated -**/*.bom.csv linguist-generated +**/*.tsv linguist-generated +**/*.csv linguist-generated **/*.gv linguist-generated **/*.html linguist-generated **/*.png linguist-generated diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6acc4ff..5604078 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,25 +19,24 @@ jobs: python-version: "3.8" runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Setup Graphviz - uses: ts-graphviz/setup-graphviz@v2 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install . - - name: Create Examples - run: PYTHONPATH=$(pwd)/src/wireviz:$PYTHONPATH cd src/wireviz/ && python build_examples.py - - name: Upload examples, demos, and tutorials - uses: actions/upload-artifact@v4 - with: - name: examples-and-tutorials-v${{ matrix.python-version }} - path: | - examples/ - tutorial/ - if-no-files-found: error - + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Setup Graphviz + uses: ts-graphviz/setup-graphviz@v2 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install . + - name: Create Examples + run: PYTHONPATH=$(pwd)/src/wireviz:$PYTHONPATH cd src/wireviz/tools/ && python build_examples.py + - name: Upload examples, demos, and tutorials + uses: actions/upload-artifact@v4 + with: + name: examples-and-tutorials-v${{ matrix.python-version }} + path: | + examples/ + tutorial/ + if-no-files-found: error diff --git a/.gitignore b/.gitignore index 7484ecb..dc58d27 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,21 @@ +# OS-specific files .DS_Store +desktop.ini +Thumbs.db + +# Development aids .idea/ -.eggs -__pycache__ -.*.swp -*.egg-info -*.pyc -build -data -dist +.vscode/ +temp/ venv/ .venv/ -desktop.ini -thumbs.db -temp/ + +# Build/compile/release artifacts +build/ +dist/ +*.egg-info +*.pyc + +# Other temporary files +__pycache__ +.*.swp diff --git a/cleanup.sh b/cleanup.sh new file mode 100755 index 0000000..9c774be --- /dev/null +++ b/cleanup.sh @@ -0,0 +1,5 @@ +#!/bin/zsh + +autoflake -i --remove-all-unused-imports src/wireviz/*.py +isort src/wireviz/*py +black src/wireviz/*.py diff --git a/devtools.txt b/devtools.txt new file mode 100644 index 0000000..adf89ca --- /dev/null +++ b/devtools.txt @@ -0,0 +1,12 @@ +# The following tools have proven useful during development +# Feel free to install while inside the WireViz virtualenv, using: +# pip install -r devtools.txt + +# Code formatting +black # black src/wireviz/*.py +isort # isort src/wireviz/*py + +# Development aids +pudb # import pudb; pudb.set_trace() +autoflake # autoflake -i --remove-all-unused-imports src/wireviz/*.py +pyan # pyan3 src/wireviz/*.py -uncge --html > temp/pyan.html diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f0d29b0..3303aa0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log -## [0.4.1] (2024-07-13) +## [0.5](https://github.com/wireviz/WireViz/tree/v0.5) (20XX-XX-XX) + +TODO + + +## [0.4.1](https://github.com/wireviz/WireViz/tree/v0.4.1) (2024-07-13) ### Improvements to help reported issues diff --git a/docs/README.md b/docs/README.md index 732f671..759c946 100644 --- a/docs/README.md +++ b/docs/README.md @@ -74,13 +74,13 @@ Output file: ![Sample output diagram](../examples/demo01.png) -[Bill of Materials](../examples/demo01.bom.tsv) (auto-generated) +[Bill of Materials](../examples/demo01.tsv) (auto-generated) ### Demo 02 ![](../examples/demo02.png) -[Source](../examples/demo02.yml) - [Bill of Materials](../examples/demo02.bom.tsv) +[Source](../examples/demo02.yml) - [Bill of Materials](../examples/demo02.tsv) ### Syntax, tutorial and example gallery @@ -133,7 +133,7 @@ Depending on the options specified, this will output some or all of the followin mywire.gv GraphViz output mywire.svg Wiring diagram as vector image mywire.png Wiring diagram as raster image -mywire.bom.tsv BOM (bill of materials) as tab-separated text file +mywire.tsv BOM (bill of materials) as tab-separated text file mywire.html HTML page with wiring diagram and BOM embedded ``` @@ -148,6 +148,11 @@ To see how to specify the output formats, as well as additional options, run: $ wireviz --help ``` +For using the .gv output one needs to use the following command: + +``` +dot .gv | gvpr -q -cf _pin2pin.gvpr | neato -n2 -T -o . +``` ### (Re-)Building the example projects diff --git a/docs/buildscript.md b/docs/buildscript.md index 35523d4..438e8ce 100644 --- a/docs/buildscript.md +++ b/docs/buildscript.md @@ -26,7 +26,7 @@ Possible group names: - `tutorial` to process`tutorial/{readme.md,tutorial*.*}` - `demos` to process`examples/demo*.*` - Affected filetypes: `.gv`, `.bom.tsv`, `.png`, `.svg`, `.html` + Affected filetypes: `.gv`, `.tsv`, `.png`, `.svg`, `.html` ## Usage hints diff --git a/docs/syntax.md b/docs/syntax.md index 2c92fd3..47bc1b5 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -83,8 +83,24 @@ tweak: # optional tweaking of .gv output hide_disconnected_pins: # defaults to false # loops - loops: # every list item is itself a list of exactly two pins - # on the connector that are to be shorted + loops: # a list(dict) of loops + - : # every list item is itself a list of pins + # on the connector that are to be shorted with a cable loop + # more information about the loop can be added by additional + # components definition (see below) + # OR + - # a list of pins to be looped + # Shorts + shorts: # a list(dict) of shorts + : # every list item is itself a list of pins + # on the connector that are to be shorted represented inside + # the connector table + # more information about the loop can be added by additional + # components definition (see below) + # OR + - # a list of pins to be shorted + # it is not posable to combine those two + shorts_hide_lable: # A Boolean to control if the lable of the shorts should be shown, if a list is used this is automatically turned true. ``` ## Cable attributes @@ -500,7 +516,7 @@ The following colors are understood: - `GD` ![##ffcf80](https://via.placeholder.com/15/ffcf80/000000?text=+) (gold) - + It is also possible to specify colors as hexadecimal RGB values, e.g. `#112233` or `#FFFF00:#009900`. Remember quoting strings containing a `#` in the YAML file. diff --git a/examples/demo01.bom.tsv b/examples/demo01.bom.tsv index 39f82ac..fef6d97 100644 --- a/examples/demo01.bom.tsv +++ b/examples/demo01.bom.tsv @@ -1,4 +1,4 @@ -Id Description Qty Unit Designators -1 Cable, 3 x 0.25 mm² shielded 0.2 m W1 -2 Connector, D-Sub, female, 9 pins 1 X1 -3 Connector, Molex KK 254, female, 3 pins 1 X2 +# Qty Unit Description Designators +1 1 Connector, D-Sub, female, 9 pins X1 +2 1 Connector, Molex KK 254, female, 3 pins X2 +3 1 m Cable, 3 x 0.25 mm² shielded W1 diff --git a/examples/demo01.gv b/examples/demo01.gv index e5fb6b6..7142f4f 100644 --- a/examples/demo01.gv +++ b/examples/demo01.gv @@ -1,184 +1,212 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
D-Subfemale9-pin
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DCD1
RX2
TX3
DTR4
GND5
DSR6
RTS7
CTS8
RI9
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
D-Subfemale9-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DCD1
RX2
TX3
DTR4
GND5
DSR6
RTS7
CTS8
RI9
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + edge [color="#000000"] + X1:p7r:e -- X1:p8r:e [label=" " color="#000000" noLabel=noLabel] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex KK 254female3-pin
-
- - - - - - - - - - - - - -
1GND
2RX
3TX
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female3-pin
+
+ + + + + + + + + + + + + +
1GND
2RX
3TX
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + +
3x0.25 mm²+ S0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:5:GND 1:WH X2:1:GND
X1:2:RX 2:BN X2:3:TX
X1:3:TX 3:GN X2:2:RX
 
X1:5:GND Shield
 
+
+> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] X1:p5r:e -- W1:w1:w W1:w1:e -- X2:p1l:w edge [color="#000000:#895956:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p3l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p2l:w edge [color="#000000"] - X1:p5r:e -- W1:ws:w - W1 [label=< - - - - -
- - -
W1
-
- - - - - -
3x0.25 mm²+ S0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:5:GND - 1:WH - X2:1:GND
- - - - -
-
X1:2:RX - 2:BN - X2:3:TX
- - - - -
-
X1:3:TX - 3:GN - X2:2:RX
- - - - -
-
 
X1:5:GNDShield
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + X1:p5r:e -- W1:w4:w + W1:w1:e -- W1:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#895956:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#00AA00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000" straight=straight] } diff --git a/examples/demo01.html b/examples/demo01.html index c661431..f1cc9fa 100644 --- a/examples/demo01.html +++ b/examples/demo01.html @@ -1,7 +1,7 @@ - + demo01 - +

demo01

Diagram

@@ -30,172 +30,205 @@
- - - - + + + X1 - - -X1 - -D-Sub - -female - -9-pin - -DCD - -1 - -RX - -2 - -TX - -3 - -DTR - -4 - -GND - -5 - -DSR - -6 - -RTS - -7 - -CTS - -8 - -RI - -9 + + + +X1 + +D-Sub + +female + +9-pin + +DCD + +1 + +RX + +2 + +TX + +3 + +DTR + +4 + +GND + +5 + +DSR + +6 + +RTS + +7 + +CTS + +8 + +RI + +9 + + + +X1:e--X1:e + - + W1 - - -W1 - -3x - -0.25 mm² - -+ S - -0.2 m -  -X1:5:GND -     1:WH     -X2:1:GND - - - -X1:2:RX -     2:BN     -X2:3:TX - - - -X1:3:TX -     3:GN     -X2:2:RX - - - -  -X1:5:GND -Shield - -  + + + +W1 + +3x + +0.25 mm² + ++ S + +0.2 m +  + X1:5:GND + +1:WH + +X2:1:GND + X1:2:RX + +2:BN + +X2:3:TX + X1:3:TX + +3:GN + +X2:2:RX +  + X1:5:GND + +Shield + + +  - + X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + - + X2 - - -X2 - -Molex KK 254 - -female - -3-pin - -1 - -GND - -2 - -RX - -3 - -TX + + + +X2 + +Molex KK 254 + +female + +3-pin + +1 + +GND + +2 + +RX + +3 + +TX - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + @@ -211,33 +244,33 @@
- - + + - - - - - - - - - + + - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 3 x 0.25 mm² shielded0.2mW1
2Connector, D-Sub, female, 9 pins1 1 Connector, D-Sub, female, 9 pins X1
3Connector, Molex KK 254, female, 3 pins2 1 Connector, Molex KK 254, female, 3 pins X2
31mCable, 3 x 0.25 mm² shieldedW1
diff --git a/examples/demo01.png b/examples/demo01.png index e222137..9b81975 100644 Binary files a/examples/demo01.png and b/examples/demo01.png differ diff --git a/examples/demo01.svg b/examples/demo01.svg index 6883a86..4f691a0 100644 --- a/examples/demo01.svg +++ b/examples/demo01.svg @@ -1,172 +1,205 @@ - - - - + + + X1 - - -X1 - -D-Sub - -female - -9-pin - -DCD - -1 - -RX - -2 - -TX - -3 - -DTR - -4 - -GND - -5 - -DSR - -6 - -RTS - -7 - -CTS - -8 - -RI - -9 + + + +X1 + +D-Sub + +female + +9-pin + +DCD + +1 + +RX + +2 + +TX + +3 + +DTR + +4 + +GND + +5 + +DSR + +6 + +RTS + +7 + +CTS + +8 + +RI + +9 + + + +X1:e--X1:e + - + W1 - - -W1 - -3x - -0.25 mm² - -+ S - -0.2 m -  -X1:5:GND -     1:WH     -X2:1:GND - - - -X1:2:RX -     2:BN     -X2:3:TX - - - -X1:3:TX -     3:GN     -X2:2:RX - - - -  -X1:5:GND -Shield - -  + + + +W1 + +3x + +0.25 mm² + ++ S + +0.2 m +  + X1:5:GND + +1:WH + +X2:1:GND + X1:2:RX + +2:BN + +X2:3:TX + X1:3:TX + +3:GN + +X2:2:RX +  + X1:5:GND + +Shield + + +  - + X1:e--W1:w - - - + + + X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + - + X2 - - -X2 - -Molex KK 254 - -female - -3-pin - -1 - -GND - -2 - -RX - -3 - -TX + + + +X2 + +Molex KK 254 + +female + +3-pin + +1 + +GND + +2 + +RX + +3 + +TX - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + diff --git a/examples/demo01.yml b/examples/demo01.yml index 56c77c1..aed5079 100644 --- a/examples/demo01.yml +++ b/examples/demo01.yml @@ -1,8 +1,13 @@ +metadata: + title: demo01 + connectors: X1: type: D-Sub subtype: female pinlabels: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI] + loops: + L1: [7,8] X2: type: Molex KK 254 subtype: female @@ -17,10 +22,8 @@ cables: shield: true connections: - - - - X1: [5,2,3] - - W1: [1,2,3] - - X2: [1,3,2] - - - - X1: 5 + - - X1: [5, 2, 3] + - W1: [1, 2, 3] + - X2: [1, 3, 2] + - - X1: 5 - W1: s diff --git a/examples/demo01_wv_gvpr.gvpr b/examples/demo01_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/demo01_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/demo02.bom.tsv b/examples/demo02.bom.tsv index cebaa36..596989a 100644 --- a/examples/demo02.bom.tsv +++ b/examples/demo02.bom.tsv @@ -1,13 +1,13 @@ -Id Description Qty Unit Designators -1 Cable, 2 x 0.25 mm² 0.3 m W4 -2 Connector, Crimp ferrule, 0.25 mm², YE 2 -3 Connector, Molex KK 254, female, 4 pins 2 X2, X3 -4 Connector, Molex KK 254, female, 5 pins 1 X4 -5 Connector, Molex KK 254, female, 8 pins 1 X1 -6 Wire, 0.14 mm², BK 0.9 m W1, W2, W3 -7 Wire, 0.14 mm², BU 0.3 m W3 -8 Wire, 0.14 mm², GN 0.6 m W1, W2 -9 Wire, 0.14 mm², OG 0.3 m W3 -10 Wire, 0.14 mm², RD 0.6 m W1, W2 -11 Wire, 0.14 mm², VT 0.3 m W3 -12 Wire, 0.14 mm², YE 0.6 m W1, W2 +# Qty Unit Description Designators +1 2 Connector, Crimp ferrule, 0.25 mm², YE +2 2 Connector, Molex KK 254, female, 4 pins X2, X3 +3 1 Connector, Molex KK 254, female, 5 pins X4 +4 1 Connector, Molex KK 254, female, 8 pins X1 +5 1 m Cable, 2 x 0.25 mm² W4 +6 3 m Wire, 0.14 mm², BK W1, W2, W3 +7 1 m Wire, 0.14 mm², BU W3 +8 2 m Wire, 0.14 mm², GN W1, W2 +9 1 m Wire, 0.14 mm², OG W3 +10 2 m Wire, 0.14 mm², RD W1, W2 +11 1 m Wire, 0.14 mm², VT W3 +12 2 m Wire, 0.14 mm², YE W1, W2 diff --git a/examples/demo02.gv b/examples/demo02.gv index ca788be..8ce63ea 100644 --- a/examples/demo02.gv +++ b/examples/demo02.gv @@ -1,549 +1,595 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex KK 254female8-pin
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GND1
+5V2
SCL3
SDA4
MISO5
MOSI6
SCK7
N/C8
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female8-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GND1
+5V2
SCL3
SDA4
MISO5
MOSI6
SCK7
N/C8
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2+5V
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2+5V
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - +
- - -
X3
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2+5V
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X3
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2+5V
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X4 [label=< - - - - +
- - -
X4
-
- - - - -
Molex KK 254female5-pin
-
- - - - - - - - - - - - - - - - - - - - - -
1GND
2+12V
3MISO
4MOSI
5SCK
-
+ + + + + + + + +
+ + + + +
X4
+
+ + + + + + +
Molex KK 254female5-pin
+
+ + + + + + + + + + + + + + + + + + + + + +
1GND
2+12V
3MISO
4MOSI
5SCK
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_1 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_1 [label=< +
- - - - - -
Crimp ferrule0.25 mm²YE
-
+ + +
+ + + + + + + +
Crimp ferrule0.25 mm²YE
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_2 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_2 [label=< +
- - - - - -
Crimp ferrule0.25 mm²YE
-
+ + +
+ + + + + + + +
Crimp ferrule0.25 mm²YE
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
4x0.14 mm² (26 AWG)0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND BK X2:1:GND
X1:2:+5V RD X2:2:+5V
X1:3:SCL YE X2:3:SCL
X1:4:SDA GN X2:4:SDA
 
+
+> shape=box style="filled,dashed"] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p3l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=< - - - - + W1:w1:e -- W1:w1:w [color="#000000:#000000:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#00AA00:#000000" straight=straight] + W2 [label=< +
- - -
W1
-
- - - - -
4x0.14 mm² (26 AWG)0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - BK - X2:1:GND
- - - - -
-
X1:2:+5V - RD - X2:2:+5V
- - - - -
-
X1:3:SCL - YE - X2:3:SCL
- - - - -
-
X1:4:SDA - GN - X2:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W2
+
+ + + + + + +
4x0.14 mm² (26 AWG)0.4 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND BK X3:1:GND
X1:2:+5V RD X3:2:+5V
X1:3:SCL YE X3:3:SCL
X1:4:SDA GN X3:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] +> shape=box style="filled,dashed"] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W2:w1:w W2:w1:e -- X3:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W2:w2:w W2:w2:e -- X3:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p3r:e -- W2:w3:w W2:w3:e -- X3:p3l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] X1:p4r:e -- W2:w4:w W2:w4:e -- X3:p4l:w - W2 [label=< - - - - + W2:w1:e -- W2:w1:w [color="#000000:#000000:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W2:w3:e -- W2:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W2:w4:e -- W2:w4:w [color="#000000:#00AA00:#000000" straight=straight] + W3 [label=< +
- - -
W2
-
- - - - -
4x0.14 mm² (26 AWG)0.4 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - BK - X3:1:GND
- - - - -
-
X1:2:+5V - RD - X3:2:+5V
- - - - -
-
X1:3:SCL - YE - X3:3:SCL
- - - - -
-
X1:4:SDA - GN - X3:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W3
+
+ + + + + + +
4x0.14 mm² (26 AWG)0.3 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND BK X4:1:GND
X1:5:MISO BU X4:3:MISO
X1:6:MOSI OG X4:4:MOSI
X1:7:SCK VT X4:5:SCK
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] +> shape=box style="filled,dashed"] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W3:w1:w W3:w1:e -- X4:p1l:w - edge [color="#000000:#0066ff:#000000"] + edge [color="#000000:#0066FF:#000000"] X1:p5r:e -- W3:w2:w W3:w2:e -- X4:p3l:w - edge [color="#000000:#ff8000:#000000"] + edge [color="#000000:#FF8000:#000000"] X1:p6r:e -- W3:w3:w W3:w3:e -- X4:p4l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X1:p7r:e -- W3:w4:w W3:w4:e -- X4:p5l:w - W3 [label=< - - - - -
- - -
W3
-
- - - - -
4x0.14 mm² (26 AWG)0.3 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - BK - X4:1:GND
- - - - -
-
X1:5:MISO - BU - X4:3:MISO
- - - - -
-
X1:6:MOSI - OG - X4:4:MOSI
- - - - -
-
X1:7:SCK - VT - X4:5:SCK
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#000000:#000000"] - __F_1:e -- W4:w1:w - W4:w1:e -- X4:p1l:w - edge [color="#000000:#ff0000:#000000"] - __F_2:e -- W4:w2:w - W4:w2:e -- X4:p2l:w + W3:w1:e -- W3:w1:w [color="#000000:#000000:#000000" straight=straight] + W3:w2:e -- W3:w2:w [color="#000000:#0066FF:#000000" straight=straight] + W3:w3:e -- W3:w3:w [color="#000000:#FF8000:#000000" straight=straight] + W3:w4:e -- W3:w4:w [color="#000000:#8000FF:#000000" straight=straight] W4 [label=< - - - - +
- - -
W4
-
- - - - -
2x0.25 mm² (24 AWG)0.3 m
-
- - - - - - - - - - - - - - - - - - - -
 
- 1:BK - X4:1:GND
- - - - -
-
- 2:RD - X4:2:+12V
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W4
+
+ + + + + + +
2x0.25 mm² (24 AWG)0.3 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
1:BK X4:1:GND
2:RD X4:2:+12V
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + edge [color="#000000:#000000:#000000"] + AUTOGENERATED_F_1:e -- W4:w1:w + W4:w1:e -- X4:p1l:w + edge [color="#000000:#FF0000:#000000"] + AUTOGENERATED_F_2:e -- W4:w2:w + W4:w2:e -- X4:p2l:w + W4:w1:e -- W4:w1:w [color="#000000:#000000:#000000" straight=straight] + W4:w2:e -- W4:w2:w [color="#000000:#FF0000:#000000" straight=straight] } diff --git a/examples/demo02.html b/examples/demo02.html index da7efe0..6eadb3b 100644 --- a/examples/demo02.html +++ b/examples/demo02.html @@ -1,18 +1,23 @@ + - - + + WireViz Demo 2 +
@@ -188,512 +202,608 @@
- - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -8-pin - -GND - -1 - -+5V - -2 - -SCL - -3 - -SDA - -4 - -MISO - -5 - -MOSI - -6 - -SCK - -7 - -N/C - -8 + + + +X1 + +Molex KK 254 + +female + +8-pin + +GND + +1 + ++5V + +2 + +SCL + +3 + +SDA + +4 + +MISO + +5 + +MOSI + +6 + +SCK + +7 + +N/C + +8 - + W1 - - -W1 - -4x - -0.14 mm² (26 AWG) - -0.2 m -  -X1:1:GND -     BK     -X2:1:GND - - - -X1:2:+5V -     RD     -X2:2:+5V - - - -X1:3:SCL -     YE     -X2:3:SCL - - - -X1:4:SDA -     GN     -X2:4:SDA - - - -  + + + +W1 + +4x + +0.14 mm² (26 AWG) + +0.2 m +  + X1:1:GND + +BK + +X2:1:GND + X1:2:+5V + +RD + +X2:2:+5V + X1:3:SCL + +YE + +X2:3:SCL + X1:4:SDA + +GN + +X2:4:SDA +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + - + X1:e--W1:w - - - - - - -X1:e--W1:w - - - + + + - + W2 - - -W2 - -4x - -0.14 mm² (26 AWG) - -0.4 m -  -X1:1:GND -     BK     -X3:1:GND - - - -X1:2:+5V -     RD     -X3:2:+5V - - - -X1:3:SCL -     YE     -X3:3:SCL - - - -X1:4:SDA -     GN     -X3:4:SDA - - - -  + + + +W2 + +4x + +0.14 mm² (26 AWG) + +0.4 m +  + X1:1:GND + +BK + +X3:1:GND + X1:2:+5V + +RD + +X3:2:+5V + X1:3:SCL + +YE + +X3:3:SCL + X1:4:SDA + +GN + +X3:4:SDA +  - + X1:e--W2:w - - - + + + - + X1:e--W2:w - - - + + + - + X1:e--W2:w - - - + + + - + X1:e--W2:w - - - + + + - + W3 - - -W3 - -4x - -0.14 mm² (26 AWG) - -0.3 m -  -X1:1:GND -     BK     -X4:1:GND - - - -X1:5:MISO -     BU     -X4:3:MISO - - - -X1:6:MOSI -     OG     -X4:4:MOSI - - - -X1:7:SCK -     VT     -X4:5:SCK - - - -  + + + +W3 + +4x + +0.14 mm² (26 AWG) + +0.3 m +  + X1:1:GND + +BK + +X4:1:GND + X1:5:MISO + +BU + +X4:3:MISO + X1:6:MOSI + +OG + +X4:4:MOSI + X1:7:SCK + +VT + +X4:5:SCK +  - + X1:e--W3:w - - - + + + - + X1:e--W3:w - - - + + + - + X1:e--W3:w - - - + + + - + X1:e--W3:w - - - + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -+5V - -3 - -SCL - -4 - -SDA + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + ++5V + +3 + +SCL + +4 + +SDA + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -+5V - -3 - -SCL - -4 - -SDA + + + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + ++5V + +3 + +SCL + +4 + +SDA + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + - + X4 - - -X4 - -Molex KK 254 - -female - -5-pin - -1 - -GND - -2 - -+12V - -3 - -MISO - -4 - -MOSI - -5 - -SCK + + + +X4 + +Molex KK 254 + +female + +5-pin + +1 + +GND + +2 + ++12V + +3 + +MISO + +4 + +MOSI + +5 + +SCK - - -__F_1 - - -Crimp ferrule - -0.25 mm² - -YE - - + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +AUTOGENERATED_F_1 + + + +Crimp ferrule + +0.25 mm² + +YE + + - + W4 - - -W4 - -2x - -0.25 mm² (24 AWG) - -0.3 m -  -     1:BK     -X4:1:GND - - - -     2:RD     -X4:2:+12V - - - -  + + + +W4 + +2x + +0.25 mm² (24 AWG) + +0.3 m +  + + +1:BK + +X4:1:GND + + +2:RD + +X4:2:+12V +  - - -__F_1:e--W4:w - - - - - - -__F_2 - - -Crimp ferrule - -0.25 mm² - -YE - - - - - -__F_2:e--W4:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W2:e--X3:w - - - - - - -W2:e--X3:w - - - - - - -W2:e--X3:w - - - - - - -W2:e--X3:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - + + +AUTOGENERATED_F_1:e--W4:w + + + - + W4:e--X4:w - - - + + + - + W4:e--X4:w - - - + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +AUTOGENERATED_F_2 + + + +Crimp ferrule + +0.25 mm² + +YE + + + + + +AUTOGENERATED_F_2:e--W4:w + + + @@ -708,94 +818,94 @@
- + + + - - - + + + - - - + + + - - - + + + - - - - - + + + - - - + + + - - - + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
12122m Wire, 0.14 mm², YE0.6m W1, W2
11111m Wire, 0.14 mm², VT0.3m W3
10102m Wire, 0.14 mm², RD0.6m W1, W2
991m Wire, 0.14 mm², OG0.3m W3
8Wire, 0.14 mm², GN0.682 mWire, 0.14 mm², GN W1, W2
7Wire, 0.14 mm², BU0.371 mWire, 0.14 mm², BU W3
6Wire, 0.14 mm², BK0.963 mWire, 0.14 mm², BK W1, W2, W3
5Connector, Molex KK 254, female, 8 pins5 1X1
4Connector, Molex KK 254, female, 5 pins1X4
3Connector, Molex KK 254, female, 4 pins2X2, X3
2Connector, Crimp ferrule, 0.25 mm², YE2
1Cable, 2 x 0.25 mm²0.3 mCable, 2 x 0.25 mm² W4
IdDescription41Connector, Molex KK 254, female, 8 pinsX1
31Connector, Molex KK 254, female, 5 pinsX4
22Connector, Molex KK 254, female, 4 pinsX2, X3
12Connector, Crimp ferrule, 0.25 mm², YE
# Qty UnitDescription Designators
@@ -886,4 +996,5 @@
- + + \ No newline at end of file diff --git a/examples/demo02.png b/examples/demo02.png index 9b5577e..7987b7b 100644 Binary files a/examples/demo02.png and b/examples/demo02.png differ diff --git a/examples/demo02.svg b/examples/demo02.svg index a219e17..d171929 100644 --- a/examples/demo02.svg +++ b/examples/demo02.svg @@ -1,512 +1,608 @@ - - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -8-pin - -GND - -1 - -+5V - -2 - -SCL - -3 - -SDA - -4 - -MISO - -5 - -MOSI - -6 - -SCK - -7 - -N/C - -8 + + + +X1 + +Molex KK 254 + +female + +8-pin + +GND + +1 + ++5V + +2 + +SCL + +3 + +SDA + +4 + +MISO + +5 + +MOSI + +6 + +SCK + +7 + +N/C + +8 - + W1 - - -W1 - -4x - -0.14 mm² (26 AWG) - -0.2 m -  -X1:1:GND -     BK     -X2:1:GND - - - -X1:2:+5V -     RD     -X2:2:+5V - - - -X1:3:SCL -     YE     -X2:3:SCL - - - -X1:4:SDA -     GN     -X2:4:SDA - - - -  + + + +W1 + +4x + +0.14 mm² (26 AWG) + +0.2 m +  + X1:1:GND + +BK + +X2:1:GND + X1:2:+5V + +RD + +X2:2:+5V + X1:3:SCL + +YE + +X2:3:SCL + X1:4:SDA + +GN + +X2:4:SDA +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + - + X1:e--W1:w - - - - - - -X1:e--W1:w - - - + + + - + W2 - - -W2 - -4x - -0.14 mm² (26 AWG) - -0.4 m -  -X1:1:GND -     BK     -X3:1:GND - - - -X1:2:+5V -     RD     -X3:2:+5V - - - -X1:3:SCL -     YE     -X3:3:SCL - - - -X1:4:SDA -     GN     -X3:4:SDA - - - -  + + + +W2 + +4x + +0.14 mm² (26 AWG) + +0.4 m +  + X1:1:GND + +BK + +X3:1:GND + X1:2:+5V + +RD + +X3:2:+5V + X1:3:SCL + +YE + +X3:3:SCL + X1:4:SDA + +GN + +X3:4:SDA +  - + X1:e--W2:w - - - + + + - + X1:e--W2:w - - - + + + - + X1:e--W2:w - - - + + + - + X1:e--W2:w - - - + + + - + W3 - - -W3 - -4x - -0.14 mm² (26 AWG) - -0.3 m -  -X1:1:GND -     BK     -X4:1:GND - - - -X1:5:MISO -     BU     -X4:3:MISO - - - -X1:6:MOSI -     OG     -X4:4:MOSI - - - -X1:7:SCK -     VT     -X4:5:SCK - - - -  + + + +W3 + +4x + +0.14 mm² (26 AWG) + +0.3 m +  + X1:1:GND + +BK + +X4:1:GND + X1:5:MISO + +BU + +X4:3:MISO + X1:6:MOSI + +OG + +X4:4:MOSI + X1:7:SCK + +VT + +X4:5:SCK +  - + X1:e--W3:w - - - + + + - + X1:e--W3:w - - - + + + - + X1:e--W3:w - - - + + + - + X1:e--W3:w - - - + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -+5V - -3 - -SCL - -4 - -SDA + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + ++5V + +3 + +SCL + +4 + +SDA + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -+5V - -3 - -SCL - -4 - -SDA + + + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + ++5V + +3 + +SCL + +4 + +SDA + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + - + X4 - - -X4 - -Molex KK 254 - -female - -5-pin - -1 - -GND - -2 - -+12V - -3 - -MISO - -4 - -MOSI - -5 - -SCK + + + +X4 + +Molex KK 254 + +female + +5-pin + +1 + +GND + +2 + ++12V + +3 + +MISO + +4 + +MOSI + +5 + +SCK - - -__F_1 - - -Crimp ferrule - -0.25 mm² - -YE - - + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +AUTOGENERATED_F_1 + + + +Crimp ferrule + +0.25 mm² + +YE + + - + W4 - - -W4 - -2x - -0.25 mm² (24 AWG) - -0.3 m -  -     1:BK     -X4:1:GND - - - -     2:RD     -X4:2:+12V - - - -  + + + +W4 + +2x + +0.25 mm² (24 AWG) + +0.3 m +  + + +1:BK + +X4:1:GND + + +2:RD + +X4:2:+12V +  - - -__F_1:e--W4:w - - - - - - -__F_2 - - -Crimp ferrule - -0.25 mm² - -YE - - - - - -__F_2:e--W4:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W2:e--X3:w - - - - - - -W2:e--X3:w - - - - - - -W2:e--X3:w - - - - - - -W2:e--X3:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - + + +AUTOGENERATED_F_1:e--W4:w + + + - + W4:e--X4:w - - - + + + - + W4:e--X4:w - - - + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +AUTOGENERATED_F_2 + + + +Crimp ferrule + +0.25 mm² + +YE + + + + + +AUTOGENERATED_F_2:e--W4:w + + + diff --git a/examples/demo02_wv_gvpr.gvpr b/examples/demo02_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/demo02_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex01.bom.tsv b/examples/ex01.bom.tsv index 0b6062d..b768b4f 100644 --- a/examples/ex01.bom.tsv +++ b/examples/ex01.bom.tsv @@ -1,3 +1,3 @@ -Id Description Qty Unit Designators -1 Cable, Serial, 4 x 0.25 mm² shielded 0.2 m W1 -2 Connector, Molex KK 254, female, 4 pins 2 X1, X2 +# Qty Unit Description Designators +1 2 Connector, Molex KK 254, female, 4 pins X1, X2 +2 1 m Cable, Serial, 4 x 0.25 mm² shielded W1 diff --git a/examples/ex01.gv b/examples/ex01.gv index 8dd0e4c..753b16d 100644 --- a/examples/ex01.gv +++ b/examples/ex01.gv @@ -1,188 +1,209 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
RX3
TX4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
RX3
TX4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3RX
4TX
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3RX
4TX
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + + +
Serial4x0.25 mm² (24 AWG)+ S0.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
 
+
+> 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"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#ff8000:#000000"] + edge [color="#000000:#FF8000:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p4l:w - edge [color="#000000:#ffff00:#000000"] + 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=< - - - - -
- - -
W1
-
- - - - - - -
Serial4x0.25 mm² (24 AWG)+ S0.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:GNDShield
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + X1:p1r:e -- W1:w5:w + W1:w1:e -- W1:w1:w [color="#000000:#895956:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FF8000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w5:e -- W1:w5:w [color="#000000" straight=straight] } diff --git a/examples/ex01.html b/examples/ex01.html index 927f8e9..8f2a7cb 100644 --- a/examples/ex01.html +++ b/examples/ex01.html @@ -1,7 +1,7 @@ - + ex01 - +

ex01

Diagram

@@ -30,178 +30,212 @@
- - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -RX - -3 - -TX - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +RX + +3 + +TX + +4 - + W1 - - -W1 - -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 - -  + + + +W1 + +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 + + +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - +W1:e--W1:w + + + + + + +W1:e--W1:w + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -RX - -4 - -TX + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + @@ -217,26 +251,26 @@
- - + + - - - - - - - - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, Serial, 4 x 0.25 mm² shielded0.2mW1
2Connector, Molex KK 254, female, 4 pins1 2 Connector, Molex KK 254, female, 4 pins X1, X2
21mCable, Serial, 4 x 0.25 mm² shieldedW1
diff --git a/examples/ex01.png b/examples/ex01.png index c97f996..8d34a9a 100644 Binary files a/examples/ex01.png and b/examples/ex01.png differ diff --git a/examples/ex01.svg b/examples/ex01.svg index 7c3940c..1f0c616 100644 --- a/examples/ex01.svg +++ b/examples/ex01.svg @@ -1,178 +1,212 @@ - - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -RX - -3 - -TX - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +RX + +3 + +TX + +4 - + W1 - - -W1 - -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 - -  + + + +W1 + +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 + + +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - +W1:e--W1:w + + + + + + +W1:e--W1:w + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -RX - -4 - -TX + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + diff --git a/examples/ex01_wv_gvpr.gvpr b/examples/ex01_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex01_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex02.bom.tsv b/examples/ex02.bom.tsv index 8cd97d8..851dfdb 100644 --- a/examples/ex02.bom.tsv +++ b/examples/ex02.bom.tsv @@ -1,5 +1,5 @@ -Id Description Qty Unit Designators -1 Cable, 2 x 0.25 mm² 0.4 m W1, W2 -2 Cable, 2 x 20 AWG 0.2 m W3 -3 Connector, Molex Micro-Fit, female, 2 pins 3 X2, X3, X4 -4 Connector, Molex Micro-Fit, male, 2 pins 1 X1 +# Qty Unit Description Designators +1 3 Connector, Molex Micro-Fit, female, 2 pins X2, X3, X4 +2 1 Connector, Molex Micro-Fit, male, 2 pins X1 +3 2 m Cable, 2 x 0.25 mm² W1, W2 +4 1 m Cable, 2 x 20 awg W3 diff --git a/examples/ex02.gv b/examples/ex02.gv index c0d8938..e309df4 100644 --- a/examples/ex02.gv +++ b/examples/ex02.gv @@ -1,299 +1,351 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex Micro-Fitmale2-pin
-
- - - - - - - - - -
GND1
VCC2
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex Micro-Fitmale2-pin
+
+ + + + + + + + + +
GND1
VCC2
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex Micro-Fitfemale2-pin
-
- - - - - - - - - -
1GND
2VCC
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex Micro-Fitfemale2-pin
+
+ + + + + + + + + +
1GND
2VCC
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - +
- - -
X3
-
- - - - -
Molex Micro-Fitfemale2-pin
-
- - - - - - - - - -
1GND
2VCC
-
+ + + + + + + + +
+ + + + +
X3
+
+ + + + + + +
Molex Micro-Fitfemale2-pin
+
+ + + + + + + + + +
1GND
2VCC
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X4 [label=< - - - - +
- - -
X4
-
- - - - -
Molex Micro-Fitfemale2-pin
-
- - - - - - - - - -
1GND
2VCC
-
+ + + + + + + + +
+ + + + +
X4
+
+ + + + + + +
Molex Micro-Fitfemale2-pin
+
+ + + + + + + + + +
1GND
2VCC
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
2x0.25 mm² (24 AWG)0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND 1:BK X2:1:GND
X1:2:VCC 2:RD X2:2:VCC
 
+
+> shape=box style=filled] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - W1 [label=< - - - - + W1:w1:e -- W1:w1:w [color="#000000:#000000:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W2 [label=< +
- - -
W1
-
- - - - -
2x0.25 mm² (24 AWG)0.2 m
-
- - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - 1:BK - X2:1:GND
- - - - -
-
X1:2:VCC - 2:RD - X2:2:VCC
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W2
+
+ + + + + + +
2x0.25 mm² (24 AWG)0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND 1:BK X3:1:GND
X1:2:VCC 2:RD X3:2:VCC
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W2:w1:w W2:w1:e -- X3:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W2:w2:w W2:w2:e -- X3:p2l:w - W2 [label=< - - - - + W2:w1:e -- W2:w1:w [color="#000000:#000000:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W3 [label=< +
- - -
W2
-
- - - - -
2x0.25 mm² (24 AWG)0.2 m
-
- - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - 1:BK - X3:1:GND
- - - - -
-
X1:2:VCC - 2:RD - X3:2:VCC
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W3
+
+ + + + + + +
2x20 awg (0.75 mm²)0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND 1:BK X4:1:GND
X1:2:VCC 2:RD X4:2:VCC
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W3:w1:w W3:w1:e -- X4:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W3:w2:w W3:w2:e -- X4:p2l:w - W3 [label=< - - - - -
- - -
W3
-
- - - - -
2x20 AWG (0.75 mm²)0.2 m
-
- - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - 1:BK - X4:1:GND
- - - - -
-
X1:2:VCC - 2:RD - X4:2:VCC
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + W3:w1:e -- W3:w1:w [color="#000000:#000000:#000000" straight=straight] + W3:w2:e -- W3:w2:w [color="#000000:#FF0000:#000000" straight=straight] } diff --git a/examples/ex02.html b/examples/ex02.html index 23a4d88..5d0b13a 100644 --- a/examples/ex02.html +++ b/examples/ex02.html @@ -1,7 +1,7 @@ - + ex02 - +

ex02

Diagram

@@ -30,261 +30,304 @@
- - - - + + + X1 - - -X1 - -Molex Micro-Fit - -male - -2-pin - -GND - -1 - -VCC - -2 + + + +X1 + +Molex Micro-Fit + +male + +2-pin + +GND + +1 + +VCC + +2 - + W1 - - -W1 - -2x - -0.25 mm² (24 AWG) - -0.2 m -  -X1:1:GND -     1:BK     -X2:1:GND - - - -X1:2:VCC -     2:RD     -X2:2:VCC - - - -  + + + +W1 + +2x + +0.25 mm² (24 AWG) + +0.2 m +  + X1:1:GND + +1:BK + +X2:1:GND + X1:2:VCC + +2:RD + +X2:2:VCC +  X1:e--W1:w - - - + + + - + X1:e--W1:w - - - + + + - + W2 - - -W2 - -2x - -0.25 mm² (24 AWG) - -0.2 m -  -X1:1:GND -     1:BK     -X3:1:GND - - - -X1:2:VCC -     2:RD     -X3:2:VCC - - - -  + + + +W2 + +2x + +0.25 mm² (24 AWG) + +0.2 m +  + X1:1:GND + +1:BK + +X3:1:GND + X1:2:VCC + +2:RD + +X3:2:VCC +  - + X1:e--W2:w - - - + + + - + X1:e--W2:w - - - + + + - + W3 - - -W3 - -2x - -20 AWG (0.75 mm²) - -0.2 m -  -X1:1:GND -     1:BK     -X4:1:GND - - - -X1:2:VCC -     2:RD     -X4:2:VCC - - - -  + + + +W3 + +2x + +20 awg (0.75 mm²) + +0.2 m +  + X1:1:GND + +1:BK + +X4:1:GND + X1:2:VCC + +2:RD + +X4:2:VCC +  - + X1:e--W3:w - - - + + + - + X1:e--W3:w - - - + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC + + + +X2 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC + + + +X3 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + - + X4 - - -X4 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W2:e--X3:w - - - - - - -W2:e--X3:w - - - + + + +X4 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC - + W3:e--X4:w - - - + + + - + W3:e--X4:w - - - + + + @@ -300,40 +343,40 @@
- - + + - - - - - - - - - - - - - - - - + + - - + + + + + + + + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 2 x 0.25 mm²0.4mW1, W2
2Cable, 2 x 20 AWG0.2mW3
3Connector, Molex Micro-Fit, female, 2 pins1 3 Connector, Molex Micro-Fit, female, 2 pins X2, X3, X4
4Connector, Molex Micro-Fit, male, 2 pins2 1 Connector, Molex Micro-Fit, male, 2 pins X1
32mCable, 2 x 0.25 mm²W1, W2
41mCable, 2 x 20 awgW3
diff --git a/examples/ex02.png b/examples/ex02.png index e1224b7..e4b39d4 100644 Binary files a/examples/ex02.png and b/examples/ex02.png differ diff --git a/examples/ex02.svg b/examples/ex02.svg index 2d7b8ad..8c73259 100644 --- a/examples/ex02.svg +++ b/examples/ex02.svg @@ -1,261 +1,304 @@ - - - - + + + X1 - - -X1 - -Molex Micro-Fit - -male - -2-pin - -GND - -1 - -VCC - -2 + + + +X1 + +Molex Micro-Fit + +male + +2-pin + +GND + +1 + +VCC + +2 - + W1 - - -W1 - -2x - -0.25 mm² (24 AWG) - -0.2 m -  -X1:1:GND -     1:BK     -X2:1:GND - - - -X1:2:VCC -     2:RD     -X2:2:VCC - - - -  + + + +W1 + +2x + +0.25 mm² (24 AWG) + +0.2 m +  + X1:1:GND + +1:BK + +X2:1:GND + X1:2:VCC + +2:RD + +X2:2:VCC +  X1:e--W1:w - - - + + + - + X1:e--W1:w - - - + + + - + W2 - - -W2 - -2x - -0.25 mm² (24 AWG) - -0.2 m -  -X1:1:GND -     1:BK     -X3:1:GND - - - -X1:2:VCC -     2:RD     -X3:2:VCC - - - -  + + + +W2 + +2x + +0.25 mm² (24 AWG) + +0.2 m +  + X1:1:GND + +1:BK + +X3:1:GND + X1:2:VCC + +2:RD + +X3:2:VCC +  - + X1:e--W2:w - - - + + + - + X1:e--W2:w - - - + + + - + W3 - - -W3 - -2x - -20 AWG (0.75 mm²) - -0.2 m -  -X1:1:GND -     1:BK     -X4:1:GND - - - -X1:2:VCC -     2:RD     -X4:2:VCC - - - -  + + + +W3 + +2x + +20 awg (0.75 mm²) + +0.2 m +  + X1:1:GND + +1:BK + +X4:1:GND + X1:2:VCC + +2:RD + +X4:2:VCC +  - + X1:e--W3:w - - - + + + - + X1:e--W3:w - - - + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC + + + +X2 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC + + + +X3 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC + + + +W2:e--X3:w + + + + + + +W2:e--X3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + - + X4 - - -X4 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W2:e--X3:w - - - - - - -W2:e--X3:w - - - + + + +X4 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC - + W3:e--X4:w - - - + + + - + W3:e--X4:w - - - + + + diff --git a/examples/ex02_wv_gvpr.gvpr b/examples/ex02_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex02_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex03.bom.tsv b/examples/ex03.bom.tsv index 5bda765..392753a 100644 --- a/examples/ex03.bom.tsv +++ b/examples/ex03.bom.tsv @@ -1,5 +1,5 @@ -Id Description Qty Unit Designators -1 Connector, Molex Micro-Fit, female, 2 pins 3 X2, X3, X4 -2 Connector, Molex Micro-Fit, male, 2 pins 1 X1 -3 Wire, 0.25 mm², BK 0.6 m W1 -4 Wire, 0.25 mm², RD 0.6 m W1 +# Qty Unit Description Designators +1 3 Connector, Molex Micro-Fit, female, 2 pins X2, X3, X4 +2 1 Connector, Molex Micro-Fit, male, 2 pins X1 +3 3 m Wire, 0.25 mm², BK W1 +4 3 m Wire, 0.25 mm², RD W1 diff --git a/examples/ex03.gv b/examples/ex03.gv index 486b1e2..fb145a3 100644 --- a/examples/ex03.gv +++ b/examples/ex03.gv @@ -1,255 +1,285 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex Micro-Fitmale2-pin
-
- - - - - - - - - -
GND1
VCC2
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex Micro-Fitmale2-pin
+
+ + + + + + + + + +
GND1
VCC2
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex Micro-Fitfemale2-pin
-
- - - - - - - - - -
1GND
2VCC
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex Micro-Fitfemale2-pin
+
+ + + + + + + + + +
1GND
2VCC
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - +
- - -
X3
-
- - - - -
Molex Micro-Fitfemale2-pin
-
- - - - - - - - - -
1GND
2VCC
-
+ + + + + + + + +
+ + + + +
X3
+
+ + + + + + +
Molex Micro-Fitfemale2-pin
+
+ + + + + + + + + +
1GND
2VCC
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X4 [label=< - - - - +
- - -
X4
-
- - - - -
Molex Micro-Fitfemale2-pin
-
- - - - - - - - - -
1GND
2VCC
-
+ + + + + + + + +
+ + + + +
X4
+
+ + + + + + +
Molex Micro-Fitfemale2-pin
+
+ + + + + + + + + +
1GND
2VCC
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
6x0.25 mm² (24 AWG)0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND BK X2:1:GND
X1:2:VCC RD X2:2:VCC
X1:1:GND BK X3:1:GND
X1:2:VCC RD X3:2:VCC
X1:1:GND BK X4:1:GND
X1:2:VCC RD X4:2:VCC
 
+
+> shape=box style="filled,dashed"] edge [color="#000000:#000000:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w edge [color="#000000:#000000:#000000"] X1:p1r:e -- W1:w3:w W1:w3:e -- X3:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W1:w4:w W1:w4:e -- X3:p2l:w edge [color="#000000:#000000:#000000"] X1:p1r:e -- W1:w5:w W1:w5:e -- X4:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W1:w6:w W1:w6:e -- X4:p2l:w - W1 [label=< - - - - -
- - -
W1
-
- - - - -
6x0.25 mm² (24 AWG)0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - BK - X2:1:GND
- - - - -
-
X1:2:VCC - RD - X2:2:VCC
- - - - -
-
X1:1:GND - BK - X3:1:GND
- - - - -
-
X1:2:VCC - RD - X3:2:VCC
- - - - -
-
X1:1:GND - BK - X4:1:GND
- - - - -
-
X1:2:VCC - RD - X4:2:VCC
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] + W1:w1:e -- W1:w1:w [color="#000000:#000000:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#000000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w5:e -- W1:w5:w [color="#000000:#000000:#000000" straight=straight] + W1:w6:e -- W1:w6:w [color="#000000:#FF0000:#000000" straight=straight] } diff --git a/examples/ex03.html b/examples/ex03.html index 59b38ef..7152643 100644 --- a/examples/ex03.html +++ b/examples/ex03.html @@ -1,7 +1,7 @@ - + ex03 - +

ex03

Diagram

@@ -30,231 +30,272 @@
- - - - + + + X1 - - -X1 - -Molex Micro-Fit - -male - -2-pin - -GND - -1 - -VCC - -2 + + + +X1 + +Molex Micro-Fit + +male + +2-pin + +GND + +1 + +VCC + +2 - + W1 - - -W1 - -6x - -0.25 mm² (24 AWG) - -0.2 m -  -X1:1:GND -     BK     -X2:1:GND - - - -X1:2:VCC -     RD     -X2:2:VCC - - - -X1:1:GND -     BK     -X3:1:GND - - - -X1:2:VCC -     RD     -X3:2:VCC - - - -X1:1:GND -     BK     -X4:1:GND - - - -X1:2:VCC -     RD     -X4:2:VCC - - - -  + + + +W1 + +6x + +0.25 mm² (24 AWG) + +0.2 m +  + X1:1:GND + +BK + +X2:1:GND + X1:2:VCC + +RD + +X2:2:VCC + X1:1:GND + +BK + +X3:1:GND + X1:2:VCC + +RD + +X3:2:VCC + X1:1:GND + +BK + +X4:1:GND + X1:2:VCC + +RD + +X4:2:VCC +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC + + + +X2 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + X3 - - -X3 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC + + + +X3 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC + + + +W1:e--X3:w + + + + + + +W1:e--X3:w + + + - + X4 - - -X4 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X3:w - - - - - - -W1:e--X3:w - - - + + + +X4 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC - + W1:e--X4:w - - - + + + - + W1:e--X4:w - - - + + + @@ -270,38 +311,38 @@
- - + + - - + + - - + + - - - + + + - - - + + +
IdDescription# Qty UnitDescription Designators
1Connector, Molex Micro-Fit, female, 2 pins1 3 Connector, Molex Micro-Fit, female, 2 pins X2, X3, X4
2Connector, Molex Micro-Fit, male, 2 pins2 1 Connector, Molex Micro-Fit, male, 2 pins X1
3Wire, 0.25 mm², BK0.633 mWire, 0.25 mm², BK W1
4Wire, 0.25 mm², RD0.643 mWire, 0.25 mm², RD W1
diff --git a/examples/ex03.png b/examples/ex03.png index e079fa0..c9b6166 100644 Binary files a/examples/ex03.png and b/examples/ex03.png differ diff --git a/examples/ex03.svg b/examples/ex03.svg index 97c6385..d5e6b37 100644 --- a/examples/ex03.svg +++ b/examples/ex03.svg @@ -1,231 +1,272 @@ - - - - + + + X1 - - -X1 - -Molex Micro-Fit - -male - -2-pin - -GND - -1 - -VCC - -2 + + + +X1 + +Molex Micro-Fit + +male + +2-pin + +GND + +1 + +VCC + +2 - + W1 - - -W1 - -6x - -0.25 mm² (24 AWG) - -0.2 m -  -X1:1:GND -     BK     -X2:1:GND - - - -X1:2:VCC -     RD     -X2:2:VCC - - - -X1:1:GND -     BK     -X3:1:GND - - - -X1:2:VCC -     RD     -X3:2:VCC - - - -X1:1:GND -     BK     -X4:1:GND - - - -X1:2:VCC -     RD     -X4:2:VCC - - - -  + + + +W1 + +6x + +0.25 mm² (24 AWG) + +0.2 m +  + X1:1:GND + +BK + +X2:1:GND + X1:2:VCC + +RD + +X2:2:VCC + X1:1:GND + +BK + +X3:1:GND + X1:2:VCC + +RD + +X3:2:VCC + X1:1:GND + +BK + +X4:1:GND + X1:2:VCC + +RD + +X4:2:VCC +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC + + + +X2 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + X3 - - -X3 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC + + + +X3 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC + + + +W1:e--X3:w + + + + + + +W1:e--X3:w + + + - + X4 - - -X4 - -Molex Micro-Fit - -female - -2-pin - -1 - -GND - -2 - -VCC - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X3:w - - - - - - -W1:e--X3:w - - - + + + +X4 + +Molex Micro-Fit + +female + +2-pin + +1 + +GND + +2 + +VCC - + W1:e--X4:w - - - + + + - + W1:e--X4:w - - - + + + diff --git a/examples/ex03_wv_gvpr.gvpr b/examples/ex03_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex03_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex04.bom.tsv b/examples/ex04.bom.tsv index 25de333..86cd3cb 100644 --- a/examples/ex04.bom.tsv +++ b/examples/ex04.bom.tsv @@ -1,8 +1,8 @@ -Id Description Qty Unit Designators -1 Connector, Crimp ferrule 12 -2 Wire, 0.25 mm², BN 0.2 m W1 -3 Wire, 0.25 mm², BU 0.2 m W1 -4 Wire, 0.25 mm², GN 0.2 m W1 -5 Wire, 0.25 mm², OG 0.2 m W1 -6 Wire, 0.25 mm², RD 0.2 m W1 -7 Wire, 0.25 mm², YE 0.2 m W1 +# Qty Unit Description Designators +1 12 Connector, Crimp ferrule +2 1 m Wire, 0.25 mm², BN W1 +3 1 m Wire, 0.25 mm², BU W1 +4 1 m Wire, 0.25 mm², GN W1 +5 1 m Wire, 0.25 mm², OG W1 +6 1 m Wire, 0.25 mm², RD W1 +7 1 m Wire, 0.25 mm², YE W1 diff --git a/examples/ex04.gv b/examples/ex04.gv index 2db8c5c..4c23323 100644 --- a/examples/ex04.gv +++ b/examples/ex04.gv @@ -1,251 +1,289 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] - __F_1 [label=< - - + AUTOGENERATED_F_1 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_2 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_2 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_3 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_3 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_4 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_4 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_5 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_5 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_6 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_6 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_7 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_7 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_8 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_8 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_9 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_9 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_10 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_10 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_11 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_11 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_12 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_12 [label=< +
- - -
Crimp ferrule
-
+ + +
+ + + + +
Crimp ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#895956:#000000"] - __F_1:e -- W1:w1:w - W1:w1:e -- __F_7:w - edge [color="#000000:#ff0000:#000000"] - __F_2:e -- W1:w2:w - W1:w2:e -- __F_8:w - edge [color="#000000:#ff8000:#000000"] - __F_3:e -- W1:w3:w - W1:w3:e -- __F_9:w - edge [color="#000000:#ffff00:#000000"] - __F_4:e -- W1:w4:w - W1:w4:e -- __F_10:w - edge [color="#000000:#00ff00:#000000"] - __F_5:e -- W1:w5:w - W1:w5:e -- __F_11:w - edge [color="#000000:#0066ff:#000000"] - __F_6:e -- W1:w6:w - W1:w6:e -- __F_12:w +> shape=box style=filled] W1 [label=< - - - - +
- - -
W1
-
- - - - -
6x0.25 mm² (24 AWG)0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- BN -
- - - - -
-
- RD -
- - - - -
-
- OG -
- - - - -
-
- YE -
- - - - -
-
- GN -
- - - - -
-
- BU -
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
6x0.25 mm² (24 AWG)0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
BN
RD
OG
YE
GN
BU
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] +> shape=box style="filled,dashed"] + edge [color="#000000:#895956:#000000"] + AUTOGENERATED_F_1:e -- W1:w1:w + W1:w1:e -- AUTOGENERATED_F_7:w + edge [color="#000000:#FF0000:#000000"] + AUTOGENERATED_F_2:e -- W1:w2:w + W1:w2:e -- AUTOGENERATED_F_8:w + edge [color="#000000:#FF8000:#000000"] + AUTOGENERATED_F_3:e -- W1:w3:w + W1:w3:e -- AUTOGENERATED_F_9:w + edge [color="#000000:#FFFF00:#000000"] + AUTOGENERATED_F_4:e -- W1:w4:w + W1:w4:e -- AUTOGENERATED_F_10:w + edge [color="#000000:#00AA00:#000000"] + AUTOGENERATED_F_5:e -- W1:w5:w + W1:w5:e -- AUTOGENERATED_F_11:w + edge [color="#000000:#0066FF:#000000"] + AUTOGENERATED_F_6:e -- W1:w6:w + W1:w6:e -- AUTOGENERATED_F_12:w + W1:w1:e -- W1:w1:w [color="#000000:#895956:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FF8000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w5:e -- W1:w5:w [color="#000000:#00AA00:#000000" straight=straight] + W1:w6:e -- W1:w6:w [color="#000000:#0066FF:#000000" straight=straight] } diff --git a/examples/ex04.html b/examples/ex04.html index af2b568..4135dc2 100644 --- a/examples/ex04.html +++ b/examples/ex04.html @@ -1,7 +1,7 @@ - + ex04 - +

ex04

Diagram

@@ -30,219 +30,280 @@
- - - - - + + + + -__F_1 - - -Crimp ferrule +AUTOGENERATED_F_1 + + + +Crimp ferrule - -W1 - - -W1 - -6x - -0.25 mm² (24 AWG) - -0.2 m -  -     BN     - - - -     RD     - - - -     OG     - - - -     YE     - - - -     GN     - - - -     BU     - - - -  - - - -__F_1:e--W1:w - - - - - -__F_2 - - -Crimp ferrule +W1 + + + +W1 + +6x + +0.25 mm² (24 AWG) + +0.2 m +  + + +BN + + + + +RD + + + + +OG + + + + +YE + + + + +GN + + + + +BU + + +  - - -__F_2:e--W1:w - - - + + +AUTOGENERATED_F_1:e--W1:w + + + - - -__F_3 - - -Crimp ferrule - - - -__F_3:e--W1:w - - - - - - -__F_4 - - -Crimp ferrule - - - -__F_4:e--W1:w - - - - - - -__F_5 - - -Crimp ferrule - - - -__F_5:e--W1:w - - - - - - -__F_6 - - -Crimp ferrule - - - -__F_6:e--W1:w - - - - - - -__F_7 - - -Crimp ferrule - - - -__F_8 - - -Crimp ferrule - - - -__F_9 - - -Crimp ferrule - - - -__F_10 - - -Crimp ferrule - - - -__F_11 - - -Crimp ferrule - - - -__F_12 - - -Crimp ferrule - - + -W1:e--__F_7:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -W1:e--__F_8:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -W1:e--__F_9:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + + +AUTOGENERATED_F_7 + + + +Crimp ferrule + + -W1:e--__F_10:w - - - +W1:e--AUTOGENERATED_F_7:w + + + - + + +AUTOGENERATED_F_8 + + + +Crimp ferrule + + + +W1:e--AUTOGENERATED_F_8:w + + + + + + +AUTOGENERATED_F_9 + + + +Crimp ferrule + + -W1:e--__F_11:w - - - +W1:e--AUTOGENERATED_F_9:w + + + - + + +AUTOGENERATED_F_10 + + + +Crimp ferrule + + + +W1:e--AUTOGENERATED_F_10:w + + + + + + +AUTOGENERATED_F_11 + + + +Crimp ferrule + + -W1:e--__F_12:w - - - +W1:e--AUTOGENERATED_F_11:w + + + + + + +AUTOGENERATED_F_12 + + + +Crimp ferrule + + + +W1:e--AUTOGENERATED_F_12:w + + + + + + +AUTOGENERATED_F_2 + + + +Crimp ferrule + + + +AUTOGENERATED_F_2:e--W1:w + + + + + + +AUTOGENERATED_F_3 + + + +Crimp ferrule + + + +AUTOGENERATED_F_3:e--W1:w + + + + + + +AUTOGENERATED_F_4 + + + +Crimp ferrule + + + +AUTOGENERATED_F_4:e--W1:w + + + + + + +AUTOGENERATED_F_5 + + + +Crimp ferrule + + + +AUTOGENERATED_F_5:e--W1:w + + + + + + +AUTOGENERATED_F_6 + + + +Crimp ferrule + + + +AUTOGENERATED_F_6:e--W1:w + + + @@ -258,59 +319,59 @@
- - + + - - + + - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - + + +
IdDescription# Qty UnitDescription Designators
1Connector, Crimp ferrule1 12 Connector, Crimp ferrule
221m Wire, 0.25 mm², BN0.2m W1
331m Wire, 0.25 mm², BU0.2m W1
441m Wire, 0.25 mm², GN0.2m W1
551m Wire, 0.25 mm², OG0.2m W1
661m Wire, 0.25 mm², RD0.2m W1
7Wire, 0.25 mm², YE0.271 mWire, 0.25 mm², YE W1
diff --git a/examples/ex04.png b/examples/ex04.png index 601281e..55d6c26 100644 Binary files a/examples/ex04.png and b/examples/ex04.png differ diff --git a/examples/ex04.svg b/examples/ex04.svg index 49abe4e..b539bba 100644 --- a/examples/ex04.svg +++ b/examples/ex04.svg @@ -1,219 +1,280 @@ - - - - - + + + + -__F_1 - - -Crimp ferrule +AUTOGENERATED_F_1 + + + +Crimp ferrule - -W1 - - -W1 - -6x - -0.25 mm² (24 AWG) - -0.2 m -  -     BN     - - - -     RD     - - - -     OG     - - - -     YE     - - - -     GN     - - - -     BU     - - - -  - - - -__F_1:e--W1:w - - - - - -__F_2 - - -Crimp ferrule +W1 + + + +W1 + +6x + +0.25 mm² (24 AWG) + +0.2 m +  + + +BN + + + + +RD + + + + +OG + + + + +YE + + + + +GN + + + + +BU + + +  - - -__F_2:e--W1:w - - - + + +AUTOGENERATED_F_1:e--W1:w + + + - - -__F_3 - - -Crimp ferrule - - - -__F_3:e--W1:w - - - - - - -__F_4 - - -Crimp ferrule - - - -__F_4:e--W1:w - - - - - - -__F_5 - - -Crimp ferrule - - - -__F_5:e--W1:w - - - - - - -__F_6 - - -Crimp ferrule - - - -__F_6:e--W1:w - - - - - - -__F_7 - - -Crimp ferrule - - - -__F_8 - - -Crimp ferrule - - - -__F_9 - - -Crimp ferrule - - - -__F_10 - - -Crimp ferrule - - - -__F_11 - - -Crimp ferrule - - - -__F_12 - - -Crimp ferrule - - + -W1:e--__F_7:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -W1:e--__F_8:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -W1:e--__F_9:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + + +AUTOGENERATED_F_7 + + + +Crimp ferrule + + -W1:e--__F_10:w - - - +W1:e--AUTOGENERATED_F_7:w + + + - + + +AUTOGENERATED_F_8 + + + +Crimp ferrule + + + +W1:e--AUTOGENERATED_F_8:w + + + + + + +AUTOGENERATED_F_9 + + + +Crimp ferrule + + -W1:e--__F_11:w - - - +W1:e--AUTOGENERATED_F_9:w + + + - + + +AUTOGENERATED_F_10 + + + +Crimp ferrule + + + +W1:e--AUTOGENERATED_F_10:w + + + + + + +AUTOGENERATED_F_11 + + + +Crimp ferrule + + -W1:e--__F_12:w - - - +W1:e--AUTOGENERATED_F_11:w + + + + + + +AUTOGENERATED_F_12 + + + +Crimp ferrule + + + +W1:e--AUTOGENERATED_F_12:w + + + + + + +AUTOGENERATED_F_2 + + + +Crimp ferrule + + + +AUTOGENERATED_F_2:e--W1:w + + + + + + +AUTOGENERATED_F_3 + + + +Crimp ferrule + + + +AUTOGENERATED_F_3:e--W1:w + + + + + + +AUTOGENERATED_F_4 + + + +Crimp ferrule + + + +AUTOGENERATED_F_4:e--W1:w + + + + + + +AUTOGENERATED_F_5 + + + +Crimp ferrule + + + +AUTOGENERATED_F_5:e--W1:w + + + + + + +AUTOGENERATED_F_6 + + + +Crimp ferrule + + + +AUTOGENERATED_F_6:e--W1:w + + + diff --git a/examples/ex04_wv_gvpr.gvpr b/examples/ex04_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex04_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex05.bom.tsv b/examples/ex05.bom.tsv index 384e444..72ef03d 100644 --- a/examples/ex05.bom.tsv +++ b/examples/ex05.bom.tsv @@ -1,6 +1,6 @@ -Id Description Qty Unit Designators -1 Connector, Molex KK 254, female, 4 pins 3 X1, X2, X3 -2 Wire, I2C, 0.25 mm², PK 0.4 m W1, W2 -3 Wire, I2C, 0.25 mm², TQ 0.4 m W1, W2 -4 Wire, I2C, 0.25 mm², VT 0.4 m W1, W2 -5 Wire, I2C, 0.25 mm², YE 0.4 m W1, W2 +# Qty Unit Description Designators +1 3 Connector, Molex KK 254, female, 4 pins X1, X2, X3 +2 2 m Wire, I2C, 0.25 mm², PK W1, W2 +3 2 m Wire, I2C, 0.25 mm², TQ W1, W2 +4 2 m Wire, I2C, 0.25 mm², VT W1, W2 +5 2 m Wire, I2C, 0.25 mm², YE W1, W2 diff --git a/examples/ex05.gv b/examples/ex05.gv index 3dce0bb..b34e3fd 100644 --- a/examples/ex05.gv +++ b/examples/ex05.gv @@ -1,317 +1,343 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
SCL3
SDA4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
SCL3
SDA4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - - - - - -
1GND1
2VCC2
3SCL3
4SDA4
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + + + + + +
1GND1
2VCC2
3SCL3
4SDA4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - +
- - -
X3
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X3
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ff66cc:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + +
I2C4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND PK X2:1:GND
X1:2:VCC TQ X2:2:VCC
X1:3:SCL YE X2:3:SCL
X1:4:SDA VT X2:4:SDA
 
+
+> shape=box style="filled,dashed"] + edge [color="#000000:#FF66CC:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w - edge [color="#000000:#00ffff:#000000"] + edge [color="#000000:#00FFFF:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=< - - - - + W1:w1:e -- W1:w1:w [color="#000000:#FF66CC:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#00FFFF:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W2 [label=< +
- - -
W1
-
- - - - - -
I2C4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - PK - X2:1:GND
- - - - -
-
X1:2:VCC - TQ - X2:2:VCC
- - - - -
-
X1:3:SCL - YE - X2:3:SCL
- - - - -
-
X1:4:SDA - VT - X2:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W2
+
+ + + + + + + +
I2C4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X2:1:GND PK X3:1:GND
X2:2:VCC TQ X3:2:VCC
X2:3:SCL YE X3:3:SCL
X2:4:SDA VT X3:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#ff66cc:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#FF66CC:#000000"] X2:p1r:e -- W2:w1:w W2:w1:e -- X3:p1l:w - edge [color="#000000:#00ffff:#000000"] + edge [color="#000000:#00FFFF:#000000"] X2:p2r:e -- W2:w2:w W2:w2:e -- X3:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X2:p3r:e -- W2:w3:w W2:w3:e -- X3:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X2:p4r:e -- W2:w4:w W2:w4:e -- X3:p4l:w - W2 [label=< - - - - -
- - -
W2
-
- - - - - -
I2C4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X2:1:GND - PK - X3:1:GND
- - - - -
-
X2:2:VCC - TQ - X3:2:VCC
- - - - -
-
X2:3:SCL - YE - X3:3:SCL
- - - - -
-
X2:4:SDA - VT - X3:4:SDA
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] + W2:w1:e -- W2:w1:w [color="#000000:#FF66CC:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#00FFFF:#000000" straight=straight] + W2:w3:e -- W2:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W2:w4:e -- W2:w4:w [color="#000000:#8000FF:#000000" straight=straight] } diff --git a/examples/ex05.html b/examples/ex05.html index e233416..01675b7 100644 --- a/examples/ex05.html +++ b/examples/ex05.html @@ -1,7 +1,7 @@ - + ex05 - +

ex05

Diagram

@@ -30,301 +30,354 @@
- - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W1 - - -W1 - -I2C - -4x - -0.25 mm² - -0.2 m -  -X1:1:GND -     PK     -X2:1:GND - - - -X1:2:VCC -     TQ     -X2:2:VCC - - - -X1:3:SCL -     YE     -X2:3:SCL - - - -X1:4:SDA -     VT     -X2:4:SDA - - - -  + + + +W1 + +I2C + +4x + +0.25 mm² + +0.2 m +  + X1:1:GND + +PK + +X2:1:GND + X1:2:VCC + +TQ + +X2:2:VCC + X1:3:SCL + +YE + +X2:3:SCL + X1:4:SDA + +VT + +X2:4:SDA +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -1 - -2 - -VCC - -2 - -3 - -SCL - -3 - -4 - -SDA - -4 + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +1 + +2 + +VCC + +2 + +3 + +SCL + +3 + +4 + +SDA + +4 + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + W2 - - -W2 - -I2C - -4x - -0.25 mm² - -0.2 m -  -X2:1:GND -     PK     -X3:1:GND - - - -X2:2:VCC -     TQ     -X3:2:VCC - - - -X2:3:SCL -     YE     -X3:3:SCL - - - -X2:4:SDA -     VT     -X3:4:SDA - - - -  - - - -X2:e--W2:w - - - - - - -X2:e--W2:w - - - + + + +W2 + +I2C + +4x + +0.25 mm² + +0.2 m +  + X2:1:GND + +PK + +X3:1:GND + X2:2:VCC + +TQ + +X3:2:VCC + X2:3:SCL + +YE + +X3:3:SCL + X2:4:SDA + +VT + +X3:4:SDA +  X2:e--W2:w - - - + + + + + + +X2:e--W2:w + + + X2:e--W2:w - - - + + + + + + +X2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - + + + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + @@ -340,45 +393,45 @@
- - + + - - + + - + + + - - - + + + - - - + + + - - - - - + + +
IdDescription# Qty UnitDescription Designators
1Connector, Molex KK 254, female, 4 pins1 3 Connector, Molex KK 254, female, 4 pins X1, X2, X3
222m Wire, I2C, 0.25 mm², PK0.4m W1, W2
332m Wire, I2C, 0.25 mm², TQ0.4m W1, W2
442m Wire, I2C, 0.25 mm², VT0.4m W1, W2
5Wire, I2C, 0.25 mm², YE0.452 mWire, I2C, 0.25 mm², YE W1, W2
diff --git a/examples/ex05.png b/examples/ex05.png index 82db4c1..9c3edd9 100644 Binary files a/examples/ex05.png and b/examples/ex05.png differ diff --git a/examples/ex05.svg b/examples/ex05.svg index 1844bed..815a59b 100644 --- a/examples/ex05.svg +++ b/examples/ex05.svg @@ -1,301 +1,354 @@ - - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W1 - - -W1 - -I2C - -4x - -0.25 mm² - -0.2 m -  -X1:1:GND -     PK     -X2:1:GND - - - -X1:2:VCC -     TQ     -X2:2:VCC - - - -X1:3:SCL -     YE     -X2:3:SCL - - - -X1:4:SDA -     VT     -X2:4:SDA - - - -  + + + +W1 + +I2C + +4x + +0.25 mm² + +0.2 m +  + X1:1:GND + +PK + +X2:1:GND + X1:2:VCC + +TQ + +X2:2:VCC + X1:3:SCL + +YE + +X2:3:SCL + X1:4:SDA + +VT + +X2:4:SDA +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -1 - -2 - -VCC - -2 - -3 - -SCL - -3 - -4 - -SDA - -4 + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +1 + +2 + +VCC + +2 + +3 + +SCL + +3 + +4 + +SDA + +4 + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + W2 - - -W2 - -I2C - -4x - -0.25 mm² - -0.2 m -  -X2:1:GND -     PK     -X3:1:GND - - - -X2:2:VCC -     TQ     -X3:2:VCC - - - -X2:3:SCL -     YE     -X3:3:SCL - - - -X2:4:SDA -     VT     -X3:4:SDA - - - -  - - - -X2:e--W2:w - - - - - - -X2:e--W2:w - - - + + + +W2 + +I2C + +4x + +0.25 mm² + +0.2 m +  + X2:1:GND + +PK + +X3:1:GND + X2:2:VCC + +TQ + +X3:2:VCC + X2:3:SCL + +YE + +X3:3:SCL + X2:4:SDA + +VT + +X3:4:SDA +  X2:e--W2:w - - - + + + + + + +X2:e--W2:w + + + X2:e--W2:w - - - + + + + + + +X2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - + + + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + diff --git a/examples/ex05_wv_gvpr.gvpr b/examples/ex05_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex05_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex06.bom.tsv b/examples/ex06.bom.tsv index 534bad6..62377db 100644 --- a/examples/ex06.bom.tsv +++ b/examples/ex06.bom.tsv @@ -1,6 +1,6 @@ -Id Description Qty Unit Designators -1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6 -2 Wire, 0.25 mm², PK 1 m W1, W2, W3, W4, W5 -3 Wire, 0.25 mm², TQ 1 m W1, W2, W3, W4, W5 -4 Wire, 0.25 mm², VT 1 m W1, W2, W3, W4, W5 -5 Wire, 0.25 mm², YE 1 m W1, W2, W3, W4, W5 +# Qty Unit Description Designators +1 6 Connector, Molex KK 254, female, 4 pins X1, X2, X3, X4, X5, X6 +2 5 m Wire, 0.25 mm², PK W1, W2, W3, W4, W5 +3 5 m Wire, 0.25 mm², TQ W1, W2, W3, W4, W5 +4 5 m Wire, 0.25 mm², VT W1, W2, W3, W4, W5 +5 5 m Wire, 0.25 mm², YE W1, W2, W3, W4, W5 diff --git a/examples/ex06.gv b/examples/ex06.gv index ee6b656..274592b 100644 --- a/examples/ex06.gv +++ b/examples/ex06.gv @@ -1,713 +1,763 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
SCL3
SDA4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
SCL3
SDA4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - +
- - -
X3
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
SCL3
SDA4
-
+ + + + + + + + +
+ + + + +
X3
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
SCL3
SDA4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X4 [label=< - - - - +
- - -
X4
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X4
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X5 [label=< - - - - +
- - -
X5
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
SCL3
SDA4
-
+ + + + + + + + +
+ + + + +
X5
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
SCL3
SDA4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X6 [label=< - - - - +
- - -
X6
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X6
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ff66cc:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND PK X2:1:GND
X1:2:VCC TQ X2:2:VCC
X1:3:SCL YE X2:3:SCL
X1:4:SDA VT X2:4:SDA
 
+
+> shape=box style="filled,dashed"] + edge [color="#000000:#FF66CC:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w - edge [color="#000000:#00ffff:#000000"] + edge [color="#000000:#00FFFF:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=< - - - - + W1:w1:e -- W1:w1:w [color="#000000:#FF66CC:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#00FFFF:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W2 [label=< +
- - -
W1
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - PK - X2:1:GND
- - - - -
-
X1:2:VCC - TQ - X2:2:VCC
- - - - -
-
X1:3:SCL - YE - X2:3:SCL
- - - - -
-
X1:4:SDA - VT - X2:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W2
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X3:1:GND PK X2:1:GND
X3:2:VCC TQ X2:2:VCC
X3:3:SCL YE X2:3:SCL
X3:4:SDA VT X2:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#ff66cc:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#FF66CC:#000000"] X3:p1r:e -- W2:w1:w W2:w1:e -- X2:p1l:w - edge [color="#000000:#00ffff:#000000"] + edge [color="#000000:#00FFFF:#000000"] X3:p2r:e -- W2:w2:w W2:w2:e -- X2:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X3:p3r:e -- W2:w3:w W2:w3:e -- X2:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X3:p4r:e -- W2:w4:w W2:w4:e -- X2:p4l:w - W2 [label=< - - - - + W2:w1:e -- W2:w1:w [color="#000000:#FF66CC:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#00FFFF:#000000" straight=straight] + W2:w3:e -- W2:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W2:w4:e -- W2:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W3 [label=< +
- - -
W2
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X3:1:GND - PK - X2:1:GND
- - - - -
-
X3:2:VCC - TQ - X2:2:VCC
- - - - -
-
X3:3:SCL - YE - X2:3:SCL
- - - - -
-
X3:4:SDA - VT - X2:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W3
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X3:1:GND PK X4:1:GND
X3:2:VCC TQ X4:2:VCC
X3:3:SCL YE X4:3:SCL
X3:4:SDA VT X4:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#ff66cc:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#FF66CC:#000000"] X3:p1r:e -- W3:w1:w W3:w1:e -- X4:p1l:w - edge [color="#000000:#00ffff:#000000"] + edge [color="#000000:#00FFFF:#000000"] X3:p2r:e -- W3:w2:w W3:w2:e -- X4:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X3:p3r:e -- W3:w3:w W3:w3:e -- X4:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X3:p4r:e -- W3:w4:w W3:w4:e -- X4:p4l:w - W3 [label=< - - - - + W3:w1:e -- W3:w1:w [color="#000000:#FF66CC:#000000" straight=straight] + W3:w2:e -- W3:w2:w [color="#000000:#00FFFF:#000000" straight=straight] + W3:w3:e -- W3:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W3:w4:e -- W3:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W4 [label=< +
- - -
W3
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X3:1:GND - PK - X4:1:GND
- - - - -
-
X3:2:VCC - TQ - X4:2:VCC
- - - - -
-
X3:3:SCL - YE - X4:3:SCL
- - - - -
-
X3:4:SDA - VT - X4:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W4
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X5:1:GND PK X4:1:GND
X5:2:VCC TQ X4:2:VCC
X5:3:SCL YE X4:3:SCL
X5:4:SDA VT X4:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#ff66cc:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#FF66CC:#000000"] X5:p1r:e -- W4:w1:w W4:w1:e -- X4:p1l:w - edge [color="#000000:#00ffff:#000000"] + edge [color="#000000:#00FFFF:#000000"] X5:p2r:e -- W4:w2:w W4:w2:e -- X4:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X5:p3r:e -- W4:w3:w W4:w3:e -- X4:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X5:p4r:e -- W4:w4:w W4:w4:e -- X4:p4l:w - W4 [label=< - - - - + W4:w1:e -- W4:w1:w [color="#000000:#FF66CC:#000000" straight=straight] + W4:w2:e -- W4:w2:w [color="#000000:#00FFFF:#000000" straight=straight] + W4:w3:e -- W4:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W4:w4:e -- W4:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W5 [label=< +
- - -
W4
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X5:1:GND - PK - X4:1:GND
- - - - -
-
X5:2:VCC - TQ - X4:2:VCC
- - - - -
-
X5:3:SCL - YE - X4:3:SCL
- - - - -
-
X5:4:SDA - VT - X4:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W5
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X5:1:GND PK X6:1:GND
X5:2:VCC TQ X6:2:VCC
X5:3:SCL YE X6:3:SCL
X5:4:SDA VT X6:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#ff66cc:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#FF66CC:#000000"] X5:p1r:e -- W5:w1:w W5:w1:e -- X6:p1l:w - edge [color="#000000:#00ffff:#000000"] + edge [color="#000000:#00FFFF:#000000"] X5:p2r:e -- W5:w2:w W5:w2:e -- X6:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X5:p3r:e -- W5:w3:w W5:w3:e -- X6:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X5:p4r:e -- W5:w4:w W5:w4:e -- X6:p4l:w - W5 [label=< - - - - -
- - -
W5
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X5:1:GND - PK - X6:1:GND
- - - - -
-
X5:2:VCC - TQ - X6:2:VCC
- - - - -
-
X5:3:SCL - YE - X6:3:SCL
- - - - -
-
X5:4:SDA - VT - X6:4:SDA
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] + W5:w1:e -- W5:w1:w [color="#000000:#FF66CC:#000000" straight=straight] + W5:w2:e -- W5:w2:w [color="#000000:#00FFFF:#000000" straight=straight] + W5:w3:e -- W5:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W5:w4:e -- W5:w4:w [color="#000000:#8000FF:#000000" straight=straight] } diff --git a/examples/ex06.html b/examples/ex06.html index ac5fda5..db5a2d8 100644 --- a/examples/ex06.html +++ b/examples/ex06.html @@ -1,7 +1,7 @@ - + ex06 - +

ex06

Diagram

@@ -30,661 +30,792 @@
- - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W1 - - -W1 - -4x - -0.25 mm² - -0.2 m -  -X1:1:GND -     PK     -X2:1:GND - - - -X1:2:VCC -     TQ     -X2:2:VCC - - - -X1:3:SCL -     YE     -X2:3:SCL - - - -X1:4:SDA -     VT     -X2:4:SDA - - - -  + + + +W1 + +4x + +0.25 mm² + +0.2 m +  + X1:1:GND + +PK + +X2:1:GND + X1:2:VCC + +TQ + +X2:2:VCC + X1:3:SCL + +YE + +X2:3:SCL + X1:4:SDA + +VT + +X2:4:SDA +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X3 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W2 - - -W2 - -4x - -0.25 mm² - -0.2 m -  -X3:1:GND -     PK     -X2:1:GND - - - -X3:2:VCC -     TQ     -X2:2:VCC - - - -X3:3:SCL -     YE     -X2:3:SCL - - - -X3:4:SDA -     VT     -X2:4:SDA - - - -  - - - -X3:e--W2:w - - - - - - -X3:e--W2:w - - - + + + +W2 + +4x + +0.25 mm² + +0.2 m +  + X3:1:GND + +PK + +X2:1:GND + X3:2:VCC + +TQ + +X2:2:VCC + X3:3:SCL + +YE + +X2:3:SCL + X3:4:SDA + +VT + +X2:4:SDA +  X3:e--W2:w - - - + + + + + + +X3:e--W2:w + + + X3:e--W2:w - - - + + + + + + +X3:e--W2:w + + + - + W3 - - -W3 - -4x - -0.25 mm² - -0.2 m -  -X3:1:GND -     PK     -X4:1:GND - - - -X3:2:VCC -     TQ     -X4:2:VCC - - - -X3:3:SCL -     YE     -X4:3:SCL - - - -X3:4:SDA -     VT     -X4:4:SDA - - - -  + + + +W3 + +4x + +0.25 mm² + +0.2 m +  + X3:1:GND + +PK + +X4:1:GND + X3:2:VCC + +TQ + +X4:2:VCC + X3:3:SCL + +YE + +X4:3:SCL + X3:4:SDA + +VT + +X4:4:SDA +  X3:e--W3:w - - - + + + + + + +X3:e--W3:w + + + X3:e--W3:w - - - + + + + +X3:e--W3:w + + + + + -X3:e--W3:w - - - +W2:e--X2:w + + + - + + +W2:e--X2:w + + + + + -X3:e--W3:w - - - +W2:e--X2:w + + + + + + +W2:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + - + X4 - - -X4 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA + + + +X4 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + - + X5 - - -X5 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X5 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W4 - - -W4 - -4x - -0.25 mm² - -0.2 m -  -X5:1:GND -     PK     -X4:1:GND - - - -X5:2:VCC -     TQ     -X4:2:VCC - - - -X5:3:SCL -     YE     -X4:3:SCL - - - -X5:4:SDA -     VT     -X4:4:SDA - - - -  + + + +W4 + +4x + +0.25 mm² + +0.2 m +  + X5:1:GND + +PK + +X4:1:GND + X5:2:VCC + +TQ + +X4:2:VCC + X5:3:SCL + +YE + +X4:3:SCL + X5:4:SDA + +VT + +X4:4:SDA +  - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + W5 - - -W5 - -4x - -0.25 mm² - -0.2 m -  -X5:1:GND -     PK     -X6:1:GND - - - -X5:2:VCC -     TQ     -X6:2:VCC - - - -X5:3:SCL -     YE     -X6:3:SCL - - - -X5:4:SDA -     VT     -X6:4:SDA - - - -  + + + +W5 + +4x + +0.25 mm² + +0.2 m +  + X5:1:GND + +PK + +X6:1:GND + X5:2:VCC + +TQ + +X6:2:VCC + X5:3:SCL + +YE + +X6:3:SCL + X5:4:SDA + +VT + +X6:4:SDA +  - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + - + X6 - - -X6 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - + + + +X6 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + @@ -700,45 +831,45 @@
- - + + - - + + - + + + - - - + + + - - - + + + - - - - - + + +
IdDescription# Qty UnitDescription Designators
1Connector, Molex KK 254, female, 4 pins1 6 Connector, Molex KK 254, female, 4 pins X1, X2, X3, X4, X5, X6
225m Wire, 0.25 mm², PK1m W1, W2, W3, W4, W5
335m Wire, 0.25 mm², TQ1m W1, W2, W3, W4, W5
445m Wire, 0.25 mm², VT1m W1, W2, W3, W4, W5
5Wire, 0.25 mm², YE155 mWire, 0.25 mm², YE W1, W2, W3, W4, W5
diff --git a/examples/ex06.png b/examples/ex06.png index 7b4a618..c6f5192 100644 Binary files a/examples/ex06.png and b/examples/ex06.png differ diff --git a/examples/ex06.svg b/examples/ex06.svg index 30edde4..94f5be1 100644 --- a/examples/ex06.svg +++ b/examples/ex06.svg @@ -1,661 +1,792 @@ - - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W1 - - -W1 - -4x - -0.25 mm² - -0.2 m -  -X1:1:GND -     PK     -X2:1:GND - - - -X1:2:VCC -     TQ     -X2:2:VCC - - - -X1:3:SCL -     YE     -X2:3:SCL - - - -X1:4:SDA -     VT     -X2:4:SDA - - - -  + + + +W1 + +4x + +0.25 mm² + +0.2 m +  + X1:1:GND + +PK + +X2:1:GND + X1:2:VCC + +TQ + +X2:2:VCC + X1:3:SCL + +YE + +X2:3:SCL + X1:4:SDA + +VT + +X2:4:SDA +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X3 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W2 - - -W2 - -4x - -0.25 mm² - -0.2 m -  -X3:1:GND -     PK     -X2:1:GND - - - -X3:2:VCC -     TQ     -X2:2:VCC - - - -X3:3:SCL -     YE     -X2:3:SCL - - - -X3:4:SDA -     VT     -X2:4:SDA - - - -  - - - -X3:e--W2:w - - - - - - -X3:e--W2:w - - - + + + +W2 + +4x + +0.25 mm² + +0.2 m +  + X3:1:GND + +PK + +X2:1:GND + X3:2:VCC + +TQ + +X2:2:VCC + X3:3:SCL + +YE + +X2:3:SCL + X3:4:SDA + +VT + +X2:4:SDA +  X3:e--W2:w - - - + + + + + + +X3:e--W2:w + + + X3:e--W2:w - - - + + + + + + +X3:e--W2:w + + + - + W3 - - -W3 - -4x - -0.25 mm² - -0.2 m -  -X3:1:GND -     PK     -X4:1:GND - - - -X3:2:VCC -     TQ     -X4:2:VCC - - - -X3:3:SCL -     YE     -X4:3:SCL - - - -X3:4:SDA -     VT     -X4:4:SDA - - - -  + + + +W3 + +4x + +0.25 mm² + +0.2 m +  + X3:1:GND + +PK + +X4:1:GND + X3:2:VCC + +TQ + +X4:2:VCC + X3:3:SCL + +YE + +X4:3:SCL + X3:4:SDA + +VT + +X4:4:SDA +  X3:e--W3:w - - - + + + + + + +X3:e--W3:w + + + X3:e--W3:w - - - + + + + +X3:e--W3:w + + + + + -X3:e--W3:w - - - +W2:e--X2:w + + + - + + +W2:e--X2:w + + + + + -X3:e--W3:w - - - +W2:e--X2:w + + + + + + +W2:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + - + X4 - - -X4 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA + + + +X4 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + - + X5 - - -X5 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X5 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W4 - - -W4 - -4x - -0.25 mm² - -0.2 m -  -X5:1:GND -     PK     -X4:1:GND - - - -X5:2:VCC -     TQ     -X4:2:VCC - - - -X5:3:SCL -     YE     -X4:3:SCL - - - -X5:4:SDA -     VT     -X4:4:SDA - - - -  + + + +W4 + +4x + +0.25 mm² + +0.2 m +  + X5:1:GND + +PK + +X4:1:GND + X5:2:VCC + +TQ + +X4:2:VCC + X5:3:SCL + +YE + +X4:3:SCL + X5:4:SDA + +VT + +X4:4:SDA +  - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + W5 - - -W5 - -4x - -0.25 mm² - -0.2 m -  -X5:1:GND -     PK     -X6:1:GND - - - -X5:2:VCC -     TQ     -X6:2:VCC - - - -X5:3:SCL -     YE     -X6:3:SCL - - - -X5:4:SDA -     VT     -X6:4:SDA - - - -  + + + +W5 + +4x + +0.25 mm² + +0.2 m +  + X5:1:GND + +PK + +X6:1:GND + X5:2:VCC + +TQ + +X6:2:VCC + X5:3:SCL + +YE + +X6:3:SCL + X5:4:SDA + +VT + +X6:4:SDA +  - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + - + X6 - - -X6 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - + + + +X6 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + diff --git a/examples/ex06_wv_gvpr.gvpr b/examples/ex06_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex06_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex07.bom.tsv b/examples/ex07.bom.tsv index cacb779..86ffe9d 100644 --- a/examples/ex07.bom.tsv +++ b/examples/ex07.bom.tsv @@ -1,4 +1,4 @@ -Id Description Qty Unit Designators -1 Cable, 2 x 20 AWG 1 m C1 -2 Connector, D-Sub, female, 9 pins 1 X2 -3 Connector, TE 776164-1, female, 35 pins 1 X1 +# Qty Unit Description Designators +1 1 Connector, D-Sub, female, 9 pins X2 +2 1 Connector, TE 776164-1, female, 35 pins X1 +3 1 m Cable, 2 x 20 AWG C1 diff --git a/examples/ex07.gv b/examples/ex07.gv index 1d7c7e6..1da26b3 100644 --- a/examples/ex07.gv +++ b/examples/ex07.gv @@ -1,129 +1,165 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - - +
- - -
X1
-
- - - - -
TE 776164-1female35-pin
-
- - - - - - - -
5
6
-
- - -
Unconnected pins are not shown
-
+ + + + + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
TE 776164-1female35-pin
+
+ + + + + + + + + +
5
6
+
+ + + + +
Unconnected pins are not shown
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - - +
- - -
X2
-
- - - - -
D-Subfemale9-pin
-
- - - - - - - -
2
7
-
- - -
Unconnected pins are not shown
-
+ + + + + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
D-Subfemale9-pin
+
+ + + + + + + + + +
2
7
+
+ + + + +
Unconnected pins are not shown
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffff00:#000000"] +> shape=box style=filled] + C1 [label=< + + + + + + + + + + +
+ + + + +
C1
+
+ + + + + + +
2x20 AWG1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:5 1:YE X2:7
X1:6 2:GN X2:2
 
+
+> shape=box style=filled] + edge [color="#000000:#FFFF00:#000000"] X1:p5r:e -- C1:w1:w C1:w1:e -- X2:p7l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] X1:p6r:e -- C1:w2:w C1:w2:e -- X2:p2l:w - C1 [label=< - - - - -
- - -
C1
-
- - - - -
2x20 AWG1 m
-
- - - - - - - - - - - - - - - - - - - -
 
X1:5 - 1:YE - X2:7
- - - - -
-
X1:6 - 2:GN - X2:2
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + C1:w1:e -- C1:w1:w [color="#000000:#FFFF00:#000000" straight=straight] + C1:w2:e -- C1:w2:w [color="#000000:#00AA00:#000000" straight=straight] } diff --git a/examples/ex07.html b/examples/ex07.html index f8c80ea..b9f4684 100644 --- a/examples/ex07.html +++ b/examples/ex07.html @@ -1,7 +1,7 @@ - + ex07 - +

ex07

Diagram

@@ -30,105 +30,120 @@
- - - - + + + X1 - - -X1 - -TE 776164-1 - -female - -35-pin - -5 - -6 - -Unconnected pins are not shown + + + +X1 + +TE 776164-1 + +female + +35-pin + +5 + +6 + +Unconnected pins are not shown - + C1 - - -C1 - -2x - -20 AWG - -1 m -  -X1:5 -     1:YE     -X2:7 - - - -X1:6 -     2:GN     -X2:2 - - - -  + + + +C1 + +2x + +20 AWG + +1 m +  + X1:5 + +1:YE + +X2:7 + X1:6 + +2:GN + +X2:2 +  X1:e--C1:w - - - + + + - + X1:e--C1:w - - - + + + + + + +C1:e--C1:w + + + + + + +C1:e--C1:w + + + - + X2 - - -X2 - -D-Sub - -female - -9-pin - -2 - -7 - -Unconnected pins are not shown + + + +X2 + +D-Sub + +female + +9-pin + +2 + +7 + +Unconnected pins are not shown - + C1:e--X2:w - - - + + + - + C1:e--X2:w - - - + + + @@ -144,33 +159,33 @@
- - + + - - - - - - - - - + + - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 2 x 20 AWG1mC1
2Connector, D-Sub, female, 9 pins1 1 Connector, D-Sub, female, 9 pins X2
3Connector, TE 776164-1, female, 35 pins2 1 Connector, TE 776164-1, female, 35 pins X1
31mCable, 2 x 20 AWGC1
diff --git a/examples/ex07.png b/examples/ex07.png index 16c4850..2fd5c84 100644 Binary files a/examples/ex07.png and b/examples/ex07.png differ diff --git a/examples/ex07.svg b/examples/ex07.svg index 970a483..16baab4 100644 --- a/examples/ex07.svg +++ b/examples/ex07.svg @@ -1,105 +1,120 @@ - - - - + + + X1 - - -X1 - -TE 776164-1 - -female - -35-pin - -5 - -6 - -Unconnected pins are not shown + + + +X1 + +TE 776164-1 + +female + +35-pin + +5 + +6 + +Unconnected pins are not shown - + C1 - - -C1 - -2x - -20 AWG - -1 m -  -X1:5 -     1:YE     -X2:7 - - - -X1:6 -     2:GN     -X2:2 - - - -  + + + +C1 + +2x + +20 AWG + +1 m +  + X1:5 + +1:YE + +X2:7 + X1:6 + +2:GN + +X2:2 +  X1:e--C1:w - - - + + + - + X1:e--C1:w - - - + + + + + + +C1:e--C1:w + + + + + + +C1:e--C1:w + + + - + X2 - - -X2 - -D-Sub - -female - -9-pin - -2 - -7 - -Unconnected pins are not shown + + + +X2 + +D-Sub + +female + +9-pin + +2 + +7 + +Unconnected pins are not shown - + C1:e--X2:w - - - + + + - + C1:e--X2:w - - - + + + diff --git a/examples/ex07_wv_gvpr.gvpr b/examples/ex07_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex07_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex08.bom.tsv b/examples/ex08.bom.tsv index c0aec09..b03b2ea 100644 --- a/examples/ex08.bom.tsv +++ b/examples/ex08.bom.tsv @@ -1,3 +1,3 @@ -Id Description Qty Unit Designators -1 Cable, 3 x 24 AWG shielded, BK 0.2 m W1 -2 Connector, Phone Connector, male 3.5 1 Key +# Qty Unit Description Designators +1 1 Connector, Phone Connector, male 3.5 Key +2 1 m Cable, 3 x 24 AWG shielded, BK W1 diff --git a/examples/ex08.gv b/examples/ex08.gv index 3594950..7178d8b 100644 --- a/examples/ex08.gv +++ b/examples/ex08.gv @@ -1,150 +1,184 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] Key [label=< - - - - - - +
- - -
Key
-
- - - -
Phone Connectormale 3.5
-
- - - - - - - - - - - - - -
DotT
DashR
GroundS
-
- - -
-
- - -
Tip, Ring, and Sleeve
-
+ + + + + + + + + + + + + + +
+ + + + +
Key
+
+ + + + + +
Phone Connectormale 3.5
+
+ + + + + + + + + + + + + +
DotT
DashR
GroundS
+
+ + + + +
+
+ + + + +
Tip, Ring, and Sleeve
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + + + +
3x24 AWG+ S0.2 mBK
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Key:S:Ground 1:WH
Key:R:Dash 2:BN
Key:T:Dot 3:GN
 
Key:S:Ground SN:Shield
 
+
+ + + + +
+ + + + +
+
+
+ + + + +
Cross-section
+
+> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] Key:p3r:e -- W1:w1:w edge [color="#000000:#895956:#000000"] Key:p2r:e -- W1:w2:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] Key:p1r:e -- W1:w3:w - edge [color="#000000:#aaaaaa:#000000"] - Key:p3r:e -- W1:ws:w - W1 [label=< - - - - - - -
- - -
W1
-
- - - - - - - -
3x24 AWG+ S0.2 mBK
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
Key:S:Ground - 1:WH -
- - - - -
-
Key:R:Dash - 2:BN -
- - - - -
-
Key:T:Dot - 3:GN -
- - - - -
-
 
Key:S:GroundShield
 
-
- - -
- - -
-
-
- - -
Cross-section
-
-> fillcolor="#FFFFFF" shape=box style=filled] + edge [color="#000000:#AAAAAA:#000000"] + Key:p3r:e -- W1:w4:w + W1:w1:e -- W1:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#895956:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#00AA00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#AAAAAA:#000000" straight=straight] } diff --git a/examples/ex08.html b/examples/ex08.html index 16a777b..06e8ae7 100644 --- a/examples/ex08.html +++ b/examples/ex08.html @@ -1,7 +1,7 @@ - + ex08 - +

ex08

Diagram

@@ -30,113 +30,143 @@
- - - - + + + Key - - -Key - -Phone Connector - -male 3.5 - -Dot - -T - -Dash - -R - -Ground - -S - - - -Tip, Ring, and Sleeve + + + +Key + +Phone Connector + +male 3.5 + +Dot + +T + +Dash + +R + +Ground + +S + + + +Tip, Ring, and Sleeve W1 - - -W1 - -3x - -24 AWG - -+ S - -0.2 m - -BK - - -  -Key:S:Ground -     1:WH     - - - -Key:R:Dash -     2:BN     - - - -Key:T:Dot -     3:GN     - - - -  -Key:S:Ground -Shield - - - -  - - - -Cross-section + + + +W1 + +3x + +24 AWG + ++ S + +0.2 m + +BK + + +  + Key:S:Ground + +1:WH + + + Key:R:Dash + +2:BN + + + Key:T:Dot + +3:GN + + +  + Key:S:Ground + +SN:Shield + + +  + + + +Cross-section Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + @@ -152,26 +182,26 @@
- - + + - - - - - - - - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 3 x 24 AWG shielded, BK0.2mW1
2Connector, Phone Connector, male 3.51 1 Connector, Phone Connector, male 3.5 Key
21mCable, 3 x 24 AWG shielded, BKW1
diff --git a/examples/ex08.png b/examples/ex08.png index 09cac13..f59caf1 100644 Binary files a/examples/ex08.png and b/examples/ex08.png differ diff --git a/examples/ex08.svg b/examples/ex08.svg index a196465..c3b04f8 100644 --- a/examples/ex08.svg +++ b/examples/ex08.svg @@ -1,113 +1,143 @@ - - - - + + + Key - - -Key - -Phone Connector - -male 3.5 - -Dot - -T - -Dash - -R - -Ground - -S - - - -Tip, Ring, and Sleeve + + + +Key + +Phone Connector + +male 3.5 + +Dot + +T + +Dash + +R + +Ground + +S + + + +Tip, Ring, and Sleeve W1 - - -W1 - -3x - -24 AWG - -+ S - -0.2 m - -BK - - -  -Key:S:Ground -     1:WH     - - - -Key:R:Dash -     2:BN     - - - -Key:T:Dot -     3:GN     - - - -  -Key:S:Ground -Shield - - - -  - - - -Cross-section + + + +W1 + +3x + +24 AWG + ++ S + +0.2 m + +BK + + +  + Key:S:Ground + +1:WH + + + Key:R:Dash + +2:BN + + + Key:T:Dot + +3:GN + + +  + Key:S:Ground + +SN:Shield + + +  + + + +Cross-section Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + Key:e--W1:w - - - + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + diff --git a/examples/ex08_wv_gvpr.gvpr b/examples/ex08_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex08_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex09.bom.tsv b/examples/ex09.bom.tsv index 26362d3..74a0586 100644 --- a/examples/ex09.bom.tsv +++ b/examples/ex09.bom.tsv @@ -1,4 +1,4 @@ -Id Description Qty Unit Designators -1 Cable, 12 x 0.25 mm² shielded 0.2 m W1 -2 Connector, D-Sub, male, 25 pins 1 X1 -3 Connector, F48, female, 48 pins 1 X2 +# Qty Unit Description Designators +1 1 Connector, D-Sub, male, 25 pins X1 +2 1 Connector, F48, female, 48 pins X2 +3 1 m Cable, 12 x 0.25 mm² shielded W1 diff --git a/examples/ex09.gv b/examples/ex09.gv index ce6ff89..424dd96 100644 --- a/examples/ex09.gv +++ b/examples/ex09.gv @@ -1,527 +1,532 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
D-Submale25-pin
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SENSE_P_11
SENSE_N_114
SENSE_P_23
SENSE_N_216
SENSE_P_35
SENSE_N_318
SENSE_P_47
SENSE_N_420
SENSE_P_59
SENSE_N_522
SENSE_P_611
SENSE_N_624
GND13
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
D-Submale25-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SENSE_P_11
SENSE_N_114
SENSE_P_23
SENSE_N_216
SENSE_P_35
SENSE_N_318
SENSE_P_47
SENSE_N_420
SENSE_P_59
SENSE_N_522
SENSE_P_611
SENSE_N_624
GND13
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
F48female48-pin
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
z2
b2
d2
z4
b4
d4
z6
b6
d6
z8
b8
d8
z10
b10
d10
z12
b12
d12
z14
b14
d14
z16
b16
d16
z18
b18
d18
z20
b20
d20
z22
b22
d22
z24
b24
d24
z26
b26
d26
z28
b28
d28
z30
b30
d30
z32
b32
d32
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
F48female48-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
z2
b2
d2
z4
b4
d4
z6
b6
d6
z8
b8
d8
z10
b10
d10
z12
b12
d12
z14
b14
d14
z16
b16
d16
z18
b18
d18
z20
b20
d20
z22
b22
d22
z24
b24
d24
z26
b26
d26
z28
b28
d28
z30
b30
d30
z32
b32
d32
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + +
12x0.25 mm²+ S0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:14:SENSE_N_1 1:WH X2:z2
X1:1:SENSE_P_1 2:BN X2:d4
X1:16:SENSE_N_2 3:GN X2:z8
X1:3:SENSE_P_2 4:YE X2:d10
X1:18:SENSE_N_3 5:GY X2:z14
X1:5:SENSE_P_3 6:PK X2:d16
X1:20:SENSE_N_4 7:BU X2:z18
X1:7:SENSE_P_4 8:RD X2:d20
X1:22:SENSE_N_5 9:BK X2:z24
X1:9:SENSE_P_5 10:VT X2:d26
X1:24:SENSE_N_6 11:GYPK X2:z30
X1:11:SENSE_P_6 12:RDBU X2:d32
 
X1:13:GND Shield
 
+
+> shape=box style=filled] edge [color="#000000:#895956:#895956:#895956:#000000"] X1:p1r:e -- W1:w2:w W1:w2:e -- X2:p6l:w - edge [color="#000000:#ffffff:#ffffff:#ffffff:#000000"] + edge [color="#000000:#FFFFFF:#FFFFFF:#FFFFFF:#000000"] X1:p2r:e -- W1:w1:w W1:w1:e -- X2:p1l:w - edge [color="#000000:#ffff00:#ffff00:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#FFFF00:#FFFF00:#000000"] X1:p3r:e -- W1:w4:w W1:w4:e -- X2:p15l:w - edge [color="#000000:#00ff00:#00ff00:#00ff00:#000000"] + edge [color="#000000:#00AA00:#00AA00:#00AA00:#000000"] X1:p4r:e -- W1:w3:w W1:w3:e -- X2:p10l:w - edge [color="#000000:#ff66cc:#ff66cc:#ff66cc:#000000"] + edge [color="#000000:#FF66CC:#FF66CC:#FF66CC:#000000"] X1:p5r:e -- W1:w6:w W1:w6:e -- X2:p24l:w edge [color="#000000:#999999:#999999:#999999:#000000"] X1:p6r:e -- W1:w5:w W1:w5:e -- X2:p19l:w - edge [color="#000000:#ff0000:#ff0000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#FF0000:#FF0000:#000000"] X1:p7r:e -- W1:w8:w W1:w8:e -- X2:p30l:w - edge [color="#000000:#0066ff:#0066ff:#0066ff:#000000"] + edge [color="#000000:#0066FF:#0066FF:#0066FF:#000000"] X1:p8r:e -- W1:w7:w W1:w7:e -- X2:p25l:w - edge [color="#000000:#8000ff:#8000ff:#8000ff:#000000"] + edge [color="#000000:#8000FF:#8000FF:#8000FF:#000000"] X1:p9r:e -- W1:w10:w W1:w10:e -- X2:p39l:w edge [color="#000000:#000000:#000000:#000000:#000000"] X1:p10r:e -- W1:w9:w W1:w9:e -- X2:p34l:w - edge [color="#000000:#ff0000:#0066ff:#ff0000:#000000"] + edge [color="#000000:#FF0000:#0066FF:#FF0000:#000000"] X1:p11r:e -- W1:w12:w W1:w12:e -- X2:p48l:w - edge [color="#000000:#999999:#ff66cc:#999999:#000000"] + edge [color="#000000:#999999:#FF66CC:#999999:#000000"] X1:p12r:e -- W1:w11:w W1:w11:e -- X2:p43l:w edge [color="#000000"] - X1:p13r:e -- W1:ws:w - W1 [label=< - - - - -
- - -
W1
-
- - - - - -
12x0.25 mm²+ S0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:14:SENSE_N_1 - 1:WH - X2:z2
- - - - - - -
-
X1:1:SENSE_P_1 - 2:BN - X2:d4
- - - - - - -
-
X1:16:SENSE_N_2 - 3:GN - X2:z8
- - - - - - -
-
X1:3:SENSE_P_2 - 4:YE - X2:d10
- - - - - - -
-
X1:18:SENSE_N_3 - 5:GY - X2:z14
- - - - - - -
-
X1:5:SENSE_P_3 - 6:PK - X2:d16
- - - - - - -
-
X1:20:SENSE_N_4 - 7:BU - X2:z18
- - - - - - -
-
X1:7:SENSE_P_4 - 8:RD - X2:d20
- - - - - - -
-
X1:22:SENSE_N_5 - 9:BK - X2:z24
- - - - - - -
-
X1:9:SENSE_P_5 - 10:VT - X2:d26
- - - - - - -
-
X1:24:SENSE_N_6 - 11:GYPK - X2:z30
- - - - - - -
-
X1:11:SENSE_P_6 - 12:RDBU - X2:d32
- - - - - - -
-
 
X1:13:GNDShield
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + X1:p13r:e -- W1:w13:w + W1:w1:e -- W1:w1:w [color="#000000:#FFFFFF:#FFFFFF:#FFFFFF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#895956:#895956:#895956:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#00AA00:#00AA00:#00AA00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#FFFF00:#FFFF00:#000000" straight=straight] + W1:w5:e -- W1:w5:w [color="#000000:#999999:#999999:#999999:#000000" straight=straight] + W1:w6:e -- W1:w6:w [color="#000000:#FF66CC:#FF66CC:#FF66CC:#000000" straight=straight] + W1:w7:e -- W1:w7:w [color="#000000:#0066FF:#0066FF:#0066FF:#000000" straight=straight] + W1:w8:e -- W1:w8:w [color="#000000:#FF0000:#FF0000:#FF0000:#000000" straight=straight] + W1:w9:e -- W1:w9:w [color="#000000:#000000:#000000:#000000:#000000" straight=straight] + W1:w10:e -- W1:w10:w [color="#000000:#8000FF:#8000FF:#8000FF:#000000" straight=straight] + W1:w11:e -- W1:w11:w [color="#000000:#999999:#FF66CC:#999999:#000000" straight=straight] + W1:w12:e -- W1:w12:w [color="#000000:#FF0000:#0066FF:#FF0000:#000000" straight=straight] + W1:w13:e -- W1:w13:w [color="#000000" straight=straight] } diff --git a/examples/ex09.html b/examples/ex09.html index aefb616..4c45c20 100644 --- a/examples/ex09.html +++ b/examples/ex09.html @@ -1,7 +1,7 @@ - + ex09 - +

ex09

Diagram

@@ -30,524 +30,606 @@
- - - - + + + X1 - - -X1 - -D-Sub - -male - -25-pin - -SENSE_P_1 - -1 - -SENSE_N_1 - -14 - -SENSE_P_2 - -3 - -SENSE_N_2 - -16 - -SENSE_P_3 - -5 - -SENSE_N_3 - -18 - -SENSE_P_4 - -7 - -SENSE_N_4 - -20 - -SENSE_P_5 - -9 - -SENSE_N_5 - -22 - -SENSE_P_6 - -11 - -SENSE_N_6 - -24 - -GND - -13 + + + +X1 + +D-Sub + +male + +25-pin + +SENSE_P_1 + +1 + +SENSE_N_1 + +14 + +SENSE_P_2 + +3 + +SENSE_N_2 + +16 + +SENSE_P_3 + +5 + +SENSE_N_3 + +18 + +SENSE_P_4 + +7 + +SENSE_N_4 + +20 + +SENSE_P_5 + +9 + +SENSE_N_5 + +22 + +SENSE_P_6 + +11 + +SENSE_N_6 + +24 + +GND + +13 - + W1 - - -W1 - -12x - -0.25 mm² - -+ S - -0.2 m -  -X1:14:SENSE_N_1 -     1:WH     -X2:z2 - - - - - -X1:1:SENSE_P_1 -     2:BN     -X2:d4 - - - - - -X1:16:SENSE_N_2 -     3:GN     -X2:z8 - - - - - -X1:3:SENSE_P_2 -     4:YE     -X2:d10 - - - - - -X1:18:SENSE_N_3 -     5:GY     -X2:z14 - - - - - -X1:5:SENSE_P_3 -     6:PK     -X2:d16 - - - - - -X1:20:SENSE_N_4 -     7:BU     -X2:z18 - - - - - -X1:7:SENSE_P_4 -     8:RD     -X2:d20 - - - - - -X1:22:SENSE_N_5 -     9:BK     -X2:z24 - - - - - -X1:9:SENSE_P_5 -     10:VT     -X2:d26 - - - - - -X1:24:SENSE_N_6 -     11:GYPK     -X2:z30 - - - - - -X1:11:SENSE_P_6 -     12:RDBU     -X2:d32 - - - - - -  -X1:13:GND -Shield - -  + + + +W1 + +12x + +0.25 mm² + ++ S + +0.2 m +  + X1:14:SENSE_N_1 + +1:WH + +X2:z2 + X1:1:SENSE_P_1 + +2:BN + +X2:d4 + X1:16:SENSE_N_2 + +3:GN + +X2:z8 + X1:3:SENSE_P_2 + +4:YE + +X2:d10 + X1:18:SENSE_N_3 + +5:GY + +X2:z14 + X1:5:SENSE_P_3 + +6:PK + +X2:d16 + X1:20:SENSE_N_4 + +7:BU + +X2:z18 + X1:7:SENSE_P_4 + +8:RD + +X2:d20 + X1:22:SENSE_N_5 + +9:BK + +X2:z24 + X1:9:SENSE_P_5 + +10:VT + +X2:d26 + X1:24:SENSE_N_6 + +11:GYPK + +X2:z30 + X1:11:SENSE_P_6 + +12:RDBU + +X2:d32 +  + X1:13:GND + +Shield + + +  X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - +W1:e--W1:w + + + + + + + + +W1:e--W1:w + - + X2 - - -X2 - -F48 - -female - -48-pin - -z2 - -b2 - -d2 - -z4 - -b4 - -d4 - -z6 - -b6 - -d6 - -z8 - -b8 - -d8 - -z10 - -b10 - -d10 - -z12 - -b12 - -d12 - -z14 - -b14 - -d14 - -z16 - -b16 - -d16 - -z18 - -b18 - -d18 - -z20 - -b20 - -d20 - -z22 - -b22 - -d22 - -z24 - -b24 - -d24 - -z26 - -b26 - -d26 - -z28 - -b28 - -d28 - -z30 - -b30 - -d30 - -z32 - -b32 - -d32 + + + +X2 + +F48 + +female + +48-pin + +z2 + +b2 + +d2 + +z4 + +b4 + +d4 + +z6 + +b6 + +d6 + +z8 + +b8 + +d8 + +z10 + +b10 + +d10 + +z12 + +b12 + +d12 + +z14 + +b14 + +d14 + +z16 + +b16 + +d16 + +z18 + +b18 + +d18 + +z20 + +b20 + +d20 + +z22 + +b22 + +d22 + +z24 + +b24 + +d24 + +z26 + +b26 + +d26 + +z28 + +b28 + +d28 + +z30 + +b30 + +d30 + +z32 + +b32 + +d32 - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + @@ -563,33 +645,33 @@
- - + + - - - - - - - - - + + - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 12 x 0.25 mm² shielded0.2mW1
2Connector, D-Sub, male, 25 pins1 1 Connector, D-Sub, male, 25 pins X1
3Connector, F48, female, 48 pins2 1 Connector, F48, female, 48 pins X2
31mCable, 12 x 0.25 mm² shieldedW1
diff --git a/examples/ex09.png b/examples/ex09.png index d9bfc57..5d8e623 100644 Binary files a/examples/ex09.png and b/examples/ex09.png differ diff --git a/examples/ex09.svg b/examples/ex09.svg index 9a9f832..0008ebb 100644 --- a/examples/ex09.svg +++ b/examples/ex09.svg @@ -1,524 +1,606 @@ - - - - + + + X1 - - -X1 - -D-Sub - -male - -25-pin - -SENSE_P_1 - -1 - -SENSE_N_1 - -14 - -SENSE_P_2 - -3 - -SENSE_N_2 - -16 - -SENSE_P_3 - -5 - -SENSE_N_3 - -18 - -SENSE_P_4 - -7 - -SENSE_N_4 - -20 - -SENSE_P_5 - -9 - -SENSE_N_5 - -22 - -SENSE_P_6 - -11 - -SENSE_N_6 - -24 - -GND - -13 + + + +X1 + +D-Sub + +male + +25-pin + +SENSE_P_1 + +1 + +SENSE_N_1 + +14 + +SENSE_P_2 + +3 + +SENSE_N_2 + +16 + +SENSE_P_3 + +5 + +SENSE_N_3 + +18 + +SENSE_P_4 + +7 + +SENSE_N_4 + +20 + +SENSE_P_5 + +9 + +SENSE_N_5 + +22 + +SENSE_P_6 + +11 + +SENSE_N_6 + +24 + +GND + +13 - + W1 - - -W1 - -12x - -0.25 mm² - -+ S - -0.2 m -  -X1:14:SENSE_N_1 -     1:WH     -X2:z2 - - - - - -X1:1:SENSE_P_1 -     2:BN     -X2:d4 - - - - - -X1:16:SENSE_N_2 -     3:GN     -X2:z8 - - - - - -X1:3:SENSE_P_2 -     4:YE     -X2:d10 - - - - - -X1:18:SENSE_N_3 -     5:GY     -X2:z14 - - - - - -X1:5:SENSE_P_3 -     6:PK     -X2:d16 - - - - - -X1:20:SENSE_N_4 -     7:BU     -X2:z18 - - - - - -X1:7:SENSE_P_4 -     8:RD     -X2:d20 - - - - - -X1:22:SENSE_N_5 -     9:BK     -X2:z24 - - - - - -X1:9:SENSE_P_5 -     10:VT     -X2:d26 - - - - - -X1:24:SENSE_N_6 -     11:GYPK     -X2:z30 - - - - - -X1:11:SENSE_P_6 -     12:RDBU     -X2:d32 - - - - - -  -X1:13:GND -Shield - -  + + + +W1 + +12x + +0.25 mm² + ++ S + +0.2 m +  + X1:14:SENSE_N_1 + +1:WH + +X2:z2 + X1:1:SENSE_P_1 + +2:BN + +X2:d4 + X1:16:SENSE_N_2 + +3:GN + +X2:z8 + X1:3:SENSE_P_2 + +4:YE + +X2:d10 + X1:18:SENSE_N_3 + +5:GY + +X2:z14 + X1:5:SENSE_P_3 + +6:PK + +X2:d16 + X1:20:SENSE_N_4 + +7:BU + +X2:z18 + X1:7:SENSE_P_4 + +8:RD + +X2:d20 + X1:22:SENSE_N_5 + +9:BK + +X2:z24 + X1:9:SENSE_P_5 + +10:VT + +X2:d26 + X1:24:SENSE_N_6 + +11:GYPK + +X2:z30 + X1:11:SENSE_P_6 + +12:RDBU + +X2:d32 +  + X1:13:GND + +Shield + + +  X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - +W1:e--W1:w + + + + + + + + +W1:e--W1:w + - + X2 - - -X2 - -F48 - -female - -48-pin - -z2 - -b2 - -d2 - -z4 - -b4 - -d4 - -z6 - -b6 - -d6 - -z8 - -b8 - -d8 - -z10 - -b10 - -d10 - -z12 - -b12 - -d12 - -z14 - -b14 - -d14 - -z16 - -b16 - -d16 - -z18 - -b18 - -d18 - -z20 - -b20 - -d20 - -z22 - -b22 - -d22 - -z24 - -b24 - -d24 - -z26 - -b26 - -d26 - -z28 - -b28 - -d28 - -z30 - -b30 - -d30 - -z32 - -b32 - -d32 + + + +X2 + +F48 + +female + +48-pin + +z2 + +b2 + +d2 + +z4 + +b4 + +d4 + +z6 + +b6 + +d6 + +z8 + +b8 + +d8 + +z10 + +b10 + +d10 + +z12 + +b12 + +d12 + +z14 + +b14 + +d14 + +z16 + +b16 + +d16 + +z18 + +b18 + +d18 + +z20 + +b20 + +d20 + +z22 + +b22 + +d22 + +z24 + +b24 + +d24 + +z26 + +b26 + +d26 + +z28 + +b28 + +d28 + +z30 + +b30 + +d30 + +z32 + +b32 + +d32 - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + diff --git a/examples/ex09_wv_gvpr.gvpr b/examples/ex09_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex09_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex10.bom.tsv b/examples/ex10.bom.tsv index bdb68a6..91e69d2 100644 --- a/examples/ex10.bom.tsv +++ b/examples/ex10.bom.tsv @@ -1,3 +1,3 @@ -Id Description Qty Unit Designators -1 Cable, CAT5e, 8 x 24 AWG 1 m W1 -2 Connector, Stewart Connector SS-37000-002, male, 8 pins 2 X1, X2 +# Qty Unit Description Designators +1 2 Connector, Stewart Connector SS-37000-002, male, 8 pins X1, X2 +2 1 m Cable, CAT5e, 8 x 24 AWG W1 diff --git a/examples/ex10.gv b/examples/ex10.gv index 976494a..602af91 100644 --- a/examples/ex10.gv +++ b/examples/ex10.gv @@ -1,302 +1,280 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Stewart Connector SS-37000-002male8-pin
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DA+1
DA-2
DB+3
DC+4
DC-5
DB-6
DD+7
DD-8
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Stewart Connector SS-37000-002male8-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DA+1
DA-2
DB+3
DC+4
DC-5
DB-6
DD+7
DD-8
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Stewart Connector SS-37000-002male8-pin
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1DB+
2DB-
3DA+
4DD+
5DD-
6DA-
7DC+
8DC-
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Stewart Connector SS-37000-002male8-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1DB+
2DB-
3DA+
4DD+
5DD-
6DA-
7DC+
8DC-
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#00ff00:#ffffff:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + +
CAT5e8x24 AWG1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:DA+ 1:WHGN X2:3:DA+
X1:2:DA- 2:GN X2:6:DA-
X1:3:DB+ 3:WHOG X2:1:DB+
X1:4:DC+ 4:BU X2:7:DC+
X1:5:DC- 5:WHBU X2:8:DC-
X1:6:DB- 6:OG X2:2:DB-
X1:7:DD+ 7:WHBN X2:4:DD+
X1:8:DD- 8:BN X2:5:DD-
 
+
+> shape=box style=filled] + edge [color="#000000:#FFFFFF:#00AA00:#FFFFFF:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p3l:w - edge [color="#000000:#00ff00:#00ff00:#00ff00:#000000"] + edge [color="#000000:#00AA00:#00AA00:#00AA00:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p6l:w - edge [color="#000000:#ffffff:#ff8000:#ffffff:#000000"] + edge [color="#000000:#FFFFFF:#FF8000:#FFFFFF:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p1l:w - edge [color="#000000:#0066ff:#0066ff:#0066ff:#000000"] + edge [color="#000000:#0066FF:#0066FF:#0066FF:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p7l:w - edge [color="#000000:#ffffff:#0066ff:#ffffff:#000000"] + edge [color="#000000:#FFFFFF:#0066FF:#FFFFFF:#000000"] X1:p5r:e -- W1:w5:w W1:w5:e -- X2:p8l:w - edge [color="#000000:#ff8000:#ff8000:#ff8000:#000000"] + edge [color="#000000:#FF8000:#FF8000:#FF8000:#000000"] X1:p6r:e -- W1:w6:w W1:w6:e -- X2:p2l:w - edge [color="#000000:#ffffff:#895956:#ffffff:#000000"] + edge [color="#000000:#FFFFFF:#895956:#FFFFFF:#000000"] X1:p7r:e -- W1:w7:w W1:w7:e -- X2:p4l:w edge [color="#000000:#895956:#895956:#895956:#000000"] X1:p8r:e -- W1:w8:w W1:w8:e -- X2:p5l:w - W1 [label=< - - - - -
- - -
W1
-
- - - - - -
CAT5e8x24 AWG1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:DA+ - 1:WHGN - X2:3:DA+
- - - - - - -
-
X1:2:DA- - 2:GN - X2:6:DA-
- - - - - - -
-
X1:3:DB+ - 3:WHOG - X2:1:DB+
- - - - - - -
-
X1:4:DC+ - 4:BU - X2:7:DC+
- - - - - - -
-
X1:5:DC- - 5:WHBU - X2:8:DC-
- - - - - - -
-
X1:6:DB- - 6:OG - X2:2:DB-
- - - - - - -
-
X1:7:DD+ - 7:WHBN - X2:4:DD+
- - - - - - -
-
X1:8:DD- - 8:BN - X2:5:DD-
- - - - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + W1:w1:e -- W1:w1:w [color="#000000:#FFFFFF:#00AA00:#FFFFFF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#00AA00:#00AA00:#00AA00:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FFFFFF:#FF8000:#FFFFFF:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#0066FF:#0066FF:#0066FF:#000000" straight=straight] + W1:w5:e -- W1:w5:w [color="#000000:#FFFFFF:#0066FF:#FFFFFF:#000000" straight=straight] + W1:w6:e -- W1:w6:w [color="#000000:#FF8000:#FF8000:#FF8000:#000000" straight=straight] + W1:w7:e -- W1:w7:w [color="#000000:#FFFFFF:#895956:#FFFFFF:#000000" straight=straight] + W1:w8:e -- W1:w8:w [color="#000000:#895956:#895956:#895956:#000000" straight=straight] } diff --git a/examples/ex10.html b/examples/ex10.html index d0d4fdf..ccee404 100644 --- a/examples/ex10.html +++ b/examples/ex10.html @@ -1,7 +1,7 @@ - + ex10 - +

ex10

Diagram

@@ -30,327 +30,378 @@
- - - - + + + X1 - - -X1 - -Stewart Connector SS-37000-002 - -male - -8-pin - -DA+ - -1 - -DA- - -2 - -DB+ - -3 - -DC+ - -4 - -DC- - -5 - -DB- - -6 - -DD+ - -7 - -DD- - -8 + + + +X1 + +Stewart Connector SS-37000-002 + +male + +8-pin + +DA+ + +1 + +DA- + +2 + +DB+ + +3 + +DC+ + +4 + +DC- + +5 + +DB- + +6 + +DD+ + +7 + +DD- + +8 - + W1 - - -W1 - -CAT5e - -8x - -24 AWG - -1 m -  -X1:1:DA+ -     1:WHGN     -X2:3:DA+ - - - - - -X1:2:DA- -     2:GN     -X2:6:DA- - - - - - -X1:3:DB+ -     3:WHOG     -X2:1:DB+ - - - - - -X1:4:DC+ -     4:BU     -X2:7:DC+ - - - - - -X1:5:DC- -     5:WHBU     -X2:8:DC- - - - - - -X1:6:DB- -     6:OG     -X2:2:DB- - - - - - -X1:7:DD+ -     7:WHBN     -X2:4:DD+ - - - - - -X1:8:DD- -     8:BN     -X2:5:DD- - - - - - -  + + + +W1 + +CAT5e + +8x + +24 AWG + +1 m +  + X1:1:DA+ + +1:WHGN + +X2:3:DA+ + X1:2:DA- + +2:GN + +X2:6:DA- + X1:3:DB+ + +3:WHOG + +X2:1:DB+ + X1:4:DC+ + +4:BU + +X2:7:DC+ + X1:5:DC- + +5:WHBU + +X2:8:DC- + X1:6:DB- + +6:OG + +X2:2:DB- + X1:7:DD+ + +7:WHBN + +X2:4:DD+ + X1:8:DD- + +8:BN + +X2:5:DD- +  X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + +X1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + + - + X2 - - -X2 - -Stewart Connector SS-37000-002 - -male - -8-pin - -1 - -DB+ - -2 - -DB- - -3 - -DA+ - -4 - -DD+ - -5 - -DD- - -6 - -DA- - -7 - -DC+ - -8 - -DC- + + + +X2 + +Stewart Connector SS-37000-002 + +male + +8-pin + +1 + +DB+ + +2 + +DB- + +3 + +DA+ + +4 + +DD+ + +5 + +DD- + +6 + +DA- + +7 + +DC+ + +8 + +DC- - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + @@ -366,26 +417,26 @@
- - + + - - - - - - - - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, CAT5e, 8 x 24 AWG1mW1
2Connector, Stewart Connector SS-37000-002, male, 8 pins1 2 Connector, Stewart Connector SS-37000-002, male, 8 pins X1, X2
21mCable, CAT5e, 8 x 24 AWGW1
diff --git a/examples/ex10.png b/examples/ex10.png index dfd4577..7333e4d 100644 Binary files a/examples/ex10.png and b/examples/ex10.png differ diff --git a/examples/ex10.svg b/examples/ex10.svg index 4158b29..662f8ea 100644 --- a/examples/ex10.svg +++ b/examples/ex10.svg @@ -1,327 +1,378 @@ - - - - + + + X1 - - -X1 - -Stewart Connector SS-37000-002 - -male - -8-pin - -DA+ - -1 - -DA- - -2 - -DB+ - -3 - -DC+ - -4 - -DC- - -5 - -DB- - -6 - -DD+ - -7 - -DD- - -8 + + + +X1 + +Stewart Connector SS-37000-002 + +male + +8-pin + +DA+ + +1 + +DA- + +2 + +DB+ + +3 + +DC+ + +4 + +DC- + +5 + +DB- + +6 + +DD+ + +7 + +DD- + +8 - + W1 - - -W1 - -CAT5e - -8x - -24 AWG - -1 m -  -X1:1:DA+ -     1:WHGN     -X2:3:DA+ - - - - - -X1:2:DA- -     2:GN     -X2:6:DA- - - - - - -X1:3:DB+ -     3:WHOG     -X2:1:DB+ - - - - - -X1:4:DC+ -     4:BU     -X2:7:DC+ - - - - - -X1:5:DC- -     5:WHBU     -X2:8:DC- - - - - - -X1:6:DB- -     6:OG     -X2:2:DB- - - - - - -X1:7:DD+ -     7:WHBN     -X2:4:DD+ - - - - - -X1:8:DD- -     8:BN     -X2:5:DD- - - - - - -  + + + +W1 + +CAT5e + +8x + +24 AWG + +1 m +  + X1:1:DA+ + +1:WHGN + +X2:3:DA+ + X1:2:DA- + +2:GN + +X2:6:DA- + X1:3:DB+ + +3:WHOG + +X2:1:DB+ + X1:4:DC+ + +4:BU + +X2:7:DC+ + X1:5:DC- + +5:WHBU + +X2:8:DC- + X1:6:DB- + +6:OG + +X2:2:DB- + X1:7:DD+ + +7:WHBN + +X2:4:DD+ + X1:8:DD- + +8:BN + +X2:5:DD- +  X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + + + +X1:e--W1:w + + + + + X1:e--W1:w - - - - - + + + + + + +X1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + - + + +W1:e--W1:w + + + + + + + -X1:e--W1:w - - - - - +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + + - + X2 - - -X2 - -Stewart Connector SS-37000-002 - -male - -8-pin - -1 - -DB+ - -2 - -DB- - -3 - -DA+ - -4 - -DD+ - -5 - -DD- - -6 - -DA- - -7 - -DC+ - -8 - -DC- + + + +X2 + +Stewart Connector SS-37000-002 + +male + +8-pin + +1 + +DB+ + +2 + +DB- + +3 + +DA+ + +4 + +DD+ + +5 + +DD- + +6 + +DA- + +7 + +DC+ + +8 + +DC- - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + - + W1:e--X2:w - - - - - + + + + + diff --git a/examples/ex10_wv_gvpr.gvpr b/examples/ex10_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex10_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex11.bom.tsv b/examples/ex11.bom.tsv index 0264161..a2652b5 100644 --- a/examples/ex11.bom.tsv +++ b/examples/ex11.bom.tsv @@ -1,4 +1,4 @@ -Id Description Qty Unit Designators -1 Cable, 4 wires, BK 0 m W1 -2 Connector, Ferrule, GY 4 -3 Connector, Screw connector, male, 4 pins, GN 1 X1 +# Qty Description Designators +1 4 Connector, Ferrule, GY +2 1 Connector, Screw connector, male, 4 pins, GN X1 +3 1 Cable, 4 wires, BK W1 diff --git a/examples/ex11.gv b/examples/ex11.gv index 6b859ef..fcee36b 100644 --- a/examples/ex11.gv +++ b/examples/ex11.gv @@ -1,191 +1,211 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] - __F_1 [label=< - - + AUTOGENERATED_F_1 [label=< +
- - - - -
FerruleGY
-
+ + +
+ + + + + + +
FerruleGY
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_2 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_2 [label=< +
- - - - -
FerruleGY
-
+ + +
+ + + + + + +
FerruleGY
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_3 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_3 [label=< +
- - - - -
FerruleGY
-
+ + +
+ + + + + + +
FerruleGY
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_4 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_4 [label=< +
- - - - -
FerruleGY
-
+ + +
+ + + + + + +
FerruleGY
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X1 [label=< - - - - +
- - -
X1
-
- - - - - - -
Screw connectormale4-pinGN
-
- - - - - - - - - - - - - - - - - -
1A
2B
3C
4D
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + + + +
Screw connectormale4-pinGN
+
+ + + + + + + + + + + + + + + + + +
1A
2B
3C
4D
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#000000:#000000"] - W1:w1:e -- __F_1:w - edge [color="#000000:#ffffff:#000000"] - W1:w2:e -- __F_2:w - edge [color="#000000:#0066ff:#000000"] - W1:w3:e -- __F_3:w - edge [color="#000000:#895956:#000000"] - W1:w4:e -- __F_4:w +> shape=box style=filled] W1 [label=< - - - - +
- - -
W1
-
- - - - -
4xBK
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- 1:BK -
- - - - -
-
- 2:WH -
- - - - -
-
- 3:BU -
- - - - -
-
- 4:BN -
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
4xBK
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
1:BK
2:WH
3:BU
4:BN
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + edge [color="#000000:#000000:#000000"] + W1:w1:e -- AUTOGENERATED_F_1:w + edge [color="#000000:#FFFFFF:#000000"] + W1:w2:e -- AUTOGENERATED_F_2:w + edge [color="#000000:#0066FF:#000000"] + W1:w3:e -- AUTOGENERATED_F_3:w + edge [color="#000000:#895956:#000000"] + W1:w4:e -- AUTOGENERATED_F_4:w + W1:w1:e -- W1:w1:w [color="#000000:#000000:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FFFFFF:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#0066FF:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#895956:#000000" straight=straight] edge [color="#000000" dir=forward style=dashed] - __F_1:e -- X1:p1l:w + AUTOGENERATED_F_1:p1r:e -- X1:p1l:w edge [color="#000000" dir=forward style=dashed] - __F_2:e -- X1:p2l:w + AUTOGENERATED_F_2:p1r:e -- X1:p2l:w edge [color="#000000" dir=forward style=dashed] - __F_3:e -- X1:p3l:w + AUTOGENERATED_F_3:p1r:e -- X1:p3l:w edge [color="#000000" dir=forward style=dashed] - __F_4:e -- X1:p4l:w + AUTOGENERATED_F_4:p1r:e -- X1:p4l:w } diff --git a/examples/ex11.html b/examples/ex11.html index cb83ac3..0cf591d 100644 --- a/examples/ex11.html +++ b/examples/ex11.html @@ -1,7 +1,7 @@ - + ex11 - +

ex11

Diagram

@@ -30,172 +30,210 @@
- - - - - + + + + -__F_1 - - -Ferrule - -GY - - +AUTOGENERATED_F_1 + + + +Ferrule + +GY + + - -X1 - - -X1 - -Screw connector - -male - -4-pin - -GN - - - -1 - -A - -2 - -B - -3 - -C - -4 - -D - - - -__F_1:e--X1:w - - - - -__F_2 - - -Ferrule - -GY - - +X1 + + + +X1 + +Screw connector + +male + +4-pin + +GN + + + +1 + +A + +2 + +B + +3 + +C + +4 + +D - - -__F_2:e--X1:w - - + + +AUTOGENERATED_F_1:e--X1:w + + - + -__F_3 - - -Ferrule - -GY - - +AUTOGENERATED_F_2 + + + +Ferrule + +GY + + - - -__F_3:e--X1:w - - + + +AUTOGENERATED_F_2:e--X1:w + + - + -__F_4 - - -Ferrule - -GY - - +AUTOGENERATED_F_3 + + + +Ferrule + +GY + + - - -__F_4:e--X1:w - - + + +AUTOGENERATED_F_3:e--X1:w + + + + + +AUTOGENERATED_F_4 + + + +Ferrule + +GY + + + + + +AUTOGENERATED_F_4:e--X1:w + + W1 - - -W1 - -4x - -BK - - -  -     1:BK     - - - -     2:WH     - - - -     3:BU     - - - -     4:BN     - - - -  + + + +W1 + +4x + +BK + + +  + + +1:BK + + + + +2:WH + + + + +3:BU + + + + +4:BN + + +  - - -W1:e--__F_1:w - - - + + +W1:e--AUTOGENERATED_F_1:w + + + - - -W1:e--__F_2:w - - - + + +W1:e--AUTOGENERATED_F_2:w + + + - - -W1:e--__F_3:w - - - + + +W1:e--AUTOGENERATED_F_3:w + + + - - -W1:e--__F_4:w - - - + + +W1:e--AUTOGENERATED_F_4:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + @@ -211,33 +249,29 @@
- - + - + - - - - - - - - - + - + - - + - + + + + + + +
IdDescription# QtyUnitDescription Designators
1Cable, 4 wires, BK0mW1
2Connector, Ferrule, GY1 4Connector, Ferrule, GY
3Connector, Screw connector, male, 4 pins, GN2 1Connector, Screw connector, male, 4 pins, GN X1
31Cable, 4 wires, BKW1
diff --git a/examples/ex11.png b/examples/ex11.png index ce4bc42..a42bc3b 100644 Binary files a/examples/ex11.png and b/examples/ex11.png differ diff --git a/examples/ex11.svg b/examples/ex11.svg index 5ab1d79..0038aa8 100644 --- a/examples/ex11.svg +++ b/examples/ex11.svg @@ -1,172 +1,210 @@ - - - - - + + + + -__F_1 - - -Ferrule - -GY - - +AUTOGENERATED_F_1 + + + +Ferrule + +GY + + - -X1 - - -X1 - -Screw connector - -male - -4-pin - -GN - - - -1 - -A - -2 - -B - -3 - -C - -4 - -D - - - -__F_1:e--X1:w - - - - -__F_2 - - -Ferrule - -GY - - +X1 + + + +X1 + +Screw connector + +male + +4-pin + +GN + + + +1 + +A + +2 + +B + +3 + +C + +4 + +D - - -__F_2:e--X1:w - - + + +AUTOGENERATED_F_1:e--X1:w + + - + -__F_3 - - -Ferrule - -GY - - +AUTOGENERATED_F_2 + + + +Ferrule + +GY + + - - -__F_3:e--X1:w - - + + +AUTOGENERATED_F_2:e--X1:w + + - + -__F_4 - - -Ferrule - -GY - - +AUTOGENERATED_F_3 + + + +Ferrule + +GY + + - - -__F_4:e--X1:w - - + + +AUTOGENERATED_F_3:e--X1:w + + + + + +AUTOGENERATED_F_4 + + + +Ferrule + +GY + + + + + +AUTOGENERATED_F_4:e--X1:w + + W1 - - -W1 - -4x - -BK - - -  -     1:BK     - - - -     2:WH     - - - -     3:BU     - - - -     4:BN     - - - -  + + + +W1 + +4x + +BK + + +  + + +1:BK + + + + +2:WH + + + + +3:BU + + + + +4:BN + + +  - - -W1:e--__F_1:w - - - + + +W1:e--AUTOGENERATED_F_1:w + + + - - -W1:e--__F_2:w - - - + + +W1:e--AUTOGENERATED_F_2:w + + + - - -W1:e--__F_3:w - - - + + +W1:e--AUTOGENERATED_F_3:w + + + - - -W1:e--__F_4:w - - - + + +W1:e--AUTOGENERATED_F_4:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + diff --git a/examples/ex11_wv_gvpr.gvpr b/examples/ex11_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex11_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex12.bom.tsv b/examples/ex12.bom.tsv index b7242cb..cafd8fe 100644 --- a/examples/ex12.bom.tsv +++ b/examples/ex12.bom.tsv @@ -1,7 +1,7 @@ -Id Description Qty Unit Designators -1 Connector, Dupont 2.54mm, female, 5 pins, BK 1 X2 -2 Connector, Dupont 2.54mm, male, 5 pins, BK 1 X1 -3 Wire, BK 0.4 m W1, W2 -4 Wire, BU 0.4 m W1, W2 -5 Wire, GN 0.4 m W1, W2 -6 Wire, RD 0.4 m W1, W2 +# Qty Unit Description Designators +1 1 Connector, Dupont 2.54mm, female, 5 pins, BK X2 +2 1 Connector, Dupont 2.54mm, male, 5 pins, BK X1 +3 2 m Wire, BK W1, W2 +4 2 m Wire, BU W1, W2 +5 2 m Wire, GN W1, W2 +6 2 m Wire, RD W1, W2 diff --git a/examples/ex12.gv b/examples/ex12.gv index f0cb0e9..a507970 100644 --- a/examples/ex12.gv +++ b/examples/ex12.gv @@ -1,269 +1,295 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - - - -
Dupont 2.54mmmale5-pinBK
-
- - - - - - - - - - - - - - - - -
1
2
3
4
5
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + + + +
Dupont 2.54mmmale5-pinBK
+
+ + + + + + + + + + + + + + + + + + + + + +
1
2
3
4
5
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - - - -
Dupont 2.54mmfemale5-pinBK
-
- - - - - - - - - - - - - - - - -
1
2
3
4
5
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + + + +
Dupont 2.54mmfemale5-pinBK
+
+ + + + + + + + + + + + + + + + + + + + + +
1
2
3
4
5
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ff0000:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + +
4x0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
RD X1:1
BK X1:2
BU X1:3
GN X1:4
 
+
+> shape=box style="filled,dashed"] + edge [color="#000000:#FF0000:#000000"] W1:w1:e -- X1:p1l:w edge [color="#000000:#000000:#000000"] W1:w2:e -- X1:p2l:w - edge [color="#000000:#0066ff:#000000"] + edge [color="#000000:#0066FF:#000000"] W1:w3:e -- X1:p3l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] W1:w4:e -- X1:p4l:w - W1 [label=< - - - - + W1:w1:e -- W1:w1:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#000000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#0066FF:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#00AA00:#000000" straight=straight] + W2 [label=< +
- - -
W1
-
- - - -
4x0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- RD - X1:1
- - - - -
-
- BK - X1:2
- - - - -
-
- BU - X1:3
- - - - -
-
- GN - X1:4
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W2
+
+ + + + + +
4x0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X2:1 RD
X2:2 BK
X2:3 BU
X2:4 GN
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#ff0000:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#FF0000:#000000"] X2:p1r:e -- W2:w1:w edge [color="#000000:#000000:#000000"] X2:p2r:e -- W2:w2:w - edge [color="#000000:#0066ff:#000000"] + edge [color="#000000:#0066FF:#000000"] X2:p3r:e -- W2:w3:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] X2:p4r:e -- W2:w4:w - W2 [label=< - - - - -
- - -
W2
-
- - - -
4x0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X2:1 - RD -
- - - - -
-
X2:2 - BK -
- - - - -
-
X2:3 - BU -
- - - - -
-
X2:4 - GN -
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#000000" dir=forward style=dashed] + W2:w1:e -- W2:w1:w [color="#000000:#FF0000:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#000000:#000000" straight=straight] + W2:w3:e -- W2:w3:w [color="#000000:#0066FF:#000000" straight=straight] + W2:w4:e -- W2:w4:w [color="#000000:#00AA00:#000000" straight=straight] + edge [color="#000000" dir=forward style=dashed] X1:e -- X2:w } diff --git a/examples/ex12.html b/examples/ex12.html index e610829..02cb025 100644 --- a/examples/ex12.html +++ b/examples/ex12.html @@ -1,7 +1,7 @@ - + ex12 - +

ex12

Diagram

@@ -30,195 +30,254 @@
- - - - + + + X1 - - -X1 - -Dupont 2.54mm - -male - -5-pin - -BK - - - -1 - -2 - -3 - -4 - -5 + + + +X1 + +Dupont 2.54mm + +male + +5-pin + +BK + + + +1 + +2 + +3 + +4 + +5 X2 - - -X2 - -Dupont 2.54mm - -female - -5-pin - -BK - - - -1 - -2 - -3 - -4 - -5 + + + +X2 + +Dupont 2.54mm + +female + +5-pin + +BK + + + +1 + +2 + +3 + +4 + +5 - + X1:e--X2:w - - - + + - + W2 - - -W2 - -4x - -0.2 m -  -X2:1 -     RD     - - - -X2:2 -     BK     - - - -X2:3 -     BU     - - - -X2:4 -     GN     - - - -  + + + +W2 + +4x + +0.2 m +  + X2:1 + +RD + + + X2:2 + +BK + + + X2:3 + +BU + + + X2:4 + +GN + + +  + + + +X2:e--W2:w + + + + + + +X2:e--W2:w + + + + + + +X2:e--W2:w + + + X2:e--W2:w - - - + + + - + -X2:e--W2:w - - - +W2:e--W2:w + + + - + -X2:e--W2:w - - - +W2:e--W2:w + + + - + -X2:e--W2:w - - - +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + W1 - - -W1 - -4x - -0.2 m -  -     RD     -X1:1 - - - -     BK     -X1:2 - - - -     BU     -X1:3 - - - -     GN     -X1:4 - - - -  + + + +W1 + +4x + +0.2 m +  + + +RD + +X1:1 + + +BK + +X1:2 + + +BU + +X1:3 + + +GN + +X1:4 +  - + W1:e--X1:w - - - + + + - + W1:e--X1:w - - - + + + - + W1:e--X1:w - - - + + + - + W1:e--X1:w - - - + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + @@ -234,52 +293,52 @@
- - + + - - + + - - + + - + + + - - - + + + - - - + + + - - - - - + + +
IdDescription# Qty UnitDescription Designators
1Connector, Dupont 2.54mm, female, 5 pins, BK1 1 Connector, Dupont 2.54mm, female, 5 pins, BK X2
2Connector, Dupont 2.54mm, male, 5 pins, BK2 1 Connector, Dupont 2.54mm, male, 5 pins, BK X1
332m Wire, BK0.4m W1, W2
442m Wire, BU0.4m W1, W2
552m Wire, GN0.4m W1, W2
6Wire, RD0.462 mWire, RD W1, W2
diff --git a/examples/ex12.png b/examples/ex12.png index 713e37e..c7fedac 100644 Binary files a/examples/ex12.png and b/examples/ex12.png differ diff --git a/examples/ex12.svg b/examples/ex12.svg index 9c8fa40..17acded 100644 --- a/examples/ex12.svg +++ b/examples/ex12.svg @@ -1,195 +1,254 @@ - - - - + + + X1 - - -X1 - -Dupont 2.54mm - -male - -5-pin - -BK - - - -1 - -2 - -3 - -4 - -5 + + + +X1 + +Dupont 2.54mm + +male + +5-pin + +BK + + + +1 + +2 + +3 + +4 + +5 X2 - - -X2 - -Dupont 2.54mm - -female - -5-pin - -BK - - - -1 - -2 - -3 - -4 - -5 + + + +X2 + +Dupont 2.54mm + +female + +5-pin + +BK + + + +1 + +2 + +3 + +4 + +5 - + X1:e--X2:w - - - + + - + W2 - - -W2 - -4x - -0.2 m -  -X2:1 -     RD     - - - -X2:2 -     BK     - - - -X2:3 -     BU     - - - -X2:4 -     GN     - - - -  + + + +W2 + +4x + +0.2 m +  + X2:1 + +RD + + + X2:2 + +BK + + + X2:3 + +BU + + + X2:4 + +GN + + +  + + + +X2:e--W2:w + + + + + + +X2:e--W2:w + + + + + + +X2:e--W2:w + + + X2:e--W2:w - - - + + + - + -X2:e--W2:w - - - +W2:e--W2:w + + + - + -X2:e--W2:w - - - +W2:e--W2:w + + + - + -X2:e--W2:w - - - +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + W1 - - -W1 - -4x - -0.2 m -  -     RD     -X1:1 - - - -     BK     -X1:2 - - - -     BU     -X1:3 - - - -     GN     -X1:4 - - - -  + + + +W1 + +4x + +0.2 m +  + + +RD + +X1:1 + + +BK + +X1:2 + + +BU + +X1:3 + + +GN + +X1:4 +  - + W1:e--X1:w - - - + + + - + W1:e--X1:w - - - + + + - + W1:e--X1:w - - - + + + - + W1:e--X1:w - - - + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + diff --git a/examples/ex12_wv_gvpr.gvpr b/examples/ex12_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex12_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex13.bom.tsv b/examples/ex13.bom.tsv index b5936d2..92c458f 100644 --- a/examples/ex13.bom.tsv +++ b/examples/ex13.bom.tsv @@ -1,4 +1,4 @@ -Id Description Qty Unit Designators -1 Cable, 4 wires 0 m C1, C2, C3 -2 Connector, 4 pins 3 X1, X2, X3 -3 Connector, ferrule 4 +# Qty Description Designators +1 3 Connector, 4 pins X1, X2, X3 +2 4 Connector, ferrule F1, F2, F3, F4 +3 3 Cable, 4 wires C1, C2, C3 diff --git a/examples/ex13.gv b/examples/ex13.gv index 9488310..137812b 100644 --- a/examples/ex13.gv +++ b/examples/ex13.gv @@ -1,433 +1,461 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - -
4-pin
-
- - - - - - - - - - - - - - - - - -
A1
B2
C3
D4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + +
4-pin
+
+ + + + + + + + + + + + + + + + + +
A1
B2
C3
D4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] F1 [label=< - - +
- - -
ferrule
-
+ + +
+ + + + +
ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] F2 [label=< - - +
- - -
ferrule
-
+ + +
+ + + + +
ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] F3 [label=< - - +
- - -
ferrule
-
+ + +
+ + + + +
ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] F4 [label=< - - +
- - -
ferrule
-
+ + +
+ + + + +
ferrule
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - -
4-pin
-
- - - - - - - - - - - - - - - - - -
1A
2B
3C
4D
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + +
4-pin
+
+ + + + + + + + + + + + + + + + + +
1A
2B
3C
4D
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - +
- - -
X3
-
- - -
4-pin
-
- - - - - - - - - - - - - - - - - -
1A
2B
3C
4D
-
+ + + + + + + + +
+ + + + +
X3
+
+ + + + +
4-pin
+
+ + + + + + + + + + + + + + + + + +
1A
2B
3C
4D
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + C1 [label=< + + + + + + + + + + +
+ + + + +
C1
+
+ + + + +
4x
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:A 1:WH F1
X1:2:B 2:BN F2
X1:3:C 3:GN F3
X1:4:D 4:YE F4
 
+
+> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] X1:p1r:e -- C1:w1:w C1:w1:e -- F1:w edge [color="#000000:#895956:#000000"] X1:p2r:e -- C1:w2:w C1:w2:e -- F2:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] X1:p3r:e -- C1:w3:w C1:w3:e -- F3:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p4r:e -- C1:w4:w C1:w4:e -- F4:w - C1 [label=< - - - - + C1:w1:e -- C1:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + C1:w2:e -- C1:w2:w [color="#000000:#895956:#000000" straight=straight] + C1:w3:e -- C1:w3:w [color="#000000:#00AA00:#000000" straight=straight] + C1:w4:e -- C1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + C2 [label=< +
- - -
C1
-
- - -
4x
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:A - 1:WH -
- - - - -
-
X1:2:B - 2:BN -
- - - - -
-
X1:3:C - 3:GN -
- - - - -
-
X1:4:D - 4:YE -
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
C2
+
+ + + + +
4x
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
F1 1:WH X2:1:A
F2 2:BN X2:2:B
F3 3:GN X2:3:C
F4 4:YE X2:4:D
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] F1:e -- C2:w1:w C2:w1:e -- X2:p1l:w edge [color="#000000:#895956:#000000"] F2:e -- C2:w2:w C2:w2:e -- X2:p2l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] F3:e -- C2:w3:w C2:w3:e -- X2:p3l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] F4:e -- C2:w4:w C2:w4:e -- X2:p4l:w - C2 [label=< - - - - + C2:w1:e -- C2:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + C2:w2:e -- C2:w2:w [color="#000000:#895956:#000000" straight=straight] + C2:w3:e -- C2:w3:w [color="#000000:#00AA00:#000000" straight=straight] + C2:w4:e -- C2:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + C3 [label=< +
- - -
C2
-
- - -
4x
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- 1:WH - X2:1:A
- - - - -
-
- 2:BN - X2:2:B
- - - - -
-
- 3:GN - X2:3:C
- - - - -
-
- 4:YE - X2:4:D
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
C3
+
+ + + + +
4x
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
F1 1:WH X3:1:A
F2 2:BN X3:2:B
F3 3:GN X3:3:C
F4 4:YE X3:4:D
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] F1:e -- C3:w1:w C3:w1:e -- X3:p1l:w edge [color="#000000:#895956:#000000"] F2:e -- C3:w2:w C3:w2:e -- X3:p2l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] F3:e -- C3:w3:w C3:w3:e -- X3:p3l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] F4:e -- C3:w4:w C3:w4:e -- X3:p4l:w - C3 [label=< - - - - -
- - -
C3
-
- - -
4x
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- 1:WH - X3:1:A
- - - - -
-
- 2:BN - X3:2:B
- - - - -
-
- 3:GN - X3:3:C
- - - - -
-
- 4:YE - X3:4:D
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + C3:w1:e -- C3:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + C3:w2:e -- C3:w2:w [color="#000000:#895956:#000000" straight=straight] + C3:w3:e -- C3:w3:w [color="#000000:#00AA00:#000000" straight=straight] + C3:w4:e -- C3:w4:w [color="#000000:#FFFF00:#000000" straight=straight] } diff --git a/examples/ex13.html b/examples/ex13.html index 606d0f0..5242444 100644 --- a/examples/ex13.html +++ b/examples/ex13.html @@ -1,7 +1,7 @@ - + ex13 - +

ex13

Diagram

@@ -30,376 +30,470 @@
- - - - + + + X1 - - -X1 - -4-pin - -A - -1 - -B - -2 - -C - -3 - -D - -4 + + + +X1 + +4-pin + +A + +1 + +B + +2 + +C + +3 + +D + +4 - + C1 - - -C1 - -4x -  -X1:1:A -     1:WH     - - - -X1:2:B -     2:BN     - - - -X1:3:C -     3:GN     - - - -X1:4:D -     4:YE     - - - -  + + + +C1 + +4x +  + X1:1:A + +1:WH + +F1 + X1:2:B + +2:BN + +F2 + X1:3:C + +3:GN + +F3 + X1:4:D + +4:YE + +F4 +  X1:e--C1:w - - - + + + + + + +X1:e--C1:w + + + X1:e--C1:w - - - + + + + +X1:e--C1:w + + + + + -X1:e--C1:w - - - +C1:e--C1:w + + + - + + +C1:e--C1:w + + + + + -X1:e--C1:w - - - +C1:e--C1:w + + + + + + +C1:e--C1:w + + + - -F1 - - -ferrule - - - -C2 - - -C2 - -4x -  -     1:WH     -X2:1:A - - - -     2:BN     -X2:2:B - - - -     3:GN     -X2:3:C - - - -     4:YE     -X2:4:D - - - -  - - - -F1:e--C2:w - - - - - - -C3 - - -C3 - -4x -  -     1:WH     -X3:1:A - - - -     2:BN     -X3:2:B - - - -     3:GN     -X3:3:C - - - -     4:YE     -X3:4:D - - - -  - - - -F1:e--C3:w - - - - - -F2 - - -ferrule - - - -F2:e--C2:w - - - - - - -F2:e--C3:w - - - - - - -F3 - - -ferrule - - - -F3:e--C2:w - - - - - - -F3:e--C3:w - - - - - - -F4 - - -ferrule - - - -F4:e--C2:w - - - - - - -F4:e--C3:w - - - - - - -X2 - - -X2 - -4-pin - -1 - -A - -2 - -B - -3 - -C - -4 - -D - - - -X3 - - -X3 - -4-pin - -1 - -A - -2 - -B - -3 - -C - -4 - -D +F1 + + + +ferrule - + C1:e--F1:w - - - + + + + + + +F2 + + + +ferrule - + C1:e--F2:w - - - + + + + + + +F3 + + + +ferrule - + C1:e--F3:w - - - + + + + + + +F4 + + + +ferrule - -C1:e--F4:w - - - - - - -C2:e--X2:w - - - - - -C2:e--X2:w - - - +C1:e--F4:w + + + - + + +C2 + + + +C2 + +4x +  + F1 + +1:WH + +X2:1:A + F2 + +2:BN + +X2:2:B + F3 + +3:GN + +X2:3:C + F4 + +4:YE + +X2:4:D +  + + + +F1:e--C2:w + + + + + + +C3 + + + +C3 + +4x +  + F1 + +1:WH + +X3:1:A + F2 + +2:BN + +X3:2:B + F3 + +3:GN + +X3:3:C + F4 + +4:YE + +X3:4:D +  + + -C2:e--X2:w - - - +F1:e--C3:w + + + + + + +F2:e--C2:w + + + + + + +F2:e--C3:w + + + + + + +F3:e--C2:w + + + + + + +F3:e--C3:w + + + + + + +F4:e--C2:w + + + + + + +F4:e--C3:w + + + + + + +C2:e--C2:w + + + + + + +C2:e--C2:w + + + + + + +C2:e--C2:w + + + + + + +C2:e--C2:w + + + + + + +X2 + + + +X2 + +4-pin + +1 + +A + +2 + +B + +3 + +C + +4 + +D - + C2:e--X2:w - - - + + + - - -C3:e--X3:w - - - - - + -C3:e--X3:w - - - +C2:e--X2:w + + + - + + +C2:e--X2:w + + + + + -C3:e--X3:w - - - +C2:e--X2:w + + + + + + +C3:e--C3:w + + + + + + +C3:e--C3:w + + + + + + +C3:e--C3:w + + + + + + +C3:e--C3:w + + + + + + +X3 + + + +X3 + +4-pin + +1 + +A + +2 + +B + +3 + +C + +4 + +D - + C3:e--X3:w - - - + + + + + + +C3:e--X3:w + + + + + + +C3:e--X3:w + + + + + + +C3:e--X3:w + + + @@ -415,32 +509,28 @@
- - + - + - - - - - - - - - + - + - - + - - + + + + + + + +
IdDescription# QtyUnitDescription Designators
1Cable, 4 wires0mC1, C2, C3
2Connector, 4 pins1 3Connector, 4 pins X1, X2, X3
3Connector, ferrule2 4Connector, ferruleF1, F2, F3, F4
33Cable, 4 wiresC1, C2, C3
diff --git a/examples/ex13.png b/examples/ex13.png index f0d4a98..61a4782 100644 Binary files a/examples/ex13.png and b/examples/ex13.png differ diff --git a/examples/ex13.svg b/examples/ex13.svg index c2281c1..222d6e3 100644 --- a/examples/ex13.svg +++ b/examples/ex13.svg @@ -1,376 +1,470 @@ - - - - + + + X1 - - -X1 - -4-pin - -A - -1 - -B - -2 - -C - -3 - -D - -4 + + + +X1 + +4-pin + +A + +1 + +B + +2 + +C + +3 + +D + +4 - + C1 - - -C1 - -4x -  -X1:1:A -     1:WH     - - - -X1:2:B -     2:BN     - - - -X1:3:C -     3:GN     - - - -X1:4:D -     4:YE     - - - -  + + + +C1 + +4x +  + X1:1:A + +1:WH + +F1 + X1:2:B + +2:BN + +F2 + X1:3:C + +3:GN + +F3 + X1:4:D + +4:YE + +F4 +  X1:e--C1:w - - - + + + + + + +X1:e--C1:w + + + X1:e--C1:w - - - + + + + +X1:e--C1:w + + + + + -X1:e--C1:w - - - +C1:e--C1:w + + + - + + +C1:e--C1:w + + + + + -X1:e--C1:w - - - +C1:e--C1:w + + + + + + +C1:e--C1:w + + + - -F1 - - -ferrule - - - -C2 - - -C2 - -4x -  -     1:WH     -X2:1:A - - - -     2:BN     -X2:2:B - - - -     3:GN     -X2:3:C - - - -     4:YE     -X2:4:D - - - -  - - - -F1:e--C2:w - - - - - - -C3 - - -C3 - -4x -  -     1:WH     -X3:1:A - - - -     2:BN     -X3:2:B - - - -     3:GN     -X3:3:C - - - -     4:YE     -X3:4:D - - - -  - - - -F1:e--C3:w - - - - - -F2 - - -ferrule - - - -F2:e--C2:w - - - - - - -F2:e--C3:w - - - - - - -F3 - - -ferrule - - - -F3:e--C2:w - - - - - - -F3:e--C3:w - - - - - - -F4 - - -ferrule - - - -F4:e--C2:w - - - - - - -F4:e--C3:w - - - - - - -X2 - - -X2 - -4-pin - -1 - -A - -2 - -B - -3 - -C - -4 - -D - - - -X3 - - -X3 - -4-pin - -1 - -A - -2 - -B - -3 - -C - -4 - -D +F1 + + + +ferrule - + C1:e--F1:w - - - + + + + + + +F2 + + + +ferrule - + C1:e--F2:w - - - + + + + + + +F3 + + + +ferrule - + C1:e--F3:w - - - + + + + + + +F4 + + + +ferrule - -C1:e--F4:w - - - - - - -C2:e--X2:w - - - - - -C2:e--X2:w - - - +C1:e--F4:w + + + - + + +C2 + + + +C2 + +4x +  + F1 + +1:WH + +X2:1:A + F2 + +2:BN + +X2:2:B + F3 + +3:GN + +X2:3:C + F4 + +4:YE + +X2:4:D +  + + + +F1:e--C2:w + + + + + + +C3 + + + +C3 + +4x +  + F1 + +1:WH + +X3:1:A + F2 + +2:BN + +X3:2:B + F3 + +3:GN + +X3:3:C + F4 + +4:YE + +X3:4:D +  + + -C2:e--X2:w - - - +F1:e--C3:w + + + + + + +F2:e--C2:w + + + + + + +F2:e--C3:w + + + + + + +F3:e--C2:w + + + + + + +F3:e--C3:w + + + + + + +F4:e--C2:w + + + + + + +F4:e--C3:w + + + + + + +C2:e--C2:w + + + + + + +C2:e--C2:w + + + + + + +C2:e--C2:w + + + + + + +C2:e--C2:w + + + + + + +X2 + + + +X2 + +4-pin + +1 + +A + +2 + +B + +3 + +C + +4 + +D - + C2:e--X2:w - - - + + + - - -C3:e--X3:w - - - - - + -C3:e--X3:w - - - +C2:e--X2:w + + + - + + +C2:e--X2:w + + + + + -C3:e--X3:w - - - +C2:e--X2:w + + + + + + +C3:e--C3:w + + + + + + +C3:e--C3:w + + + + + + +C3:e--C3:w + + + + + + +C3:e--C3:w + + + + + + +X3 + + + +X3 + +4-pin + +1 + +A + +2 + +B + +3 + +C + +4 + +D - + C3:e--X3:w - - - + + + + + + +C3:e--X3:w + + + + + + +C3:e--X3:w + + + + + + +C3:e--X3:w + + + diff --git a/examples/ex13_wv_gvpr.gvpr b/examples/ex13_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex13_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex14.bom.tsv b/examples/ex14.bom.tsv index c0e5307..fe077f4 100644 --- a/examples/ex14.bom.tsv +++ b/examples/ex14.bom.tsv @@ -1,8 +1,8 @@ -Id Description Qty Unit Designators -1 Cable, 1 wires 0.1 m -2 Cable, 4 wires 0.4 m W1, W2, W21, W3 -3 Connector, Ferrule, GY 4 -4 Connector, JST SM, female, 4 pins 1 X2 -5 Connector, JST SM, male, 4 pins 2 X1, X3 -6 Connector, Screw terminal connector, 4 pins, GN 1 X4 -7 Connector, Splice, CU 8 +# Qty Unit Description Designators +1 4 Connector, Ferrule, GY +2 1 Connector, JST SM, female, 4 pins X2 +3 2 Connector, JST SM, male, 4 pins X1, X3 +4 1 Connector, Screw terminal connector, 4 pins, GN X4 +5 8 Connector, Splice, CU S1 +6 1 m Cable, 1 wires +7 4 m Cable, 4 wires W1, W2, W21, W3 diff --git a/examples/ex14.gv b/examples/ex14.gv index 776e08b..3028c81 100644 --- a/examples/ex14.gv +++ b/examples/ex14.gv @@ -1,717 +1,786 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
JST SMmale4-pin
-
- - - - - - - - - - - - - - - - - -
A1
B2
C3
D4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
JST SMmale4-pin
+
+ + + + + + + + + + + + + + + + + +
A1
B2
C3
D4
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __S_1 [label=< - - +> shape=box style=filled] + AUTOGENERATED_S_1 [label=< +
- - - - -
SpliceCU
-
+ + +
+ + + + + + +
SpliceCU
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __S_2 [label=< - - +> shape=box style=filled] + AUTOGENERATED_S_2 [label=< +
- - - - -
SpliceCU
-
+ + +
+ + + + + + +
SpliceCU
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] S1 [label=< - - +
- - - - -
SpliceCU
-
+ + +
+ + + + + + +
SpliceCU
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __S_3 [label=< - - +> shape=box style=filled] + AUTOGENERATED_S_3 [label=< +
- - - - -
SpliceCU
-
+ + +
+ + + + + + +
SpliceCU
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __S_4 [label=< - - +> shape=box style=filled] + AUTOGENERATED_S_4 [label=< +
- - - - -
SpliceCU
-
+ + +
+ + + + + + +
SpliceCU
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __S_5 [label=< - - +> shape=box style=filled] + AUTOGENERATED_S_5 [label=< +
- - - - -
SpliceCU
-
+ + +
+ + + + + + +
SpliceCU
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __S_6 [label=< - - +> shape=box style=filled] + AUTOGENERATED_S_6 [label=< +
- - - - -
SpliceCU
-
+ + +
+ + + + + + +
SpliceCU
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __S_7 [label=< - - +> shape=box style=filled] + AUTOGENERATED_S_7 [label=< +
- - - - -
SpliceCU
-
+ + +
+ + + + + + +
SpliceCU
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
JST SMfemale4-pin
-
- - - - - - - - - - - - - - - - - -
1A
2B
3C
4D
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
JST SMfemale4-pin
+
+ + + + + + + + + + + + + + + + + +
1A
2B
3C
4D
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - +
- - -
X3
-
- - - - -
JST SMmale4-pin
-
- - - - - - - - - - - - - - - - - -
A1
B2
C3
D4
-
+ + + + + + + + +
+ + + + +
X3
+
+ + + + + + +
JST SMmale4-pin
+
+ + + + + + + + + + + + + + + + + +
A1
B2
C3
D4
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_1 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_1 [label=< +
- - - - -
FerruleGY
-
+ + +
+ + + + + + +
FerruleGY
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_2 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_2 [label=< +
- - - - -
FerruleGY
-
+ + +
+ + + + + + +
FerruleGY
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_3 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_3 [label=< +
- - - - -
FerruleGY
-
+ + +
+ + + + + + +
FerruleGY
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_4 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_4 [label=< +
- - - - -
FerruleGY
-
+ + +
+ + + + + + +
FerruleGY
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X4 [label=< - - - - +
- - -
X4
-
- - - - - -
Screw terminal connector4-pinGN
-
- - - - - - - - - - - - - - - - - -
1W
2X
3Y
4Z
-
+ + + + + + + + +
+ + + + +
X4
+
+ + + + + + + +
Screw terminal connector4-pinGN
+
+ + + + + + + + + + + + + + + + + +
1W
2X
3Y
4Z
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + +
4x0.1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:4:D 1:WH
X1:3:C 2:BN
X1:2:B 3:GN S1
X1:1:A 4:YE
 
+
+> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] X1:p4r:e -- W1:w1:w - W1:w1:e -- __S_1:w + W1:w1:e -- AUTOGENERATED_S_1:w edge [color="#000000:#895956:#000000"] X1:p3r:e -- W1:w2:w - W1:w2:e -- __S_2:w - edge [color="#000000:#00ff00:#000000"] + W1:w2:e -- AUTOGENERATED_S_2:w + edge [color="#000000:#00AA00:#000000"] X1:p2r:e -- W1:w3:w W1:w3:e -- S1:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p1r:e -- W1:w4:w - W1:w4:e -- __S_3:w - W1 [label=< - - - - -
- - -
W1
-
- - - -
4x0.1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:4:D - 1:WH -
- - - - -
-
X1:3:C - 2:BN -
- - - - -
-
X1:2:B - 3:GN -
- - - - -
-
X1:1:A - 4:YE -
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] - __S_1:e -- W2:w1:w - W2:w1:e -- __S_4:w - edge [color="#000000:#895956:#000000"] - __S_2:e -- W2:w2:w - W2:w2:e -- __S_5:w - edge [color="#000000:#00ff00:#000000"] - S1:e -- W2:w3:w - W2:w3:e -- __S_6:w - edge [color="#000000:#ffff00:#000000"] - __S_3:e -- W2:w4:w - W2:w4:e -- __S_7:w + W1:w4:e -- AUTOGENERATED_S_3:w + W1:w1:e -- W1:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#895956:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#00AA00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] W2 [label=< - - - - +
- - -
W2
-
- - - -
4x0.1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- 1:WH -
- - - - -
-
- 2:BN -
- - - - -
-
- 3:GN -
- - - - -
-
- 4:YE -
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W2
+
+ + + + + +
4x0.1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
1:WH
2:BN
S1 3:GN
4:YE
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] - __S_4:e -- W21:w1:w +> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] + AUTOGENERATED_S_1:e -- W2:w1:w + W2:w1:e -- AUTOGENERATED_S_4:w + edge [color="#000000:#895956:#000000"] + AUTOGENERATED_S_2:e -- W2:w2:w + W2:w2:e -- AUTOGENERATED_S_5:w + edge [color="#000000:#00AA00:#000000"] + S1:e -- W2:w3:w + W2:w3:e -- AUTOGENERATED_S_6:w + edge [color="#000000:#FFFF00:#000000"] + AUTOGENERATED_S_3:e -- W2:w4:w + W2:w4:e -- AUTOGENERATED_S_7:w + W2:w1:e -- W2:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#895956:#000000" straight=straight] + W2:w3:e -- W2:w3:w [color="#000000:#00AA00:#000000" straight=straight] + W2:w4:e -- W2:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + W21 [label=< + + + + + + + + + + +
+ + + + +
W21
+
+ + + + + +
4x0.1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
1:WH X2:1:A
2:BN X2:2:B
3:GN X2:3:C
4:YE X2:4:D
 
+
+> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] + AUTOGENERATED_S_4:e -- W21:w1:w W21:w1:e -- X2:p1l:w edge [color="#000000:#895956:#000000"] - __S_5:e -- W21:w2:w + AUTOGENERATED_S_5:e -- W21:w2:w W21:w2:e -- X2:p2l:w - edge [color="#000000:#00ff00:#000000"] - __S_6:e -- W21:w3:w + edge [color="#000000:#00AA00:#000000"] + AUTOGENERATED_S_6:e -- W21:w3:w W21:w3:e -- X2:p3l:w - edge [color="#000000:#ffff00:#000000"] - __S_7:e -- W21:w4:w + edge [color="#000000:#FFFF00:#000000"] + AUTOGENERATED_S_7:e -- W21:w4:w W21:w4:e -- X2:p4l:w - W21 [label=< - - - - + W21:w1:e -- W21:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + W21:w2:e -- W21:w2:w [color="#000000:#895956:#000000" straight=straight] + W21:w3:e -- W21:w3:w [color="#000000:#00AA00:#000000" straight=straight] + W21:w4:e -- W21:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + W3 [label=< +
- - -
W21
-
- - - -
4x0.1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- 1:WH - X2:1:A
- - - - -
-
- 2:BN - X2:2:B
- - - - -
-
- 3:GN - X2:3:C
- - - - -
-
- 4:YE - X2:4:D
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W3
+
+ + + + + +
4x0.1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X3:1:A 1:WH
X3:2:B 2:BN
X3:3:C 3:GN
X3:4:D 4:YE
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] X3:p1r:e -- W3:w1:w - W3:w1:e -- __F_1:w + W3:w1:e -- AUTOGENERATED_F_1:w edge [color="#000000:#895956:#000000"] X3:p2r:e -- W3:w2:w - W3:w2:e -- __F_2:w - edge [color="#000000:#00ff00:#000000"] + W3:w2:e -- AUTOGENERATED_F_2:w + edge [color="#000000:#00AA00:#000000"] X3:p3r:e -- W3:w3:w - W3:w3:e -- __F_3:w - edge [color="#000000:#ffff00:#000000"] + W3:w3:e -- AUTOGENERATED_F_3:w + edge [color="#000000:#FFFF00:#000000"] X3:p4r:e -- W3:w4:w - W3:w4:e -- __F_4:w - W3 [label=< - - - - + W3:w4:e -- AUTOGENERATED_F_4:w + W3:w1:e -- W3:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + W3:w2:e -- W3:w2:w [color="#000000:#895956:#000000" straight=straight] + W3:w3:e -- W3:w3:w [color="#000000:#00AA00:#000000" straight=straight] + W3:w4:e -- W3:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + AUTOGENERATED_WIRE_1 [label=< +
- - -
W3
-
- - - -
4x0.1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X3:1:A - 1:WH -
- - - - -
-
X3:2:B - 2:BN -
- - - - -
-
X3:3:C - 3:GN -
- - - - -
-
X3:4:D - 4:YE -
- - - - -
-
 
-
+ + + + + +
+ + + + + +
1x0.1 m
+
+ + + + + + + + + + + + + + + + + +
 
S1 1:BK X2:4:D
 
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] edge [color="#000000:#000000:#000000"] - S1:e -- __WIRE_1:w1:w - __WIRE_1:w1:e -- X2:p4l:w - __WIRE_1 [label=< - - - -
- - - -
1x0.1 m
-
- - - - - - - - - - - -
 
- 1:BK - X2:4:D
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#000000" dir=both style=dashed] + S1:e -- AUTOGENERATED_WIRE_1:w1:w + AUTOGENERATED_WIRE_1:w1:e -- X2:p4l:w + AUTOGENERATED_WIRE_1:w1:e -- AUTOGENERATED_WIRE_1:w1:w [color="#000000:#000000:#000000" straight=straight] + edge [color="#000000" dir=both style=dashed] X2:e -- X3:w edge [color="#000000" dir=forward style=dashed] - __F_1:e -- X4:p2l:w + AUTOGENERATED_F_1:p1r:e -- X4:p2l:w edge [color="#000000" dir=forward style=dashed] - __F_2:e -- X4:p1l:w + AUTOGENERATED_F_2:p1r:e -- X4:p1l:w edge [color="#000000" dir=forward style=dashed] - __F_3:e -- X4:p4l:w + AUTOGENERATED_F_3:p1r:e -- X4:p4l:w edge [color="#000000" dir=forward style=dashed] - __F_4:e -- X4:p3l:w + AUTOGENERATED_F_4:p1r:e -- X4:p3l:w } diff --git a/examples/ex14.html b/examples/ex14.html index 6007638..0bc708e 100644 --- a/examples/ex14.html +++ b/examples/ex14.html @@ -1,7 +1,7 @@ - + ex14 - +

ex14

Diagram

@@ -30,676 +30,819 @@
- - - - + + + X1 - - -X1 - -JST SM - -male - -4-pin - -A - -1 - -B - -2 - -C - -3 - -D - -4 + + + +X1 + +JST SM + +male + +4-pin + +A + +1 + +B + +2 + +C + +3 + +D + +4 - + W1 - - -W1 - -4x - -0.1 m -  -X1:4:D -     1:WH     - - - -X1:3:C -     2:BN     - - - -X1:2:B -     3:GN     - - - -X1:1:A -     4:YE     - - - -  + + + +W1 + +4x + +0.1 m +  + X1:4:D + +1:WH + + + X1:3:C + +2:BN + + + X1:2:B + +3:GN + +S1 + X1:1:A + +4:YE + + +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - - -__S_1 - - -Splice - -CU - - + + +W1:e--W1:w + + + - - -W2 - - -W2 - -4x - -0.1 m -  -     1:WH     - - - -     2:BN     - - - -     3:GN     - - - -     4:YE     - - - -  - - - -__S_1:e--W2:w - - - - - + -__S_2 - - -Splice - -CU - - +AUTOGENERATED_S_1 + + + +Splice + +CU + + - - -__S_2:e--W2:w - - - + + +W1:e--AUTOGENERATED_S_1:w + + + + + + +AUTOGENERATED_S_2 + + + +Splice + +CU + + + + + +W1:e--AUTOGENERATED_S_2:w + + + - -S1 - - -Splice - -CU - - - - - -S1:e--W2:w - - - - - - -__WIRE_1 - - -1x - -0.1 m -  -     1:BK     -X2:4:D - - - -  - - - -S1:e--__WIRE_1:w - - - - - -__S_3 - - -Splice - -CU - - - - - -__S_3:e--W2:w - - - - - - -__S_4 - - -Splice - -CU - - - - - -W21 - - -W21 - -4x - -0.1 m -  -     1:WH     -X2:1:A - - - -     2:BN     -X2:2:B - - - -     3:GN     -X2:3:C - - - -     4:YE     -X2:4:D - - - -  - - - -__S_4:e--W21:w - - - - - - -__S_5 - - -Splice - -CU - - - - - -__S_5:e--W21:w - - - - - - -__S_6 - - -Splice - -CU - - - - - -__S_6:e--W21:w - - - - - - -__S_7 - - -Splice - -CU - - - - - -__S_7:e--W21:w - - - - - - -X2 - - -X2 - -JST SM - -female - -4-pin - -1 - -A - -2 - -B - -3 - -C - -4 - -D - - - -X3 - - -X3 - -JST SM - -male - -4-pin - -A - -1 - -B - -2 - -C - -3 - -D - -4 - - - -X2:e--X3:w - - - - - - - -W3 - - -W3 - -4x - -0.1 m -  -X3:1:A -     1:WH     - - - -X3:2:B -     2:BN     - - - -X3:3:C -     3:GN     - - - -X3:4:D -     4:YE     - - - -  - - - -X3:e--W3:w - - - - - - -X3:e--W3:w - - - - - - -X3:e--W3:w - - - - - - -X3:e--W3:w - - - - - - -__F_1 - - -Ferrule - -GY - - - - - -X4 - - -X4 - -Screw terminal connector - -4-pin - -GN - - - -1 - -W - -2 - -X - -3 - -Y - -4 - -Z - - - -__F_1:e--X4:w - - - - - -__F_2 - - -Ferrule - -GY - - - - - -__F_2:e--X4:w - - - - - -__F_3 - - -Ferrule - -GY - - - - - -__F_3:e--X4:w - - - - - -__F_4 - - -Ferrule - -GY - - - - - -__F_4:e--X4:w - - - - - -W1:e--__S_1:w - - - - - - -W1:e--__S_2:w - - - +S1 + + + +Splice + +CU + + - + W1:e--S1:w - - - + + + - - -W1:e--__S_3:w - - - + + +AUTOGENERATED_S_3 + + + +Splice + +CU + + - - -W2:e--__S_4:w - - - - - + -W2:e--__S_5:w - - - +W1:e--AUTOGENERATED_S_3:w + + + - - -W2:e--__S_6:w - - - + + +W2 + + + +W2 + +4x + +0.1 m +  + + +1:WH + + + + +2:BN + + + S1 + +3:GN + + + + +4:YE + + +  - - -W2:e--__S_7:w - - - + + +AUTOGENERATED_S_1:e--W2:w + + + - - -W21:e--X2:w - - - - - - -W21:e--X2:w - - - - - + -W21:e--X2:w - - - +AUTOGENERATED_S_2:e--W2:w + + + + + + +S1:e--W2:w + + + + + + +AUTOGENERATED_WIRE_1 + + + +1x + +0.1 m +  + S1 + +1:BK + +X2:4:D +  + + + +S1:e--AUTOGENERATED_WIRE_1:w + + + + + + +AUTOGENERATED_S_3:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +AUTOGENERATED_S_4 + + + +Splice + +CU + + + + + +W2:e--AUTOGENERATED_S_4:w + + + + + + +AUTOGENERATED_S_5 + + + +Splice + +CU + + + + + +W2:e--AUTOGENERATED_S_5:w + + + + + + +AUTOGENERATED_S_6 + + + +Splice + +CU + + + + + +W2:e--AUTOGENERATED_S_6:w + + + + + + +AUTOGENERATED_S_7 + + + +Splice + +CU + + + + + +W2:e--AUTOGENERATED_S_7:w + + + + + + +W21 + + + +W21 + +4x + +0.1 m +  + + +1:WH + +X2:1:A + + +2:BN + +X2:2:B + + +3:GN + +X2:3:C + + +4:YE + +X2:4:D +  + + + +AUTOGENERATED_S_4:e--W21:w + + + + + + +AUTOGENERATED_S_5:e--W21:w + + + + + + +AUTOGENERATED_S_6:e--W21:w + + + + + + +AUTOGENERATED_S_7:e--W21:w + + + + + + +AUTOGENERATED_WIRE_1:e--AUTOGENERATED_WIRE_1:w + + + + + + +X2 + + + +X2 + +JST SM + +female + +4-pin + +1 + +A + +2 + +B + +3 + +C + +4 + +D + + + +AUTOGENERATED_WIRE_1:e--X2:w + + + + + + +X3 + + + +X3 + +JST SM + +male + +4-pin + +A + +1 + +B + +2 + +C + +3 + +D + +4 + + + +X2:e--X3:w + + + - + W21:e--X2:w - - - + + + - - -W3:e--__F_1:w - - - - - - -W3:e--__F_2:w - - - - - - -W3:e--__F_3:w - - - - - - -W3:e--__F_4:w - - - - - + -__WIRE_1:e--X2:w - - - +W21:e--X2:w + + + + + + +W21:e--X2:w + + + + + + +W21:e--X2:w + + + + + + +W21:e--W21:w + + + + + + +W21:e--W21:w + + + + + + +W21:e--W21:w + + + + + + +W21:e--W21:w + + + + + + +W3 + + + +W3 + +4x + +0.1 m +  + X3:1:A + +1:WH + + + X3:2:B + +2:BN + + + X3:3:C + +3:GN + + + X3:4:D + +4:YE + + +  + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +AUTOGENERATED_F_1 + + + +Ferrule + +GY + + + + + +W3:e--AUTOGENERATED_F_1:w + + + + + + +AUTOGENERATED_F_2 + + + +Ferrule + +GY + + + + + +W3:e--AUTOGENERATED_F_2:w + + + + + + +AUTOGENERATED_F_3 + + + +Ferrule + +GY + + + + + +W3:e--AUTOGENERATED_F_3:w + + + + + + +AUTOGENERATED_F_4 + + + +Ferrule + +GY + + + + + +W3:e--AUTOGENERATED_F_4:w + + + + + + +X4 + + + +X4 + +Screw terminal connector + +4-pin + +GN + + + +1 + +W + +2 + +X + +3 + +Y + +4 + +Z + + + +AUTOGENERATED_F_1:e--X4:w + + + + + +AUTOGENERATED_F_2:e--X4:w + + + + + +AUTOGENERATED_F_3:e--X4:w + + + + + +AUTOGENERATED_F_4:e--X4:w + + @@ -715,61 +858,61 @@
- - + + - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 1 wires0.1m
2Cable, 4 wires0.4mW1, W2, W21, W3
3Connector, Ferrule, GY1 4 Connector, Ferrule, GY
4Connector, JST SM, female, 4 pins2 1 Connector, JST SM, female, 4 pins X2
5Connector, JST SM, male, 4 pins3 2 Connector, JST SM, male, 4 pins X1, X3
6Connector, Screw terminal connector, 4 pins, GN4 1 Connector, Screw terminal connector, 4 pins, GN X4
7Connector, Splice, CU5 8 Connector, Splice, CUS1
61mCable, 1 wires
74mCable, 4 wiresW1, W2, W21, W3
diff --git a/examples/ex14.png b/examples/ex14.png index 8116ed3..08155fd 100644 Binary files a/examples/ex14.png and b/examples/ex14.png differ diff --git a/examples/ex14.svg b/examples/ex14.svg index 302b7e3..6fc4655 100644 --- a/examples/ex14.svg +++ b/examples/ex14.svg @@ -1,676 +1,819 @@ - - - - + + + X1 - - -X1 - -JST SM - -male - -4-pin - -A - -1 - -B - -2 - -C - -3 - -D - -4 + + + +X1 + +JST SM + +male + +4-pin + +A + +1 + +B + +2 + +C + +3 + +D + +4 - + W1 - - -W1 - -4x - -0.1 m -  -X1:4:D -     1:WH     - - - -X1:3:C -     2:BN     - - - -X1:2:B -     3:GN     - - - -X1:1:A -     4:YE     - - - -  + + + +W1 + +4x + +0.1 m +  + X1:4:D + +1:WH + + + X1:3:C + +2:BN + + + X1:2:B + +3:GN + +S1 + X1:1:A + +4:YE + + +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - - -__S_1 - - -Splice - -CU - - + + +W1:e--W1:w + + + - - -W2 - - -W2 - -4x - -0.1 m -  -     1:WH     - - - -     2:BN     - - - -     3:GN     - - - -     4:YE     - - - -  - - - -__S_1:e--W2:w - - - - - + -__S_2 - - -Splice - -CU - - +AUTOGENERATED_S_1 + + + +Splice + +CU + + - - -__S_2:e--W2:w - - - + + +W1:e--AUTOGENERATED_S_1:w + + + + + + +AUTOGENERATED_S_2 + + + +Splice + +CU + + + + + +W1:e--AUTOGENERATED_S_2:w + + + - -S1 - - -Splice - -CU - - - - - -S1:e--W2:w - - - - - - -__WIRE_1 - - -1x - -0.1 m -  -     1:BK     -X2:4:D - - - -  - - - -S1:e--__WIRE_1:w - - - - - -__S_3 - - -Splice - -CU - - - - - -__S_3:e--W2:w - - - - - - -__S_4 - - -Splice - -CU - - - - - -W21 - - -W21 - -4x - -0.1 m -  -     1:WH     -X2:1:A - - - -     2:BN     -X2:2:B - - - -     3:GN     -X2:3:C - - - -     4:YE     -X2:4:D - - - -  - - - -__S_4:e--W21:w - - - - - - -__S_5 - - -Splice - -CU - - - - - -__S_5:e--W21:w - - - - - - -__S_6 - - -Splice - -CU - - - - - -__S_6:e--W21:w - - - - - - -__S_7 - - -Splice - -CU - - - - - -__S_7:e--W21:w - - - - - - -X2 - - -X2 - -JST SM - -female - -4-pin - -1 - -A - -2 - -B - -3 - -C - -4 - -D - - - -X3 - - -X3 - -JST SM - -male - -4-pin - -A - -1 - -B - -2 - -C - -3 - -D - -4 - - - -X2:e--X3:w - - - - - - - -W3 - - -W3 - -4x - -0.1 m -  -X3:1:A -     1:WH     - - - -X3:2:B -     2:BN     - - - -X3:3:C -     3:GN     - - - -X3:4:D -     4:YE     - - - -  - - - -X3:e--W3:w - - - - - - -X3:e--W3:w - - - - - - -X3:e--W3:w - - - - - - -X3:e--W3:w - - - - - - -__F_1 - - -Ferrule - -GY - - - - - -X4 - - -X4 - -Screw terminal connector - -4-pin - -GN - - - -1 - -W - -2 - -X - -3 - -Y - -4 - -Z - - - -__F_1:e--X4:w - - - - - -__F_2 - - -Ferrule - -GY - - - - - -__F_2:e--X4:w - - - - - -__F_3 - - -Ferrule - -GY - - - - - -__F_3:e--X4:w - - - - - -__F_4 - - -Ferrule - -GY - - - - - -__F_4:e--X4:w - - - - - -W1:e--__S_1:w - - - - - - -W1:e--__S_2:w - - - +S1 + + + +Splice + +CU + + - + W1:e--S1:w - - - + + + - - -W1:e--__S_3:w - - - + + +AUTOGENERATED_S_3 + + + +Splice + +CU + + - - -W2:e--__S_4:w - - - - - + -W2:e--__S_5:w - - - +W1:e--AUTOGENERATED_S_3:w + + + - - -W2:e--__S_6:w - - - + + +W2 + + + +W2 + +4x + +0.1 m +  + + +1:WH + + + + +2:BN + + + S1 + +3:GN + + + + +4:YE + + +  - - -W2:e--__S_7:w - - - + + +AUTOGENERATED_S_1:e--W2:w + + + - - -W21:e--X2:w - - - - - - -W21:e--X2:w - - - - - + -W21:e--X2:w - - - +AUTOGENERATED_S_2:e--W2:w + + + + + + +S1:e--W2:w + + + + + + +AUTOGENERATED_WIRE_1 + + + +1x + +0.1 m +  + S1 + +1:BK + +X2:4:D +  + + + +S1:e--AUTOGENERATED_WIRE_1:w + + + + + + +AUTOGENERATED_S_3:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +AUTOGENERATED_S_4 + + + +Splice + +CU + + + + + +W2:e--AUTOGENERATED_S_4:w + + + + + + +AUTOGENERATED_S_5 + + + +Splice + +CU + + + + + +W2:e--AUTOGENERATED_S_5:w + + + + + + +AUTOGENERATED_S_6 + + + +Splice + +CU + + + + + +W2:e--AUTOGENERATED_S_6:w + + + + + + +AUTOGENERATED_S_7 + + + +Splice + +CU + + + + + +W2:e--AUTOGENERATED_S_7:w + + + + + + +W21 + + + +W21 + +4x + +0.1 m +  + + +1:WH + +X2:1:A + + +2:BN + +X2:2:B + + +3:GN + +X2:3:C + + +4:YE + +X2:4:D +  + + + +AUTOGENERATED_S_4:e--W21:w + + + + + + +AUTOGENERATED_S_5:e--W21:w + + + + + + +AUTOGENERATED_S_6:e--W21:w + + + + + + +AUTOGENERATED_S_7:e--W21:w + + + + + + +AUTOGENERATED_WIRE_1:e--AUTOGENERATED_WIRE_1:w + + + + + + +X2 + + + +X2 + +JST SM + +female + +4-pin + +1 + +A + +2 + +B + +3 + +C + +4 + +D + + + +AUTOGENERATED_WIRE_1:e--X2:w + + + + + + +X3 + + + +X3 + +JST SM + +male + +4-pin + +A + +1 + +B + +2 + +C + +3 + +D + +4 + + + +X2:e--X3:w + + + - + W21:e--X2:w - - - + + + - - -W3:e--__F_1:w - - - - - - -W3:e--__F_2:w - - - - - - -W3:e--__F_3:w - - - - - - -W3:e--__F_4:w - - - - - + -__WIRE_1:e--X2:w - - - +W21:e--X2:w + + + + + + +W21:e--X2:w + + + + + + +W21:e--X2:w + + + + + + +W21:e--W21:w + + + + + + +W21:e--W21:w + + + + + + +W21:e--W21:w + + + + + + +W21:e--W21:w + + + + + + +W3 + + + +W3 + +4x + +0.1 m +  + X3:1:A + +1:WH + + + X3:2:B + +2:BN + + + X3:3:C + +3:GN + + + X3:4:D + +4:YE + + +  + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +X3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +AUTOGENERATED_F_1 + + + +Ferrule + +GY + + + + + +W3:e--AUTOGENERATED_F_1:w + + + + + + +AUTOGENERATED_F_2 + + + +Ferrule + +GY + + + + + +W3:e--AUTOGENERATED_F_2:w + + + + + + +AUTOGENERATED_F_3 + + + +Ferrule + +GY + + + + + +W3:e--AUTOGENERATED_F_3:w + + + + + + +AUTOGENERATED_F_4 + + + +Ferrule + +GY + + + + + +W3:e--AUTOGENERATED_F_4:w + + + + + + +X4 + + + +X4 + +Screw terminal connector + +4-pin + +GN + + + +1 + +W + +2 + +X + +3 + +Y + +4 + +Z + + + +AUTOGENERATED_F_1:e--X4:w + + + + + +AUTOGENERATED_F_2:e--X4:w + + + + + +AUTOGENERATED_F_3:e--X4:w + + + + + +AUTOGENERATED_F_4:e--X4:w + + diff --git a/examples/ex14_wv_gvpr.gvpr b/examples/ex14_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex14_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex15.bom.tsv b/examples/ex15.bom.tsv new file mode 100644 index 0000000..53017cb --- /dev/null +++ b/examples/ex15.bom.tsv @@ -0,0 +1,5 @@ +# Qty Unit Description Designators Manufacturer MPN +1 2 Connector, Molex KK 254, female, 7 pins X1, X2 +2 1 m Cable, Serial, 4 x 0.25 mm² shielded W1 +3 42 mm shortPartA X1 WireViz 42XCD42A5 +4 1 shortPartB X1 WireViz 42XCD42A5 diff --git a/examples/ex15.gv b/examples/ex15.gv new file mode 100644 index 0000000..b1d7df4 --- /dev/null +++ b/examples/ex15.gv @@ -0,0 +1,297 @@ +graph { +// Graph generated by WireViz 0.5-dev+refactor +// https://github.com/wireviz/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] + X1 [label=< + + + + + + + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female7-pin
+
+ + + + + + + + + + [, ] + + + + + [, ] + + + + + [, ] + + + + + [, ] + + + + + [, ] + + + + + [, ] + + + + + [, ] + + +
SH1SH2
GND1
VCC2
RX3
TX4
GND5
VCC6
GND7
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
42mmshortPartA
WireViz: 42XCD42A5
1xshortPartB
WireViz: 42XCD42A5
+
+> shape=box style=filled] + edge [color="#000000"] + X1:p1j:c -- X1:p5j:c [addPTS=.18 color="#FFFFFF:#FF66CC:#FFFFFF" colorPTS="#FF66CC:#FFFFFF" headclip=false straight=straight tailclip=false] + X1:p5j:c -- X1:p7j:c [addPTS=.18 color="#FFFFFF:#FF66CC:#FFFFFF" colorPTS="#FF66CC:#FFFFFF" headclip=false straight=straight tailclip=false] + X1:p2j:c -- X1:p6j:c [addPTS=.18 color="#FFFFFF:#FF0000:#FFFFFF" colorPTS="#FF0000:#FFFFFF" headclip=false straight=straight tailclip=false] + X2 [label=< + + + + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female7-pin
+
+ + + + + + + + + + + [, ] + + + + + [, ] + + + + + [, ] + + + + + [, ] + + + + + [, ] + + + + + [, ] + + + + + [, ] + +
SH1SH2
1GND
2VCC
3RX
4TX
5GND
6VCC
7GND
+
+> shape=box style=filled] + edge [color="#000000"] + X2:p1j:c -- X2:p5j:c [addPTS=.18 color="#FFFFFF:#000000:#FFFFFF" colorPTS="#000000:#FFFFFF" headclip=false straight=straight tailclip=false] + X2:p5j:c -- X2:p7j:c [addPTS=.18 color="#FFFFFF:#000000:#FFFFFF" colorPTS="#000000:#FFFFFF" headclip=false straight=straight tailclip=false] + X2:p2j:c -- X2:p6j:c [addPTS=.18 color="#FFFFFF:#000000:#FFFFFF" colorPTS="#000000:#FFFFFF" headclip=false straight=straight tailclip=false] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + + +
Serial4x0.25 mm² (24 AWG)+ S0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND 1:BUWH X2:1:GND
X1:2:VCC 2:WHBU X2:2:VCC
X1:3:RX 3:OGWH X2:4:TX
X1:4:TX 4:WHOG X2:3:RX
 
X1:1:GND Shield
 
+
+> shape=box style=filled] + edge [color="#000000:#0066FF:#FFFFFF:#0066FF:#000000"] + X1:p1r:e -- W1:w1:w + W1:w1:e -- X2:p1l:w + edge [color="#000000:#FFFFFF:#0066FF:#FFFFFF:#000000"] + X1:p2r:e -- W1:w2:w + W1:w2:e -- X2:p2l:w + edge [color="#000000:#FF8000:#FFFFFF:#FF8000:#000000"] + X1:p3r:e -- W1:w3:w + W1:w3:e -- X2:p4l:w + edge [color="#000000:#FFFFFF:#FF8000:#FFFFFF:#000000"] + X1:p4r:e -- W1:w4:w + W1:w4:e -- X2:p3l:w + edge [color="#000000"] + X1:p1r:e -- W1:w5:w + W1:w1:e -- W1:w1:w [color="#000000:#0066FF:#FFFFFF:#0066FF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FFFFFF:#0066FF:#FFFFFF:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FF8000:#FFFFFF:#FF8000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFFFF:#FF8000:#FFFFFF:#000000" straight=straight] + W1:w5:e -- W1:w5:w [color="#000000" straight=straight] +} diff --git a/examples/ex15.html b/examples/ex15.html new file mode 100644 index 0000000..c652c24 --- /dev/null +++ b/examples/ex15.html @@ -0,0 +1,501 @@ + + + + + ex15 + + +

ex15

+

Diagram

+ +
+ +
+ +
+ + + + + + + + +X1 + + + +X1 + +Molex KK 254 + +female + +7-pin + + +SH1 + +SH2 + + +GND + + + +1 + +VCC + + + +2 + +RX + + + +3 + +TX + + + +4 + +GND + + + +5 + +VCC + + + +6 + +GND + + + +7 +42 +mm +shortPartA +WireViz: 42XCD42A5 +1 +x +shortPartB +WireViz: 42XCD42A5 + + + + +X1:c--X1:c + + + + + + +X1:c--X1:c + + + + + + +X1:c--X1:c + + + + + + +W1 + + + +W1 + +Serial + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  + X1:1:GND + +1:BUWH + +X2:1:GND + X1:2:VCC + +2:WHBU + +X2:2:VCC + X1:3:RX + +3:OGWH + +X2:4:TX + X1:4:TX + +4:WHOG + +X2:3:RX +  + X1:1:GND + +Shield + + +  + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + +X2 + + + +X2 + +Molex KK 254 + +female + +7-pin + + + +SH1 + +SH2 + +1 + +GND + + + +2 + +VCC + + + +3 + +RX + + + +4 + +TX + + + +5 + +GND + + + +6 + +VCC + + + +7 + +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 + + + + + + +__CIRCLE__1 + + + + +__CIRCLE__2 + + + + +__CIRCLE__3 + + + + +__CIRCLE__4 + + + + +__CIRCLE__5 + + + + +__CIRCLE__6 + + + + +__CIRCLE__7 + + + + +__CIRCLE__8 + + + + +__CIRCLE__9 + + + + +__CIRCLE__10 + + + + +__CIRCLE__11 + + + + +__CIRCLE__12 + + + + + +
+ +
+ +
+ +

Bill of Materials

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#QtyUnitDescriptionDesignatorsManufacturerMPN
12Connector, Molex KK 254, female, 7 pinsX1, X2
21mCable, Serial, 4 x 0.25 mm² shieldedW1
342mmshortPartAX1WireViz42XCD42A5
41shortPartBX1WireViz42XCD42A5
+ +
+ + diff --git a/examples/ex15.png b/examples/ex15.png new file mode 100644 index 0000000..d60f197 Binary files /dev/null and b/examples/ex15.png differ diff --git a/examples/ex15.svg b/examples/ex15.svg new file mode 100644 index 0000000..21ba1e0 --- /dev/null +++ b/examples/ex15.svg @@ -0,0 +1,411 @@ + + + + + + + + + +X1 + + + +X1 + +Molex KK 254 + +female + +7-pin + + +SH1 + +SH2 + + +GND + + + +1 + +VCC + + + +2 + +RX + + + +3 + +TX + + + +4 + +GND + + + +5 + +VCC + + + +6 + +GND + + + +7 +42 +mm +shortPartA +WireViz: 42XCD42A5 +1 +x +shortPartB +WireViz: 42XCD42A5 + + + + +X1:c--X1:c + + + + + + +X1:c--X1:c + + + + + + +X1:c--X1:c + + + + + + +W1 + + + +W1 + +Serial + +4x + +0.25 mm² (24 AWG) + ++ S + +0.2 m +  + X1:1:GND + +1:BUWH + +X2:1:GND + X1:2:VCC + +2:WHBU + +X2:2:VCC + X1:3:RX + +3:OGWH + +X2:4:TX + X1:4:TX + +4:WHOG + +X2:3:RX +  + X1:1:GND + +Shield + + +  + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + + + + + +X1:e--W1:w + + + + +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + + + + + +W1:e--W1:w + + + + +X2 + + + +X2 + +Molex KK 254 + +female + +7-pin + + + +SH1 + +SH2 + +1 + +GND + + + +2 + +VCC + + + +3 + +RX + + + +4 + +TX + + + +5 + +GND + + + +6 + +VCC + + + +7 + +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 + + + + + + +__CIRCLE__1 + + + + +__CIRCLE__2 + + + + +__CIRCLE__3 + + + + +__CIRCLE__4 + + + + +__CIRCLE__5 + + + + +__CIRCLE__6 + + + + +__CIRCLE__7 + + + + +__CIRCLE__8 + + + + +__CIRCLE__9 + + + + +__CIRCLE__10 + + + + +__CIRCLE__11 + + + + +__CIRCLE__12 + + + + diff --git a/examples/ex15.yml b/examples/ex15.yml new file mode 100644 index 0000000..0e90e2e --- /dev/null +++ b/examples/ex15.yml @@ -0,0 +1,46 @@ +connectors: # This is based on ex1 and adds some Shorts to the connectors + X1: # An example of Shorts with more information + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + shorts: # A List(Dict) of shorts is created + SH1: [1, 5, 7] # First is the designator than a list of pins to be shorted + SH2: [2, 6] + additional_components: # Some Additional Components to describe the short in more detail + - references: SH1 + color: PK # The color of the short, can also be multicolor + manufacturer: WireViz + mpn: 42XCD42A5 + type: shortPartA + amount: 42 mm # The length or some other quantity + - references: SH2 + color: RD + manufacturer: WireViz + mpn: 42XCD42A5 + type: shortPartB + X2: # An example of a simple short definition + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + shorts: # The definition is the same as above but there is no additional_components for more information + SH1: [1, 5, 7] + SH2: [2, 6] + +cables: + W1: + color_code: TEL + wirecount: 4 + gauge: 0.25 mm2 + show_equiv: true + length: 0.2 + shield: true + type: Serial + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1,2,4,3] + - + - X1: 1 + - W1: s \ No newline at end of file diff --git a/examples/ex15_wv_gvpr.gvpr b/examples/ex15_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex15_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/ex16.bom.tsv b/examples/ex16.bom.tsv new file mode 100644 index 0000000..54f73d0 --- /dev/null +++ b/examples/ex16.bom.tsv @@ -0,0 +1,6 @@ +# Qty Unit Description Designators Manufacturer MPN +1 2 Connector, Molex KK 254, female, 7 pins X1, X2 +2 1 m Cable, Serial, 4 x 0.25 mm² shielded W1 +3 42 mm loopPartA X1 WireViz 42XCD42A5 +4 74 mm loopPartB X1 WireViz 42XCD42A5 +5 21 mm loopPartC X2 WireViz 42XCD42A5 diff --git a/examples/ex16.gv b/examples/ex16.gv new file mode 100644 index 0000000..49f886d --- /dev/null +++ b/examples/ex16.gv @@ -0,0 +1,289 @@ +graph { +// Graph generated by WireViz 0.5-dev+refactor +// https://github.com/wireviz/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] + X1 [label=< + + + + + + + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female7-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GND1
VCC2
RX3
TX4
GND5
VCC6
GND7
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
42mmloopPartA
WireViz: 42XCD42A5
74mmloopPartB
WireViz: 42XCD42A5
+
+> shape=box style=filled] + edge [color="#000000"] + X1:p1r:e -- X1:p5r:e [label=" " color="#FF66CC" noLabel=noLabel] + X1:p5r:e -- X1:p7r:e [label=" " color="#FF66CC" noLabel=noLabel] + X1:p2r:e -- X1:p6r:e [label=" " color="#FF0000:#0066FF:#FF8000:#A0DFFF" noLabel=noLabel] + X2 [label=< + + + + + + + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female7-pin
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1GND
2VCC
3RX
4TX
5GND
6VCC
7GND
+
+ + + + + + + + + + + + + +
21mmloopPartC
WireViz: 42XCD42A5
+
+> shape=box style=filled] + edge [color="#000000"] + X2:p1l:w -- X2:p5l:w [label=" " color="#FF66CC" noLabel=noLabel] + X2:p5l:w -- X2:p7l:w [label=" " color="#FF66CC" noLabel=noLabel] + X2:p2l:w -- X2:p6l:w [label=" " color="#FF66CC" noLabel=noLabel] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + + +
Serial4x0.25 mm² (24 AWG)+ S0.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
 
+
+> 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:w5:w + W1:w1:e -- W1:w1:w [color="#000000:#895956:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FF8000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w5:e -- W1:w5:w [color="#000000" straight=straight] +} diff --git a/examples/ex16.html b/examples/ex16.html new file mode 100644 index 0000000..5d219a8 --- /dev/null +++ b/examples/ex16.html @@ -0,0 +1,382 @@ + + + + + ex16 + + +

ex16

+

Diagram

+ +
+ +
+ +
+ + + + + + + + +X1 + + + +X1 + +Molex KK 254 + +female + +7-pin + +GND + +1 + +VCC + +2 + +RX + +3 + +TX + +4 + +GND + +5 + +VCC + +6 + +GND + +7 +42 +mm +loopPartA +WireViz: 42XCD42A5 +74 +mm +loopPartB +WireViz: 42XCD42A5 + + + + +X1:e--X1:e + + + + +X1:e--X1:e + + + + +X1:e--X1:e + + + + + + + +W1 + + + +W1 + +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 + + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + +X2 + + + +X2 + +Molex KK 254 + +female + +7-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX + +5 + +GND + +6 + +VCC + +7 + +GND +21 +mm +loopPartC +WireViz: 42XCD42A5 + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +X2:w--X2:w + + + + +X2:w--X2:w + + + + +X2:w--X2:w + + + + + +
+ +
+ +
+ +

Bill of Materials

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#QtyUnitDescriptionDesignatorsManufacturerMPN
12Connector, Molex KK 254, female, 7 pinsX1, X2
21mCable, Serial, 4 x 0.25 mm² shieldedW1
342mmloopPartAX1WireViz42XCD42A5
474mmloopPartBX1WireViz42XCD42A5
521mmloopPartCX2WireViz42XCD42A5
+ +
+ + diff --git a/examples/ex16.png b/examples/ex16.png new file mode 100644 index 0000000..480ba39 Binary files /dev/null and b/examples/ex16.png differ diff --git a/examples/ex16.svg b/examples/ex16.svg new file mode 100644 index 0000000..3cced10 --- /dev/null +++ b/examples/ex16.svg @@ -0,0 +1,283 @@ + + + + + + + + + +X1 + + + +X1 + +Molex KK 254 + +female + +7-pin + +GND + +1 + +VCC + +2 + +RX + +3 + +TX + +4 + +GND + +5 + +VCC + +6 + +GND + +7 +42 +mm +loopPartA +WireViz: 42XCD42A5 +74 +mm +loopPartB +WireViz: 42XCD42A5 + + + + +X1:e--X1:e + + + + +X1:e--X1:e + + + + +X1:e--X1:e + + + + + + + +W1 + + + +W1 + +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 + + +  + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + + + +X1:e--W1:w + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + + + +W1:e--W1:w + + + + +X2 + + + +X2 + +Molex KK 254 + +female + +7-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX + +5 + +GND + +6 + +VCC + +7 + +GND +21 +mm +loopPartC +WireViz: 42XCD42A5 + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +X2:w--X2:w + + + + +X2:w--X2:w + + + + +X2:w--X2:w + + + + diff --git a/examples/ex16.yml b/examples/ex16.yml new file mode 100644 index 0000000..88ee705 --- /dev/null +++ b/examples/ex16.yml @@ -0,0 +1,58 @@ +options: + mini_bom_mode: false # disable mini_bom to show difference to ex15 + +connectors: # This is based on ex1 and adds some Loops to the connectors + X1: + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + loops: # A List(Dict) of loops is created + LO1: [1, 5, 7] # First is the designator than a list of pins to be shorted + LO2: [2, 6] + additional_components: # Some Additional Components to describe the short in more detail + - references: LO1 + color: PK # The color of the short, can also be multicolor + manufacturer: WireViz + mpn: 42XCD42A5 + type: loopPartA + amount: 42 mm # The length or some other quantity + - references: LO2 + color: RDBUOGLB # multicolor example + manufacturer: WireViz + mpn: 42XCD42A5 + type: loopPartB + amount: 74 mm + + X2: + type: Molex KK 254 + subtype: female + pinlabels: [GND, VCC, RX, TX, GND, VCC, GND] + loops: + LO1: [1, 5, 7] + LO2: [2, 6] + additional_components: + - references: [LO1, LO2] # example to show how one additional_components can reference more than one short or loop + color: PK + manufacturer: WireViz + mpn: 42XCD42A5 + type: loopPartC + amount: 21 mm + +cables: + W1: + color_code: IEC + wirecount: 4 + gauge: 0.25 mm2 + show_equiv: true + length: 0.2 + shield: true + type: Serial + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1,2,4,3] + - + - X1: 1 + - W1: s \ No newline at end of file diff --git a/examples/ex16_wv_gvpr.gvpr b/examples/ex16_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/examples/ex16_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/examples/readme.md b/examples/readme.md index 88a4389..739eac6 100644 --- a/examples/readme.md +++ b/examples/readme.md @@ -3,84 +3,96 @@ ## Example 01 ![](ex01.png) -[Source](ex01.yml) - [Bill of Materials](ex01.bom.tsv) +[Source](ex01.yml) - [Bill of Materials](ex01.tsv) ## Example 02 ![](ex02.png) -[Source](ex02.yml) - [Bill of Materials](ex02.bom.tsv) +[Source](ex02.yml) - [Bill of Materials](ex02.tsv) ## Example 03 ![](ex03.png) -[Source](ex03.yml) - [Bill of Materials](ex03.bom.tsv) +[Source](ex03.yml) - [Bill of Materials](ex03.tsv) ## Example 04 ![](ex04.png) -[Source](ex04.yml) - [Bill of Materials](ex04.bom.tsv) +[Source](ex04.yml) - [Bill of Materials](ex04.tsv) ## Example 05 ![](ex05.png) -[Source](ex05.yml) - [Bill of Materials](ex05.bom.tsv) +[Source](ex05.yml) - [Bill of Materials](ex05.tsv) ## Example 06 ![](ex06.png) -[Source](ex06.yml) - [Bill of Materials](ex06.bom.tsv) +[Source](ex06.yml) - [Bill of Materials](ex06.tsv) ## Example 07 ![](ex07.png) -[Source](ex07.yml) - [Bill of Materials](ex07.bom.tsv) +[Source](ex07.yml) - [Bill of Materials](ex07.tsv) ## Example 08 ![](ex08.png) -[Source](ex08.yml) - [Bill of Materials](ex08.bom.tsv) +[Source](ex08.yml) - [Bill of Materials](ex08.tsv) ## Example 09 ![](ex09.png) -[Source](ex09.yml) - [Bill of Materials](ex09.bom.tsv) +[Source](ex09.yml) - [Bill of Materials](ex09.tsv) ## Example 10 ![](ex10.png) -[Source](ex10.yml) - [Bill of Materials](ex10.bom.tsv) +[Source](ex10.yml) - [Bill of Materials](ex10.tsv) ## Example 11 ![](ex11.png) -[Source](ex11.yml) - [Bill of Materials](ex11.bom.tsv) +[Source](ex11.yml) - [Bill of Materials](ex11.tsv) ## Example 12 ![](ex12.png) -[Source](ex12.yml) - [Bill of Materials](ex12.bom.tsv) +[Source](ex12.yml) - [Bill of Materials](ex12.tsv) ## Example 13 ![](ex13.png) -[Source](ex13.yml) - [Bill of Materials](ex13.bom.tsv) +[Source](ex13.yml) - [Bill of Materials](ex13.tsv) ## Example 14 ![](ex14.png) -[Source](ex14.yml) - [Bill of Materials](ex14.bom.tsv) +[Source](ex14.yml) - [Bill of Materials](ex14.tsv) + + +## Example 15 +![](ex15.png) + +[Source](ex15.yml) - [Bill of Materials](ex15.tsv) + + +## Example 16 +![](ex16.png) + +[Source](ex16.yml) - [Bill of Materials](ex16.tsv) diff --git a/requirements.txt b/requirements.txt index 07564c3..9405dd1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ graphviz pillow pyyaml setuptools +tabulate diff --git a/setup.py b/setup.py index 8d7654c..e998449 100644 --- a/setup.py +++ b/setup.py @@ -15,14 +15,15 @@ setup( author="Daniel Rojas", # author_email='', description="Easily document cables and wiring harnesses", - long_description=open(README_PATH).read(), + long_description=README_PATH.read_text(), long_description_content_type="text/markdown", install_requires=[ "click", - "pyyaml", - "pillow", "graphviz", "jinja2", + "pillow", + "pyyaml", + "tabulate", ], license="GPLv3", keywords="cable connector hardware harness wiring wiring-diagram wiring-harness", @@ -39,8 +40,11 @@ setup( "Development Status :: 4 - Beta", "Environment :: Console", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Utilities", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", ], diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py deleted file mode 100644 index d14e445..0000000 --- a/src/wireviz/DataClasses.py +++ /dev/null @@ -1,435 +0,0 @@ -# -*- coding: utf-8 -*- - -from dataclasses import InitVar, dataclass, field -from enum import Enum, auto -from pathlib import Path -from typing import Dict, List, Optional, Tuple, Union - -from wireviz.wv_colors import COLOR_CODES, Color, ColorMode, Colors, ColorScheme -from wireviz.wv_helper import aspect_ratio, int2tuple - -# Each type alias have their legal values described in comments - validation might be implemented in the future -PlainText = str # Text not containing HTML tags nor newlines -Hypertext = str # Text possibly including HTML hyperlinks that are removed in all outputs except HTML output -MultilineHypertext = ( - str # Hypertext possibly also including newlines to break lines in diagram output -) - -Designator = PlainText # Case insensitive unique name of connector or cable - -# Literal type aliases below are commented to avoid requiring python 3.8 -ConnectorMultiplier = PlainText # = Literal['pincount', 'populated', 'unpopulated'] -CableMultiplier = ( - PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length'] -) -ImageScale = PlainText # = Literal['false', 'true', 'width', 'height', 'both'] - -# Type combinations -Pin = Union[int, PlainText] # Pin identifier -PinIndex = int # Zero-based pin index -Wire = Union[int, PlainText] # Wire number or Literal['s'] for shield -NoneOrMorePins = Union[ - Pin, Tuple[Pin, ...], None -] # None, one, or a tuple of pin identifiers -NoneOrMorePinIndices = Union[ - PinIndex, Tuple[PinIndex, ...], None -] # None, one, or a tuple of zero-based pin indices -OneOrMoreWires = Union[Wire, Tuple[Wire, ...]] # One or a tuple of wires - -# Metadata can contain whatever is needed by the HTML generation/template. -MetadataKeys = PlainText # Literal['title', 'description', 'notes', ...] - - -Side = Enum("Side", "LEFT RIGHT") - - -class Metadata(dict): - pass - - -@dataclass -class Options: - fontname: PlainText = "arial" - bgcolor: Color = "WH" - bgcolor_node: Optional[Color] = "WH" - bgcolor_connector: Optional[Color] = None - bgcolor_cable: Optional[Color] = None - bgcolor_bundle: Optional[Color] = None - color_mode: ColorMode = "SHORT" - mini_bom_mode: bool = True - template_separator: str = "." - - def __post_init__(self): - if not self.bgcolor_node: - self.bgcolor_node = self.bgcolor - if not self.bgcolor_connector: - self.bgcolor_connector = self.bgcolor_node - if not self.bgcolor_cable: - self.bgcolor_cable = self.bgcolor_node - if not self.bgcolor_bundle: - self.bgcolor_bundle = self.bgcolor_cable - - -@dataclass -class Tweak: - override: Optional[Dict[Designator, Dict[str, Optional[str]]]] = None - append: Union[str, List[str], None] = None - - -@dataclass -class Image: - # Attributes of the image object : - src: str - scale: Optional[ImageScale] = None - # Attributes of the image cell containing the image: - width: Optional[int] = None - height: Optional[int] = None - fixedsize: Optional[bool] = None - bgcolor: Optional[Color] = None - # Contents of the text cell just below the image cell: - caption: Optional[MultilineHypertext] = None - # See also HTML doc at https://graphviz.org/doc/info/shapes.html#html - - def __post_init__(self): - if self.fixedsize is None: - # Default True if any dimension specified unless self.scale also is specified. - self.fixedsize = (self.width or self.height) and self.scale is None - - if self.scale is None: - if not self.width and not self.height: - self.scale = "false" - elif self.width and self.height: - self.scale = "both" - else: - self.scale = "true" # When only one dimension is specified. - - if self.fixedsize: - # If only one dimension is specified, compute the other - # because Graphviz requires both when fixedsize=True. - if self.height: - if not self.width: - self.width = self.height * aspect_ratio(self.src) - else: - if self.width: - self.height = self.width / aspect_ratio(self.src) - - -@dataclass -class AdditionalComponent: - type: MultilineHypertext - subtype: Optional[MultilineHypertext] = None - manufacturer: Optional[MultilineHypertext] = None - mpn: Optional[MultilineHypertext] = None - supplier: Optional[MultilineHypertext] = None - spn: Optional[MultilineHypertext] = None - pn: Optional[Hypertext] = None - qty: float = 1 - unit: Optional[str] = None - qty_multiplier: Union[ConnectorMultiplier, CableMultiplier, None] = None - bgcolor: Optional[Color] = None - - @property - def description(self) -> str: - t = self.type.rstrip() - st = f", {self.subtype.rstrip()}" if self.subtype else "" - t = t + st - return t - - -@dataclass -class Connector: - name: Designator - bgcolor: Optional[Color] = None - bgcolor_title: Optional[Color] = None - manufacturer: Optional[MultilineHypertext] = None - mpn: Optional[MultilineHypertext] = None - supplier: Optional[MultilineHypertext] = None - spn: Optional[MultilineHypertext] = None - pn: Optional[Hypertext] = None - style: Optional[str] = None - category: Optional[str] = None - type: Optional[MultilineHypertext] = None - subtype: Optional[MultilineHypertext] = None - pincount: Optional[int] = None - image: Optional[Image] = None - notes: Optional[MultilineHypertext] = None - pins: List[Pin] = field(default_factory=list) - pinlabels: List[Pin] = field(default_factory=list) - pincolors: List[Color] = field(default_factory=list) - color: Optional[Color] = None - show_name: Optional[bool] = None - show_pincount: Optional[bool] = None - hide_disconnected_pins: bool = False - loops: List[List[Pin]] = field(default_factory=list) - ignore_in_bom: bool = False - additional_components: List[AdditionalComponent] = field(default_factory=list) - - def __post_init__(self) -> None: - if isinstance(self.image, dict): - self.image = Image(**self.image) - - self.ports_left = False - self.ports_right = False - self.visible_pins = {} - - if self.style == "simple": - if self.pincount and self.pincount > 1: - raise Exception( - "Connectors with style set to simple may only have one pin" - ) - self.pincount = 1 - - if not self.pincount: - self.pincount = max( - len(self.pins), len(self.pinlabels), len(self.pincolors) - ) - if not self.pincount: - raise Exception( - "You need to specify at least one, pincount, pins, pinlabels, or pincolors" - ) - - # create default list for pins (sequential) if not specified - if not self.pins: - self.pins = list(range(1, self.pincount + 1)) - - if len(self.pins) != len(set(self.pins)): - raise Exception("Pins are not unique") - - if self.show_name is None: - # hide designators for simple and for auto-generated connectors by default - self.show_name = self.style != "simple" and self.name[0:2] != "__" - - if self.show_pincount is None: - # hide pincount for simple (1 pin) connectors by default - self.show_pincount = self.style != "simple" - - for loop in self.loops: - # TODO: allow using pin labels in addition to pin numbers, just like when defining regular connections - # TODO: include properties of wire used to create the loop - if len(loop) != 2: - raise Exception("Loops must be between exactly two pins!") - for pin in loop: - if pin not in self.pins: - raise Exception( - f'Unknown loop pin "{pin}" for connector "{self.name}"!' - ) - # Make sure loop connected pins are not hidden. - self.activate_pin(pin, None) - - for i, item in enumerate(self.additional_components): - if isinstance(item, dict): - self.additional_components[i] = AdditionalComponent(**item) - - def activate_pin(self, pin: Pin, side: Side) -> None: - self.visible_pins[pin] = True - if side == Side.LEFT: - self.ports_left = True - elif side == Side.RIGHT: - self.ports_right = True - - def get_qty_multiplier(self, qty_multiplier: Optional[ConnectorMultiplier]) -> int: - if not qty_multiplier: - return 1 - elif qty_multiplier == "pincount": - return self.pincount - elif qty_multiplier == "populated": - return sum(self.visible_pins.values()) - elif qty_multiplier == "unpopulated": - return max(0, self.pincount - sum(self.visible_pins.values())) - else: - raise ValueError( - f"invalid qty multiplier parameter for connector {qty_multiplier}" - ) - - -@dataclass -class Cable: - name: Designator - bgcolor: Optional[Color] = None - bgcolor_title: Optional[Color] = None - manufacturer: Union[MultilineHypertext, List[MultilineHypertext], None] = None - mpn: Union[MultilineHypertext, List[MultilineHypertext], None] = None - supplier: Union[MultilineHypertext, List[MultilineHypertext], None] = None - spn: Union[MultilineHypertext, List[MultilineHypertext], None] = None - pn: Union[Hypertext, List[Hypertext], None] = None - category: Optional[str] = None - type: Optional[MultilineHypertext] = None - gauge: Optional[float] = None - gauge_unit: Optional[str] = None - show_equiv: bool = False - length: float = 0 - length_unit: Optional[str] = None - color: Optional[Color] = None - wirecount: Optional[int] = None - shield: Union[bool, Color] = False - image: Optional[Image] = None - notes: Optional[MultilineHypertext] = None - colors: List[Colors] = field(default_factory=list) - wirelabels: List[Wire] = field(default_factory=list) - color_code: Optional[ColorScheme] = None - show_name: Optional[bool] = None - show_wirecount: bool = True - show_wirenumbers: Optional[bool] = None - ignore_in_bom: bool = False - additional_components: List[AdditionalComponent] = field(default_factory=list) - - def __post_init__(self) -> None: - if isinstance(self.image, dict): - self.image = Image(**self.image) - - if isinstance(self.gauge, str): # gauge and unit specified - try: - g, u = self.gauge.split(" ") - except Exception: - raise Exception( - f"Cable {self.name} gauge={self.gauge} - Gauge must be a number, or number and unit separated by a space" - ) - self.gauge = g - - if self.gauge_unit is not None: - print( - f"Warning: Cable {self.name} gauge_unit={self.gauge_unit} is ignored because its gauge contains {u}" - ) - if u.upper() == "AWG": - self.gauge_unit = u.upper() - else: - self.gauge_unit = u.replace("mm2", "mm\u00B2") - - elif self.gauge is not None: # gauge specified, assume mm2 - if self.gauge_unit is None: - self.gauge_unit = "mm\u00B2" - else: - pass # gauge not specified - - if isinstance(self.length, str): # length and unit specified - try: - L, u = self.length.split(" ") - L = float(L) - except Exception: - raise Exception( - f"Cable {self.name} length={self.length} - Length must be a number, or number and unit separated by a space" - ) - self.length = L - if self.length_unit is not None: - print( - f"Warning: Cable {self.name} length_unit={self.length_unit} is ignored because its length contains {u}" - ) - self.length_unit = u - elif not isinstance(self.length, (int, float)): - raise Exception(f"Cable {self.name} length has a non-numeric value") - elif self.length_unit is None: - self.length_unit = "m" - - self.connections = [] - - if self.wirecount: # number of wires explicitly defined - if self.colors: # use custom color palette (partly or looped if needed) - pass - elif self.color_code: - # use standard color palette (partly or looped if needed) - if self.color_code not in COLOR_CODES: - raise Exception("Unknown color code") - self.colors = COLOR_CODES[self.color_code] - else: # no colors defined, add dummy colors - self.colors = [""] * self.wirecount - - # make color code loop around if more wires than colors - if self.wirecount > len(self.colors): - m = self.wirecount // len(self.colors) + 1 - self.colors = self.colors * int(m) - # cut off excess after looping - self.colors = self.colors[: self.wirecount] - else: # wirecount implicit in length of color list - if not self.colors: - raise Exception( - "Unknown number of wires. Must specify wirecount or colors (implicit length)" - ) - self.wirecount = len(self.colors) - - if self.wirelabels: - if self.shield and "s" in self.wirelabels: - raise Exception( - '"s" may not be used as a wire label for a shielded cable.' - ) - - # if lists of part numbers are provided check this is a bundle and that it matches the wirecount. - for idfield in [self.manufacturer, self.mpn, self.supplier, self.spn, self.pn]: - if isinstance(idfield, list): - if self.category == "bundle": - # check the length - if len(idfield) != self.wirecount: - raise Exception("lists of part data must match wirecount") - else: - raise Exception("lists of part data are only supported for bundles") - - if self.show_name is None: - # hide designators for auto-generated cables by default - self.show_name = self.name[0:2] != "__" - - if self.show_wirenumbers is None: - # by default, show wire numbers for cables, hide for bundles - self.show_wirenumbers = self.category != "bundle" - - for i, item in enumerate(self.additional_components): - if isinstance(item, dict): - self.additional_components[i] = AdditionalComponent(**item) - - # The *_pin arguments accept a tuple, but it seems not in use with the current code. - def connect( - self, - from_name: Optional[Designator], - from_pin: NoneOrMorePinIndices, - via_wire: OneOrMoreWires, - to_name: Optional[Designator], - to_pin: NoneOrMorePinIndices, - ) -> None: - from_pin = int2tuple(from_pin) - via_wire = int2tuple(via_wire) - to_pin = int2tuple(to_pin) - if len(from_pin) != len(to_pin): - raise Exception("from_pin must have the same number of elements as to_pin") - for i, _ in enumerate(from_pin): - self.connections.append( - Connection(from_name, from_pin[i], via_wire[i], to_name, to_pin[i]) - ) - - def get_qty_multiplier(self, qty_multiplier: Optional[CableMultiplier]) -> float: - if not qty_multiplier: - return 1 - elif qty_multiplier == "wirecount": - return self.wirecount - elif qty_multiplier == "terminations": - return len(self.connections) - elif qty_multiplier == "length": - return self.length - elif qty_multiplier == "total_length": - return self.length * self.wirecount - else: - raise ValueError( - f"invalid qty multiplier parameter for cable {qty_multiplier}" - ) - - -@dataclass -class Connection: - from_name: Optional[Designator] - from_pin: Optional[Pin] - via_port: Wire - to_name: Optional[Designator] - to_pin: Optional[Pin] - - -@dataclass -class MatePin: - from_name: Designator - from_pin: Pin - to_name: Designator - to_pin: Pin - shape: str - - -@dataclass -class MateComponent: - from_name: Designator - to_name: Designator - shape: str diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py deleted file mode 100644 index c4af236..0000000 --- a/src/wireviz/Harness.py +++ /dev/null @@ -1,715 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from collections import Counter -from dataclasses import dataclass -from itertools import zip_longest -from pathlib import Path -from typing import Any, List, Union - -from graphviz import Graph -from wireviz import APP_NAME, APP_URL, __version__, wv_colors -from wireviz.DataClasses import ( - Cable, - Connector, - MateComponent, - MatePin, - Metadata, - Options, - Side, - Tweak, -) -from wireviz.svgembed import embed_svg_images, embed_svg_images_file -from wireviz.wv_bom import ( - HEADER_MPN, - HEADER_PN, - HEADER_SPN, - bom_list, - component_table_entry, - generate_bom, - get_additional_component_table, - pn_info_string, -) -from wireviz.wv_colors import get_color_hex, translate_color -from wireviz.wv_gv_html import ( - html_bgcolor, - html_bgcolor_attr, - html_caption, - html_colorbar, - html_image, - html_line_breaks, - nested_html_table, - remove_links, -) -from wireviz.wv_helper import ( - awg_equiv, - file_write_text, - flatten2d, - is_arrow, - mm2_equiv, - tuplelist2tsv, -) -from wireviz.wv_html import generate_html_output - -OLD_CONNECTOR_ATTR = { - "pinout": "was renamed to 'pinlabels' in v0.2", - "pinnumbers": "was renamed to 'pins' in v0.2", - "autogenerate": "is replaced with new syntax in v0.4", -} - - -def check_old(node: str, old_attr: dict, args: dict) -> None: - """Raise exception for any outdated attributes in args.""" - for attr, descr in old_attr.items(): - if attr in args: - raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}") - - -@dataclass -class Harness: - metadata: Metadata - options: Options - tweak: Tweak - - def __post_init__(self): - self.connectors = {} - self.cables = {} - self.mates = [] - self._bom = [] # Internal Cache for generated bom - self.additional_bom_items = [] - - def add_connector(self, name: str, *args, **kwargs) -> None: - check_old(f"Connector '{name}'", OLD_CONNECTOR_ATTR, kwargs) - self.connectors[name] = Connector(name, *args, **kwargs) - - def add_cable(self, name: str, *args, **kwargs) -> None: - self.cables[name] = Cable(name, *args, **kwargs) - - def add_mate_pin(self, from_name, from_pin, to_name, to_pin, arrow_type) -> None: - self.mates.append(MatePin(from_name, from_pin, to_name, to_pin, arrow_type)) - self.connectors[from_name].activate_pin(from_pin, Side.RIGHT) - self.connectors[to_name].activate_pin(to_pin, Side.LEFT) - - def add_mate_component(self, from_name, to_name, arrow_type) -> None: - self.mates.append(MateComponent(from_name, to_name, arrow_type)) - - def add_bom_item(self, item: dict) -> None: - self.additional_bom_items.append(item) - - def connect( - self, - from_name: str, - from_pin: (int, str), - via_name: str, - via_wire: (int, str), - to_name: str, - to_pin: (int, str), - ) -> None: - # check from and to connectors - for name, pin in zip([from_name, to_name], [from_pin, to_pin]): - if name is not None and name in self.connectors: - connector = self.connectors[name] - # check if provided name is ambiguous - if pin in connector.pins and pin in connector.pinlabels: - if connector.pins.index(pin) != connector.pinlabels.index(pin): - raise Exception( - f"{name}:{pin} is defined both in pinlabels and pins, for different pins." - ) - # TODO: Maybe issue a warning if present in both lists but referencing the same pin? - if pin in connector.pinlabels: - if connector.pinlabels.count(pin) > 1: - raise Exception(f"{name}:{pin} is defined more than once.") - index = connector.pinlabels.index(pin) - pin = connector.pins[index] # map pin name to pin number - if name == from_name: - from_pin = pin - if name == to_name: - to_pin = pin - if not pin in connector.pins: - raise Exception(f"{name}:{pin} not found.") - - # check via cable - if via_name in self.cables: - cable = self.cables[via_name] - # check if provided name is ambiguous - if via_wire in cable.colors and via_wire in cable.wirelabels: - if cable.colors.index(via_wire) != cable.wirelabels.index(via_wire): - raise Exception( - f"{via_name}:{via_wire} is defined both in colors and wirelabels, for different wires." - ) - # TODO: Maybe issue a warning if present in both lists but referencing the same wire? - if via_wire in cable.colors: - if cable.colors.count(via_wire) > 1: - raise Exception( - f"{via_name}:{via_wire} is used for more than one wire." - ) - # list index starts at 0, wire IDs start at 1 - via_wire = cable.colors.index(via_wire) + 1 - elif via_wire in cable.wirelabels: - if cable.wirelabels.count(via_wire) > 1: - raise Exception( - f"{via_name}:{via_wire} is used for more than one wire." - ) - via_wire = ( - cable.wirelabels.index(via_wire) + 1 - ) # list index starts at 0, wire IDs start at 1 - - # perform the actual connection - self.cables[via_name].connect(from_name, from_pin, via_wire, to_name, to_pin) - if from_name in self.connectors: - self.connectors[from_name].activate_pin(from_pin, Side.RIGHT) - if to_name in self.connectors: - self.connectors[to_name].activate_pin(to_pin, Side.LEFT) - - def create_graph(self) -> Graph: - dot = Graph() - dot.body.append(f"// Graph generated by {APP_NAME} {__version__}\n") - dot.body.append(f"// {APP_URL}\n") - dot.attr( - "graph", - rankdir="LR", - ranksep="2", - bgcolor=wv_colors.translate_color(self.options.bgcolor, "HEX"), - nodesep="0.33", - fontname=self.options.fontname, - ) # TODO: Add graph attribute: charset="utf-8", - dot.attr( - "node", - shape="none", - width="0", - height="0", - margin="0", # Actual size of the node is entirely determined by the label. - style="filled", - fillcolor=wv_colors.translate_color(self.options.bgcolor_node, "HEX"), - fontname=self.options.fontname, - ) - dot.attr("edge", style="bold", fontname=self.options.fontname) - - for connector in self.connectors.values(): - # If no wires connected (except maybe loop wires)? - if not (connector.ports_left or connector.ports_right): - connector.ports_left = True # Use left side pins. - - html = [] - # fmt: off - rows = [[f'{html_bgcolor(connector.bgcolor_title)}{remove_links(connector.name)}' - if connector.show_name else None], - [pn_info_string(HEADER_PN, None, remove_links(connector.pn)), - html_line_breaks(pn_info_string(HEADER_MPN, connector.manufacturer, connector.mpn)), - html_line_breaks(pn_info_string(HEADER_SPN, connector.supplier, connector.spn))], - [html_line_breaks(connector.type), - html_line_breaks(connector.subtype), - f'{connector.pincount}-pin' if connector.show_pincount else None, - translate_color(connector.color, self.options.color_mode) if connector.color else None, - html_colorbar(connector.color)], - '' if connector.style != 'simple' else None, - [html_image(connector.image)], - [html_caption(connector.image)]] - # fmt: on - - rows.extend(get_additional_component_table(self, connector)) - rows.append([html_line_breaks(connector.notes)]) - html.extend(nested_html_table(rows, html_bgcolor_attr(connector.bgcolor))) - - if connector.style != "simple": - pinhtml = [] - pinhtml.append( - '' - ) - - for pinindex, (pinname, pinlabel, pincolor) in enumerate( - zip_longest( - connector.pins, connector.pinlabels, connector.pincolors - ) - ): - if ( - connector.hide_disconnected_pins - and not connector.visible_pins.get(pinname, False) - ): - continue - - pinhtml.append(" ") - if connector.ports_left: - pinhtml.append(f' ') - if pinlabel: - pinhtml.append(f" ") - if connector.pincolors: - if pincolor in wv_colors._color_hex.keys(): - # fmt: off - pinhtml.append(f' ') - pinhtml.append( ' ') - # fmt: on - else: - pinhtml.append(' ') - - if connector.ports_right: - pinhtml.append(f' ') - pinhtml.append(" ") - - pinhtml.append("
{pinname}{pinlabel}{translate_color(pincolor, self.options.color_mode)}') - pinhtml.append( ' ') - pinhtml.append(f' ') - pinhtml.append( '
') - pinhtml.append( '
{pinname}
") - - if len(pinhtml) == 2: # Table start and end with no rows between? - pinhtml = [""] # Avoid Graphviz error - - html = [ - row.replace("", "\n".join(pinhtml)) - for row in html - ] - - html = "\n".join(html) - dot.node( - connector.name, - label=f"<\n{html}\n>", - shape="box", - style="filled", - fillcolor=translate_color(self.options.bgcolor_connector, "HEX"), - ) - - 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}", - label=" ", # Work-around to avoid over-sized loops. - ) - - # 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 - pad = any( - len(colorstr) > 2 - for cable in self.cables.values() - for colorstr in cable.colors - ) - - for cable in self.cables.values(): - html = [] - - awg_fmt = "" - if cable.show_equiv: - # Only convert units we actually know about, i.e. currently - # mm2 and awg --- other units _are_ technically allowed, - # and passed through as-is. - if cable.gauge_unit == "mm\u00B2": - awg_fmt = f" ({awg_equiv(cable.gauge)} AWG)" - elif cable.gauge_unit.upper() == "AWG": - awg_fmt = f" ({mm2_equiv(cable.gauge)} mm\u00B2)" - - # fmt: off - rows = [[f'{html_bgcolor(cable.bgcolor_title)}{remove_links(cable.name)}' - if cable.show_name else None], - [pn_info_string(HEADER_PN, None, - remove_links(cable.pn)) if not isinstance(cable.pn, list) else None, - html_line_breaks(pn_info_string(HEADER_MPN, - cable.manufacturer if not isinstance(cable.manufacturer, list) else None, - cable.mpn if not isinstance(cable.mpn, list) else None)), - html_line_breaks(pn_info_string(HEADER_SPN, - cable.supplier if not isinstance(cable.supplier, list) else None, - cable.spn if not isinstance(cable.spn, list) else None))], - [html_line_breaks(cable.type), - f'{cable.wirecount}x' if cable.show_wirecount else None, - f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None, - '+ S' if cable.shield else None, - f'{cable.length} {cable.length_unit}' if cable.length > 0 else None, - translate_color(cable.color, self.options.color_mode) if cable.color else None, - html_colorbar(cable.color)], - '', - [html_image(cable.image)], - [html_caption(cable.image)]] - # fmt: on - - rows.extend(get_additional_component_table(self, cable)) - rows.append([html_line_breaks(cable.notes)]) - html.extend(nested_html_table(rows, html_bgcolor_attr(cable.bgcolor))) - - wirehtml = [] - # conductor table - wirehtml.append('') - wirehtml.append(" ") - - for i, (connection_color, wirelabel) in enumerate( - zip_longest(cable.colors, cable.wirelabels), 1 - ): - wirehtml.append(" ") - wirehtml.append(f" ") - wirehtml.append(f" ") - wirehtml.append(f" ") - wirehtml.append(" ") - - # fmt: off - bgcolors = ['#000000'] + get_color_hex(connection_color, pad=pad) + ['#000000'] - wirehtml.append(f" ") - wirehtml.append(f' ") - wirehtml.append(" ") - # fmt: on - - # for bundles, individual wires can have part information - if cable.category == "bundle": - # create a list of wire parameters - wireidentification = [] - if isinstance(cable.pn, list): - wireidentification.append( - pn_info_string( - HEADER_PN, None, remove_links(cable.pn[i - 1]) - ) - ) - manufacturer_info = pn_info_string( - HEADER_MPN, - ( - cable.manufacturer[i - 1] - if isinstance(cable.manufacturer, list) - else None - ), - cable.mpn[i - 1] if isinstance(cable.mpn, list) else None, - ) - supplier_info = pn_info_string( - HEADER_SPN, - ( - cable.supplier[i - 1] - if isinstance(cable.supplier, list) - else None - ), - cable.spn[i - 1] if isinstance(cable.spn, list) else None, - ) - if manufacturer_info: - wireidentification.append(html_line_breaks(manufacturer_info)) - if supplier_info: - wireidentification.append(html_line_breaks(supplier_info)) - # print parameters into a table row under the wire - if len(wireidentification) > 0: - # fmt: off - wirehtml.append(' ") - # fmt: on - - if cable.shield: - wirehtml.append(" ") # spacer - wirehtml.append(" ") - wirehtml.append(" ") - wirehtml.append(" ") - wirehtml.append(" ") - wirehtml.append(" ") - if isinstance(cable.shield, str): - # shield is shown with specified color and black borders - shield_color_hex = wv_colors.get_color_hex(cable.shield)[0] - attributes = ( - f'height="6" bgcolor="{shield_color_hex}" border="2" sides="tb"' - ) - else: - # shield is shown as a thin black wire - attributes = f'height="2" bgcolor="#000000" border="0"' - # fmt: off - wirehtml.append(f' ') - # fmt: on - - wirehtml.append(" ") - wirehtml.append("
 
") - - wireinfo = [] - if cable.show_wirenumbers: - wireinfo.append(str(i)) - colorstr = wv_colors.translate_color( - connection_color, self.options.color_mode - ) - if colorstr: - wireinfo.append(colorstr) - if cable.wirelabels: - wireinfo.append(wirelabel if wirelabel is not None else "") - wirehtml.append(f' {":".join(wireinfo)}') - - wirehtml.append(f"
') - wirehtml.append(' ') - for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors - wirehtml.append(f' ') - wirehtml.append("
") - wirehtml.append("
') - wirehtml.append(' ') - for attrib in wireidentification: - wirehtml.append(f" ") - wirehtml.append("
{attrib}
") - wirehtml.append("
 
Shield
 
") - - html = [ - row.replace("", "\n".join(wirehtml)) for row in html - ] - - # connections - for connection in cable.connections: - if isinstance(connection.via_port, int): - # check if it's an actual wire and not a shield - dot.attr( - "edge", - color=":".join( - ["#000000"] - + wv_colors.get_color_hex( - cable.colors[connection.via_port - 1], pad=pad - ) - + ["#000000"] - ), - ) - else: # it's a shield connection - # shield is shown with specified color and black borders, or as a thin black wire otherwise - dot.attr( - "edge", - color=( - ":".join(["#000000", shield_color_hex, "#000000"]) - if isinstance(cable.shield, str) - else "#000000" - ), - ) - if connection.from_pin is not None: # connect to left - from_connector = self.connectors[connection.from_name] - from_pin_index = from_connector.pins.index(connection.from_pin) - from_port_str = ( - f":p{from_pin_index+1}r" - if from_connector.style != "simple" - else "" - ) - code_left_1 = f"{connection.from_name}{from_port_str}:e" - code_left_2 = f"{cable.name}:w{connection.via_port}:w" - dot.edge(code_left_1, code_left_2) - if from_connector.show_name: - from_info = [ - str(connection.from_name), - str(connection.from_pin), - ] - if from_connector.pinlabels: - pinlabel = from_connector.pinlabels[from_pin_index] - if pinlabel != "": - from_info.append(pinlabel) - from_string = ":".join(from_info) - else: - from_string = "" - html = [ - row.replace(f"", from_string) - for row in html - ] - if connection.to_pin is not None: # connect to right - to_connector = self.connectors[connection.to_name] - to_pin_index = to_connector.pins.index(connection.to_pin) - to_port_str = ( - f":p{to_pin_index+1}l" if to_connector.style != "simple" else "" - ) - code_right_1 = f"{cable.name}:w{connection.via_port}:e" - code_right_2 = f"{connection.to_name}{to_port_str}:w" - dot.edge(code_right_1, code_right_2) - if to_connector.show_name: - to_info = [str(connection.to_name), str(connection.to_pin)] - if to_connector.pinlabels: - pinlabel = to_connector.pinlabels[to_pin_index] - if pinlabel != "": - to_info.append(pinlabel) - to_string = ":".join(to_info) - else: - to_string = "" - html = [ - row.replace(f"", to_string) - for row in html - ] - - style, bgcolor = ( - ("filled,dashed", self.options.bgcolor_bundle) - if cable.category == "bundle" - else ("filled", self.options.bgcolor_cable) - ) - html = "\n".join(html) - dot.node( - cable.name, - label=f"<\n{html}\n>", - shape="box", - style=style, - fillcolor=translate_color(bgcolor, "HEX"), - ) - - # mates - for mate in self.mates: - if mate.shape[-1] == ">": - dir = "both" if mate.shape[0] == "<" else "forward" - else: - dir = "back" if mate.shape[0] == "<" else "none" - - if isinstance(mate, MatePin): - color = "#000000" - elif isinstance(mate, MateComponent): - color = "#000000:#000000" - else: - raise Exception(f"{mate} is an unknown mate") - - from_connector = self.connectors[mate.from_name] - to_connector = self.connectors[mate.to_name] - if isinstance(mate, MatePin) and from_connector.style != "simple": - from_pin_index = from_connector.pins.index(mate.from_pin) - from_port_str = f":p{from_pin_index+1}r" - else: # MateComponent or style == 'simple' - from_port_str = "" - if isinstance(mate, MatePin) and to_connector.style != "simple": - to_pin_index = to_connector.pins.index(mate.to_pin) - to_port_str = f":p{to_pin_index+1}l" - else: # MateComponent or style == 'simple' - to_port_str = "" - code_from = f"{mate.from_name}{from_port_str}:e" - code_to = f"{mate.to_name}{to_port_str}:w" - - dot.attr("edge", color=color, style="dashed", dir=dir) - dot.edge(code_from, code_to) - - def typecheck(name: str, value: Any, expect: type) -> None: - if not isinstance(value, expect): - raise Exception( - f"Unexpected value type of {name}: Expected {expect}, got {type(value)}\n{value}" - ) - - # TODO?: Differ between override attributes and HTML? - if self.tweak.override is not None: - typecheck("tweak.override", self.tweak.override, dict) - for k, d in self.tweak.override.items(): - typecheck(f"tweak.override.{k} key", k, str) - typecheck(f"tweak.override.{k} value", d, dict) - for a, v in d.items(): - typecheck(f"tweak.override.{k}.{a} key", a, str) - typecheck(f"tweak.override.{k}.{a} value", v, (str, type(None))) - - # Override generated attributes of selected entries matching tweak.override. - for i, entry in enumerate(dot.body): - if isinstance(entry, str): - # Find a possibly quoted keyword after leading TAB(s) and followed by [ ]. - match = re.match( - r'^\t*(")?((?(1)[^"]|[^ "])+)(?(1)") \[.*\]$', entry, re.S - ) - keyword = match and match[2] - if keyword in self.tweak.override.keys(): - for attr, value in self.tweak.override[keyword].items(): - if value is None: - entry, n_subs = re.subn( - f'( +)?{attr}=("[^"]*"|[^] ]*)(?(1)| *)', "", entry - ) - if n_subs < 1: - print( - f"Harness.create_graph() warning: {attr} not found in {keyword}!" - ) - elif n_subs > 1: - print( - f"Harness.create_graph() warning: {attr} removed {n_subs} times in {keyword}!" - ) - continue - - if len(value) == 0 or " " in value: - value = value.replace('"', r"\"") - value = f'"{value}"' - entry, n_subs = re.subn( - f'{attr}=("[^"]*"|[^] ]*)', f"{attr}={value}", entry - ) - if n_subs < 1: - # If attr not found, then append it - entry = re.sub(r"\]$", f" {attr}={value}]", entry) - elif n_subs > 1: - print( - f"Harness.create_graph() warning: {attr} overridden {n_subs} times in {keyword}!" - ) - - dot.body[i] = entry - - if self.tweak.append is not None: - if isinstance(self.tweak.append, list): - for i, element in enumerate(self.tweak.append, 1): - typecheck(f"tweak.append[{i}]", element, str) - dot.body.extend(self.tweak.append) - else: - typecheck("tweak.append", self.tweak.append, str) - dot.body.append(self.tweak.append) - - # Tweak processing above must be the last before returning dot. - # Please don't insert any code that might change the dot contents - # after tweak processing. - - return dot - - # cache for the GraphViz Graph object - # do not access directly, use self.graph instead - _graph = None - - @property - def graph(self): - if not self._graph: # no cached graph exists, generate one - self._graph = self.create_graph() - return self._graph # return cached graph - - @property - def png(self): - from io import BytesIO - - graph = self.graph - data = BytesIO() - data.write(graph.pipe(format="png")) - data.seek(0) - return data.read() - - @property - def svg(self): # TODO?: Verify xml encoding="utf-8" in SVG? - graph = self.graph - return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd()) - - def output( - self, - filename: (str, Path), - view: bool = False, - cleanup: bool = True, - fmt: tuple = ("html", "png", "svg", "tsv"), - ) -> None: - # graphical output - graph = self.graph - svg_already_exists = Path( - f"{filename}.svg" - ).exists() # if SVG already exists, do not delete later - # graphical output - for f in fmt: - if f in ("png", "svg", "html"): - if f == "html": # if HTML format is specified, - f = "svg" # generate SVG for embedding into HTML - # SVG file will be renamed/deleted later - _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) - # embed images into SVG output - if "svg" in fmt or "html" in fmt: - embed_svg_images_file(f"{filename}.tmp.svg") - # GraphViz output - if "gv" in fmt: - graph.save(filename=f"{filename}.gv") - # BOM output - bomlist = bom_list(self.bom()) - if "tsv" in fmt: - file_write_text(f"{filename}.bom.tsv", tuplelist2tsv(bomlist)) - if "csv" in fmt: - # TODO: implement CSV output (preferrably using CSV library) - print("CSV output is not yet supported") - # HTML output - if "html" in fmt: - generate_html_output(filename, bomlist, self.metadata, self.options) - # PDF output - if "pdf" in fmt: - # TODO: implement PDF output - print("PDF output is not yet supported") - # delete SVG if not needed - if "html" in fmt and not "svg" in fmt: - # SVG file was just needed to generate HTML - Path(f"{filename}.tmp.svg").unlink() - elif "svg" in fmt: - Path(f"{filename}.tmp.svg").replace(f"{filename}.svg") - - def bom(self): - if not self._bom: - self._bom = generate_bom(self) - return self._bom diff --git a/src/wireviz/__init__.py b/src/wireviz/__init__.py index e3edc24..aab6422 100644 --- a/src/wireviz/__init__.py +++ b/src/wireviz/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Please don't import anything in this file to avoid issues when it is imported in setup.py -__version__ = "0.4.1" +__version__ = "0.5-dev+refactor" CMD_NAME = "wireviz" # Lower case command and module name APP_NAME = "WireViz" # Application name in texts meant to be human readable diff --git a/src/wireviz/svgembed.py b/src/wireviz/svgembed.py deleted file mode 100644 index 535fa4a..0000000 --- a/src/wireviz/svgembed.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- - -import base64 -import re -from pathlib import Path -from typing import Union - -mime_subtype_replacements = {"jpg": "jpeg", "tif": "tiff"} - - -# TODO: Share cache and code between data_URI_base64() and embed_svg_images() -def data_URI_base64(file: Union[str, Path], media: str = "image") -> str: - """Return Base64-encoded data URI of input file.""" - file = Path(file) - b64 = base64.b64encode(file.read_bytes()).decode("utf-8") - uri = f"data:{media}/{get_mime_subtype(file)};base64, {b64}" - # print(f"data_URI_base64('{file}', '{media}') -> {len(uri)}-character URI") - if len(uri) > 65535: - print( - "data_URI_base64(): Warning: Browsers might have different URI length limitations" - ) - return uri - - -def embed_svg_images(svg_in: str, base_path: Union[str, Path] = Path.cwd()) -> str: - images_b64 = {} # cache of base64-encoded images - - def image_tag(pre: str, url: str, post: str) -> str: - return f'' - - def replace(match: re.Match) -> str: - imgurl = match["URL"] - if not imgurl in images_b64: # only encode/cache every unique URL once - imgurl_abs = (Path(base_path) / imgurl).resolve() - image = imgurl_abs.read_bytes() - images_b64[imgurl] = base64.b64encode(image).decode("utf-8") - return image_tag( - match["PRE"] or "", - f"data:image/{get_mime_subtype(imgurl)};base64, {images_b64[imgurl]}", - match["POST"] or "", - ) - - pattern = re.compile( - image_tag(r"(?P
 [^>]*?)?", r'(?P[^"]*?)', r"(?P [^>]*?)?"),
-        re.IGNORECASE,
-    )
-    return pattern.sub(replace, svg_in)
-
-
-def get_mime_subtype(filename: Union[str, Path]) -> str:
-    mime_subtype = Path(filename).suffix.lstrip(".").lower()
-    if mime_subtype in mime_subtype_replacements:
-        mime_subtype = mime_subtype_replacements[mime_subtype]
-    return mime_subtype
-
-
-def embed_svg_images_file(
-    filename_in: Union[str, Path], overwrite: bool = True
-) -> None:
-    filename_in = Path(filename_in).resolve()
-    filename_out = filename_in.with_suffix(".b64.svg")
-    filename_out.write_text(  # TODO?: Verify xml encoding="utf-8" in SVG?
-        embed_svg_images(filename_in.read_text(), filename_in.parent)
-    )  # TODO: Use encoding="utf-8" in both read_text() and write_text()
-    if overwrite:
-        filename_out.replace(filename_in)
diff --git a/src/wireviz/templates/README.md b/src/wireviz/templates/README.md
index 31d3ef8..693ea3c 100644
--- a/src/wireviz/templates/README.md
+++ b/src/wireviz/templates/README.md
@@ -39,10 +39,10 @@ Note that there must be one single space between `--` and `%` at both ends.
 | `` | `1` (multi-page documents not yet supported) |
 | ``   | `1` (multi-page documents not yet supported) |
 | ``       | Embedded SVG diagram as valid HTML |
-| ``  | Embedded base64 encoded PNG diagram as URI |
-| ``           | String or numeric value of `metadata.{item}` |
-| ``       | Category number `{i}` within dict value of `metadata.{item}` |
-| `` | Value of `metadata.{item}.{category}.{key}` |
+| `` | Embedded base64 encoded PNG diagram as URI |
+| ``             | String or numeric value of `metadata.{item}` |
+| ``         | Category number `{i}` within dict value of `metadata.{item}` |
+| ``   | Value of `metadata.{item}.{category}.{key}` |
 | `` | Value of `metadata.template.sheetsize` |
 
 Note that `{item}`, `{category}` and `{key}` in the description above can be
diff --git a/src/wireviz/templates/din-6771.html b/src/wireviz/templates/din-6771.html
index 1aab000..05f563f 100644
--- a/src/wireviz/templates/din-6771.html
+++ b/src/wireviz/templates/din-6771.html
@@ -1,18 +1,23 @@
 
 
+
 
   
-  
+  
   
   <!-- %title% -->
   
   
 
+
 
   
@@ -283,4 +297,5 @@
- + + \ No newline at end of file diff --git a/src/wireviz/build_examples.py b/src/wireviz/tools/build_examples.py similarity index 92% rename from src/wireviz/build_examples.py rename to src/wireviz/tools/build_examples.py index e54d0f5..7ad295a 100755 --- a/src/wireviz/build_examples.py +++ b/src/wireviz/tools/build_examples.py @@ -7,13 +7,12 @@ import sys from pathlib import Path script_path = Path(__file__).absolute() - -sys.path.insert(0, str(script_path.parent.parent)) # to find wireviz module -from wv_helper import open_file_append, open_file_read, open_file_write +sys.path.insert(0, str(script_path.parent.parent.parent)) # to find wireviz module from wireviz import APP_NAME, __version__, wireviz +from wireviz.wv_utils import open_file_append, open_file_read, open_file_write -dir = script_path.parent.parent.parent +dir = script_path.parent.parent.parent.parent readme = "readme.md" groups = { "examples": { @@ -32,10 +31,11 @@ groups = { "path": dir / "examples", "prefix": "demo", }, + **{p.stem: {"path": p} for p in (dir / "tests").glob("**")}, } input_extensions = [".yml"] -extensions_not_containing_graphviz_output = [".gv", ".bom.tsv"] +extensions_not_containing_graphviz_output = [".gv", ".tsv"] extensions_containing_graphviz_output = [".png", ".svg", ".html"] generated_extensions = ( extensions_not_containing_graphviz_output + extensions_containing_graphviz_output @@ -44,7 +44,7 @@ generated_extensions = ( def collect_filenames(description, groupkey, ext_list): path = groups[groupkey]["path"] - patterns = [f"{groups[groupkey]['prefix']}*{ext}" for ext in ext_list] + patterns = [f"{groups[groupkey].get('prefix', '')}*{ext}" for ext in ext_list] if ext_list != input_extensions and readme in groups[groupkey]: patterns.append(readme) print(f'{description} {groupkey} in "{path}"') @@ -88,7 +88,7 @@ def build_generated(groupkeys): out.write(f"![]({yaml_file.stem}.png)\n\n") out.write( - f"[Source]({yaml_file.name}) - [Bill of Materials]({yaml_file.stem}.bom.tsv)\n\n\n" + f"[Source]({yaml_file.name}) - [Bill of Materials]({yaml_file.stem}.tsv)\n\n\n" ) @@ -98,7 +98,7 @@ def clean_generated(groupkeys): for filename in collect_filenames("Cleaning", key, generated_extensions): if filename.is_file(): print(f' rm "{filename}"') - Path(filename).unlink() + filename.unlink() def compare_generated(groupkeys, branch="", include_graphviz_output=False): diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index 391b1ac..fac305e 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -3,6 +3,7 @@ import platform import sys +from errno import EINVAL, ENAMETOOLONG from pathlib import Path from typing import Any, Dict, List, Tuple, Union @@ -11,9 +12,9 @@ import yaml if __name__ == "__main__": sys.path.insert(0, str(Path(__file__).parent.parent)) # add src/wireviz to PATH -from wireviz.DataClasses import Metadata, Options, Tweak -from wireviz.Harness import Harness -from wireviz.wv_helper import ( +from wireviz.wv_dataclasses import AUTOGENERATED_PREFIX, Metadata, Options, Tweak +from wireviz.wv_harness import Harness +from wireviz.wv_utils import ( expand, file_read_text, get_single_key_and_value, @@ -37,7 +38,7 @@ def parse( and outputs the result as one or more files and/or as a function return value Accepted inputs: - * A path to a YAML source file to parse + * A Path object or a path-like string pointing to a YAML source file to parse * A string containing the YAML data to parse * A Python Dict containing the pre-parsed YAML data @@ -47,10 +48,8 @@ def parse( * "harness": the diagram as a Harness Python object Supported output formats: - * "csv": the BOM, as a comma-separated text file * "gv": the diagram, as a GraphViz source file * "html": the diagram and (depending on the template) the BOM, as a HTML file - * "png": the diagram, as a PNG raster image * "pdf": the diagram and (depending on the template) the BOM, as a PDF file * "svg": the diagram, as a SVG vector image * "tsv": the BOM, as a tab-separated text file @@ -84,6 +83,7 @@ def parse( * SVG data * a Harness object """ + # TODO: add CSV and PDF to docstring once they are supported if not output_formats and not return_types: raise Exception("No output formats or return types specified") @@ -100,7 +100,8 @@ def parse( output_file = output_dir / output_name if yaml_file: - # if reading from file, ensure that input file's parent directory is included in image_paths + # if reading from file, ensure that input file's parent directory + # is included in image_paths default_image_path = yaml_file.parent.resolve() if not default_image_path in [Path(x).resolve() for x in image_paths]: image_paths.append(default_image_path) @@ -136,7 +137,8 @@ def parse( if len(yaml_data[sec]) > 0: # section has contents if ty == dict: for key, attribs in yaml_data[sec].items(): - # The Image dataclass might need to open an image file with a relative path. + # The Image dataclass might need to open + # an image file with a relative path. image = attribs.get("image") if isinstance(image, dict): image_path = image["src"] @@ -172,12 +174,16 @@ def parse( autogenerated_designators[template] = ( autogenerated_designators.get(template, 0) + 1 ) - designator = f"__{template}_{autogenerated_designators[template]}" + designator = ( + f"{AUTOGENERATED_PREFIX}" + f"{template}_{autogenerated_designators[template]}" + ) # check if redefining existing component to different template if designator in designators_and_templates: if designators_and_templates[designator] != template: raise Exception( - f"Trying to redefine {designator} from {designators_and_templates[designator]} to {template}" + f"Trying to redefine {designator}" + f" from {designators_and_templates[designator]} to {template}" ) else: designators_and_templates[designator] = template @@ -289,7 +295,7 @@ def parse( # generate new connector instance from template check_type(designator, template, "connector") harness.add_connector( - name=designator, **template_connectors[template] + designator=designator, **template_connectors[template] ) elif designator in harness.cables: # existing cable instance @@ -297,7 +303,9 @@ def parse( elif template in template_cables.keys(): # generate new cable instance from template check_type(designator, template, "cable/arrow") - harness.add_cable(name=designator, **template_cables[template]) + harness.add_cable( + designator=designator, **template_cables[template] + ) elif is_arrow(designator): check_type(designator, template, "cable/arrow") @@ -307,7 +315,8 @@ def parse( f"{template} is an unknown template/designator/arrow." ) - alternate_type() # entries in connection set must alternate between connectors and cables/arrows + # entries in connection set must alternate between connectors and cables/arrows + alternate_type() # transpose connection set list # before: one item per component, one subitem per connection in set @@ -375,11 +384,13 @@ def parse( ) print(", ".join(forgotten_components)) - # harness population completed ============================================= - if "additional_bom_items" in yaml_data: for line in yaml_data["additional_bom_items"]: - harness.add_bom_item(line) + harness.add_additional_bom_item(line) + + # harness population completed ============================================= + + harness.populate_bom() if output_formats: harness.output(filename=output_file, fmt=output_formats, view=False) @@ -402,7 +413,7 @@ def parse( return tuple(returns) if len(returns) != 1 else returns[0] -def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path): +def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> Tuple[Dict, Path]: # determine whether inp is a file path, a YAML string, or a Dict if not isinstance(inp, Dict): # received a str or a Path try: @@ -417,8 +428,6 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path): # instead in some cases (depending on the Python version). # Catch these specific errors, but raise any others. - from errno import EINVAL, ENAMETOOLONG - if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG, None): print( f"OSError(errno={e.errno}) in Python {sys.version} at {platform.platform()}" diff --git a/src/wireviz/wv_bom.py b/src/wireviz/wv_bom.py index 7eecfdf..cf5c04f 100644 --- a/src/wireviz/wv_bom.py +++ b/src/wireviz/wv_bom.py @@ -1,278 +1,87 @@ # -*- coding: utf-8 -*- -from dataclasses import asdict -from itertools import groupby -from typing import Any, Dict, List, Optional, Tuple, Union +from collections import namedtuple +from dataclasses import dataclass +from enum import Enum, IntEnum +from typing import List, Optional, Union -from wireviz.DataClasses import AdditionalComponent, Cable, Color, Connector -from wireviz.wv_colors import translate_color -from wireviz.wv_gv_html import html_bgcolor_attr, html_line_breaks -from wireviz.wv_helper import clean_whitespace +import tabulate as tabulate_module -BOM_COLUMNS_ALWAYS = ("id", "description", "qty", "unit", "designators") -BOM_COLUMNS_OPTIONAL = ("pn", "manufacturer", "mpn", "supplier", "spn") -BOM_COLUMNS_IN_KEY = ("description", "unit") + BOM_COLUMNS_OPTIONAL +from wireviz.wv_utils import html_line_breaks -HEADER_PN = "P/N" -HEADER_MPN = "MPN" -HEADER_SPN = "SPN" - -BOMKey = Tuple[str, ...] -BOMColumn = str # = Literal[*BOM_COLUMNS_ALWAYS, *BOM_COLUMNS_OPTIONAL] -BOMEntry = Dict[BOMColumn, Union[str, int, float, List[str], None]] +BOM_HASH_FIELDS = "description qty_unit amount partnumbers" -def optional_fields(part: Union[Connector, Cable, AdditionalComponent]) -> BOMEntry: - """Return part field values for the optional BOM columns as a dict.""" - part = asdict(part) - return {field: part.get(field) for field in BOM_COLUMNS_OPTIONAL} +BomEntry = namedtuple("BomEntry", "category qty designators") +BomHash = namedtuple("BomHash", BOM_HASH_FIELDS) +BomHashList = namedtuple("BomHashList", BOM_HASH_FIELDS) +PartNumberInfo = namedtuple("PartNumberInfo", "pn manufacturer mpn supplier spn") + +# TODO: different BOM modes +# BomMode +# "normal" # no bubbles, full PN info in GV node +# "bubbles" # = "full" -> maximum info in GV node +# "hide PN info" +# "PN crossref" = "PN bubbles" + "hide PN info" +# "additionally: BOM table in GV graph label (#227)" +# "title block in GV graph label" -def get_additional_component_table( - harness: "Harness", component: Union[Connector, Cable] +BomCategory = IntEnum( # to enforce ordering in BOM + "BomEntry", "CONNECTOR CABLE WIRE ADDITIONAL_INSIDE ADDITIONAL_OUTSIDE" +) +QtyMultiplierConnector = Enum( + "QtyMultiplierConnector", "PINCOUNT POPULATED UNPOPULATED CONNECTIONS" +) +QtyMultiplierCable = Enum( + "QtyMultiplierCable", "WIRECOUNT TERMINATION LENGTH TOTAL_LENGTH" +) + +PART_NUMBER_HEADERS = PartNumberInfo( + pn="P/N", manufacturer=None, mpn="MPN", supplier=None, spn="SPN" +) + + +def partnumbers2list( + partnumbers: PartNumberInfo, parent_partnumbers: PartNumberInfo = None ) -> List[str]: - """Return a list of diagram node table row strings with additional components.""" - rows = [] - if component.additional_components: - rows.append(["Additional components"]) - # Ignore components that have qty 0 - for part in [ - part - for part in component.additional_components - if component.get_qty_multiplier(part.qty_multiplier) - ]: - common_args = { - "qty": part.qty * component.get_qty_multiplier(part.qty_multiplier), - "unit": part.unit, - "bgcolor": part.bgcolor, - } - if harness.options.mini_bom_mode: - id = get_bom_index( - harness.bom(), - bom_entry_key({**asdict(part), "description": part.description}), - ) - rows.append( - component_table_entry( - f"#{id} ({part.type.rstrip()})", **common_args - ) - ) - else: - rows.append( - component_table_entry( - part.description, **common_args, **optional_fields(part) - ) - ) - return rows + if parent_partnumbers is None: + _is_toplevel = True + parent_partnumbers = partnumbers + else: + _is_toplevel = False + # Note: != operator used as XOR in the following section (https://stackoverflow.com/a/433161) -def get_additional_component_bom(component: Union[Connector, Cable]) -> List[BOMEntry]: - """Return a list of BOM entries with additional components.""" - bom_entries = [] - # Ignore components that have qty 0 - for part in [ - part - for part in component.additional_components - if component.get_qty_multiplier(part.qty_multiplier) - ]: - bom_entries.append( - { - "description": part.description, - "qty": part.qty * component.get_qty_multiplier(part.qty_multiplier), - "unit": part.unit, - "designators": component.name if component.show_name else None, - **optional_fields(part), - } + if _is_toplevel != isinstance(parent_partnumbers.pn, List): + # top level and not a list, or wire level and list + cell_pn = pn_info_string(PART_NUMBER_HEADERS.pn, None, partnumbers.pn) + else: + # top level and list -> do per wire later + # wire level and not list -> already done at top level + cell_pn = None + + if _is_toplevel != isinstance(parent_partnumbers.mpn, List): + # TODO: edge case: different manufacturers, but same MPN? + cell_mpn = pn_info_string( + PART_NUMBER_HEADERS.mpn, partnumbers.manufacturer, partnumbers.mpn ) - return bom_entries + else: + cell_mpn = None - -def bom_entry_key(entry: BOMEntry) -> BOMKey: - """Return a tuple of string values from the dict that must be equal to join BOM entries.""" - if "key" not in entry: - entry["key"] = tuple( - clean_whitespace(make_str(entry.get(c))) for c in BOM_COLUMNS_IN_KEY + if _is_toplevel != isinstance(parent_partnumbers.spn, List): + # TODO: edge case: different suppliers, but same SPN? + cell_spn = pn_info_string( + PART_NUMBER_HEADERS.spn, partnumbers.supplier, partnumbers.spn ) - return entry["key"] + else: + cell_spn = None - -def generate_bom(harness: "Harness") -> List[BOMEntry]: - """Return a list of BOM entries generated from the harness.""" - from wireviz.Harness import Harness # Local import to avoid circular imports - - bom_entries = [] - # connectors - for connector in harness.connectors.values(): - if not connector.ignore_in_bom: - description = ( - "Connector" - + (f", {connector.type}" if connector.type else "") - + (f", {connector.subtype}" if connector.subtype else "") - + (f", {connector.pincount} pins" if connector.show_pincount else "") - + ( - f", {translate_color(connector.color, harness.options.color_mode)}" - if connector.color - else "" - ) - ) - bom_entries.append( - { - "description": description, - "designators": connector.name if connector.show_name else None, - **optional_fields(connector), - } - ) - - # add connectors aditional components to bom - bom_entries.extend(get_additional_component_bom(connector)) - - # cables - # TODO: If category can have other non-empty values than 'bundle', maybe it should be part of description? - for cable in harness.cables.values(): - if not cable.ignore_in_bom: - if cable.category != "bundle": - # process cable as a single entity - description = ( - "Cable" - + (f", {cable.type}" if cable.type else "") - + (f", {cable.wirecount}") - + ( - f" x {cable.gauge} {cable.gauge_unit}" - if cable.gauge - else " wires" - ) - + (" shielded" if cable.shield else "") - + ( - f", {translate_color(cable.color, harness.options.color_mode)}" - if cable.color - else "" - ) - ) - bom_entries.append( - { - "description": description, - "qty": cable.length, - "unit": cable.length_unit, - "designators": cable.name if cable.show_name else None, - **optional_fields(cable), - } - ) - else: - # add each wire from the bundle to the bom - for index, color in enumerate(cable.colors): - description = ( - "Wire" - + (f", {cable.type}" if cable.type else "") - + (f", {cable.gauge} {cable.gauge_unit}" if cable.gauge else "") - + ( - f", {translate_color(color, harness.options.color_mode)}" - if color - else "" - ) - ) - bom_entries.append( - { - "description": description, - "qty": cable.length, - "unit": cable.length_unit, - "designators": cable.name if cable.show_name else None, - **{ - k: index_if_list(v, index) - for k, v in optional_fields(cable).items() - }, - } - ) - - # add cable/bundles aditional components to bom - bom_entries.extend(get_additional_component_bom(cable)) - - # add harness aditional components to bom directly, as they both are List[BOMEntry] - bom_entries.extend(harness.additional_bom_items) - - # remove line breaks if present and cleanup any resulting whitespace issues - bom_entries = [ - {k: clean_whitespace(v) for k, v in entry.items()} for entry in bom_entries - ] - - # deduplicate bom - bom = [] - for _, group in groupby(sorted(bom_entries, key=bom_entry_key), key=bom_entry_key): - group_entries = list(group) - designators = sum( - (make_list(entry.get("designators")) for entry in group_entries), [] - ) - total_qty = sum(entry.get("qty", 1) for entry in group_entries) - bom.append( - { - **group_entries[0], - "qty": int(total_qty) - if float(total_qty).is_integer() - else round(total_qty, 3), - "designators": sorted(set(designators)), - } - ) - - # add an incrementing id to each bom entry - return [{**entry, "id": index} for index, entry in enumerate(bom, 1)] - - -def get_bom_index(bom: List[BOMEntry], target: BOMKey) -> int: - """Return id of BOM entry or raise exception if not found.""" - for entry in bom: - if bom_entry_key(entry) == target: - return entry["id"] - raise Exception("Internal error: No BOM entry found matching: " + "|".join(target)) - - -def bom_list(bom: List[BOMEntry]) -> List[List[str]]: - """Return list of BOM rows as lists of column strings with headings in top row.""" - keys = list(BOM_COLUMNS_ALWAYS) # Always include this fixed set of BOM columns. - for fieldname in BOM_COLUMNS_OPTIONAL: - # Include only those optional BOM columns that are in use. - if any(entry.get(fieldname) for entry in bom): - keys.append(fieldname) - # Custom mapping from internal name to BOM column headers. - # Headers not specified here are generated by capitilising the internal name. - bom_headings = { - "pn": HEADER_PN, - "mpn": HEADER_MPN, - "spn": HEADER_SPN, - } - return [ - [bom_headings.get(k, k.capitalize()) for k in keys] - ] + [ # Create header row with key names - [make_str(entry.get(k)) for k in keys] for entry in bom - ] # Create string list for each entry row - - -def component_table_entry( - type: str, - qty: Union[int, float], - unit: Optional[str] = None, - bgcolor: Optional[Color] = None, - pn: Optional[str] = None, - manufacturer: Optional[str] = None, - mpn: Optional[str] = None, - supplier: Optional[str] = None, - spn: Optional[str] = None, -) -> str: - """Return a diagram node table row string with an additional component.""" - part_number_list = [ - pn_info_string(HEADER_PN, None, pn), - pn_info_string(HEADER_MPN, manufacturer, mpn), - pn_info_string(HEADER_SPN, supplier, spn), - ] - output = ( - f"{qty}" - + (f" {unit}" if unit else "") - + f" x {type}" - + ("
" if any(part_number_list) else "") - + (", ".join([pn for pn in part_number_list if pn])) - ) - # format the above output as left aligned text in a single visible cell - # indent is set to two to match the indent in the generated html table - return f""" - -
{html_line_breaks(output)}
""" + cell_contents = [cell_pn, cell_mpn, cell_spn] + if any(cell_contents): + return [html_line_breaks(cell) for cell in cell_contents] + else: + return None def pn_info_string( @@ -286,16 +95,51 @@ def pn_info_string( return None -def index_if_list(value: Any, index: int) -> Any: - """Return the value indexed if it is a list, or simply the value otherwise.""" - return value[index] if isinstance(value, list) else value +def bom_list(bom): + headers = ( + "# Qty Unit Description Amount Unit Designators " + "P/N Manufacturer MPN Supplier SPN Category".split(" ") + ) + rows = [] + rows.append(headers) + # fill rows + for hash, entry in bom.items(): + cells = [ + entry["id"], + entry["qty"], + hash.qty_unit, + hash.description, + hash.amount.number if hash.amount else None, + hash.amount.unit if hash.amount else None, + ", ".join(sorted(entry["designators"])), + ] + if hash.partnumbers: + cells.extend( + [ + hash.partnumbers.pn, + hash.partnumbers.manufacturer, + hash.partnumbers.mpn, + hash.partnumbers.supplier, + hash.partnumbers.spn, + ] + ) + else: + cells.extend([None, None, None, None, None]) + # cells.extend([f"{entry['category']} ({entry['category'].name})"]) # for debugging + rows.append(cells) + # remove empty columns + transposed = list(map(list, zip(*rows))) + transposed = [ + column + for column in transposed + if any([cell is not None for cell in column[1:]]) + # ^ ignore header cell in check + ] + rows = list(map(list, zip(*transposed))) + return rows -def make_list(value: Any) -> list: - """Return value if a list, empty list if None, or single element list otherwise.""" - return value if isinstance(value, list) else [] if value is None else [value] - - -def make_str(value: Any) -> str: - """Return comma separated elements if a list, empty string if None, or value as a string otherwise.""" - return ", ".join(str(element) for element in make_list(value)) +def print_bom_table(bom): + print() + print(tabulate_module.tabulate(bom_list(bom), headers="firstrow")) + print() diff --git a/src/wireviz/wv_cli.py b/src/wireviz/wv_cli.py index 4ab0d91..10c7dbf 100644 --- a/src/wireviz/wv_cli.py +++ b/src/wireviz/wv_cli.py @@ -12,21 +12,24 @@ if __name__ == "__main__": import wireviz.wireviz as wv from wireviz import APP_NAME, __version__ -from wireviz.wv_helper import file_read_text +from wireviz.wv_utils import file_read_text format_codes = { - # "c": "csv", + # "c": "csv", # TODO: support CSV "g": "gv", "h": "html", "p": "png", - # "P": "pdf", + # "P": "pdf", # TODO: support PDF "s": "svg", "t": "tsv", } -epilog = "The -f or --format option accepts a string containing one or more of the " -epilog += "following characters to specify which file types to output:\n" -epilog += ", ".join([f"{key} ({value.upper()})" for key, value in format_codes.items()]) + +epilog = ( + "The -f or --format option accepts a string containing one or more of the " + "following characters to specify which file types to output:\n" + + f", ".join([f"{key} ({value.upper()})" for key, value in format_codes.items()]) +) @click.command( @@ -70,7 +73,10 @@ epilog += ", ".join([f"{key} ({value.upper()})" for key, value in format_codes.i "--output-name", default=None, type=str, - help="File name (without extension) to use for output files, if different from input file name.", + help=( + "File name (without extension) to use for output files, " + "if different from input file name." + ), ) @click.option( "-V", @@ -83,7 +89,7 @@ def wireviz(file, format, prepend, include_path, output_dir, output_name, versio """ Parses the provided FILE and generates the specified outputs. """ - print() + print() # blank line before execution print(f"{APP_NAME} {__version__}") if version: return # print version number only and exit @@ -117,6 +123,8 @@ def wireviz(file, format, prepend, include_path, output_dir, output_name, versio prepend_file = Path(prepend_file) if not prepend_file.exists(): raise Exception(f"File does not exist:\n{prepend_file}") + if not prepend_file.is_file(): + raise Exception(f"Path is not a file:\n{prepend_file}") print("Prepend file:", prepend_file) prepend_input += file_read_text(prepend_file) + "\n" @@ -137,6 +145,8 @@ def wireviz(file, format, prepend, include_path, output_dir, output_name, versio file = Path(file) if not file.exists(): raise Exception(f"File does not exist:\n{file}") + if not file.is_file(): + raise Exception(f"Path is not a file:\n{file}") # file_out = file.with_suffix("") if not output_file else output_file _output_dir = file.parent if not output_dir else output_dir @@ -167,7 +177,7 @@ def wireviz(file, format, prepend, include_path, output_dir, output_name, versio image_paths=list(image_paths), ) - print() + print() # blank line after execution if __name__ == "__main__": diff --git a/src/wireviz/wv_colors.py b/src/wireviz/wv_colors.py index 62957f9..f7247b7 100644 --- a/src/wireviz/wv_colors.py +++ b/src/wireviz/wv_colors.py @@ -1,6 +1,205 @@ # -*- coding: utf-8 -*- -from typing import Dict, List +from collections import namedtuple +from dataclasses import dataclass, field +from enum import Enum +from typing import List + +padding_amount = 1 + +ColorOutputMode = Enum( + "ColorOutputMode", "EN_LOWER EN_UPPER DE_LOWER DE_UPPER HTML_LOWER HTML_UPPER" +) + +color_output_mode = ColorOutputMode.EN_UPPER + +KnownColor = namedtuple("KnownColor", "html code_de full_en full_de") + +known_colors = { # v--------v--------- for future use + "BK": KnownColor("#000000", "sw", "black", "schwarz"), + "WH": KnownColor("#ffffff", "ws", "white", "weiß"), + "GY": KnownColor("#999999", "gr", "grey", "grau"), + "PK": KnownColor("#ff66cc", "rs", "pink", "rosa"), + "RD": KnownColor("#ff0000", "rt", "red", "rot"), + "OG": KnownColor("#ff8000", "or", "orange", "orange"), + "YE": KnownColor("#ffff00", "ge", "yellow", "gelb"), + "OL": KnownColor("#708000", "ol", "olive green", "olivgrün"), + "GN": KnownColor("#00aa00", "gn", "green", "grün"), + "TQ": KnownColor("#00ffff", "tk", "turquoise", "türkis"), + "LB": KnownColor("#a0dfff", "hb", "light blue", "hellblau"), + "BU": KnownColor("#0066ff", "bl", "blue", "blau"), + "VT": KnownColor("#8000ff", "vi", "violet", "violett"), + "BN": KnownColor("#895956", "br", "brown", "braun"), + "BG": KnownColor("#ceb673", "bg", "beige", "beige"), + "IV": KnownColor("#f5f0d0", "eb", "ivory", "elfenbein"), + "SL": KnownColor("#708090", "si", "slate", "schiefer"), + "CU": KnownColor("#d6775e", "ku", "copper", "Kupfer"), + "SN": KnownColor("#aaaaaa", "vz", "tin", "verzinkt"), + "SR": KnownColor("#84878c", "ag", "silver", "Silber"), + "GD": KnownColor("#ffcf80", "au", "gold", "Gold"), +} + + +def convert_case(inp): + if "_LOWER" in color_output_mode.name: + return inp.lower() + elif "_UPPER" in color_output_mode.name: + return inp.upper() + else: # currently not used + return inp + + +def get_color_by_colorcode_index(color_code: str, index: int) -> str: + num_colors_in_code = len(COLOR_CODES[color_code]) + actual_index = index % num_colors_in_code # wrap around if index is out of bounds + return COLOR_CODES[color_code][actual_index] + + +@dataclass +class SingleColor: + _code_en: str + _html: str + + @property + def code_en(self): + return convert_case(self._code_en) if self._code_en else None + + @property + def code_de(self): + return ( + convert_case(known_colors[self._code_en.upper()].code_de) + if self._code_en + else None + ) + + @property + def html(self): + return convert_case(self._html) if self._code_en else None + + @property + def known(self): + # treat None as a known color + return self.code_en.upper() in known_colors.keys() if self._code_en else True + + def __init__(self, inp): + if inp is None: + self._html = None + self._code_en = None + elif isinstance(inp, int): + hex_str = f"#{inp:06x}" + self._html = hex_str + self._code_en = hex_str # do not perform reverse lookup - why not? + elif not isinstance(inp, str): + raise Exception(f"Unknown single color {inp}!") + else: + inp_upper = inp.upper() + if inp_upper in known_colors.keys(): + self._code_en = inp_upper + self._html = known_colors[inp_upper].html + else: + try: # Maybe inp is an int as string? + inp = f"#{int(inp, 0):06x}" + except ValueError: + pass # assume it's a valid HTML color name + self._html = inp + self._code_en = inp + + @property + def html_padded(self): + return ":".join([self.html] * padding_amount) + + def __bool__(self): + return self._code_en is not None + + def __str__(self): + if self._html is None: + return "" + elif self.known and "EN_" in color_output_mode.name: + return self.code_en + elif self.known and "DE_" in color_output_mode.name: + return self.code_de + else: + return self.html + + +@dataclass +class MultiColor: + colors: List[SingleColor] = field(default_factory=list) + + def __init__(self, inp): + self.colors = [] + if inp is None: + pass + elif isinstance(inp, List): # input is already a list + for item in inp: + if item is None: + pass + elif isinstance(item, SingleColor): + self.colors.append(item) + else: # string or integer (type check done inside) + self.colors.append(SingleColor(item)) + elif isinstance(inp, SingleColor): # single color + self.colors = [inp] + elif isinstance(inp, int): + self.colors = [SingleColor(inp)] + elif not isinstance(inp, str): + raise Exception(f"Unknown multi-color {inp}!") + elif ":" in inp: # split input into list + self.colors = [SingleColor(item) for item in inp.split(":")] + else: + if len(inp) % 2 == 0: + items = [inp[i : i + 2] for i in range(0, len(inp), 2)] + known = [item.upper() in known_colors.keys() for item in items] + if all(known): + self.colors = [SingleColor(item) for item in items] + return + # assume it's a valid HTML color name + self.colors = [SingleColor(inp)] + + def __len__(self): + return len(self.colors) + + def __bool__(self): + return len(self.colors) >= 1 + + def __str__(self): + if "EN_" in color_output_mode.name or "DE_" in color_output_mode.name: + joiner = "" if self.all_known else ":" + elif "HTML_" in color_output_mode.name: + joiner = ":" + else: + joiner = "???" + return joiner.join([str(color) for color in self.colors]) + + @property + def all_known(self): + return all([color.known for color in self.colors]) + + @property + def html(self): + return ":".join([color.html for color in self.colors]) + + @property + def html_padded_list(self): + # padding only properly works for padding_amount 1 or 3 + if padding_amount == 1: + out = [color.html for color in self.colors] + elif len(self) == 0: + out = [] + elif len(self) == 1: + out = [self.colors[0].html for i in range(3)] + elif len(self) == 2: + out = [self.colors[0].html, self.colors[1].html, self.colors[0].html] + elif len(self) == 3: + out = [color.html for color in self.colors] + else: + raise Exception(f"Padding not supported for len {len(self)}") + return [str(color) for color in out] + + @property + def html_padded(self): + return ":".join(self.html_padded_list) + COLOR_CODES = { # fmt: off @@ -38,164 +237,3 @@ COLOR_CODES = { "T568A": ["WHGN", "GN", "WHOG", "BU", "WHBU", "OG", "WHBN", "BN"], "T568B": ["WHOG", "OG", "WHGN", "BU", "WHBU", "GN", "WHBN", "BN"], } - -# Convention: Color names should be 2 letters long, to allow for multicolored wires - -_color_hex = { - "BK": "#000000", - "WH": "#ffffff", - "GY": "#999999", - "PK": "#ff66cc", - "RD": "#ff0000", - "OG": "#ff8000", - "YE": "#ffff00", - "OL": "#708000", # olive green - "GN": "#00ff00", - "TQ": "#00ffff", - "LB": "#a0dfff", # light blue - "BU": "#0066ff", - "VT": "#8000ff", - "BN": "#895956", - "BG": "#ceb673", # beige - "IV": "#f5f0d0", # ivory - "SL": "#708090", - "CU": "#d6775e", # Faux-copper look, for bare CU wire - "SN": "#aaaaaa", # Silvery look for tinned bare wire - "SR": "#84878c", # Darker silver for silvered wire - "GD": "#ffcf80", # Golden color for gold -} - -_color_full = { - "BK": "black", - "WH": "white", - "GY": "grey", - "PK": "pink", - "RD": "red", - "OG": "orange", - "YE": "yellow", - "OL": "olive green", - "GN": "green", - "TQ": "turquoise", - "LB": "light blue", - "BU": "blue", - "VT": "violet", - "BN": "brown", - "BG": "beige", - "IV": "ivory", - "SL": "slate", - "CU": "copper", - "SN": "tin", - "SR": "silver", - "GD": "gold", -} - -_color_ger = { - "BK": "sw", - "WH": "ws", - "GY": "gr", - "PK": "rs", - "RD": "rt", - "OG": "or", - "YE": "ge", - "OL": "ol", # olivgrün - "GN": "gn", - "TQ": "tk", - "LB": "hb", # hellblau - "BU": "bl", - "VT": "vi", - "BN": "br", - "BG": "bg", # beige - "IV": "eb", # elfenbeinfarben - "SL": "si", # Schiefer - "CU": "ku", # Kupfer - "SN": "vz", # verzinkt - "SR": "ag", # Silber - "GD": "au", # Gold -} - - -color_default = "#ffffff" - -_hex_digits = set("0123456789abcdefABCDEF") - - -# Literal type aliases below are commented to avoid requiring python 3.8 -Color = str # Two-letter color name = Literal[_color_hex.keys()] -Colors = str # One or more two-letter color names (Color) concatenated into one string -ColorMode = ( - str # = Literal['full', 'FULL', 'hex', 'HEX', 'short', 'SHORT', 'ger', 'GER'] -) -ColorScheme = str # Color scheme name = Literal[COLOR_CODES.keys()] - - -def get_color_hex(input: Colors, pad: bool = False) -> List[str]: - """Return list of hex colors from either a string of color names or :-separated hex colors.""" - if input is None or input == "": - return [color_default] - elif input[0] == "#": # Hex color(s) - output = input.split(":") - for i, c in enumerate(output): - if c[0] != "#" or not all(d in _hex_digits for d in c[1:]): - if c != input: - c += f" in input: {input}" - print(f"Invalid hex color: {c}") - output[i] = color_default - else: # Color name(s) - - def lookup(c: str) -> str: - try: - return _color_hex[c] - except KeyError: - if c != input: - c += f" in input: {input}" - print(f"Unknown color name: {c}") - return color_default - - output = [lookup(input[i : i + 2]) for i in range(0, len(input), 2)] - - if len(output) == 2: # Give wires with EXACTLY 2 colors that striped look. - output += output[:1] - elif pad and len(output) == 1: # Hacky style fix: Give single color wires - output *= 3 # a triple-up so that wires are the same size - - return output - - -def get_color_translation(translate: Dict[Color, str], input: Colors) -> List[str]: - """Return list of colors translations from either a string of color names or :-separated hex colors.""" - - def from_hex(hex_input: str) -> str: - for color, hex in _color_hex.items(): - if hex == hex_input: - return translate[color] - return f'({",".join(str(int(hex_input[i:i+2], 16)) for i in range(1, 6, 2))})' - - return ( - [from_hex(h) for h in input.lower().split(":")] - if input[0] == "#" - else [translate.get(input[i : i + 2], "??") for i in range(0, len(input), 2)] - ) - - -def translate_color(input: Colors, color_mode: ColorMode) -> str: - if input == "" or input is None: - return "" - upper = color_mode.isupper() - if not (color_mode.isupper() or color_mode.islower()): - raise Exception("Unknown color mode capitalization") - - color_mode = color_mode.lower() - if color_mode == "full": - output = "/".join(get_color_translation(_color_full, input)) - elif color_mode == "hex": - output = ":".join(get_color_hex(input, pad=False)) - elif color_mode == "ger": - output = "".join(get_color_translation(_color_ger, input)) - elif color_mode == "short": - output = input - else: - raise Exception("Unknown color mode") - if upper: - return output.upper() - else: - return output.lower() diff --git a/src/wireviz/wv_dataclasses.py b/src/wireviz/wv_dataclasses.py new file mode 100644 index 0000000..1009ade --- /dev/null +++ b/src/wireviz/wv_dataclasses.py @@ -0,0 +1,872 @@ +# -*- coding: utf-8 -*- + +from collections import namedtuple +from dataclasses import dataclass, field, asdict +from enum import Enum +from itertools import zip_longest +from typing import Any, Dict, List, Optional, Tuple, Union + +from wireviz.wv_bom import ( + BomHash, + BomHashList, + PartNumberInfo, + QtyMultiplierCable, + QtyMultiplierConnector, +) +from wireviz.wv_colors import ( + COLOR_CODES, + ColorOutputMode, + MultiColor, + SingleColor, + get_color_by_colorcode_index, +) +from wireviz.wv_utils import ( + NumberAndUnit, + aspect_ratio, + awg_equiv, + mm2_equiv, + parse_number_and_unit, + remove_links, +) + +# Each type alias have their legal values described in comments +# - validation might be implemented in the future +PlainText = str # Text not containing HTML tags nor newlines +Hypertext = str # Text possibly including HTML hyperlinks that are removed in all outputs except HTML output +MultilineHypertext = ( + str # Hypertext possibly also including newlines to break lines in diagram output +) + +Designator = PlainText # Case insensitive unique name of connector or cable + +# Literal type aliases below are commented to avoid requiring python 3.8 +ImageScale = PlainText # = Literal['false', 'true', 'width', 'height', 'both'] + +# Type combinations +Pin = Union[int, PlainText] # Pin identifier +PinIndex = int # Zero-based pin index +Wire = Union[int, PlainText] # Wire number or Literal['s'] for shield +NoneOrMorePins = Union[ + Pin, Tuple[Pin, ...], None +] # None, one, or a tuple of pin identifiers +NoneOrMorePinIndices = Union[ + PinIndex, Tuple[PinIndex, ...], None +] # None, one, or a tuple of zero-based pin indices +OneOrMoreWires = Union[Wire, Tuple[Wire, ...]] # One or a tuple of wires + +# Metadata can contain whatever is needed by the HTML generation/template. +MetadataKeys = PlainText # Literal['title', 'description', 'notes', ...] + + +Side = Enum("Side", "LEFT RIGHT") +ArrowDirection = Enum("ArrowDirection", "NONE BACK FORWARD BOTH") +ArrowWeight = Enum("ArrowWeight", "SINGLE DOUBLE") + +AUTOGENERATED_PREFIX = "AUTOGENERATED_" + + +@dataclass +class Arrow: + direction: ArrowDirection + weight: ArrowWeight + + +class Metadata(dict): + pass + + +@dataclass +class Options: + fontname: PlainText = "arial" + bgcolor: SingleColor = "WH" # will be converted to SingleColor in __post_init__ + bgcolor_node: SingleColor = "WH" + bgcolor_connector: SingleColor = None + bgcolor_cable: SingleColor = None + bgcolor_bundle: SingleColor = None + color_output_mode: ColorOutputMode = ColorOutputMode.EN_UPPER + mini_bom_mode: bool = True + template_separator: str = "." + _pad: int = 0 + # TODO: resolve template and image paths during rendering, not during YAML parsing + _template_paths: List = field(default_factory=list) + _image_paths: List = field(default_factory=list) + + def __post_init__(self): + self.bgcolor = SingleColor(self.bgcolor) + self.bgcolor_node = SingleColor(self.bgcolor_node) + self.bgcolor_connector = SingleColor(self.bgcolor_connector) + self.bgcolor_cable = SingleColor(self.bgcolor_cable) + self.bgcolor_bundle = SingleColor(self.bgcolor_bundle) + + if not self.bgcolor_node: + self.bgcolor_node = self.bgcolor + if not self.bgcolor_connector: + self.bgcolor_connector = self.bgcolor_node + if not self.bgcolor_cable: + self.bgcolor_cable = self.bgcolor_node + if not self.bgcolor_bundle: + self.bgcolor_bundle = self.bgcolor_cable + + +@dataclass +class Tweak: + override: Optional[Dict[Designator, Dict[str, Optional[str]]]] = None + append: Union[str, List[str], None] = None + + +@dataclass +class Image: + # Attributes of the image object : + src: str + scale: Optional[ImageScale] = None + # Attributes of the image cell containing the image: + width: Optional[int] = None + height: Optional[int] = None + fixedsize: Optional[bool] = None + bgcolor: SingleColor = None + # Contents of the text cell just below the image cell: + caption: Optional[MultilineHypertext] = None + # See also HTML doc at https://graphviz.org/doc/info/shapes.html#html + + def __post_init__(self): + self.bgcolor = SingleColor(self.bgcolor) + + if self.fixedsize is None: + # Default True if any dimension specified unless self.scale also is specified. + self.fixedsize = (self.width or self.height) and self.scale is None + + if self.scale is None: + if not self.width and not self.height: + self.scale = "false" + elif self.width and self.height: + self.scale = "both" + else: + self.scale = "true" # When only one dimension is specified. + + if self.fixedsize: + # If only one dimension is specified, compute the other + # because Graphviz requires both when fixedsize=True. + if self.height: + if not self.width: + self.width = self.height * aspect_ratio(self.src) + else: + if self.width: + self.height = self.width / aspect_ratio(self.src) + + +@dataclass +class PinClass: + index: int + id: str + label: str + color: MultiColor + parent: str # designator of parent connector + _num_connections = 0 # incremented in Connector.connect() + _anonymous: bool = False # true for pins on autogenerated connectors + _simple: bool = False # true for simple connector + + def __str__(self): + snippets = [ # use str() for each in case they are int or other non-str + str(self.parent) if not self._anonymous else "", + str(self.id) if not self._anonymous and not self._simple else "", + str(self.label) if self.label else "", + ] + return ":".join([snip for snip in snippets if snip != ""]) + + +@dataclass +class Component: + category: Optional[str] = None # currently only used by cables, to define bundles + type: Union[MultilineHypertext, List[MultilineHypertext]] = None + subtype: Union[MultilineHypertext, List[MultilineHypertext]] = None + + # part number + partnumbers: PartNumberInfo = None # filled by __post_init__() + # the following are provided for user convenience and should not be accessed later. + # their contents are loaded into partnumbers during the child class __post_init__() + pn: str = None + manufacturer: str = None + mpn: str = None + supplier: str = None + spn: str = None + # BOM info + qty: Optional[Union[None, int, float]] = None + amount: Optional[NumberAndUnit] = None + sum_amounts_in_bom: bool = True + ignore_in_bom: bool = False + bom_id: Optional[str] = None # to be filled after harness is built + + def __post_init__(self): + partnos = [self.pn, self.manufacturer, self.mpn, self.supplier, self.spn] + partnos = [remove_links(entry) for entry in partnos] + partnos = tuple(partnos) + self.partnumbers = PartNumberInfo(*partnos) + self.amount = parse_number_and_unit(self.amount, None) + + @property + def bom_hash(self) -> BomHash: + if isinstance(self, AdditionalComponent): + _amount = self.amount_computed + else: + _amount = self.amount + + if self.sum_amounts_in_bom: + _hash = BomHash( + description=self.description, + qty_unit=_amount.unit if _amount else None, + amount=None, + partnumbers=self.partnumbers, + ) + else: + _hash = BomHash( + description=self.description, + qty_unit=None, + amount=_amount, + partnumbers=self.partnumbers, + ) + return _hash + + @property + def has_pn_info(self) -> bool: + return any([self.pn, self.manufacturer, self.mpn, self.supplier, self.spn]) + + @property + def description(self) -> str: + return f"{self.type}{', ' + self.subtype if self.subtype else ''}" + + +@dataclass +class AdditionalBomItem(Component): + designators: Optional[str] = None + + @property + def additional_components(self): + # An additional item may not have further nested additional comonents. + # This property is currently needed for objects in the same list as + # TopLevelGraphicalComponent objects in a Harness method. + return [] + + +@dataclass +class GraphicalComponent(Component): # abstract class + bgcolor: Optional[SingleColor] = None + + def __post_init__(self): + super().__post_init__() + self.bgcolor = SingleColor(self.bgcolor) + + +@dataclass +class AdditionalComponent(GraphicalComponent): + qty_multiplier: Union[QtyMultiplierConnector, QtyMultiplierCable, int] = 1 + qty_computed: Optional[int] = None + explicit_qty: bool = True + amount_computed: Optional[NumberAndUnit] = None + note: str = None + color: Optional[MultiColor] = None + references: Optional[List[str]] = field(default_factory=list) + + def __post_init__(self): + super().__post_init__() + + self.color = MultiColor(self.color) + + if isinstance(self.qty_multiplier, float) or isinstance( + self.qty_multiplier, int + ): + pass + else: + self.qty_multiplier = self.qty_multiplier.upper() + if self.qty_multiplier in QtyMultiplierConnector.__members__.keys(): + self.qty_multiplier = QtyMultiplierConnector[self.qty_multiplier] + elif self.qty_multiplier in QtyMultiplierCable.__members__.keys(): + self.qty_multiplier = QtyMultiplierCable[self.qty_multiplier] + else: + raise Exception(f"Unknown qty multiplier: {self.qty_multiplier}") + + if self.qty is None and self.qty_multiplier in [ + QtyMultiplierCable.TOTAL_LENGTH, + QtyMultiplierCable.LENGTH, + 1, + ]: # simplify add.comp. table in parent node for implicit qty 1 + self.qty = 1 + self.explicit_qty = False + + +@dataclass +class TopLevelGraphicalComponent(GraphicalComponent): # abstract class + # component properties + designator: Designator = None + color: Optional[MultiColor] = None + image: Optional[Image] = None + additional_parameters: Optional[Dict] = None + additional_components: List[AdditionalComponent] = field(default_factory=list) + notes: Optional[MultilineHypertext] = None + # rendering options + bgcolor_title: Optional[SingleColor] = None + show_name: Optional[bool] = None + + +@dataclass +class Connector(TopLevelGraphicalComponent): + # connector-specific properties + style: Optional[str] = None + # TODO: Move shorts and loops to PinClass + loops: Union[Dict[str, List[int]], List[List[int]]] = field(default_factory=dict) + shorts: Union[Dict[str, List[int]], List[List[int]]] = field(default_factory=dict) + shorts_hide_lable: bool = False + # pin information in particular + pincount: Optional[int] = None + pins: List[Pin] = field(default_factory=list) # legacy + pinlabels: List[Pin] = field(default_factory=list) # legacy + pincolors: List[str] = field(default_factory=list) # legacy + pin_objects: Dict[Any, PinClass] = field(default_factory=dict) # new + # rendering option + show_pincount: Optional[bool] = None + hide_disconnected_pins: bool = False + + @property + def is_autogenerated(self): + return self.designator.startswith(AUTOGENERATED_PREFIX) + + @property + def description(self) -> str: + substrs = [ + "Connector", + self.type, + self.subtype, + f"{self.pincount} pins" if self.show_pincount else None, + str(self.color) if self.color else None, + ] + return ", ".join([str(s) for s in substrs if s is not None and s != ""]) + + def should_show_pin(self, pin_id): + return ( + not self.hide_disconnected_pins + or self.pin_objects[pin_id]._num_connections > 0 + ) + + @property + def unit(self): # for compatibility with BOM hashing + return None # connectors do not support units. + + def __post_init__(self) -> None: + super().__post_init__() + + self.bgcolor_title = SingleColor(self.bgcolor_title) + self.color = MultiColor(self.color) + + # connectors do not support custom qty or amount + if self.qty is None: + self.qty = 1 + if self.qty != 1: + raise Exception("Connector qty != 1 not supported") + if self.amount is not None: + raise Exception("Connector amount not supported") + + if isinstance(self.image, dict): + self.image = Image(**self.image) + + self.ports_left = False + self.ports_right = False + self.visible_pins = {} + + if self.style == "simple": + if self.pincount and self.pincount > 1: + raise Exception( + "Connectors with style set to simple may only have one pin" + ) + self.pincount = 1 + + if not self.pincount: + self.pincount = max( + len(self.pins), len(self.pinlabels), len(self.pincolors) + ) + if not self.pincount: + raise Exception( + "You need to specify at least one: " + "pincount, pins, pinlabels, or pincolors" + ) + + # create default list for pins (sequential) if not specified + if not self.pins: + self.pins = list(range(1, self.pincount + 1)) + + if len(self.pins) != len(set(self.pins)): + raise Exception("Pins are not unique") + + # all checks have passed + pin_tuples = zip_longest( + self.pins, + self.pinlabels, + self.pincolors, + ) + for pin_index, (pin_id, pin_label, pin_color) in enumerate(pin_tuples): + self.pin_objects[pin_id] = PinClass( + index=pin_index, + id=pin_id, + label=pin_label, + color=MultiColor(pin_color), + parent=self.designator, + _anonymous=self.is_autogenerated, + _simple=self.style == "simple", + ) + + if self.show_name is None: + self.show_name = self.style != "simple" and not self.is_autogenerated + + if self.show_pincount is None: + # hide pincount for simple (1 pin) connectors by default + self.show_pincount = self.style != "simple" + + # Convert short List to Short Dict + if type(self.shorts) == list: + self.shorts_hide_lable = True + shDict = dict() + for shIndex in range(0, len(self.shorts)): + key = "AutoSH" + str(shIndex) + shDict[key] = self.shorts[shIndex] + self.shorts = shDict + + # Convert loop List to loop Dict + if type(self.loops) == list: + loDict = dict() + for loIndex in range(0, len(self.loops)): + key = "AutoLO" + str(loIndex) + loDict[key] = self.loops[loIndex] + self.loops = loDict + + # TODO: allow using pin labels in addition to pin numbers, + # just like when defining regular connections + # TODO: include properties of wire used to create the loop + for loopName in self.loops: + for pin in self.loops[loopName]: + if pin not in self.pins: + raise Exception( + f'Unknown loop pin "{pin}" for connector "{self.designator}"!' + ) + # Make sure loop connected pins are not hidden. + self.activate_pin(pin, None) + for short in self.shorts: + for pin in self.shorts[short]: + if pin not in self.pins: + raise Exception( + f'Unknown loop pin "{pin}" for connector "{self.designator}"!' + ) + # Make sure loop connected pins are not hidden. + self.activate_pin(pin, None) + + # TODO: Remove the outcommented code here if it is no longer needed as reference + # for loop in self.loops: + # # TODO: allow using pin labels in addition to pin numbers, + # # just like when defining regular connections + # # TODO: include properties of wire used to create the loop + # if len(loop) != 2: + # raise Exception("Loops must be between exactly two pins!") + # for pin in loop: + # if pin not in self.pins: + # raise Exception( + # f'Unknown loop pin "{pin}" for connector "{self.name}"!' + # ) + # # Make sure loop connected pins are not hidden. + # # side=None, determine side to show loops during rendering + # self.activate_pin(pin, side=None, is_connection=True) + + for i, item in enumerate(self.additional_components): + if isinstance(item, dict): + self.additional_components[i] = AdditionalComponent(**item) + + def activate_pin(self, pin_id, side: Side = None, is_connection=True) -> None: + if is_connection: + self.pin_objects[pin_id]._num_connections += 1 + if side == Side.LEFT: + self.ports_left = True + elif side == Side.RIGHT: + self.ports_right = True + + def compute_qty_multipliers(self): + # do not run before all connections in harness have been made! + num_populated_pins = len( + [pin for pin in self.pin_objects.values() if pin._num_connections > 0] + ) + num_connections = sum( + [pin._num_connections for pin in self.pin_objects.values()] + ) + qty_multipliers_computed = { + "PINCOUNT": self.pincount, + "POPULATED": num_populated_pins, + "UNPOPULATED": max(0, self.pincount - num_populated_pins), + "CONNECTIONS": num_connections, + } + for subitem in self.additional_components: + if isinstance(subitem.qty_multiplier, QtyMultiplierConnector): + computed_factor = qty_multipliers_computed[subitem.qty_multiplier.name] + elif isinstance(subitem.qty_multiplier, QtyMultiplierCable): + raise Exception("Used a cable multiplier in a connector!") + else: # int or float + computed_factor = subitem.qty_multiplier + + if subitem.qty is not None: + subitem.qty_computed = subitem.qty * computed_factor + else: + subitem.qty_computed = computed_factor + subitem.amount_computed = subitem.amount + + +@dataclass +class WireClass: + parent: str # designator of parent cable/bundle + # wire-specific properties + index: int + id: str + label: str + color: MultiColor + # ... + bom_id: Optional[str] = None # to be filled after harness is built + # inheritable from parent cable + type: Union[MultilineHypertext, List[MultilineHypertext]] = None + subtype: Union[MultilineHypertext, List[MultilineHypertext]] = None + gauge: Optional[NumberAndUnit] = None + length: Optional[NumberAndUnit] = None + ignore_in_bom: Optional[bool] = False + sum_amounts_in_bom: bool = True + partnumbers: PartNumberInfo = None + + @property + def bom_hash(self) -> BomHash: + if self.sum_amounts_in_bom: + _hash = BomHash( + description=self.description, + qty_unit=self.length.unit if self.length else None, + amount=None, + partnumbers=self.partnumbers, + ) + else: + _hash = BomHash( + description=self.description, + qty_unit=None, + amount=self.length, + partnumbers=self.partnumbers, + ) + return _hash + + @property + def gauge_str(self): + if not self.gauge: + return None + actual_gauge = f"{self.gauge.number} {self.gauge.unit}" + actual_gauge = actual_gauge.replace("mm2", "mm\u00B2") + return actual_gauge + + @property + def description(self) -> str: + substrs = [ + "Wire", + self.type, + self.subtype, + self.gauge_str, + str(self.color) if self.color else None, + ] + desc = ", ".join([s for s in substrs if s is not None and s != ""]) + return desc + + +@dataclass +class ShieldClass(WireClass): + pass # TODO, for wires with multiple shields more shield details, ... + + +@dataclass +class Connection: + from_: PinClass = None + via: Union[WireClass, ShieldClass] = None + to: PinClass = None + + +@dataclass +class Cable(TopLevelGraphicalComponent): + # cable-specific properties + gauge: Optional[NumberAndUnit] = None + length: Optional[NumberAndUnit] = None + color_code: Optional[str] = None + # wire information in particular + wirecount: Optional[int] = None + shield: Union[bool, MultiColor] = False + colors: List[str] = field(default_factory=list) # legacy + wirelabels: List[Wire] = field(default_factory=list) # legacy + wire_objects: Dict[Any, WireClass] = field(default_factory=dict) # new + # internal + _connections: List[Connection] = field(default_factory=list) + # rendering options + show_name: Optional[bool] = None + show_equiv: bool = False + show_wirecount: bool = True + show_wirenumbers: Optional[bool] = None + + @property + def is_autogenerated(self): + return self.designator.startswith(AUTOGENERATED_PREFIX) + + @property + def unit(self): # for compatibility with parent class + return self.length + + @property + def gauge_str(self): + if not self.gauge: + return None + actual_gauge = f"{self.gauge.number} {self.gauge.unit}" + actual_gauge = actual_gauge.replace("mm2", "mm\u00B2") + return actual_gauge + + @property + def gauge_str_with_equiv(self): + if not self.gauge: + return None + actual_gauge = self.gauge_str + equivalent_gauge = "" + if self.show_equiv: + # convert unit if known + if self.gauge.unit == "mm2": + equivalent_gauge = f" ({awg_equiv(self.gauge.number)} AWG)" + elif self.gauge.unit.upper() == "AWG": + equivalent_gauge = f" ({mm2_equiv(self.gauge.number)} mm2)" + out = f"{actual_gauge}{equivalent_gauge}" + out = out.replace("mm2", "mm\u00B2") + return out + + @property + def length_str(self): + if not self.length: + return None + out = f"{self.length.number} {self.length.unit}" + return out + + @property + def bom_hash(self): + if self.category == "bundle": + # This line should never be reached, since caller checks + # whether item is a bundle and if so, calls bom_hash + # for each individual wire instead + raise Exception("Do this at the wire level!") + else: + return super().bom_hash + + @property + def description(self) -> str: + if self.category == "bundle": + raise Exception("Do this at the wire level!") + else: + substrs = [ + ("", "Cable"), + (", ", self.type), + (", ", self.subtype), + (", ", self.wirecount), + (" ", f"x {self.gauge_str}" if self.gauge else "wires"), + (" ", "shielded" if self.shield else None), + (", ", str(self.color) if self.color else None), + ] + desc = "".join( + [f"{s[0]}{s[1]}" for s in substrs if s[1] is not None and s[1] != ""] + ) + return desc + + def _get_wire_partnumber(self, idx) -> PartNumberInfo: + def _get_correct_element(inp, idx): + return inp[idx] if isinstance(inp, List) else inp + + # TODO: possibly make more robust/elegant + if self.category == "bundle": + return PartNumberInfo( + _get_correct_element(self.partnumbers.pn, idx), + _get_correct_element(self.partnumbers.manufacturer, idx), + _get_correct_element(self.partnumbers.mpn, idx), + _get_correct_element(self.partnumbers.supplier, idx), + _get_correct_element(self.partnumbers.spn, idx), + ) + else: + return None # non-bundles do not support lists of part data + + def __post_init__(self) -> None: + super().__post_init__() + + self.bgcolor_title = SingleColor(self.bgcolor_title) + self.color = MultiColor(self.color) + + # cables do not support custom qty or amount + if self.qty is None: + self.qty = 1 + if self.qty != 1: + raise Exception("Cable qty != 1 not supported") + + if isinstance(self.image, dict): + self.image = Image(**self.image) + + # TODO: + # allow gauge, length, and other fields to be lists too (like part numbers), + # and assign them the same way to bundles. + + self.gauge = parse_number_and_unit(self.gauge, "mm2") + self.length = parse_number_and_unit(self.length, "m") + self.amount = self.length # for BOM + + if self.wirecount: # number of wires explicitly defined + if self.colors: # use custom color palette (partly or looped if needed) + self.colors = [ + self.colors[i % len(self.colors)] for i in range(self.wirecount) + ] + elif self.color_code: + # use standard color palette (partly or looped if needed) + if self.color_code not in COLOR_CODES: + raise Exception("Unknown color code") + self.colors = [ + get_color_by_colorcode_index(self.color_code, i) + for i in range(self.wirecount) + ] + else: # no colors defined, add dummy colors + self.colors = [""] * self.wirecount + + else: # wirecount implicit in length of color list + if not self.colors: + raise Exception( + "Unknown number of wires. " + "Must specify wirecount or colors (implicit length)" + ) + self.wirecount = len(self.colors) + + if self.wirelabels: + if self.shield and "s" in self.wirelabels: + raise Exception( + '"s" may not be used as a wire label for a shielded cable.' + ) + + # if lists of part numbers are provided, + # check this is a bundle and that it matches the wirecount. + for idfield in [self.manufacturer, self.mpn, self.supplier, self.spn, self.pn]: + if isinstance(idfield, list): + if self.category == "bundle": + # check the length + if len(idfield) != self.wirecount: + raise Exception("lists of part data must match wirecount") + else: + raise Exception("lists of part data are only supported for bundles") + + # all checks have passed + wire_tuples = zip_longest( + # TODO: self.wire_ids + self.colors, + self.wirelabels, + ) + for wire_index, (wire_color, wire_label) in enumerate(wire_tuples): + id = wire_index + 1 + self.wire_objects[id] = WireClass( + parent=self.designator, + # wire-specific properties + index=wire_index, # TODO: wire_id + id=id, # TODO: wire_id + label=wire_label, + color=MultiColor(wire_color), + # inheritable from parent cable + type=self.type, + subtype=self.subtype, + gauge=self.gauge, + length=self.length, + sum_amounts_in_bom=self.sum_amounts_in_bom, + ignore_in_bom=self.ignore_in_bom, + partnumbers=self._get_wire_partnumber(wire_index), + ) + + if self.shield: + index_offset = len(self.wire_objects) + # TODO: add support for multiple shields + id = "s" + self.wire_objects[id] = ShieldClass( + index=index_offset, + id=id, + label="Shield", + color=( + MultiColor(self.shield) + if isinstance(self.shield, str) + else MultiColor(None) + ), + parent=self.designator, + ) + + if self.show_name is None: + self.show_name = not self.is_autogenerated + + if self.show_wirenumbers is None: + # by default, show wire numbers for cables, hide for bundles + self.show_wirenumbers = self.category != "bundle" + + for i, item in enumerate(self.additional_components): + if isinstance(item, dict): + self.additional_components[i] = AdditionalComponent(**item) + + def _connect( + self, + from_pin_obj: List[PinClass], + via_wire_id: str, + to_pin_obj: List[PinClass], + ) -> None: + via_wire_obj = self.wire_objects[via_wire_id] + self._connections.append(Connection(from_pin_obj, via_wire_obj, to_pin_obj)) + + def compute_qty_multipliers(self): + # do not run before all connections in harness have been made! + total_length = sum( + [ + wire.length.number if wire.length else 0 + for wire in self.wire_objects.values() + ] + ) + qty_multipliers_computed = { + "WIRECOUNT": len(self.wire_objects), + # "TERMINATIONS": ___, # TODO + "LENGTH": self.length.number if self.length else 0, + "TOTAL_LENGTH": total_length, + } + for subitem in self.additional_components: + if isinstance(subitem.qty_multiplier, QtyMultiplierCable): + computed_factor = qty_multipliers_computed[subitem.qty_multiplier.name] + if subitem.qty_multiplier.name in ["LENGTH", "TOTAL_LENGTH"]: + # since length can have a unit, use amount fields to hold + if subitem.amount is not None: + raise Exception( + f"No amount may be specified when using " + f"{subitem.qty_multiplier.name} as a multiplier." + ) + subitem.qty_computed = subitem.qty if subitem.qty else 1 + subitem.amount_computed = NumberAndUnit( + computed_factor, self.length.unit + ) + else: + # multiplier unrelated to length, therefore no unit + if subitem.qty is not None: + subitem.qty_computed = subitem.qty * computed_factor + else: + subitem.qty_computed = computed_factor + subitem.amount_computed = subitem.amount + + elif isinstance(subitem.qty_multiplier, QtyMultiplierConnector): + raise Exception("Used a connector multiplier in a cable!") + else: # int or float + if subitem.qty is not None: + subitem.qty_computed = subitem.qty * subitem.qty_multiplier + else: + subitem.qty_computed = subitem.qty_multiplier + subitem.amount_computed = subitem.amount + + +@dataclass +class MatePin: + from_: PinClass + to: PinClass + arrow: Arrow + + +@dataclass +class MateComponent: + from_: str # Designator + to: str # Designator + arrow: Arrow diff --git a/src/wireviz/wv_graphviz.py b/src/wireviz/wv_graphviz.py new file mode 100644 index 0000000..29ab520 --- /dev/null +++ b/src/wireviz/wv_graphviz.py @@ -0,0 +1,691 @@ +# -*- coding: utf-8 -*- + +import re +import warnings +from itertools import zip_longest +from typing import Any, List, Optional, Tuple, Union + +from wireviz import APP_NAME, APP_URL, __version__ +from wireviz.wv_bom import partnumbers2list +from wireviz.wv_colors import MultiColor +from wireviz.wv_dataclasses import ( + ArrowDirection, + ArrowWeight, + Cable, + Component, + Connector, + MateComponent, + MatePin, + Options, + PartNumberInfo, + ShieldClass, + WireClass, +) +from wireviz.wv_html import Img, Table, Td, Tr +from wireviz.wv_utils import html_line_breaks, remove_links, getAddCompFromRef + + +def gv_node_component(component: Component) -> Table: + # If no wires connected (except maybe loop wires)? + if isinstance(component, Connector): + if not (component.ports_left or component.ports_right): + component.ports_left = True # Use left side pins by default + + # generate all rows to be shown in the node + if component.show_name: + str_name = f"{remove_links(component.designator)}" + line_name = Td(str_name, bgcolor=component.bgcolor_title.html) + else: + line_name = None + + line_pn = partnumbers2list(component.partnumbers) + + is_simple_connector = ( + isinstance(component, Connector) and component.style == "simple" + ) + + if isinstance(component, Connector): + line_info = [ + bom_bubble(component.bom_id), + html_line_breaks(component.type), + html_line_breaks(component.subtype), + f"{component.pincount}-pin" if component.show_pincount else None, + str(component.color) if component.color else None, + ] + elif isinstance(component, Cable): + line_info = [ + bom_bubble(component.bom_id) if component.category != "bundle" else None, + html_line_breaks(component.type), + f"{component.wirecount}x" if component.show_wirecount else None, + component.gauge_str_with_equiv, + "+ S" if component.shield else None, + component.length_str, + str(component.color) if component.color else None, + ] + + if component.additional_parameters: + line_additional_parameters = nested_table_dict(component.additional_parameters) + else: + line_additional_parameters = [] + + if component.color: + line_info.extend(colorbar_cells(component.color)) + + line_image, line_image_caption = image_and_caption_cells(component) + line_additional_component_table = gv_additional_component_table(component) + line_notes = [Td(html_line_breaks(component.notes), balign="left")] + + if isinstance(component, Connector): + if component.style != "simple": + line_ports = gv_pin_table(component) + else: + line_ports = None + elif isinstance(component, Cable): + line_ports = gv_conductor_table(component) + + lines = [ + line_name, + line_pn, + line_info, + line_additional_parameters, + line_ports, + line_image, + line_image_caption, + line_additional_component_table, + line_notes, + ] + + tbl = nested_table(lines) + if is_simple_connector: + # Simple connectors have no pin table, and therefore, no ports to attach wires to. + # Manually assign left and right ports here if required. + # Use table itself for right port, and the first cell for left port. + # Even if the table only has one cell, two separate ports can still be assigned. + tbl.update_attribs(port="p1r") + first_cell_in_tbl = tbl.contents[0].contents + first_cell_in_tbl.update_attribs(port="p1l") + + return tbl + + +def gv_additional_component_table(component): + if not component.additional_components: + return None + + rows = [] + for subitem in component.additional_components: + if subitem.explicit_qty: + text_qty, unit_qty = subitem.qty_computed, "x" + if subitem.amount_computed is not None: + text_desc = f"{subitem.amount_computed.number} {subitem.amount_computed.unit} {subitem.description}" + else: + text_desc = f"{subitem.description}" + else: + if subitem.amount_computed is not None: + text_qty, unit_qty = ( + subitem.amount_computed.number, + subitem.amount_computed.unit, + ) + else: + text_qty, unit_qty = "1", "x" + text_desc = subitem.description + + firstline = [ + Td(bom_bubble(subitem.bom_id)), + Td(text_qty, align="right"), + Td(unit_qty, align="left"), + Td(text_desc, align="left"), + Td(f"{subitem.note if subitem.note else ''}", align="left"), + ] + rows.append(Tr(firstline)) + + if subitem.has_pn_info: + pn_list = partnumbers2list(subitem.partnumbers) + secondline = [ + Td("", colspan=3), + Td(", ".join(pn for pn in pn_list if pn), align="left"), + Td(""), + ] + rows.append(Tr(secondline)) + + return Table(rows, border=1, cellborder=0, cellpadding=3, cellspacing=0) + + +def calculate_node_bgcolor(component, harness_options): + # assign component node bgcolor at the GraphViz node level + # instead of at the HTML table level for better rendering of node outline + if component.bgcolor: + return component.bgcolor.html + elif isinstance(component, Connector) and harness_options.bgcolor_connector: + return harness_options.bgcolor_connector.html + elif ( + isinstance(component, Cable) + and component.category == "bundle" + and harness_options.bgcolor_bundle + ): + return harness_options.bgcolor_bundle.html + elif isinstance(component, Cable) and harness_options.bgcolor_cable: + return harness_options.bgcolor_cable.html + + +def bom_bubble(id) -> Table: + if id is None: + return None + else: + # TODO: activate BOM bubbles + return None + # size and style of BOM bubble is optimized to be a rounded square, + # big enough to hold any two-digit ID without GraphViz warnings + text = id + # text = f'{id}' + return Table( + Tr( + Td( + text, + border=1, + cellpadding=0, + fixedsize="true", + style="rounded", + height=20, + width=20, + # bgcolor="#000000", + ) + ), + border=0, + ) + + +def make_list_of_cells(inp) -> List[Td]: + # inp may be List, + if isinstance(inp, List): + # ensure all list items are Td + list_out = [item if isinstance(item, Td) else Td(item) for item in inp] + return list_out + else: + if inp is None: + return [] + if isinstance(inp, Td): + return [inp] + else: + return [Td(inp)] + + +def nested_table(lines: List[Td]) -> Table: + cell_lists = [make_list_of_cells(line) for line in lines] + rows = [] + + for lst in cell_lists: + if len(lst) == 0: + continue # no cells in list + cells = [item for item in lst if item.contents is not None] + if len(cells) == 0: + continue # no cells in list, or all cells are None + if ( + len(cells) == 1 + and isinstance(cells[0].contents, Table) + and not "!" in cells[0].contents.attribs.get("id", "") + ): + # cell content is already a table, no need to re-wrap it; + # unless explicitly asked to by a "!" in the ID field + # as used by image_and_caption_cells() + inner_table = cells[0].contents + else: + # nest cell content inside a table + inner_table = Table( + Tr(cells), border=0, cellborder=1, cellpadding=3, cellspacing=0 + ) + rows.append(Tr(Td(inner_table))) + + if len(rows) == 0: # create dummy row to avoid GraphViz errors due to empty + inner_table = Table( + Tr(Td("")), border=0, cellborder=1, cellpadding=3, cellspacing=0 + ) + rows = [Tr(Td(inner_table))] + tbl = Table(rows, border=0, cellspacing=0, cellpadding=0) + return tbl + + +def nested_table_dict(d: dict) -> Table: + rows = [] + for k, v in d.items(): + rows.append( + Tr( + [ + Td(k, align="left", balign="left", valign="top"), + Td(html_line_breaks(v), align="left", balign="left"), + ] + ) + ) + return Table(rows, border=0, cellborder=1, cellpadding=3, cellspacing=0) + + + +def gv_shorts_info_row(component) -> Tr: + shorts_info = [] + if component.ports_left: + shorts_info.append(Td(f"")) + if component.pinlabels: + shorts_info.append(Td(f"")) + + for short in component.shorts: + shorts_info.append(Td(f"{short}")) + + if component.ports_right: + shorts_info.append(Td(f"")) + return Tr(shorts_info) + + +def gv_pin_table(component) -> Table: + pin_rows = [] + + if len(component.shorts) > 0 and not component.shorts_hide_lable: + pin_rows.append(gv_shorts_info_row(component)) + + for pin in component.pin_objects.values(): + if component.should_show_pin(pin.id): + pin_rows.append(gv_pin_row(pin, component)) + if len(pin_rows) == 0: + # TODO: write test for empty pin tables, and for unconnected connectors that hide disconnected pins + pass + tbl = Table(pin_rows, border=0, cellborder=1, cellpadding=3, cellspacing=0) + return tbl + + +def gv_short_row_part(pin, connector) -> List: + short_row = [] # Td("ADA"), Td("DAD") + for short, shPins in connector.shorts.items(): + if pin.index + 1 in shPins: + short_row.append(Td("", port=f"p{pin.index+1}j")) + else: + short_row.append(Td("")) + return short_row if len(short_row) > 0 else None + + +def gv_pin_row(pin, connector) -> Tr: + # ports in GraphViz are 1-indexed for more natural maping to pin/wire numbers + has_pincolors = any([_pin.color for _pin in connector.pin_objects.values()]) + cells = [ + Td(pin.id, port=f"p{pin.index+1}l") if connector.ports_left else None, + Td(pin.label, delete_if_empty=True), + Td(str(pin.color) if pin.color else "", sides="TBL") if has_pincolors else None, + Td(color_minitable(pin.color), sides="TBR") if has_pincolors else None, + gv_short_row_part(pin, connector), + Td(pin.id, port=f"p{pin.index+1}r") if connector.ports_right else None, + ] + return Tr(cells) + + +def gv_connector_loops(connector: Connector) -> List: + loop_edges = [] + 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, loPins in connector.loops.items(): + comp = getAddCompFromRef(loop, connector) + loColor = "#000000" + if comp != None and comp.color != None: + loColor = comp.color.html + + for i in range(1, len(loPins)): + head = f"{connector.designator}:p{loPins[i - 1]}{loop_side}:{loop_dir}" + tail = f"{connector.designator}:p{loPins[i]}{loop_side}:{loop_dir}" + loop_edges.append((head, tail, loColor)) + return loop_edges + + +def gv_connector_shorts(connector: Connector) -> List: + short_edges = [] + + for short, shPins in connector.shorts.items(): + comp = getAddCompFromRef(short, connector) + shColor = "#FFFFFF:#000000:#FFFFFF" + if comp != None and comp.color != None: + shColor = f"#FFFFFF:{comp.color.html}:#FFFFFF" + + for i in range(1, len(shPins)): + head = f"{connector.designator}:p{shPins[i - 1]}j:c" + tail = f"{connector.designator}:p{shPins[i]}j:c" + short_edges.append((head, tail, shColor)) + return short_edges + + +def gv_conductor_table(cable) -> Table: + rows = [] + rows.append(Tr(Td(" "))) # spacer row on top + + inserted_break_inbetween = False + for wire in cable.wire_objects.values(): + # insert blank space between wires and shields + if isinstance(wire, ShieldClass) and not inserted_break_inbetween: + rows.append(Tr(Td(" "))) # spacer row between wires and shields + inserted_break_inbetween = True + + # row above the wire + wireinfo = [] + if cable.show_wirenumbers and not isinstance(wire, ShieldClass): + wireinfo.append(str(wire.id)) + wireinfo.append(str(wire.color)) + wireinfo.append(wire.label) + + ins, outs = [], [] + for conn in cable._connections: + if conn.via.id == wire.id: + if conn.from_ is not None: + ins.append(str(conn.from_)) + if conn.to is not None: + outs.append(str(conn.to)) + + cells_above = [ + Td(" " + ", ".join(ins), align="left"), + Td(" "), # increase cell spacing here + Td(bom_bubble(wire.bom_id)) if cable.category == "bundle" else None, + Td(":".join([wi for wi in wireinfo if wi is not None and wi != ""])), + Td(" "), # increase cell spacing here + Td(", ".join(outs) + " ", align="right"), + ] + cells_above = [cell for cell in cells_above if cell is not None] + rows.append(Tr(cells_above)) + + # the wire itself + rows.append(Tr(gv_wire_cell(wire, len(cells_above)))) + + # row below the wire + if wire.partnumbers: + cells_below = partnumbers2list( + wire.partnumbers, parent_partnumbers=cable.partnumbers + ) + if cells_below is not None and len(cells_below) > 0: + table_below = ( + Table( + Tr([Td(cell) for cell in cells_below]), + border=0, + cellborder=0, + cellspacing=0, + ), + ) + rows.append(Tr(Td(table_below, colspan=len(cells_above)))) + + rows.append(Tr(Td(" "))) # spacer row on bottom + tbl = Table(rows, border=0, cellborder=0, cellspacing=0) + return tbl + + +def gv_wire_cell(wire: Union[WireClass, ShieldClass], colspan: int) -> Td: + wire_outer_cell_attribs = { + "border": 0, + "cellspacing": 0, + "cellpadding": 0, + "colspan": colspan, + "height": 6, + "port": f"w{wire.index+1}", + } + # ports in GraphViz are 1-indexed for more natural maping to pin/wire numbers + wire_outer_cell = Td(None, **wire_outer_cell_attribs) + + return wire_outer_cell + + dot.attr("edge", headclip="true", tailclip="true", style="bold") # TODO: ? + + + + # color, l1, l2, r1, r2 +def gv_edge_wire(harness, cable, connection) -> Tuple[str, str, str, str, str]: + if connection.via.color: + # check if it's an actual wire and not a shield + color = f"#000000:{connection.via.color.html_padded}:#000000" + else: # it's a shield connection + color = "#000000" + + if connection.from_ is not None: # connect to left + from_port_str = ( + f":p{connection.from_.index+1}r" + if harness.connectors[connection.from_.parent].style != "simple" + else "" + ) + code_left_1 = f"{connection.from_.parent}{from_port_str}:e" + code_left_2 = f"{connection.via.parent}:w{connection.via.index+1}:w" + # ports in GraphViz are 1-indexed for more natural maping to pin/wire numbers + else: + code_left_1, code_left_2 = None, None + + if connection.to is not None: # connect to right + to_port_str = ( + f":p{connection.to.index+1}l" + if harness.connectors[connection.to.parent].style != "simple" + else "" + ) + code_right_1 = f"{connection.via.parent}:w{connection.via.index+1}:e" + code_right_2 = f"{connection.to.parent}{to_port_str}:w" + else: + code_right_1, code_right_2 = None, None + + return color, code_left_1, code_left_2, code_right_1, code_right_2 + + # color, we, ww, +def gv_edge_wire_inside(cable) -> List[Tuple[str, str, str]]: + wires = [] + # print(cable.wire_objects) + for wire in cable.wire_objects.values(): + color = "#000000" + if wire.color: + # check if it's an actual wire and not a shield + color = f"#000000:{wire.color.html_padded}:#000000" + else: # it's a shield connection + color = "#000000" + + we = f"{wire.parent}:w{wire.index+1}:e" + ww = f"{wire.parent}:w{wire.index+1}:w" + + wires.append([color, we, ww]) + return wires + + +def parse_arrow_str(inp: str) -> ArrowDirection: + if inp[0] == "<" and inp[-1] == ">": + return ArrowDirection.BOTH + elif inp[0] == "<": + return ArrowDirection.BACK + elif inp[-1] == ">": + return ArrowDirection.FORWARD + else: + return ArrowDirection.NONE + + +def gv_edge_mate(mate) -> Tuple[str, str, str, str]: + if mate.arrow.weight == ArrowWeight.SINGLE: + color = "#000000" + elif mate.arrow.weight == ArrowWeight.DOUBLE: + color = "#000000:#000000" + + dir = mate.arrow.direction.name.lower() + + if isinstance(mate, MatePin): + from_pin_index = mate.from_.index + from_port_str = f":p{from_pin_index+1}r" + from_designator = mate.from_.parent + to_pin_index = mate.to.index + to_port_str = f":p{to_pin_index+1}l" + to_designator = mate.to.parent + elif isinstance(mate, MateComponent): + from_designator = mate.from_ + from_port_str = "" + to_designator = mate.to + to_port_str = "" + else: + raise Exception(f"Unknown type of mate:\n{mate}") + + code_from = f"{from_designator}{from_port_str}:e" + code_to = f"{to_designator}{to_port_str}:w" + + return color, dir, code_from, code_to + + +def colorbar_cells(color, mini=False) -> List[Td]: + cells = [] + mini = {"height": 8, "width": 8, "fixedsize": "true"} if mini else {} + for index, subcolor in enumerate(color.colors): + sides_l = "L" if index == 0 else "" + sides_r = "R" if index == len(color.colors) - 1 else "" + sides = "TB" + sides_l + sides_r + cells.append(Td("", bgcolor=subcolor.html, sides=sides, **mini)) + return cells + + +def color_minitable(color: Optional[MultiColor]) -> Union[Table, str]: + if color is None or len(color) == 0: + return "" + + cells = colorbar_cells(color, mini=True) + + return Table( + Tr(cells), + border=0, + cellborder=1, + cellspacing=0, + height=8, + width=8 * len(cells), + fixedsize="true", + ) + + +def image_and_caption_cells(component: Component) -> Tuple[Td, Td]: + if not component.image: + return (None, None) + + image_tag = Img(scale=component.image.scale, src=component.image.src) + image_cell_inner = Td(image_tag, flat=True) + if component.image.fixedsize: + # further nest the image in a table with width/height/fixedsize parameters, + # and place that table in a cell + image_cell_inner.update_attribs(**html_size_attr_dict(component.image)) + image_cell = Td( + Table(Tr(image_cell_inner), border=0, cellborder=0, cellspacing=0, id="!") + ) + else: + image_cell = image_cell_inner + + image_cell.update_attribs( + balign="left", + bgcolor=component.image.bgcolor.html, + sides="TLR" if component.image.caption else None, + ) + + if component.image.caption: + caption_cell = Td( + f"{html_line_breaks(component.image.caption)}", balign="left", sides="BLR" + ) + else: + caption_cell = None + return (image_cell, caption_cell) + + +def html_size_attr_dict(image): + # Return Graphviz HTML attributes to specify minimum or fixed size of a TABLE or TD object + pass + + attr_dict = {} + if image: + if image.width: + attr_dict["width"] = image.width + if image.height: + attr_dict["height"] = image.height + if image.fixedsize: + attr_dict["fixedsize"] = "true" + return attr_dict + + +def set_dot_basics(dot, options): + dot.body.append(f"// Graph generated by {APP_NAME} {__version__}\n") + dot.body.append(f"// {APP_URL}\n") + dot.attr( + "graph", + rankdir="LR", + ranksep="2", + bgcolor=options.bgcolor.html, + nodesep="0.33", + fontname=options.fontname, + ) # TODO: Add graph attribute: charset="utf-8", + dot.attr( + "node", + shape="none", + width="0", + height="0", + margin="0", # Actual size of the node is entirely determined by the label. + style="filled", + fillcolor=options.bgcolor_node.html, + fontname=options.fontname, + ) + dot.attr("edge", style="bold", fontname=options.fontname) + + +def apply_dot_tweaks(dot, tweak): + def typecheck(name: str, value: Any, expect: type) -> None: + if not isinstance(value, expect): + raise Exception( + f"Unexpected value type of {name}: " + f"Expected {expect}, got {type(value)}\n{value}" + ) + + # TODO?: Differ between override attributes and HTML? + if tweak.override is not None: + typecheck("tweak.override", tweak.override, dict) + for k, d in tweak.override.items(): + typecheck(f"tweak.override.{k} key", k, str) + typecheck(f"tweak.override.{k} value", d, dict) + for a, v in d.items(): + typecheck(f"tweak.override.{k}.{a} key", a, str) + typecheck(f"tweak.override.{k}.{a} value", v, (str, type(None))) + + # Override generated attributes of selected entries matching tweak.override. + for i, entry in enumerate(dot.body): + if not isinstance(entry, str): + continue + # Find a possibly quoted keyword after leading TAB(s) and followed by [ ]. + match = re.match(r'^\t*(")?((?(1)[^"]|[^ "])+)(?(1)") \[.*\]$', entry, re.S) + keyword = match and match[2] + if not keyword in tweak.override.keys(): + continue + + for attr, value in tweak.override[keyword].items(): + if value is None: + entry, n_subs = re.subn( + f'( +)?{attr}=("[^"]*"|[^] ]*)(?(1)| *)', "", entry + ) + if n_subs < 1: + warnings.warn(f"tweak: {attr} not found in {keyword}!") + elif n_subs > 1: + warnings.warn( + f"tweak: {attr} removed {n_subs} times in {keyword}!" + ) + continue + + if len(value) == 0 or " " in value: + value = value.replace('"', r"\"") + value = f'"{value}"' + entry, n_subs = re.subn( + f'{attr}=("[^"]*"|[^] ]*)', f"{attr}={value}", entry + ) + if n_subs < 1: + # If attr not found, then append it + entry = re.sub(r"\]$", f" {attr}={value}]", entry) + elif n_subs > 1: + warnings.warn( + f"tweak: {attr} overridden {n_subs} times in {keyword}!" + ) + + dot.body[i] = entry + + if tweak.append is not None: + if isinstance(tweak.append, list): + for i, element in enumerate(tweak.append, 1): + typecheck(f"tweak.append[{i}]", element, str) + dot.body.extend(tweak.append) + else: + typecheck("tweak.append", tweak.append, str) + dot.body.append(tweak.append) diff --git a/src/wireviz/wv_gv_html.py b/src/wireviz/wv_gv_html.py deleted file mode 100644 index ec80aa7..0000000 --- a/src/wireviz/wv_gv_html.py +++ /dev/null @@ -1,111 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from typing import List, Optional, Union - -from wireviz.DataClasses import Color -from wireviz.wv_colors import translate_color -from wireviz.wv_helper import remove_links - - -def nested_html_table( - rows: List[Union[str, List[Optional[str]], None]], table_attrs: str = "" -) -> str: - # input: list, each item may be scalar or list - # output: a parent table with one child table per parent item that is list, and one cell per parent item that is scalar - # purpose: create the appearance of one table, where cell widths are independent between rows - # attributes in any leading inside a list are injected into to the preceeding \n" - for item in bom[0]: - th_class = f"bom_col_{item.lower()}" - bom_header_html = f'{bom_header_html} \n' - bom_header_html = f"{bom_header_html} \n" + def __init__(self, contents, flat=None, delete_if_empty=False, **kwargs): + self.contents = contents + self.flat = flat + self.delete_if_empty = delete_if_empty + self.attribs = Attribs({**kwargs}) - # generate BOM contents - bom_contents = [] - for row in bom[1:]: - row_html = " \n" - for i, item in enumerate(row): - td_class = f"bom_col_{bom[0][i].lower()}" - row_html = f'{row_html} \n' - row_html = f"{row_html} \n" - bom_contents.append(row_html) + def update_attribs(self, **kwargs): + for k, v in kwargs.items(): + self.attribs[k] = v - bom_html = ( - '
tag - html = [] - html.append( - f'' - ) - - num_rows = 0 - for row in rows: - if isinstance(row, List): - if len(row) > 0 and any(row): - html.append(" ") - num_rows = num_rows + 1 - elif row is not None: - html.append(" ") - num_rows = num_rows + 1 - if num_rows == 0: # empty table - # generate empty cell to avoid GraphViz errors - html.append("") - html.append("
") - # fmt: off - html.append(' ') - # fmt: on - for cell in row: - if cell is not None: - # Inject attributes to the preceeding '.replace(">
tag where needed - # fmt: off - html.append(f' {cell}
") - html.append("
") - html.append(f" {row}") - html.append("
") - return html - - -def html_bgcolor_attr(color: Color) -> str: - """Return attributes for bgcolor or '' if no color.""" - return f' bgcolor="{translate_color(color, "HEX")}"' if color else "" - - -def html_bgcolor(color: Color, _extra_attr: str = "") -> str: - """Return
attributes prefix for bgcolor or '' if no color.""" - return f"" if color else "" - - -def html_colorbar(color: Color) -> str: - """Return attributes prefix for bgcolor and minimum width or None if no color.""" - return html_bgcolor(color, ' width="4"') if color else None - - -def html_image(image): - from wireviz.DataClasses import Image - - if not image: - return None - # The leading attributes belong to the preceeding tag. See where used below. - html = f'{html_size_attr(image)}>' - if image.fixedsize: - # Close the preceeding tag and enclose the image cell in a table without - # borders to avoid narrow borders when the fixed width < the node width. - html = f"""> - - -
- """ - return f"""{html_line_breaks(image.caption)}' - if image and image.caption - else None - ) - - -def html_size_attr(image): - from wireviz.DataClasses import Image - - # Return Graphviz HTML attributes to specify minimum or fixed size of a TABLE or TD object - return ( - ( - (f' width="{image.width}"' if image.width else "") - + (f' height="{image.height}"' if image.height else "") - + (' fixedsize="true"' if image.fixedsize else "") - ) - if image - else "" - ) - - -def html_line_breaks(inp): - return remove_links(inp).replace("\n", "
") if isinstance(inp, str) else inp diff --git a/src/wireviz/wv_gvpr.gvpr b/src/wireviz/wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/src/wireviz/wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/src/wireviz/wv_harness.py b/src/wireviz/wv_harness.py new file mode 100644 index 0000000..209d573 --- /dev/null +++ b/src/wireviz/wv_harness.py @@ -0,0 +1,483 @@ +# -*- coding: utf-8 -*- +import os +import shutil + +from collections import defaultdict +from dataclasses import dataclass, field, asdict +from pathlib import Path +from typing import List, Union +#from distutils.spawn import find_executable + +from graphviz import Graph + +import wireviz.wv_colors +from wireviz.wv_bom import BomCategory, BomEntry, bom_list, print_bom_table +from wireviz.wv_dataclasses import ( + AUTOGENERATED_PREFIX, + AdditionalBomItem, + Arrow, + ArrowWeight, + Cable, + Component, + Connector, + MateComponent, + MatePin, + Metadata, + Options, + Side, + TopLevelGraphicalComponent, + Tweak, + Image, +) +from wireviz.wv_graphviz import ( + apply_dot_tweaks, + calculate_node_bgcolor, + gv_connector_loops, + gv_connector_shorts, + gv_edge_mate, + gv_edge_wire, + gv_edge_wire_inside, + gv_node_component, + parse_arrow_str, + set_dot_basics, +) +from wireviz.wv_output import ( + embed_svg_images, + embed_svg_images_file, + generate_html_output, +) +from wireviz.wv_utils import OLD_CONNECTOR_ATTR, bom2tsv, check_old, file_write_text, getAddCompFromRef + +@dataclass +class Harness: + metadata: Metadata + options: Options + tweak: Tweak + additional_bom_items: List[AdditionalBomItem] = field(default_factory=list) + + def __post_init__(self): + self.connectors = {} + self.cables = {} + self.mates = [] + self.bom = defaultdict(dict) + self.additional_bom_items = [] + + def add_connector(self, designator: str, *args, **kwargs) -> None: + check_old(f"Connector '{designator}'", OLD_CONNECTOR_ATTR, kwargs) + conn = Connector(designator=designator, *args, **kwargs) + self.connectors[designator] = conn + + def add_cable(self, designator: str, *args, **kwargs) -> None: + cbl = Cable(designator=designator, *args, **kwargs) + self.cables[designator] = cbl + + def add_additional_bom_item(self, item: dict) -> None: + new_item = AdditionalBomItem(**item) + self.additional_bom_items.append(new_item) + + def add_mate_pin(self, from_name, from_pin, to_name, to_pin, arrow_str) -> None: + from_con = self.connectors[from_name] + from_pin_obj = from_con.pin_objects[from_pin] + to_con = self.connectors[to_name] + to_pin_obj = to_con.pin_objects[to_pin] + arrow = Arrow(direction=parse_arrow_str(arrow_str), weight=ArrowWeight.SINGLE) + + self.mates.append(MatePin(from_pin_obj, to_pin_obj, arrow)) + self.connectors[from_name].activate_pin( + from_pin, Side.RIGHT, is_connection=False + ) + self.connectors[to_name].activate_pin(to_pin, Side.LEFT, is_connection=False) + + def add_mate_component(self, from_name, to_name, arrow_str) -> None: + arrow = Arrow(direction=parse_arrow_str(arrow_str), weight=ArrowWeight.SINGLE) + self.mates.append(MateComponent(from_name, to_name, arrow)) + + def populate_bom(self): # called once harness creation is complete + # helper lists + all_toplevel_items = ( + list(self.connectors.values()) + + list(self.cables.values()) + + self.additional_bom_items + ) + all_subitems = [ + subitem + for item in all_toplevel_items + for subitem in item.additional_components + ] + all_bom_relevant_items = ( + list(self.connectors.values()) + + [cable for cable in self.cables.values() if cable.category != "bundle"] + + [ + wire + for cable in self.cables.values() + if cable.category == "bundle" + for wire in cable.wire_objects.values() + ] + + all_subitems + ) + + # add items to BOM + for item in all_toplevel_items: + self._add_to_internal_bom(item) # nested subitems are also handled + # sort BOM by category first, then alphabetically by description within category + self.bom = dict( + sorted( + self.bom.items(), + key=lambda x: ( + x[1]["category"], + x[0].description, + ), # x[0] = key, x[1] = value + ) + ) + # assign BOM IDs + for id, key in enumerate(self.bom.keys(), 1): + self.bom[key]["id"] = id + # set BOM IDs within components (for BOM bubbles) + for item in all_bom_relevant_items: + if item.ignore_in_bom: + continue + if not item.bom_hash in self.bom: + print(f"{item}'s hash' not found in BOM dict.") # Should not happen + continue + item.bom_id = self.bom[item.bom_hash]["id"] + + def _add_to_internal_bom(self, item: Component): + if item.ignore_in_bom: + return + + def _add(hash, qty, designator=None, category=None): + bom_entry = self.bom[hash] + # initialize missing fields + if not "qty" in bom_entry: + bom_entry["qty"] = 0 + if not "designators" in bom_entry: + bom_entry["designators"] = set() + # update fields + bom_entry["qty"] += qty + if designator is None: + designator_list = [] + elif isinstance(designator, list): + designator_list = designator + else: + designator_list = [designator] + for des in designator_list: + if des and not des.startswith(AUTOGENERATED_PREFIX): + bom_entry["designators"].add(des) + bom_entry["category"] = category + + if isinstance(item, TopLevelGraphicalComponent): + if isinstance(item, Connector): + cat = BomCategory.CONNECTOR + elif isinstance(item, Cable): + if item.category == "bundle": + cat = BomCategory.WIRE + else: + cat = BomCategory.CABLE + else: + cat = "" + + if item.category == "bundle": + # wires of a bundle are added as individual BOM entries + for subitem in item.wire_objects.values(): + _add( + hash=subitem.bom_hash, + qty=item.qty, # should be 1 + designator=item.designator, # inherit from parent item + category=cat, + ) + else: + _add( + hash=item.bom_hash, + qty=item.qty, # should be 1 + designator=item.designator, + category=cat, + ) + + if item.additional_components: + item.compute_qty_multipliers() + + for comp in item.additional_components: + if comp.ignore_in_bom: + continue + + if comp.sum_amounts_in_bom: + if comp.amount_computed: + total_qty = comp.qty_computed * comp.amount_computed.number + else: + total_qty = comp.qty_computed + else: + total_qty = comp.qty_computed + _add( + hash=comp.bom_hash, + designator=item.designator, + qty=total_qty, + # no explicit qty specified; assume qty = 1 + # used to simplify add.comp. table within parent node + # e.g. show "10 mm Heatshrink" instead of "1x 10 mm Heatshrink" + category=BomCategory.ADDITIONAL_INSIDE, + ) + elif isinstance(item, AdditionalBomItem): + cat = BomCategory.ADDITIONAL_OUTSIDE + _add( + hash=item.bom_hash, + qty=item.qty, + designator=None, + category=cat, + ) + else: + raise Exception(f"Unknown type of item:\n{item}") + + def connect( + self, + from_name: str, + from_pin: Union[int, str], + via_name: str, + via_wire: Union[int, str], + to_name: str, + to_pin: Union[int, str], + ) -> None: + # check from and to connectors + for name, pin in zip([from_name, to_name], [from_pin, to_pin]): + if name is not None and name in self.connectors: + connector = self.connectors[name] + # check if provided name is ambiguous + if pin in connector.pins and pin in connector.pinlabels: + if connector.pins.index(pin) != connector.pinlabels.index(pin): + raise Exception( + f"{name}:{pin} is defined both in pinlabels and pins, " + "for different pins." + ) + # TODO: Maybe issue a warning if present in both lists + # but referencing the same pin? + if pin in connector.pinlabels: + if connector.pinlabels.count(pin) > 1: + raise Exception(f"{name}:{pin} is defined more than once.") + index = connector.pinlabels.index(pin) + pin = connector.pins[index] # map pin name to pin number + if name == from_name: + from_pin = pin + if name == to_name: + to_pin = pin + if not pin in connector.pins: + raise Exception(f"{name}:{pin} not found.") + + # check via cable + if via_name in self.cables: + cable = self.cables[via_name] + # check if provided name is ambiguous + if via_wire in cable.colors and via_wire in cable.wirelabels: + if cable.colors.index(via_wire) != cable.wirelabels.index(via_wire): + raise Exception( + f"{via_name}:{via_wire} is defined both in colors and wirelabels, " + "for different wires." + ) + # TODO: Maybe issue a warning if present in both lists + # but referencing the same wire? + if via_wire in cable.colors: + if cable.colors.count(via_wire) > 1: + raise Exception( + f"{via_name}:{via_wire} is used for more than one wire." + ) + # list index starts at 0, wire IDs start at 1 + via_wire = cable.colors.index(via_wire) + 1 + elif via_wire in cable.wirelabels: + if cable.wirelabels.count(via_wire) > 1: + raise Exception( + f"{via_name}:{via_wire} is used for more than one wire." + ) + via_wire = ( + cable.wirelabels.index(via_wire) + 1 + ) # list index starts at 0, wire IDs start at 1 + + # perform the actual connection + if from_name is not None: + from_con = self.connectors[from_name] + from_pin_obj = from_con.pin_objects[from_pin] + else: + from_pin_obj = None + if to_name is not None: + to_con = self.connectors[to_name] + to_pin_obj = to_con.pin_objects[to_pin] + else: + to_pin_obj = None + + self.cables[via_name]._connect(from_pin_obj, via_wire, to_pin_obj) + if from_name in self.connectors: + self.connectors[from_name].activate_pin(from_pin, Side.RIGHT) + if to_name in self.connectors: + self.connectors[to_name].activate_pin(to_pin, Side.LEFT) + + def create_graph(self) -> Graph: + dot = Graph() + set_dot_basics(dot, self.options) + + for connector in self.connectors.values(): + # generate connector node + gv_html = gv_node_component(connector) + gv_html.update_attribs( + bgcolor=calculate_node_bgcolor(connector, self.options) + ) + dot.node( + connector.designator, + label=f"<\n{gv_html}\n>", + shape="box", + style="filled", + ) + # generate edges for connector loops + if len(connector.loops) > 0: + dot.attr("edge", color="#000000") + loops = gv_connector_loops(connector) + for head, tail, color in loops: + dot.edge(head, tail, color = color, label = " ", noLabel="noLabel") + + # generate edges for connector shorts + if len(connector.shorts) > 0: + dot.attr("edge", color="#000000") + shorts = gv_connector_shorts(connector) + for head, tail, color in shorts: + dot.edge(head, tail, + color=color, + straight="straight", + addPTS=".18", # Size of the point at the end of the straight line/edge, it also enables the drawing of it + colorPTS=color.replace("#FFFFFF:", ""), + headclip="false", tailclip="false") + + # 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 + wire_is_multicolor = [ + len(wire.color) > 1 + for cable in self.cables.values() + for wire in cable.wire_objects.values() + ] + if any(wire_is_multicolor): + wireviz.wv_colors.padding_amount = 3 + else: + wireviz.wv_colors.padding_amount = 1 + + for cable in self.cables.values(): + # generate cable node + # TODO: PN info for bundles (per wire) + gv_html = gv_node_component(cable) + gv_html.update_attribs(bgcolor=calculate_node_bgcolor(cable, self.options)) + style = "filled,dashed" if cable.category == "bundle" else "filled" + dot.node( + cable.designator, + label=f"<\n{gv_html}\n>", + shape="box", + style=style, + ) + + # generate wire edges between component nodes and cable nodes + for connection in cable._connections: + color, l1, l2, r1, r2 = gv_edge_wire(self, cable, connection) + dot.attr("edge", color=color) + if not (l1, l2) == (None, None): + dot.edge(l1, l2) + if not (r1, r2) == (None, None): + dot.edge(r1, r2) + + for color, we, ww in gv_edge_wire_inside(cable): + if not (we, ww) == (None, None): + dot.edge(we, ww, color=color, straight="straight") + for mate in self.mates: + color, dir, code_from, code_to = gv_edge_mate(mate) + + dot.attr("edge", color=color, style="dashed", dir=dir) + dot.edge(code_from, code_to) + + apply_dot_tweaks(dot, self.tweak) + + return dot + + # cache for the GraphViz Graph object + # do not access directly, use self.graph instead + _graph = None + + @property + def graph(self): + if not self._graph: # no cached graph exists, generate one + self._graph = self.create_graph() + return self._graph # return cached graph + + @property + def png(self): + from io import BytesIO + + graph = self.graph + data = BytesIO() + data.write(graph.pipe(format="png")) + data.seek(0) + return data.read() + + @property + def svg(self): # TODO?: Verify xml encoding="utf-8" in SVG? + graph = self.graph + return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd()) + + def graphRender(self, type, filename, graph): + # Chack if the needed commands are existing + if shutil.which("dot") and shutil.which("gvpr") and shutil.which("neato"): + # Set enviorments variable to path of this file + os.environ['GVPRPATH'] = str(Path(__file__).parent) + # Export the gv output to a temporay file + graph.save(filename=f"{filename}_tmp.gv") + # Run the vomand and generait the output + os.system(f"dot {filename}_tmp.gv | gvpr -q -cf wv_gvpr.gvpr | neato -n2 -T{type} -o {filename}.{type}") + # Remove the temporary file + os.remove(f"{filename}_tmp.gv") + 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 + + + def output( + self, + filename: Union[str, Path], + view: bool = False, + cleanup: bool = True, + fmt: tuple = ("html", "png", "svg", "tsv"), + ) -> None: + # graphical output + graph = self.graph + for f in fmt: + if f in ("png", "svg", "html"): + if f == "html": # if HTML format is specified, + f = "svg" # generate SVG for embedding into HTML + # SVG file will be renamed/deleted later + _filename = f"{filename}.tmp" if f == "svg" else filename + # TODO: prevent rendering SVG twice when both SVG and HTML are specified + graph.format = f + 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") + # GraphViz output + if "gv" in fmt: + graph.save(filename=f"{filename}.gv") + # Print the needed comand for generaitong an output + filename_str = str(filename) + shutil.copyfile(str(Path(__file__).parent).replace('\\', '/') + "/wv_gvpr.gvpr", filename_str + "_wv_gvpr.gvpr") + print(f"Use: dot {filename_str}.gv | gvpr -q -cf {filename_str}_wv_gvpr.gvpr | neato -n2 -T -o {filename_str}.") + # BOM output + bomlist = bom_list(self.bom) + # bomlist = [[]] + if "tsv" in fmt: + tsv = bom2tsv(bomlist) + file_write_text(f"{filename}.bom.tsv", tsv) + + if "csv" in fmt: + # TODO: implement CSV output (preferrably using CSV library) + print("CSV output is not yet supported") + # HTML output + if "html" in fmt: + generate_html_output(filename, bomlist, self.metadata, self.options) + # PDF output + if "pdf" in fmt: + # TODO: implement PDF output + print("PDF output is not yet supported") + # delete SVG if not needed + if "html" in fmt and not "svg" in fmt: + # SVG file was just needed to generate HTML + Path(f"{filename}.tmp.svg").unlink() + elif "svg" in fmt: + Path(f"{filename}.tmp.svg").replace(f"{filename}.svg") diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 4230110..1c4b750 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -1,130 +1,125 @@ # -*- coding: utf-8 -*- -import re -from pathlib import Path -from typing import Callable, Dict, List, Union +from collections.abc import Iterable +from dataclasses import dataclass, field +from typing import Dict -from wireviz import APP_NAME, APP_URL, __version__, wv_colors -from wireviz.DataClasses import Metadata, Options -from wireviz.svgembed import data_URI_base64 -from wireviz.wv_gv_html import html_line_breaks -from wireviz.wv_helper import ( - file_read_text, - file_write_text, - flatten2d, - smart_file_resolve, -) +indent_count = 1 -def generate_html_output( - filename: Union[str, Path], - bom_list: List[List[str]], - metadata: Metadata, - options: Options, -): - # load HTML template - templatename = metadata.get("template", {}).get("name") - if templatename: - # if relative path to template was provided, check directory of YAML file first, fall back to built-in template directory - templatefile = smart_file_resolve( - f"{templatename}.html", - [Path(filename).parent, Path(__file__).parent / "templates"], - ) - else: - # fall back to built-in simple template if no template was provided - templatefile = Path(__file__).parent / "templates/simple.html" +class Attribs(Dict): + def __repr__(self): + if len(self) == 0: + return "" - html = file_read_text(templatefile) # TODO?: Warn if unexpected meta charset? + html = [] + for k, v in self.items(): + if v is not None: + html.append(f' {k}="{v}"') + # else: + # html.append(f" {k}") + return "".join(html) - # embed SVG diagram (only if used) - def svgdata() -> str: - return re.sub( # TODO?: Verify xml encoding="utf-8" in SVG? - "^<[?]xml [^?>]*[?]>[^<]*]*>", - "", - file_read_text(f"{filename}.tmp.svg"), - 1, - ) - # generate BOM table - bom = flatten2d(bom_list) +@dataclass +class Tag: + contents = None + attribs: Attribs = field(default_factory=Attribs) + flat: bool = None + delete_if_empty: bool = False - # generate BOM header (may be at the top or bottom of the table) - bom_header_html = "
{item}
{item}
\n' + bom_header_html + "".join(bom_contents) + "
\n" - ) - bom_html_reversed = ( - '\n' - + "".join(list(reversed(bom_contents))) - + bom_header_html - + "
\n" - ) + @property + def tagname(self): + return type(self).__name__.lower() - # prepare simple replacements - replacements = { - "": f"{APP_NAME} {__version__} - {APP_URL}", - "": options.fontname, - "": wv_colors.translate_color(options.bgcolor, "hex"), - "": str(filename), - "": Path(filename).stem, - "": bom_html, - "": bom_html_reversed, - "": "1", # TODO: handle multi-page documents - "": "1", # TODO: handle multi-page documents - "": metadata.get("template", {}).get( - "sheetsize", "" - ), - } + @property + def auto_flat(self): + if self.flat is not None: # user specified + return self.flat + if not _is_iterable_not_str(self.contents): # catch str, int, float, ... + if not isinstance(self.contents, Tag): # avoid recursion + return not "\n" in str(self.contents) # flatten if single line - def replacement_if_used(key: str, func: Callable[[], str]) -> None: - """Append replacement only if used in html.""" - if key in html: - replacements[key] = func() + @property + def is_empty(self): + return self.get_contents(force_flat=True) == "" - replacement_if_used("", svgdata) - replacement_if_used( - "", lambda: data_URI_base64(f"{filename}.png") - ) + def indent_lines(self, lines, force_flat=False): + if self.auto_flat or force_flat: + return lines + else: + indenter = " " * indent_count + return "\n".join(f"{indenter}{line}" for line in lines.split("\n")) - # prepare metadata replacements - if metadata: - for item, contents in metadata.items(): - if isinstance(contents, (str, int, float)): - replacements[f""] = html_line_breaks(str(contents)) - elif isinstance(contents, Dict): # useful for authors, revisions - for index, (category, entry) in enumerate(contents.items()): - if isinstance(entry, Dict): - replacements[f""] = str(category) - for entry_key, entry_value in entry.items(): - replacements[ - f"" - ] = html_line_breaks(str(entry_value)) - elif isinstance(entry, (str, int, float)): - pass # TODO?: replacements[f""] = html_line_breaks(str(entry)) + def get_contents(self, force_flat=False): + separator = "" if self.auto_flat or force_flat else "\n" + if _is_iterable_not_str(self.contents): + return separator.join( + [ + self.indent_lines(str(c), force_flat) + for c in self.contents + if c is not None + ] + ) + elif self.contents is None: + return "" + else: # str, int, float, etc. + return self.indent_lines(str(self.contents), force_flat) - # perform replacements - # regex replacement adapted from: - # https://gist.github.com/bgusach/a967e0587d6e01e889fd1d776c5f3729 + def __repr__(self): + separator = "" if self.auto_flat else "\n" + if self.delete_if_empty and self.is_empty: + return "" + else: + html = [ + f"<{self.tagname}{str(self.attribs)}>", + f"{self.get_contents()}", + f"", + ] + html_joined = separator.join(html) + return html_joined - # longer replacements first, just in case - replacements_sorted = sorted(replacements, key=len, reverse=True) - replacements_escaped = map(re.escape, replacements_sorted) - pattern = re.compile("|".join(replacements_escaped)) - html = pattern.sub(lambda match: replacements[match.group(0)], html) - file_write_text(f"{filename}.html", html) +@dataclass +class TagSingleton(Tag): + def __init__(self, **kwargs): + self.attribs = Attribs({**kwargs}) + + def __repr__(self): + return f"<{self.tagname}{str(self.attribs)} />" + + +def _is_iterable_not_str(inp): + # str is iterable, but should be treated as not iterable + return isinstance(inp, Iterable) and not isinstance(inp, str) + + +@dataclass +class Br(TagSingleton): + pass + + +class Img(TagSingleton): + pass + + +class Td(Tag): + pass + + +class Tr(Tag): + pass + + +class Table(Tag): + pass diff --git a/src/wireviz/wv_output.py b/src/wireviz/wv_output.py new file mode 100644 index 0000000..803d886 --- /dev/null +++ b/src/wireviz/wv_output.py @@ -0,0 +1,189 @@ +# -*- coding: utf-8 -*- + +import base64 +import re +from pathlib import Path +from typing import Callable, Dict, List, Union + +import wireviz # for doing wireviz.__file__ +from wireviz import APP_NAME, APP_URL, __version__ +from wireviz.wv_dataclasses import Metadata, Options +from wireviz.wv_utils import ( + file_read_text, + file_write_text, + html_line_breaks, + smart_file_resolve, +) + +mime_subtype_replacements = {"jpg": "jpeg", "tif": "tiff"} + + +# TODO: Share cache and code between data_URI_base64() and embed_svg_images() +def data_URI_base64(file: Union[str, Path], media: str = "image") -> str: + """Return Base64-encoded data URI of input file.""" + file = Path(file) + b64 = base64.b64encode(file.read_bytes()).decode("utf-8") + uri = f"data:{media}/{get_mime_subtype(file)};base64, {b64}" + # print(f"data_URI_base64('{file}', '{media}') -> {len(uri)}-character URI") + if len(uri) > 65535: + print( + "data_URI_base64(): Warning: Browsers might have different URI length limitations" + ) + return uri + + +def embed_svg_images(svg_in: str, base_path: Union[str, Path] = Path.cwd()) -> str: + images_b64 = {} # cache of base64-encoded images + + def image_tag(pre: str, url: str, post: str) -> str: + return f'' + + def replace(match: re.Match) -> str: + imgurl = match["URL"] + if not imgurl in images_b64: # only encode/cache every unique URL once + imgurl_abs = (Path(base_path) / imgurl).resolve() + image = imgurl_abs.read_bytes() + images_b64[imgurl] = base64.b64encode(image).decode("utf-8") + return image_tag( + match["PRE"] or "", + f"data:image/{get_mime_subtype(imgurl)};base64, {images_b64[imgurl]}", + match["POST"] or "", + ) + + pattern = re.compile( + image_tag(r"(?P
 [^>]*?)?", r'(?P[^"]*?)', r"(?P [^>]*?)?"),
+        re.IGNORECASE,
+    )
+    return pattern.sub(replace, svg_in)
+
+
+def get_mime_subtype(filename: Union[str, Path]) -> str:
+    mime_subtype = Path(filename).suffix.lstrip(".").lower()
+    if mime_subtype in mime_subtype_replacements:
+        mime_subtype = mime_subtype_replacements[mime_subtype]
+    return mime_subtype
+
+
+def embed_svg_images_file(
+    filename_in: Union[str, Path], overwrite: bool = True
+) -> None:
+    filename_in = Path(filename_in).resolve()
+    filename_out = filename_in.with_suffix(".b64.svg")
+    filename_out.write_text(  # TODO?: Verify xml encoding="utf-8" in SVG?
+        embed_svg_images(filename_in.read_text(), filename_in.parent)
+    )  # TODO: Use encoding="utf-8" in both read_text() and write_text()
+    if overwrite:
+        filename_out.replace(filename_in)
+
+
+def generate_html_output(
+    filename: Union[str, Path],
+    bom: List[List[str]],
+    metadata: Metadata,
+    options: Options,
+):
+    # load HTML template
+    templatename = metadata.get("template", {}).get("name")
+    if templatename:
+        # if relative path to template was provided,
+        # check directory of YAML file first, fall back to built-in template directory
+        templatefile = smart_file_resolve(
+            f"{templatename}.html",
+            [Path(filename).parent, Path(__file__).parent / "templates"],
+        )
+    else:
+        # fall back to built-in simple template if no template was provided
+        templatefile = Path(wireviz.__file__).parent / "templates/simple.html"
+
+    html = file_read_text(templatefile)  # TODO?: Warn if unexpected meta charset?
+
+    # embed SVG diagram (only if used)
+    def svgdata() -> str:
+        return re.sub(  # TODO?: Verify xml encoding="utf-8" in SVG?
+            "^<[?]xml [^?>]*[?]>[^<]*]*>",
+            "",
+            file_read_text(f"{filename}.tmp.svg"),
+            1,
+        )
+
+    # generate BOM table
+    # generate BOM header (may be at the top or bottom of the table)
+    bom_header_html = "  \n"
+    for item in bom[0]:
+        th_class = f"bom_col_{item.lower()}"
+        bom_header_html = f'{bom_header_html}    {item}\n'
+    bom_header_html = f"{bom_header_html}  \n"
+
+    # generate BOM contents
+    bom_contents = []
+    for row in bom[1:]:
+        row_html = "  \n"
+        for i, item in enumerate(row):
+            td_class = f"bom_col_{bom[0][i].lower()}"
+            row_html = f'{row_html}    {item if item is not None else ""}\n'
+        row_html = f"{row_html}  \n"
+        bom_contents.append(row_html)
+
+    bom_html = (
+        '\n' + bom_header_html + "".join(bom_contents) + "
\n" + ) + bom_html_reversed = ( + '\n' + + "".join(list(reversed(bom_contents))) + + bom_header_html + + "
\n" + ) + + # prepare simple replacements + replacements = { + "": f"{APP_NAME} {__version__} - {APP_URL}", + "": options.fontname, + "": options.bgcolor.html, + "": str(filename), + "": Path(filename).stem, + "": bom_html, + "": bom_html_reversed, + "": "1", # TODO: handle multi-page documents + "": "1", # TODO: handle multi-page documents + "": metadata.get("template", {}).get( + "sheetsize", "" + ), + } + + def replacement_if_used(key: str, func: Callable[[], str]) -> None: + """Append replacement only if used in html.""" + if key in html: + replacements[key] = func() + + replacement_if_used("", svgdata) + replacement_if_used( + "", lambda: data_URI_base64(f"{filename}.png") + ) + + # prepare metadata replacements + if metadata: + for item, contents in metadata.items(): + if isinstance(contents, (str, int, float)): + replacements[f""] = html_line_breaks(str(contents)) + elif isinstance(contents, Dict): # useful for authors, revisions + for index, (category, entry) in enumerate(contents.items()): + if isinstance(entry, Dict): + replacements[f""] = str(category) + for entry_key, entry_value in entry.items(): + replacements[ + f"" + ] = html_line_breaks(str(entry_value)) + elif isinstance(entry, (str, int, float)): + pass # TODO?: replacements[f""] = html_line_breaks(str(entry)) + + # perform replacements + # regex replacement adapted from: + # https://gist.github.com/bgusach/a967e0587d6e01e889fd1d776c5f3729 + + # longer replacements first, just in case + replacements_sorted = sorted(replacements, key=len, reverse=True) + replacements_escaped = map(re.escape, replacements_sorted) + pattern = re.compile("|".join(replacements_escaped)) + html = pattern.sub(lambda match: replacements[match.group(0)], html) + + file_write_text(f"{filename}.html", html) diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_utils.py similarity index 69% rename from src/wireviz/wv_helper.py rename to src/wireviz/wv_utils.py index 89fb921..3ac71ec 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_utils.py @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- import re +from collections import namedtuple from pathlib import Path -from typing import Dict, List +from typing import List, Optional, Union + +NumberAndUnit = namedtuple("NumberAndUnit", "number unit") awg_equiv_table = { "0.09": "28", @@ -70,9 +73,40 @@ def expand(yaml_data): def get_single_key_and_value(d: dict): - k = list(d.keys())[0] - v = d[k] - return (k, v) + # used for defining a line in a harness' connection set + # E.g. for the YAML input `- X1: 1` + # this function returns a tuple in the form ("X1", "1") + return next(iter(d.items())) + + +def parse_number_and_unit( + inp: Optional[Union[NumberAndUnit, float, int, str]], + default_unit: Optional[str] = None, +) -> Optional[NumberAndUnit]: + if inp is None: + return None + elif isinstance(inp, NumberAndUnit): + return inp + elif isinstance(inp, float) or isinstance(inp, int): + return NumberAndUnit(inp, default_unit) + elif isinstance(inp, str): + if " " in inp: + num_str, unit = inp.split(" ", 1) + else: + num_str, unit = inp, default_unit + + try: + number = int(num_str) + except ValueError: # maybe it is a float? + try: + number = float(num_str) + except ValueError: # neither float nor int + raise Exception( + f"{inp} is not a valid number and unit.\n" + "It must be a number, or a number and unit separated by a space." + ) + + return NumberAndUnit(number, unit) def int2tuple(inp): @@ -90,16 +124,20 @@ def flatten2d(inp): ] -def tuplelist2tsv(inp, header=None): +def bom2tsv(inp, header=None): output = "" if header is not None: inp.insert(0, header) - inp = flatten2d(inp) for row in inp: + row = [item if item is not None else "" for item in row] output = output + "\t".join(str(remove_links(item)) for item in row) + "\n" return output +def html_line_breaks(inp): + return remove_links(inp).replace("\n", "
") if isinstance(inp, str) else inp + + def remove_links(inp): return ( re.sub(r"<[aA] [^>]*>([^<]*)", r"\1", inp) @@ -167,7 +205,7 @@ def aspect_ratio(image_src): return 1 # Assume 1:1 when unable to read actual image size -def smart_file_resolve(filename: str, possible_paths: (str, List[str])) -> Path: +def smart_file_resolve(filename: str, possible_paths: Union[str, List[str]]) -> Path: if not isinstance(possible_paths, List): possible_paths = [possible_paths] filename = Path(filename) @@ -189,3 +227,24 @@ def smart_file_resolve(filename: str, possible_paths: (str, List[str])) -> Path: f"{filename} was not found in any of the following locations: \n" + "\n".join([str(x) for x in possible_paths]) ) + + +OLD_CONNECTOR_ATTR = { + "pinout": "was renamed to 'pinlabels' in v0.2", + "pinnumbers": "was renamed to 'pins' in v0.2", + "autogenerate": "is replaced with new syntax in v0.4", +} + + +def check_old(node: str, old_attr: dict, args: dict) -> None: + """Raise exception for any outdated attributes in args.""" + for attr, descr in old_attr.items(): + if attr in args: + raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}") + +# Returns a Additional Component from with the given +def getAddCompFromRef(reference, part): + #print(part.additional_components) + for comp in part.additional_components: + if reference in comp.references: + return comp; \ No newline at end of file diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..87e140f --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,8 @@ +*.gv +*.html +*.png +*.svg +*.tsv +*.csv +*.html +*.pdf diff --git a/tests/bom/bomqty.yml b/tests/bom/bomqty.yml new file mode 100644 index 0000000..0cb3e15 --- /dev/null +++ b/tests/bom/bomqty.yml @@ -0,0 +1,55 @@ +connectors: + X1: + type: No additional components + pincount: 6 + + X2: + type: Contains additional components + pincount: 6 + additional_components: + - type: One, no unit + - type: Two kilometers + amount: 2 km + - type: Takes pincount times seven + qty: 7 + qty_multiplier: pincount + - type: Takes 10 mm per populated pin + amount: 10 mm + qty_multiplier: populated + - type: Takes number of connections + qty_multiplier: connections + +cables: + C1: + type: Containts additional components + wirecount: 4 + length: 1.5 + color_code: DIN + additional_components: + - type: One + - type: Three centimeters + amount: 3 cm + - type: Takes wirecount times two + qty: 2 + qty_multiplier: wirecount + - type: Takes length times three + qty: 3 + # adding amount here should cause error because the length already has a unit + qty_multiplier: length + - type: Takes total length times three + qty: 2 + # adding amount here should cause error because the length already has a unit + qty_multiplier: total_length + + W2: + category: bundle + wirecount: 2 + colors: [tomato, skyblue] + +connections: + - - X1: [1-3] + - C1: [1-3] + - X2: [1-3] + - - X1: [3, 4] + - W2: [1, 2] + - X2: [3, 4] diff --git a/tests/bom/bomqty_wv_gvpr.gvpr b/tests/bom/bomqty_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tests/bom/bomqty_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tests/rendering/00_minimal.yml b/tests/rendering/00_minimal.yml new file mode 100644 index 0000000..a61265c --- /dev/null +++ b/tests/rendering/00_minimal.yml @@ -0,0 +1,26 @@ +connectors: + X1: + pincount: 4 + X2: + pincount: 4 + X3: + pincount: 2 + F: + style: simple + +cables: + C1: + wirecount: 4 + W2: + wirecount: 2 + category: bundle + +connections: + - + - X1: [1-4] + - C1: [1-4] + - X2: [1-4] + - + - X3: [1,2] + - W2: [1,2] + - F. diff --git a/tests/rendering/00_minimal_wv_gvpr.gvpr b/tests/rendering/00_minimal_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tests/rendering/00_minimal_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tests/rendering/01_color_single.yml b/tests/rendering/01_color_single.yml new file mode 100644 index 0000000..ccdae2e --- /dev/null +++ b/tests/rendering/01_color_single.yml @@ -0,0 +1,32 @@ +connectors: + X1: # shorthand color codes + color: BK + pincount: 4 + pincolors: [RD, YE, GN, BU] + X2: # HTML color codes + color: 0xFFFFFF + pincount: 4 + pincolors: [0xFF8000, 0x00FF80, 0x8000FF] # no color for last pin + X3: # HTML color names + color: red + pincount: 4 + pincolors: [deeppink, tomato, salmon, indianred] + F: + style: simple + color: BN + +cables: + C1: + wirecount: 4 + color: GY + colors: [OG, OL, LB, PK] + +connections: + - + - X1: [1-4] + - C1: [1-4] + - X2: [1-4] + - <-- + - X3: [1-4] + - -- + - F. diff --git a/tests/rendering/01_color_single_wv_gvpr.gvpr b/tests/rendering/01_color_single_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tests/rendering/01_color_single_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tests/rendering/02_color_multi.yml b/tests/rendering/02_color_multi.yml new file mode 100644 index 0000000..8dd163c --- /dev/null +++ b/tests/rendering/02_color_multi.yml @@ -0,0 +1,35 @@ +connectors: + X1: + color: YEGN + pincount: 4 + pincolors: [WHBK, BKWH, GNYE, GNWHRD] + X2: + color: 0xCCCCCC:0x333333 + pincount: 4 + pincolors: [0xFF8000:0x80FF00, 0x00FF80, 0x8000FF] + X3: + color: red:yellow + pincount: 4 + pincolors: [deeppink, tomato, salmon, indianred] + F: + style: simple + color: IVTQ + +cables: + C1: + wirecount: 4 + color: GDSR + colors: [RDYE, YEGN, GNBU, BURD] + C2: + wirecount: 4 + colors: [0xFF8000:0x80FF00, YEGN, GNBU, BURD] + +connections: + - + - X1: [1-4] + - C1: [1-4] + - X2: [1-4] + - C2: [1-4] + - X3: [1-4] + - -- + - F. diff --git a/tests/rendering/02_color_multi_wv_gvpr.gvpr b/tests/rendering/02_color_multi_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tests/rendering/02_color_multi_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tests/rendering/03_bgcolors.yml b/tests/rendering/03_bgcolors.yml new file mode 100644 index 0000000..e84a519 --- /dev/null +++ b/tests/rendering/03_bgcolors.yml @@ -0,0 +1,51 @@ +options: + bgcolor_connector: 0xFFCCCC + bgcolor_cable: 0xCCFFCC + bgcolor_bundle: 0xCCCCFF + + +connectors: + X1: + pincount: 4 + bgcolor: 0xFF9999 + bgcolor_title: 0xFF6666 + X2: + pincount: 4 + X3: + pincount: 4 + color: GN + X: + pincount: 2 + F: + style: simple + +cables: + C1: + wirecount: 4 + bgcolor: 0x99FF99 + bgcolor_title: 0x66FF66 + C2: + wirecount: 4 + color: PK + W1: + wirecount: 2 + category: bundle + W2: + wirecount: 2 + category: bundle + bgcolor: 0x9999FF + bgcolor_title: 0x6666FF + +connections: + - + - X1: [1-4] + - C1: [1-4] + - X2: [1-4] + - C2: [1-4] + - X3: [1-4] + - + - X.X4: [1,2] + - W1: [1,2] + - X.X5: [1,2] + - W2: [1,2] + - F. diff --git a/tests/rendering/03_bgcolors_wv_gvpr.gvpr b/tests/rendering/03_bgcolors_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tests/rendering/03_bgcolors_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tutorial/readme.md b/tutorial/readme.md index 56f9cce..9f15c0c 100644 --- a/tutorial/readme.md +++ b/tutorial/readme.md @@ -27,7 +27,7 @@ connections: ![](tutorial01.png) -[Source](tutorial01.yml) - [Bill of Materials](tutorial01.bom.tsv) +[Source](tutorial01.yml) - [Bill of Materials](tutorial01.tsv) ## 02 - Adding parameters and colors @@ -68,7 +68,7 @@ connections: ![](tutorial02.png) -[Source](tutorial02.yml) - [Bill of Materials](tutorial02.bom.tsv) +[Source](tutorial02.yml) - [Bill of Materials](tutorial02.tsv) ## 03 - Pinouts, shielding, templates (I) @@ -110,7 +110,7 @@ connections: ![](tutorial03.png) -[Source](tutorial03.yml) - [Bill of Materials](tutorial03.bom.tsv) +[Source](tutorial03.yml) - [Bill of Materials](tutorial03.tsv) ## 04 - Templates (II), notes, American standards, daisy chaining (I) @@ -163,7 +163,7 @@ connections: ![](tutorial04.png) -[Source](tutorial04.yml) - [Bill of Materials](tutorial04.bom.tsv) +[Source](tutorial04.yml) - [Bill of Materials](tutorial04.tsv) ## 05 - Ferrules, wire bundles, custom wire colors @@ -209,7 +209,7 @@ connections: ![](tutorial05.png) -[Source](tutorial05.yml) - [Bill of Materials](tutorial05.bom.tsv) +[Source](tutorial05.yml) - [Bill of Materials](tutorial05.tsv) ## 06 - Custom ferrules @@ -252,7 +252,7 @@ connections: ![](tutorial06.png) -[Source](tutorial06.yml) - [Bill of Materials](tutorial06.bom.tsv) +[Source](tutorial06.yml) - [Bill of Materials](tutorial06.tsv) ## 07 - Daisy chaining (II) @@ -318,7 +318,7 @@ connections: ![](tutorial07.png) -[Source](tutorial07.yml) - [Bill of Materials](tutorial07.bom.tsv) +[Source](tutorial07.yml) - [Bill of Materials](tutorial07.tsv) ## 08 - Part numbers and additional components @@ -386,10 +386,9 @@ cables: pn: [WIRE1, WIRE2, WIRE2, WIRE3] # add a list of additional components to a part (shown in graph) additional_components: - - type: Sleve # short identifier used in graph + - type: Sleeve # short identifier used in graph subtype: Braided nylon, black, 3mm # extra information added to type in bom qty_multiplier: length # multipier for quantity (length of cable) - unit: m pn: SLV-1 connections: @@ -402,7 +401,7 @@ connections: additional_bom_items: - # define an additional item to add to the bill of materials (does not appear in graph) - description: Label, pinout information + type: Label, pinout information qty: 2 designators: - X2 @@ -414,6 +413,6 @@ additional_bom_items: ![](tutorial08.png) -[Source](tutorial08.yml) - [Bill of Materials](tutorial08.bom.tsv) +[Source](tutorial08.yml) - [Bill of Materials](tutorial08.tsv) diff --git a/tutorial/tutorial01.bom.tsv b/tutorial/tutorial01.bom.tsv index 78d7659..7490270 100644 --- a/tutorial/tutorial01.bom.tsv +++ b/tutorial/tutorial01.bom.tsv @@ -1,3 +1,3 @@ -Id Description Qty Unit Designators -1 Cable, 4 wires 1 m W1 -2 Connector, 4 pins 2 X1, X2 +# Qty Unit Description Designators +1 2 Connector, 4 pins X1, X2 +2 1 m Cable, 4 wires W1 diff --git a/tutorial/tutorial01.gv b/tutorial/tutorial01.gv index 7b53bf8..4505f76 100644 --- a/tutorial/tutorial01.gv +++ b/tutorial/tutorial01.gv @@ -1,164 +1,186 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - -
4-pin
-
- - - - - - - - - - - - - -
1
2
3
4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + +
4-pin
+
+ + + + + + + + + + + + + + + + + +
1
2
3
4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - -
4-pin
-
- - - - - - - - - - - - - -
1
2
3
4
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + +
4-pin
+
+ + + + + + + + + + + + + + + + + +
1
2
3
4
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + +
4x1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1 1 X2:1
X1:2 2 X2:2
X1:3 3 X2:3
X1:4 4 X2:4
 
+
+> shape=box style=filled] + edge [color="#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w - edge [color="#000000:#ffffff:#000000"] + edge [color="#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#ffffff:#000000"] + edge [color="#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p3l:w - edge [color="#000000:#ffffff:#000000"] + edge [color="#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=< - - - - -
- - -
W1
-
- - - -
4x1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
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] + W1:w1:e -- W1:w1:w [color="#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000" straight=straight] } diff --git a/tutorial/tutorial01.html b/tutorial/tutorial01.html index 0566981..3d5e0a9 100644 --- a/tutorial/tutorial01.html +++ b/tutorial/tutorial01.html @@ -1,7 +1,7 @@ - + tutorial01 - +

tutorial01

Diagram

@@ -30,139 +30,142 @@
- - - - + + + X1 - - -X1 - -4-pin - -1 - -2 - -3 - -4 + + + +X1 + +4-pin + +1 + +2 + +3 + +4 - + W1 - - -W1 - -4x - -1 m -  -X1:1 -     1     -X2:1 - - - -X1:2 -     2     -X2:2 - - - -X1:3 -     3     -X2:3 - - - -X1:4 -     4     -X2:4 - - - -  + + + +W1 + +4x + +1 m +  + X1:1 + +1 + +X2:1 + X1:2 + +2 + +X2:2 + X1:3 + +3 + +X2:3 + X1:4 + +4 + +X2:4 +  X1:e--W1:w - - - + + + + +X1:e--W1:w + X1:e--W1:w - - - + + +X1:e--W1:w + + + -X1:e--W1:w - - - +W1:e--W1:w + - + + +W1:e--W1:w + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + +W1:e--W1:w + - + X2 - - -X2 - -4-pin - -1 - -2 - -3 - -4 + + + +X2 + +4-pin + +1 + +2 + +3 + +4 - + W1:e--X2:w - - - + - + W1:e--X2:w - - - + - + W1:e--X2:w - - - + - + W1:e--X2:w - - - + @@ -178,26 +181,26 @@
- - + + - - - - - - - - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 4 wires1mW1
2Connector, 4 pins1 2 Connector, 4 pins X1, X2
21mCable, 4 wiresW1
diff --git a/tutorial/tutorial01.png b/tutorial/tutorial01.png index b94a390..b858f16 100644 Binary files a/tutorial/tutorial01.png and b/tutorial/tutorial01.png differ diff --git a/tutorial/tutorial01.svg b/tutorial/tutorial01.svg index 644ce4c..b3633a9 100644 --- a/tutorial/tutorial01.svg +++ b/tutorial/tutorial01.svg @@ -1,139 +1,142 @@ - - - - + + + X1 - - -X1 - -4-pin - -1 - -2 - -3 - -4 + + + +X1 + +4-pin + +1 + +2 + +3 + +4 - + W1 - - -W1 - -4x - -1 m -  -X1:1 -     1     -X2:1 - - - -X1:2 -     2     -X2:2 - - - -X1:3 -     3     -X2:3 - - - -X1:4 -     4     -X2:4 - - - -  + + + +W1 + +4x + +1 m +  + X1:1 + +1 + +X2:1 + X1:2 + +2 + +X2:2 + X1:3 + +3 + +X2:3 + X1:4 + +4 + +X2:4 +  X1:e--W1:w - - - + + + + +X1:e--W1:w + X1:e--W1:w - - - + + +X1:e--W1:w + + + -X1:e--W1:w - - - +W1:e--W1:w + - + + +W1:e--W1:w + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + +W1:e--W1:w + - + X2 - - -X2 - -4-pin - -1 - -2 - -3 - -4 + + + +X2 + +4-pin + +1 + +2 + +3 + +4 - + W1:e--X2:w - - - + - + W1:e--X2:w - - - + - + W1:e--X2:w - - - + - + W1:e--X2:w - - - + diff --git a/tutorial/tutorial01_wv_gvpr.gvpr b/tutorial/tutorial01_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tutorial/tutorial01_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tutorial/tutorial02.bom.tsv b/tutorial/tutorial02.bom.tsv index 582b78a..da57a6a 100644 --- a/tutorial/tutorial02.bom.tsv +++ b/tutorial/tutorial02.bom.tsv @@ -1,3 +1,3 @@ -Id Description Qty Unit Designators -1 Cable, 4 x 0.25 mm² 1 m W1 -2 Connector, Molex KK 254, female, 4 pins 2 X1, X2 +# Qty Unit Description Designators +1 2 Connector, Molex KK 254, female, 4 pins X1, X2 +2 1 m Cable, 4 x 0.25 mm² W1 diff --git a/tutorial/tutorial02.gv b/tutorial/tutorial02.gv index 7098d9a..5e80f29 100644 --- a/tutorial/tutorial02.gv +++ b/tutorial/tutorial02.gv @@ -1,169 +1,191 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - -
1
2
3
4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1
2
3
4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - -
1
2
3
4
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1
2
3
4
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
4x0.25 mm² (24 AWG)1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1 1:WH X2:1
X1:2 2:BN X2:2
X1:3 3:GN X2:4
X1:4 4:YE X2:3
 
+
+> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w edge [color="#000000:#895956:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p4l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p3l:w - W1 [label=< - - - - -
- - -
W1
-
- - - - -
4x0.25 mm² (24 AWG)1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1 - 1:WH - X2:1
- - - - -
-
X1:2 - 2:BN - X2:2
- - - - -
-
X1:3 - 3:GN - X2:4
- - - - -
-
X1:4 - 4:YE - X2:3
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + W1:w1:e -- W1:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#895956:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#00AA00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] } diff --git a/tutorial/tutorial02.html b/tutorial/tutorial02.html index 6252df9..ee740f6 100644 --- a/tutorial/tutorial02.html +++ b/tutorial/tutorial02.html @@ -1,7 +1,7 @@ - + tutorial02 - +

tutorial02

Diagram

@@ -30,149 +30,176 @@
- - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 - + W1 - - -W1 - -4x - -0.25 mm² (24 AWG) - -1 m -  -X1:1 -     1:WH     -X2:1 - - - -X1:2 -     2:BN     -X2:2 - - - -X1:3 -     3:GN     -X2:4 - - - -X1:4 -     4:YE     -X2:3 - - - -  + + + +W1 + +4x + +0.25 mm² (24 AWG) + +1 m +  + X1:1 + +1:WH + +X2:1 + X1:2 + +2:BN + +X2:2 + X1:3 + +3:GN + +X2:4 + X1:4 + +4:YE + +X2:3 +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + @@ -188,26 +215,26 @@
- - + + - - - - - - - - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 4 x 0.25 mm²1mW1
2Connector, Molex KK 254, female, 4 pins1 2 Connector, Molex KK 254, female, 4 pins X1, X2
21mCable, 4 x 0.25 mm²W1
diff --git a/tutorial/tutorial02.png b/tutorial/tutorial02.png index bba6a5b..78d7268 100644 Binary files a/tutorial/tutorial02.png and b/tutorial/tutorial02.png differ diff --git a/tutorial/tutorial02.svg b/tutorial/tutorial02.svg index 348b3d8..94c54b9 100644 --- a/tutorial/tutorial02.svg +++ b/tutorial/tutorial02.svg @@ -1,149 +1,176 @@ - - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 - + W1 - - -W1 - -4x - -0.25 mm² (24 AWG) - -1 m -  -X1:1 -     1:WH     -X2:1 - - - -X1:2 -     2:BN     -X2:2 - - - -X1:3 -     3:GN     -X2:4 - - - -X1:4 -     4:YE     -X2:3 - - - -  + + + +W1 + +4x + +0.25 mm² (24 AWG) + +1 m +  + X1:1 + +1:WH + +X2:1 + X1:2 + +2:BN + +X2:2 + X1:3 + +3:GN + +X2:4 + X1:4 + +4:YE + +X2:3 +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + diff --git a/tutorial/tutorial02_wv_gvpr.gvpr b/tutorial/tutorial02_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tutorial/tutorial02_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tutorial/tutorial03.bom.tsv b/tutorial/tutorial03.bom.tsv index 51f8e36..93fe12d 100644 --- a/tutorial/tutorial03.bom.tsv +++ b/tutorial/tutorial03.bom.tsv @@ -1,3 +1,3 @@ -Id Description Qty Unit Designators -1 Cable, 4 x 0.25 mm² shielded 1 m W1 -2 Connector, Molex KK 254, female, 4 pins 2 X1, X2 +# Qty Unit Description Designators +1 2 Connector, Molex KK 254, female, 4 pins X1, X2 +2 1 m Cable, 4 x 0.25 mm² shielded W1 diff --git a/tutorial/tutorial03.gv b/tutorial/tutorial03.gv index 7415055..562dcb3 100644 --- a/tutorial/tutorial03.gv +++ b/tutorial/tutorial03.gv @@ -1,187 +1,208 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
RX3
TX4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
RX3
TX4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3RX
4TX
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3RX
4TX
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffffff:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + + +
4x0.25 mm² (24 AWG)+ S1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND 1:WH X2:1:GND
X1:2:VCC 2:BN X2:2:VCC
X1:3:RX 3:GN X2:4:TX
X1:4:TX 4:YE X2:3:RX
 
X1:1:GND Shield
 
+
+> shape=box style=filled] + edge [color="#000000:#FFFFFF:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w edge [color="#000000:#895956:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#00ff00:#000000"] + edge [color="#000000:#00AA00:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p4l:w - edge [color="#000000:#ffff00:#000000"] + 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=< - - - - -
- - -
W1
-
- - - - - -
4x0.25 mm² (24 AWG)+ S1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - 1:WH - X2:1:GND
- - - - -
-
X1:2:VCC - 2:BN - X2:2:VCC
- - - - -
-
X1:3:RX - 3:GN - X2:4:TX
- - - - -
-
X1:4:TX - 4:YE - X2:3:RX
- - - - -
-
 
X1:1:GNDShield
 
-
-> fillcolor="#FFFFFF" shape=box style=filled] + X1:p1r:e -- W1:w5:w + W1:w1:e -- W1:w1:w [color="#000000:#FFFFFF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#895956:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#00AA00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w5:e -- W1:w5:w [color="#000000" straight=straight] } diff --git a/tutorial/tutorial03.html b/tutorial/tutorial03.html index 17ef045..28addd0 100644 --- a/tutorial/tutorial03.html +++ b/tutorial/tutorial03.html @@ -1,7 +1,7 @@ - + tutorial03 - +

tutorial03

Diagram

@@ -30,176 +30,210 @@
- - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -RX - -3 - -TX - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +RX + +3 + +TX + +4 - + W1 - - -W1 - -4x - -0.25 mm² (24 AWG) - -+ S - -1 m -  -X1:1:GND -     1:WH     -X2:1:GND - - - -X1:2:VCC -     2:BN     -X2:2:VCC - - - -X1:3:RX -     3:GN     -X2:4:TX - - - -X1:4:TX -     4:YE     -X2:3:RX - - - -  -X1:1:GND -Shield - -  + + + +W1 + +4x + +0.25 mm² (24 AWG) + ++ S + +1 m +  + X1:1:GND + +1:WH + +X2:1:GND + X1:2:VCC + +2:BN + +X2:2:VCC + X1:3:RX + +3:GN + +X2:4:TX + X1:4:TX + +4:YE + +X2:3:RX +  + X1:1:GND + +Shield + + +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - +W1:e--W1:w + + + + + + +W1:e--W1:w + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -RX - -4 - -TX + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + @@ -215,26 +249,26 @@
- - + + - - - - - - - - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 4 x 0.25 mm² shielded1mW1
2Connector, Molex KK 254, female, 4 pins1 2 Connector, Molex KK 254, female, 4 pins X1, X2
21mCable, 4 x 0.25 mm² shieldedW1
diff --git a/tutorial/tutorial03.png b/tutorial/tutorial03.png index 4bd8c39..131c743 100644 Binary files a/tutorial/tutorial03.png and b/tutorial/tutorial03.png differ diff --git a/tutorial/tutorial03.svg b/tutorial/tutorial03.svg index 5344fb8..06b5058 100644 --- a/tutorial/tutorial03.svg +++ b/tutorial/tutorial03.svg @@ -1,176 +1,210 @@ - - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -RX - -3 - -TX - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +RX + +3 + +TX + +4 - + W1 - - -W1 - -4x - -0.25 mm² (24 AWG) - -+ S - -1 m -  -X1:1:GND -     1:WH     -X2:1:GND - - - -X1:2:VCC -     2:BN     -X2:2:VCC - - - -X1:3:RX -     3:GN     -X2:4:TX - - - -X1:4:TX -     4:YE     -X2:3:RX - - - -  -X1:1:GND -Shield - -  + + + +W1 + +4x + +0.25 mm² (24 AWG) + ++ S + +1 m +  + X1:1:GND + +1:WH + +X2:1:GND + X1:2:VCC + +2:BN + +X2:2:VCC + X1:3:RX + +3:GN + +X2:4:TX + X1:4:TX + +4:YE + +X2:3:RX +  + X1:1:GND + +Shield + + +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - +W1:e--W1:w + + + + + + +W1:e--W1:w + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -RX - -4 - -TX + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +RX + +4 + +TX - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + - + W1:e--X2:w - - - + + + diff --git a/tutorial/tutorial03_wv_gvpr.gvpr b/tutorial/tutorial03_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tutorial/tutorial03_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tutorial/tutorial04.bom.tsv b/tutorial/tutorial04.bom.tsv index e2c3835..20975df 100644 --- a/tutorial/tutorial04.bom.tsv +++ b/tutorial/tutorial04.bom.tsv @@ -1,4 +1,4 @@ -Id Description Qty Unit Designators -1 Cable, 4 x 24 AWG 0.4 m W1, W2 -2 Connector, Molex KK 254, female, 4 pins 2 X2, X3 -3 Connector, Molex KK 254, male, 4 pins 1 X1 +# Qty Unit Description Designators +1 2 Connector, Molex KK 254, female, 4 pins X2, X3 +2 1 Connector, Molex KK 254, male, 4 pins X1 +3 2 m Cable, 4 x 24 AWG W1, W2 diff --git a/tutorial/tutorial04.gv b/tutorial/tutorial04.gv index 1e5a742..eb15335 100644 --- a/tutorial/tutorial04.gv +++ b/tutorial/tutorial04.gv @@ -1,340 +1,378 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - - +
- - -
X1
-
- - - - -
Molex KK 254male4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
SCL3
SDA4
-
- - -
to microcontroller
-
+ + + + + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254male4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
SCL3
SDA4
+
+ + + + +
to microcontroller
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - - +
- - -
X2
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - - - - - -
1GND1
2VCC2
3SCL3
4SDA4
-
- - -
to accelerometer
-
+ + + + + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + + + + + +
1GND1
2VCC2
3SCL3
4SDA4
+
+ + + + +
to accelerometer
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - - +
- - -
X3
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3SCL
4SDA
-
- - -
to temperature sensor
-
+ + + + + + + + + + + +
+ + + + +
X3
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3SCL
4SDA
+
+ + + + +
to temperature sensor
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
4x24 AWG0.3 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND 1:BN X2:1:GND
X1:2:VCC 2:RD X2:2:VCC
X1:3:SCL 3:OG X2:3:SCL
X1:4:SDA 4:YE X2:4:SDA
 
+
+ + + + +
This cable is a bit longer
+
+> 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"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#ff8000:#000000"] + edge [color="#000000:#FF8000:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p3l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=< - - - - - + W1:w1:e -- W1:w1:w [color="#000000:#895956:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FF8000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + W2 [label=< +
- - -
W1
-
- - - - -
4x24 AWG0.3 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - 1:BN - X2:1:GND
- - - - -
-
X1:2:VCC - 2:RD - X2:2:VCC
- - - - -
-
X1:3:SCL - 3:OG - X2:3:SCL
- - - - -
-
X1:4:SDA - 4:YE - X2:4:SDA
- - - - -
-
 
-
- - -
This cable is a bit longer
-
+ + + + + + + + + + + +
+ + + + +
W2
+
+ + + + + + +
4x24 AWG0.1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X2:1:GND 1:BN X3:1:GND
X2:2:VCC 2:RD X3:2:VCC
X2:3:SCL 3:OG X3:3:SCL
X2:4:SDA 4:YE X3:4:SDA
 
+
+ + + + +
This cable is a bit shorter
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] edge [color="#000000:#895956:#000000"] X2:p1r:e -- W2:w1:w W2:w1:e -- X3:p1l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X2:p2r:e -- W2:w2:w W2:w2:e -- X3:p2l:w - edge [color="#000000:#ff8000:#000000"] + edge [color="#000000:#FF8000:#000000"] X2:p3r:e -- W2:w3:w W2:w3:e -- X3:p3l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X2:p4r:e -- W2:w4:w W2:w4:e -- X3:p4l:w - W2 [label=< - - - - - -
- - -
W2
-
- - - - -
4x24 AWG0.1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X2:1:GND - 1:BN - X3:1:GND
- - - - -
-
X2:2:VCC - 2:RD - X3:2:VCC
- - - - -
-
X2:3:SCL - 3:OG - X3:3:SCL
- - - - -
-
X2:4:SDA - 4:YE - X3:4:SDA
- - - - -
-
 
-
- - -
This cable is a bit shorter
-
-> fillcolor="#FFFFFF" shape=box style=filled] + W2:w1:e -- W2:w1:w [color="#000000:#895956:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W2:w3:e -- W2:w3:w [color="#000000:#FF8000:#000000" straight=straight] + W2:w4:e -- W2:w4:w [color="#000000:#FFFF00:#000000" straight=straight] } diff --git a/tutorial/tutorial04.html b/tutorial/tutorial04.html index 408bb67..9a74a26 100644 --- a/tutorial/tutorial04.html +++ b/tutorial/tutorial04.html @@ -1,7 +1,7 @@ - + tutorial04 - +

tutorial04

Diagram

@@ -30,307 +30,360 @@
- - - - + + + X1 - - -X1 - -Molex KK 254 - -male - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 - -to microcontroller + + + +X1 + +Molex KK 254 + +male + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 + +to microcontroller - + W1 - - -W1 - -4x - -24 AWG - -0.3 m -  -X1:1:GND -     1:BN     -X2:1:GND - - - -X1:2:VCC -     2:RD     -X2:2:VCC - - - -X1:3:SCL -     3:OG     -X2:3:SCL - - - -X1:4:SDA -     4:YE     -X2:4:SDA - - - -  - -This cable is a bit longer + + + +W1 + +4x + +24 AWG + +0.3 m +  + X1:1:GND + +1:BN + +X2:1:GND + X1:2:VCC + +2:RD + +X2:2:VCC + X1:3:SCL + +3:OG + +X2:3:SCL + X1:4:SDA + +4:YE + +X2:4:SDA +  + +This cable is a bit longer X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -1 - -2 - -VCC - -2 - -3 - -SCL - -3 - -4 - -SDA - -4 - -to accelerometer + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +1 + +2 + +VCC + +2 + +3 + +SCL + +3 + +4 + +SDA + +4 + +to accelerometer + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + W2 - - -W2 - -4x - -24 AWG - -0.1 m -  -X2:1:GND -     1:BN     -X3:1:GND - - - -X2:2:VCC -     2:RD     -X3:2:VCC - - - -X2:3:SCL -     3:OG     -X3:3:SCL - - - -X2:4:SDA -     4:YE     -X3:4:SDA - - - -  - -This cable is a bit shorter - - - -X2:e--W2:w - - - - - - -X2:e--W2:w - - - + + + +W2 + +4x + +24 AWG + +0.1 m +  + X2:1:GND + +1:BN + +X3:1:GND + X2:2:VCC + +2:RD + +X3:2:VCC + X2:3:SCL + +3:OG + +X3:3:SCL + X2:4:SDA + +4:YE + +X3:4:SDA +  + +This cable is a bit shorter X2:e--W2:w - - - + + + + + + +X2:e--W2:w + + + X2:e--W2:w - - - + + + + + + +X2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA - -to temperature sensor - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - + + + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + +to temperature sensor - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + @@ -346,33 +399,33 @@
- - + + - - - - - - - - - + + - - + + + + + + + + +
IdDescription# Qty UnitDescription Designators
1Cable, 4 x 24 AWG0.4mW1, W2
2Connector, Molex KK 254, female, 4 pins1 2 Connector, Molex KK 254, female, 4 pins X2, X3
3Connector, Molex KK 254, male, 4 pins2 1 Connector, Molex KK 254, male, 4 pins X1
32mCable, 4 x 24 AWGW1, W2
diff --git a/tutorial/tutorial04.png b/tutorial/tutorial04.png index 6f7975a..55e64bf 100644 Binary files a/tutorial/tutorial04.png and b/tutorial/tutorial04.png differ diff --git a/tutorial/tutorial04.svg b/tutorial/tutorial04.svg index e101c73..1a9884f 100644 --- a/tutorial/tutorial04.svg +++ b/tutorial/tutorial04.svg @@ -1,307 +1,360 @@ - - - - + + + X1 - - -X1 - -Molex KK 254 - -male - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 - -to microcontroller + + + +X1 + +Molex KK 254 + +male + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 + +to microcontroller - + W1 - - -W1 - -4x - -24 AWG - -0.3 m -  -X1:1:GND -     1:BN     -X2:1:GND - - - -X1:2:VCC -     2:RD     -X2:2:VCC - - - -X1:3:SCL -     3:OG     -X2:3:SCL - - - -X1:4:SDA -     4:YE     -X2:4:SDA - - - -  - -This cable is a bit longer + + + +W1 + +4x + +24 AWG + +0.3 m +  + X1:1:GND + +1:BN + +X2:1:GND + X1:2:VCC + +2:RD + +X2:2:VCC + X1:3:SCL + +3:OG + +X2:3:SCL + X1:4:SDA + +4:YE + +X2:4:SDA +  + +This cable is a bit longer X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -1 - -2 - -VCC - -2 - -3 - -SCL - -3 - -4 - -SDA - -4 - -to accelerometer + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +1 + +2 + +VCC + +2 + +3 + +SCL + +3 + +4 + +SDA + +4 + +to accelerometer + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + W2 - - -W2 - -4x - -24 AWG - -0.1 m -  -X2:1:GND -     1:BN     -X3:1:GND - - - -X2:2:VCC -     2:RD     -X3:2:VCC - - - -X2:3:SCL -     3:OG     -X3:3:SCL - - - -X2:4:SDA -     4:YE     -X3:4:SDA - - - -  - -This cable is a bit shorter - - - -X2:e--W2:w - - - - - - -X2:e--W2:w - - - + + + +W2 + +4x + +24 AWG + +0.1 m +  + X2:1:GND + +1:BN + +X3:1:GND + X2:2:VCC + +2:RD + +X3:2:VCC + X2:3:SCL + +3:OG + +X3:3:SCL + X2:4:SDA + +4:YE + +X3:4:SDA +  + +This cable is a bit shorter X2:e--W2:w - - - + + + + + + +X2:e--W2:w + + + X2:e--W2:w - - - + + + + + + +X2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA - -to temperature sensor - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - + + + +X3 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + +to temperature sensor - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + diff --git a/tutorial/tutorial04_wv_gvpr.gvpr b/tutorial/tutorial04_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tutorial/tutorial04_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tutorial/tutorial05.bom.tsv b/tutorial/tutorial05.bom.tsv index 607f55b..3c01ee3 100644 --- a/tutorial/tutorial05.bom.tsv +++ b/tutorial/tutorial05.bom.tsv @@ -1,6 +1,6 @@ -Id Description Qty Unit Designators -1 Connector, Crimp ferrule, 0.5 mm², OG 4 -2 Connector, Molex 8981, female, 4 pins 1 X1 -3 Wire, 0.5 mm², BK 0.6 m W1 -4 Wire, 0.5 mm², RD 0.3 m W1 -5 Wire, 0.5 mm², YE 0.3 m W1 +# Qty Unit Description Designators +1 4 Connector, Crimp ferrule, 0.5 mm², OG +2 1 Connector, Molex 8981, female, 4 pins X1 +3 2 m Wire, 0.5 mm², BK W1 +4 1 m Wire, 0.5 mm², RD W1 +5 1 m Wire, 0.5 mm², YE W1 diff --git a/tutorial/tutorial05.gv b/tutorial/tutorial05.gv index 4140a13..754f718 100644 --- a/tutorial/tutorial05.gv +++ b/tutorial/tutorial05.gv @@ -1,189 +1,213 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] - __F1_1 [label=< - - + AUTOGENERATED_F1_1 [label=< +
- - - - - -
Crimp ferrule0.5 mm²OG
-
+ + +
+ + + + + + + +
Crimp ferrule0.5 mm²OG
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F1_2 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F1_2 [label=< +
- - - - - -
Crimp ferrule0.5 mm²OG
-
+ + +
+ + + + + + + +
Crimp ferrule0.5 mm²OG
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F1_3 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F1_3 [label=< +
- - - - - -
Crimp ferrule0.5 mm²OG
-
+ + +
+ + + + + + + +
Crimp ferrule0.5 mm²OG
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F1_4 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F1_4 [label=< +
- - - - - -
Crimp ferrule0.5 mm²OG
-
+ + +
+ + + + + + + +
Crimp ferrule0.5 mm²OG
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex 8981female4-pin
-
- - - - - - - - - - - - - - - - - -
1+12V
2GND
3GND
4+5V
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex 8981female4-pin
+
+ + + + + + + + + + + + + + + + + +
1+12V
2GND
3GND
4+5V
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffff00:#000000"] - __F1_1:e -- W1:w1:w +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
4x0.5 mm²0.3 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
YE X1:1:+12V
BK X1:2:GND
BK X1:3:GND
RD X1:4:+5V
 
+
+> shape=box style="filled,dashed"] + edge [color="#000000:#FFFF00:#000000"] + AUTOGENERATED_F1_1:e -- W1:w1:w W1:w1:e -- X1:p1l:w edge [color="#000000:#000000:#000000"] - __F1_2:e -- W1:w2:w + AUTOGENERATED_F1_2:e -- W1:w2:w W1:w2:e -- X1:p2l:w edge [color="#000000:#000000:#000000"] - __F1_3:e -- W1:w3:w + AUTOGENERATED_F1_3:e -- W1:w3:w W1:w3:e -- X1:p3l:w - edge [color="#000000:#ff0000:#000000"] - __F1_4:e -- W1:w4:w + edge [color="#000000:#FF0000:#000000"] + AUTOGENERATED_F1_4:e -- W1:w4:w W1:w4:e -- X1:p4l:w - W1 [label=< - - - - -
- - -
W1
-
- - - - -
4x0.5 mm²0.3 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- YE - X1:1:+12V
- - - - -
-
- BK - X1:2:GND
- - - - -
-
- BK - X1:3:GND
- - - - -
-
- RD - X1:4:+5V
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] + W1:w1:e -- W1:w1:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#000000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#000000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FF0000:#000000" straight=straight] } diff --git a/tutorial/tutorial05.html b/tutorial/tutorial05.html index 1555922..de99449 100644 --- a/tutorial/tutorial05.html +++ b/tutorial/tutorial05.html @@ -1,7 +1,7 @@ - + tutorial05 - +

tutorial05

Diagram

@@ -30,184 +30,218 @@
- - - - - + + + + -__F1_1 - - -Crimp ferrule - -0.5 mm² - -OG - - +AUTOGENERATED_F1_1 + + + +Crimp ferrule + +0.5 mm² + +OG + + - -W1 - - -W1 - -4x - -0.5 mm² - -0.3 m -  -     YE     -X1:1:+12V - - - -     BK     -X1:2:GND - - - -     BK     -X1:3:GND - - - -     RD     -X1:4:+5V - - - -  - - - -__F1_1:e--W1:w - - - - - -__F1_2 - - -Crimp ferrule - -0.5 mm² - -OG - - +W1 + + + +W1 + +4x + +0.5 mm² + +0.3 m +  + + +YE + +X1:1:+12V + + +BK + +X1:2:GND + + +BK + +X1:3:GND + + +RD + +X1:4:+5V +  - + + +AUTOGENERATED_F1_1:e--W1:w + + + + + + +W1:e--W1:w + + + + + -__F1_2:e--W1:w - - - +W1:e--W1:w + + + - - -__F1_3 - - -Crimp ferrule - -0.5 mm² - -OG - - + + +W1:e--W1:w + + + - + -__F1_3:e--W1:w - - - - - - -__F1_4 - - -Crimp ferrule - -0.5 mm² - -OG - - - - - -__F1_4:e--W1:w - - - +W1:e--W1:w + + + - + X1 - - -X1 - -Molex 8981 - -female - -4-pin - -1 - -+12V - -2 - -GND - -3 - -GND - -4 - -+5V - - - -W1:e--X1:w - - - - - - -W1:e--X1:w - - - + + + +X1 + +Molex 8981 + +female + +4-pin + +1 + ++12V + +2 + +GND + +3 + +GND + +4 + ++5V W1:e--X1:w - - - + + + + + + +W1:e--X1:w + + + W1:e--X1:w - - - + + + + + + +W1:e--X1:w + + + + + + +AUTOGENERATED_F1_2 + + + +Crimp ferrule + +0.5 mm² + +OG + + + + + +AUTOGENERATED_F1_2:e--W1:w + + + + + + +AUTOGENERATED_F1_3 + + + +Crimp ferrule + +0.5 mm² + +OG + + + + + +AUTOGENERATED_F1_3:e--W1:w + + + + + + +AUTOGENERATED_F1_4 + + + +Crimp ferrule + +0.5 mm² + +OG + + + + + +AUTOGENERATED_F1_4:e--W1:w + + + @@ -223,45 +257,45 @@
- - + + - - + + - - + + - + + + - - - + + + - - - - - + + +
IdDescription# Qty UnitDescription Designators
1Connector, Crimp ferrule, 0.5 mm², OG1 4 Connector, Crimp ferrule, 0.5 mm², OG
2Connector, Molex 8981, female, 4 pins2 1 Connector, Molex 8981, female, 4 pins X1
332m Wire, 0.5 mm², BK0.6m W1
441m Wire, 0.5 mm², RD0.3m W1
5Wire, 0.5 mm², YE0.351 mWire, 0.5 mm², YE W1
diff --git a/tutorial/tutorial05.png b/tutorial/tutorial05.png index 44e745a..d0c6e81 100644 Binary files a/tutorial/tutorial05.png and b/tutorial/tutorial05.png differ diff --git a/tutorial/tutorial05.svg b/tutorial/tutorial05.svg index 4f36ca3..5d02c4a 100644 --- a/tutorial/tutorial05.svg +++ b/tutorial/tutorial05.svg @@ -1,184 +1,218 @@ - - - - - + + + + -__F1_1 - - -Crimp ferrule - -0.5 mm² - -OG - - +AUTOGENERATED_F1_1 + + + +Crimp ferrule + +0.5 mm² + +OG + + - -W1 - - -W1 - -4x - -0.5 mm² - -0.3 m -  -     YE     -X1:1:+12V - - - -     BK     -X1:2:GND - - - -     BK     -X1:3:GND - - - -     RD     -X1:4:+5V - - - -  - - - -__F1_1:e--W1:w - - - - - -__F1_2 - - -Crimp ferrule - -0.5 mm² - -OG - - +W1 + + + +W1 + +4x + +0.5 mm² + +0.3 m +  + + +YE + +X1:1:+12V + + +BK + +X1:2:GND + + +BK + +X1:3:GND + + +RD + +X1:4:+5V +  - + + +AUTOGENERATED_F1_1:e--W1:w + + + + + + +W1:e--W1:w + + + + + -__F1_2:e--W1:w - - - +W1:e--W1:w + + + - - -__F1_3 - - -Crimp ferrule - -0.5 mm² - -OG - - + + +W1:e--W1:w + + + - + -__F1_3:e--W1:w - - - - - - -__F1_4 - - -Crimp ferrule - -0.5 mm² - -OG - - - - - -__F1_4:e--W1:w - - - +W1:e--W1:w + + + - + X1 - - -X1 - -Molex 8981 - -female - -4-pin - -1 - -+12V - -2 - -GND - -3 - -GND - -4 - -+5V - - - -W1:e--X1:w - - - - - - -W1:e--X1:w - - - + + + +X1 + +Molex 8981 + +female + +4-pin + +1 + ++12V + +2 + +GND + +3 + +GND + +4 + ++5V W1:e--X1:w - - - + + + + + + +W1:e--X1:w + + + W1:e--X1:w - - - + + + + + + +W1:e--X1:w + + + + + + +AUTOGENERATED_F1_2 + + + +Crimp ferrule + +0.5 mm² + +OG + + + + + +AUTOGENERATED_F1_2:e--W1:w + + + + + + +AUTOGENERATED_F1_3 + + + +Crimp ferrule + +0.5 mm² + +OG + + + + + +AUTOGENERATED_F1_3:e--W1:w + + + + + + +AUTOGENERATED_F1_4 + + + +Crimp ferrule + +0.5 mm² + +OG + + + + + +AUTOGENERATED_F1_4:e--W1:w + + + diff --git a/tutorial/tutorial05_wv_gvpr.gvpr b/tutorial/tutorial05_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tutorial/tutorial05_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tutorial/tutorial06.bom.tsv b/tutorial/tutorial06.bom.tsv index b86b323..8dd2bff 100644 --- a/tutorial/tutorial06.bom.tsv +++ b/tutorial/tutorial06.bom.tsv @@ -1,7 +1,7 @@ -Id Description Qty Unit Designators -1 Connector, Crimp ferrule, 0.5 mm², OG 2 -2 Connector, Crimp ferrule, 1.0 mm², YE 1 -3 Connector, Molex 8981, female, 4 pins 1 X1 -4 Wire, 0.5 mm², BK 0.6 m W1 -5 Wire, 0.5 mm², RD 0.3 m W1 -6 Wire, 0.5 mm², YE 0.3 m W1 +# Qty Unit Description Designators +1 2 Connector, Crimp ferrule, 0.5 mm², OG +2 1 Connector, Crimp ferrule, 1.0 mm², YE F1 +3 1 Connector, Molex 8981, female, 4 pins X1 +4 2 m Wire, 0.5 mm², BK W1 +5 1 m Wire, 0.5 mm², RD W1 +6 1 m Wire, 0.5 mm², YE W1 diff --git a/tutorial/tutorial06.gv b/tutorial/tutorial06.gv index 2976b7d..c9daeb7 100644 --- a/tutorial/tutorial06.gv +++ b/tutorial/tutorial06.gv @@ -1,83 +1,185 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] - __F_05_1 [label=< - - + AUTOGENERATED_F_05_1 [label=< +
- - - - - -
Crimp ferrule0.5 mm²OG
-
+ + +
+ + + + + + + +
Crimp ferrule0.5 mm²OG
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] F1 [label=< - - +
- - - - - -
Crimp ferrule1.0 mm²YE
-
+ + +
+ + + + + + + +
Crimp ferrule1.0 mm²YE
+
-> fillcolor="#FFFFFF" shape=box style=filled] - __F_05_2 [label=< - - +> shape=box style=filled] + AUTOGENERATED_F_05_2 [label=< +
- - - - - -
Crimp ferrule0.5 mm²OG
-
+ + +
+ + + + + + + +
Crimp ferrule0.5 mm²OG
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex 8981female4-pin
-
- - - - - - - - - - - - - - - - - -
1+12V
2GND
3GND
4+5V
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex 8981female4-pin
+
+ + + + + + + + + + + + + + + + + +
1+12V
2GND
3GND
4+5V
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffff00:#000000"] - __F_05_1:e -- W1:w1:w +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
4x0.5 mm²0.3 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
YE X1:1:+12V
F1 BK X1:2:GND
F1 BK X1:3:GND
RD X1:4:+5V
 
+
+> shape=box style="filled,dashed"] + edge [color="#000000:#FFFF00:#000000"] + AUTOGENERATED_F_05_1:e -- W1:w1:w W1:w1:e -- X1:p1l:w edge [color="#000000:#000000:#000000"] F1:e -- W1:w2:w @@ -85,93 +187,11 @@ graph { edge [color="#000000:#000000:#000000"] F1:e -- W1:w3:w W1:w3:e -- X1:p3l:w - edge [color="#000000:#ff0000:#000000"] - __F_05_2:e -- W1:w4:w + edge [color="#000000:#FF0000:#000000"] + AUTOGENERATED_F_05_2:e -- W1:w4:w W1:w4:e -- X1:p4l:w - W1 [label=< - - - - -
- - -
W1
-
- - - - -
4x0.5 mm²0.3 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
- YE - X1:1:+12V
- - - - -
-
- BK - X1:2:GND
- - - - -
-
- BK - X1:3:GND
- - - - -
-
- RD - X1:4:+5V
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] + W1:w1:e -- W1:w1:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#000000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#000000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FF0000:#000000" straight=straight] } diff --git a/tutorial/tutorial06.html b/tutorial/tutorial06.html index ce969a8..0a1ea19 100644 --- a/tutorial/tutorial06.html +++ b/tutorial/tutorial06.html @@ -1,7 +1,7 @@ - + tutorial06 - +

tutorial06

Diagram

@@ -30,171 +30,204 @@
- - - - - + + + + -__F_05_1 - - -Crimp ferrule - -0.5 mm² - -OG - - +AUTOGENERATED_F_05_1 + + + +Crimp ferrule + +0.5 mm² + +OG + + - -W1 - - -W1 - -4x - -0.5 mm² - -0.3 m -  -     YE     -X1:1:+12V - - - -     BK     -X1:2:GND - - - -     BK     -X1:3:GND - - - -     RD     -X1:4:+5V - - - -  - - - -__F_05_1:e--W1:w - - - - - -F1 - - -Crimp ferrule - -1.0 mm² - -YE - - +W1 + + + +W1 + +4x + +0.5 mm² + +0.3 m +  + + +YE + +X1:1:+12V + F1 + +BK + +X1:2:GND + F1 + +BK + +X1:3:GND + + +RD + +X1:4:+5V +  - + + +AUTOGENERATED_F_05_1:e--W1:w + + + + + + +W1:e--W1:w + + + + + -F1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -F1:e--W1:w - - - - - - -__F_05_2 - - -Crimp ferrule - -0.5 mm² - -OG - - - - - -__F_05_2:e--W1:w - - - +W1:e--W1:w + + + - + X1 - - -X1 - -Molex 8981 - -female - -4-pin - -1 - -+12V - -2 - -GND - -3 - -GND - -4 - -+5V - - - -W1:e--X1:w - - - - - - -W1:e--X1:w - - - + + + +X1 + +Molex 8981 + +female + +4-pin + +1 + ++12V + +2 + +GND + +3 + +GND + +4 + ++5V W1:e--X1:w - - - + + + + + + +W1:e--X1:w + + + W1:e--X1:w - - - + + + + + + +W1:e--X1:w + + + + + + +F1 + + + +Crimp ferrule + +1.0 mm² + +YE + + + + + +F1:e--W1:w + + + + + + +F1:e--W1:w + + + + + + +AUTOGENERATED_F_05_2 + + + +Crimp ferrule + +0.5 mm² + +OG + + + + + +AUTOGENERATED_F_05_2:e--W1:w + + + @@ -210,52 +243,52 @@
- - + + - - + + - + + + - - - + - - + + - + + + - - - + + + - - - - - + + +
IdDescription# Qty UnitDescription Designators
1Connector, Crimp ferrule, 0.5 mm², OG1 2 Connector, Crimp ferrule, 0.5 mm², OG
221 Connector, Crimp ferrule, 1.0 mm², YE1F1
3Connector, Molex 8981, female, 4 pins3 1 Connector, Molex 8981, female, 4 pins X1
442m Wire, 0.5 mm², BK0.6m W1
551m Wire, 0.5 mm², RD0.3m W1
6Wire, 0.5 mm², YE0.361 mWire, 0.5 mm², YE W1
diff --git a/tutorial/tutorial06.png b/tutorial/tutorial06.png index 43e00cb..fbc8c08 100644 Binary files a/tutorial/tutorial06.png and b/tutorial/tutorial06.png differ diff --git a/tutorial/tutorial06.svg b/tutorial/tutorial06.svg index 973fc23..5bf6e09 100644 --- a/tutorial/tutorial06.svg +++ b/tutorial/tutorial06.svg @@ -1,171 +1,204 @@ - - - - - + + + + -__F_05_1 - - -Crimp ferrule - -0.5 mm² - -OG - - +AUTOGENERATED_F_05_1 + + + +Crimp ferrule + +0.5 mm² + +OG + + - -W1 - - -W1 - -4x - -0.5 mm² - -0.3 m -  -     YE     -X1:1:+12V - - - -     BK     -X1:2:GND - - - -     BK     -X1:3:GND - - - -     RD     -X1:4:+5V - - - -  - - - -__F_05_1:e--W1:w - - - - - -F1 - - -Crimp ferrule - -1.0 mm² - -YE - - +W1 + + + +W1 + +4x + +0.5 mm² + +0.3 m +  + + +YE + +X1:1:+12V + F1 + +BK + +X1:2:GND + F1 + +BK + +X1:3:GND + + +RD + +X1:4:+5V +  - + + +AUTOGENERATED_F_05_1:e--W1:w + + + + + + +W1:e--W1:w + + + + + -F1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -F1:e--W1:w - - - - - - -__F_05_2 - - -Crimp ferrule - -0.5 mm² - -OG - - - - - -__F_05_2:e--W1:w - - - +W1:e--W1:w + + + - + X1 - - -X1 - -Molex 8981 - -female - -4-pin - -1 - -+12V - -2 - -GND - -3 - -GND - -4 - -+5V - - - -W1:e--X1:w - - - - - - -W1:e--X1:w - - - + + + +X1 + +Molex 8981 + +female + +4-pin + +1 + ++12V + +2 + +GND + +3 + +GND + +4 + ++5V W1:e--X1:w - - - + + + + + + +W1:e--X1:w + + + W1:e--X1:w - - - + + + + + + +W1:e--X1:w + + + + + + +F1 + + + +Crimp ferrule + +1.0 mm² + +YE + + + + + +F1:e--W1:w + + + + + + +F1:e--W1:w + + + + + + +AUTOGENERATED_F_05_2 + + + +Crimp ferrule + +0.5 mm² + +OG + + + + + +AUTOGENERATED_F_05_2:e--W1:w + + + diff --git a/tutorial/tutorial06_wv_gvpr.gvpr b/tutorial/tutorial06_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tutorial/tutorial06_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tutorial/tutorial07.bom.tsv b/tutorial/tutorial07.bom.tsv index 534bad6..62377db 100644 --- a/tutorial/tutorial07.bom.tsv +++ b/tutorial/tutorial07.bom.tsv @@ -1,6 +1,6 @@ -Id Description Qty Unit Designators -1 Connector, Molex KK 254, female, 4 pins 6 X1, X2, X3, X4, X5, X6 -2 Wire, 0.25 mm², PK 1 m W1, W2, W3, W4, W5 -3 Wire, 0.25 mm², TQ 1 m W1, W2, W3, W4, W5 -4 Wire, 0.25 mm², VT 1 m W1, W2, W3, W4, W5 -5 Wire, 0.25 mm², YE 1 m W1, W2, W3, W4, W5 +# Qty Unit Description Designators +1 6 Connector, Molex KK 254, female, 4 pins X1, X2, X3, X4, X5, X6 +2 5 m Wire, 0.25 mm², PK W1, W2, W3, W4, W5 +3 5 m Wire, 0.25 mm², TQ W1, W2, W3, W4, W5 +4 5 m Wire, 0.25 mm², VT W1, W2, W3, W4, W5 +5 5 m Wire, 0.25 mm², YE W1, W2, W3, W4, W5 diff --git a/tutorial/tutorial07.gv b/tutorial/tutorial07.gv index d2c45b9..9a3cbbd 100644 --- a/tutorial/tutorial07.gv +++ b/tutorial/tutorial07.gv @@ -1,713 +1,763 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - +
- - -
X1
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
SCL3
SDA4
-
+ + + + + + + + +
+ + + + +
X1
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
SCL3
SDA4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - +
- - -
X2
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - +
- - -
X3
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
SCL3
SDA4
-
+ + + + + + + + +
+ + + + +
X3
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
SCL3
SDA4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X4 [label=< - - - - +
- - -
X4
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X4
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X5 [label=< - - - - +
- - -
X5
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
GND1
VCC2
SCL3
SDA4
-
+ + + + + + + + +
+ + + + +
X5
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
GND1
VCC2
SCL3
SDA4
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X6 [label=< - - - - +
- - -
X6
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - - - - - -
1GND
2VCC
3SCL
4SDA
-
+ + + + + + + + +
+ + + + +
X6
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1GND
2VCC
3SCL
4SDA
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#00ffff:#000000"] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1:GND TQ X2:1:GND
X1:2:VCC PK X2:2:VCC
X1:3:SCL YE X2:3:SCL
X1:4:SDA VT X2:4:SDA
 
+
+> shape=box style="filled,dashed"] + edge [color="#000000:#00FFFF:#000000"] X1:p1r:e -- W1:w1:w W1:w1:e -- X2:p1l:w - edge [color="#000000:#ff66cc:#000000"] + edge [color="#000000:#FF66CC:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=< - - - - + W1:w1:e -- W1:w1:w [color="#000000:#00FFFF:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF66CC:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W2 [label=< +
- - -
W1
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1:GND - TQ - X2:1:GND
- - - - -
-
X1:2:VCC - PK - X2:2:VCC
- - - - -
-
X1:3:SCL - YE - X2:3:SCL
- - - - -
-
X1:4:SDA - VT - X2:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W2
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X3:1:GND TQ X2:1:GND
X3:2:VCC PK X2:2:VCC
X3:3:SCL YE X2:3:SCL
X3:4:SDA VT X2:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#00ffff:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#00FFFF:#000000"] X3:p1r:e -- W2:w1:w W2:w1:e -- X2:p1l:w - edge [color="#000000:#ff66cc:#000000"] + edge [color="#000000:#FF66CC:#000000"] X3:p2r:e -- W2:w2:w W2:w2:e -- X2:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X3:p3r:e -- W2:w3:w W2:w3:e -- X2:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X3:p4r:e -- W2:w4:w W2:w4:e -- X2:p4l:w - W2 [label=< - - - - + W2:w1:e -- W2:w1:w [color="#000000:#00FFFF:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#FF66CC:#000000" straight=straight] + W2:w3:e -- W2:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W2:w4:e -- W2:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W3 [label=< +
- - -
W2
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X3:1:GND - TQ - X2:1:GND
- - - - -
-
X3:2:VCC - PK - X2:2:VCC
- - - - -
-
X3:3:SCL - YE - X2:3:SCL
- - - - -
-
X3:4:SDA - VT - X2:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W3
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X3:1:GND TQ X4:1:GND
X3:2:VCC PK X4:2:VCC
X3:3:SCL YE X4:3:SCL
X3:4:SDA VT X4:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#00ffff:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#00FFFF:#000000"] X3:p1r:e -- W3:w1:w W3:w1:e -- X4:p1l:w - edge [color="#000000:#ff66cc:#000000"] + edge [color="#000000:#FF66CC:#000000"] X3:p2r:e -- W3:w2:w W3:w2:e -- X4:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X3:p3r:e -- W3:w3:w W3:w3:e -- X4:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X3:p4r:e -- W3:w4:w W3:w4:e -- X4:p4l:w - W3 [label=< - - - - + W3:w1:e -- W3:w1:w [color="#000000:#00FFFF:#000000" straight=straight] + W3:w2:e -- W3:w2:w [color="#000000:#FF66CC:#000000" straight=straight] + W3:w3:e -- W3:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W3:w4:e -- W3:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W4 [label=< +
- - -
W3
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X3:1:GND - TQ - X4:1:GND
- - - - -
-
X3:2:VCC - PK - X4:2:VCC
- - - - -
-
X3:3:SCL - YE - X4:3:SCL
- - - - -
-
X3:4:SDA - VT - X4:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W4
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X5:1:GND TQ X4:1:GND
X5:2:VCC PK X4:2:VCC
X5:3:SCL YE X4:3:SCL
X5:4:SDA VT X4:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#00ffff:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#00FFFF:#000000"] X5:p1r:e -- W4:w1:w W4:w1:e -- X4:p1l:w - edge [color="#000000:#ff66cc:#000000"] + edge [color="#000000:#FF66CC:#000000"] X5:p2r:e -- W4:w2:w W4:w2:e -- X4:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X5:p3r:e -- W4:w3:w W4:w3:e -- X4:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X5:p4r:e -- W4:w4:w W4:w4:e -- X4:p4l:w - W4 [label=< - - - - + W4:w1:e -- W4:w1:w [color="#000000:#00FFFF:#000000" straight=straight] + W4:w2:e -- W4:w2:w [color="#000000:#FF66CC:#000000" straight=straight] + W4:w3:e -- W4:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W4:w4:e -- W4:w4:w [color="#000000:#8000FF:#000000" straight=straight] + W5 [label=< +
- - -
W4
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X5:1:GND - TQ - X4:1:GND
- - - - -
-
X5:2:VCC - PK - X4:2:VCC
- - - - -
-
X5:3:SCL - YE - X4:3:SCL
- - - - -
-
X5:4:SDA - VT - X4:4:SDA
- - - - -
-
 
-
+ + + + + + + + +
+ + + + +
W5
+
+ + + + + + +
4x0.25 mm²0.2 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X5:1:GND TQ X6:1:GND
X5:2:VCC PK X6:2:VCC
X5:3:SCL YE X6:3:SCL
X5:4:SDA VT X6:4:SDA
 
+
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] - edge [color="#000000:#00ffff:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#00FFFF:#000000"] X5:p1r:e -- W5:w1:w W5:w1:e -- X6:p1l:w - edge [color="#000000:#ff66cc:#000000"] + edge [color="#000000:#FF66CC:#000000"] X5:p2r:e -- W5:w2:w W5:w2:e -- X6:p2l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X5:p3r:e -- W5:w3:w W5:w3:e -- X6:p3l:w - edge [color="#000000:#8000ff:#000000"] + edge [color="#000000:#8000FF:#000000"] X5:p4r:e -- W5:w4:w W5:w4:e -- X6:p4l:w - W5 [label=< - - - - -
- - -
W5
-
- - - - -
4x0.25 mm²0.2 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X5:1:GND - TQ - X6:1:GND
- - - - -
-
X5:2:VCC - PK - X6:2:VCC
- - - - -
-
X5:3:SCL - YE - X6:3:SCL
- - - - -
-
X5:4:SDA - VT - X6:4:SDA
- - - - -
-
 
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] + W5:w1:e -- W5:w1:w [color="#000000:#00FFFF:#000000" straight=straight] + W5:w2:e -- W5:w2:w [color="#000000:#FF66CC:#000000" straight=straight] + W5:w3:e -- W5:w3:w [color="#000000:#FFFF00:#000000" straight=straight] + W5:w4:e -- W5:w4:w [color="#000000:#8000FF:#000000" straight=straight] } diff --git a/tutorial/tutorial07.html b/tutorial/tutorial07.html index 22be913..4acf4fa 100644 --- a/tutorial/tutorial07.html +++ b/tutorial/tutorial07.html @@ -1,7 +1,7 @@ - + tutorial07 - +

tutorial07

Diagram

@@ -30,661 +30,792 @@
- - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W1 - - -W1 - -4x - -0.25 mm² - -0.2 m -  -X1:1:GND -     TQ     -X2:1:GND - - - -X1:2:VCC -     PK     -X2:2:VCC - - - -X1:3:SCL -     YE     -X2:3:SCL - - - -X1:4:SDA -     VT     -X2:4:SDA - - - -  + + + +W1 + +4x + +0.25 mm² + +0.2 m +  + X1:1:GND + +TQ + +X2:1:GND + X1:2:VCC + +PK + +X2:2:VCC + X1:3:SCL + +YE + +X2:3:SCL + X1:4:SDA + +VT + +X2:4:SDA +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X3 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W2 - - -W2 - -4x - -0.25 mm² - -0.2 m -  -X3:1:GND -     TQ     -X2:1:GND - - - -X3:2:VCC -     PK     -X2:2:VCC - - - -X3:3:SCL -     YE     -X2:3:SCL - - - -X3:4:SDA -     VT     -X2:4:SDA - - - -  - - - -X3:e--W2:w - - - - - - -X3:e--W2:w - - - + + + +W2 + +4x + +0.25 mm² + +0.2 m +  + X3:1:GND + +TQ + +X2:1:GND + X3:2:VCC + +PK + +X2:2:VCC + X3:3:SCL + +YE + +X2:3:SCL + X3:4:SDA + +VT + +X2:4:SDA +  X3:e--W2:w - - - + + + + + + +X3:e--W2:w + + + X3:e--W2:w - - - + + + + + + +X3:e--W2:w + + + - + W3 - - -W3 - -4x - -0.25 mm² - -0.2 m -  -X3:1:GND -     TQ     -X4:1:GND - - - -X3:2:VCC -     PK     -X4:2:VCC - - - -X3:3:SCL -     YE     -X4:3:SCL - - - -X3:4:SDA -     VT     -X4:4:SDA - - - -  + + + +W3 + +4x + +0.25 mm² + +0.2 m +  + X3:1:GND + +TQ + +X4:1:GND + X3:2:VCC + +PK + +X4:2:VCC + X3:3:SCL + +YE + +X4:3:SCL + X3:4:SDA + +VT + +X4:4:SDA +  X3:e--W3:w - - - + + + + + + +X3:e--W3:w + + + X3:e--W3:w - - - + + + + +X3:e--W3:w + + + + + -X3:e--W3:w - - - +W2:e--X2:w + + + - + + +W2:e--X2:w + + + + + -X3:e--W3:w - - - +W2:e--X2:w + + + + + + +W2:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + - + X4 - - -X4 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA + + + +X4 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + - + X5 - - -X5 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X5 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W4 - - -W4 - -4x - -0.25 mm² - -0.2 m -  -X5:1:GND -     TQ     -X4:1:GND - - - -X5:2:VCC -     PK     -X4:2:VCC - - - -X5:3:SCL -     YE     -X4:3:SCL - - - -X5:4:SDA -     VT     -X4:4:SDA - - - -  + + + +W4 + +4x + +0.25 mm² + +0.2 m +  + X5:1:GND + +TQ + +X4:1:GND + X5:2:VCC + +PK + +X4:2:VCC + X5:3:SCL + +YE + +X4:3:SCL + X5:4:SDA + +VT + +X4:4:SDA +  - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + W5 - - -W5 - -4x - -0.25 mm² - -0.2 m -  -X5:1:GND -     TQ     -X6:1:GND - - - -X5:2:VCC -     PK     -X6:2:VCC - - - -X5:3:SCL -     YE     -X6:3:SCL - - - -X5:4:SDA -     VT     -X6:4:SDA - - - -  + + + +W5 + +4x + +0.25 mm² + +0.2 m +  + X5:1:GND + +TQ + +X6:1:GND + X5:2:VCC + +PK + +X6:2:VCC + X5:3:SCL + +YE + +X6:3:SCL + X5:4:SDA + +VT + +X6:4:SDA +  - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + - + X6 - - -X6 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - + + + +X6 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + @@ -700,45 +831,45 @@
- - + + - - + + - + + + - - - + + + - - - + + + - - - - - + + +
IdDescription# Qty UnitDescription Designators
1Connector, Molex KK 254, female, 4 pins1 6 Connector, Molex KK 254, female, 4 pins X1, X2, X3, X4, X5, X6
225m Wire, 0.25 mm², PK1m W1, W2, W3, W4, W5
335m Wire, 0.25 mm², TQ1m W1, W2, W3, W4, W5
445m Wire, 0.25 mm², VT1m W1, W2, W3, W4, W5
5Wire, 0.25 mm², YE155 mWire, 0.25 mm², YE W1, W2, W3, W4, W5
diff --git a/tutorial/tutorial07.png b/tutorial/tutorial07.png index c919e02..f16f1c4 100644 Binary files a/tutorial/tutorial07.png and b/tutorial/tutorial07.png differ diff --git a/tutorial/tutorial07.svg b/tutorial/tutorial07.svg index a278a87..69138a8 100644 --- a/tutorial/tutorial07.svg +++ b/tutorial/tutorial07.svg @@ -1,661 +1,792 @@ - - - - + + + X1 - - -X1 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X1 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W1 - - -W1 - -4x - -0.25 mm² - -0.2 m -  -X1:1:GND -     TQ     -X2:1:GND - - - -X1:2:VCC -     PK     -X2:2:VCC - - - -X1:3:SCL -     YE     -X2:3:SCL - - - -X1:4:SDA -     VT     -X2:4:SDA - - - -  + + + +W1 + +4x + +0.25 mm² + +0.2 m +  + X1:1:GND + +TQ + +X2:1:GND + X1:2:VCC + +PK + +X2:2:VCC + X1:3:SCL + +YE + +X2:3:SCL + X1:4:SDA + +VT + +X2:4:SDA +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + + +X1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W1:w - - - +W1:e--W1:w + + + + + + +W1:e--W1:w + + + - + X2 - - -X2 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA + + + +X2 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + - + X3 - - -X3 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X3 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W2 - - -W2 - -4x - -0.25 mm² - -0.2 m -  -X3:1:GND -     TQ     -X2:1:GND - - - -X3:2:VCC -     PK     -X2:2:VCC - - - -X3:3:SCL -     YE     -X2:3:SCL - - - -X3:4:SDA -     VT     -X2:4:SDA - - - -  - - - -X3:e--W2:w - - - - - - -X3:e--W2:w - - - + + + +W2 + +4x + +0.25 mm² + +0.2 m +  + X3:1:GND + +TQ + +X2:1:GND + X3:2:VCC + +PK + +X2:2:VCC + X3:3:SCL + +YE + +X2:3:SCL + X3:4:SDA + +VT + +X2:4:SDA +  X3:e--W2:w - - - + + + + + + +X3:e--W2:w + + + X3:e--W2:w - - - + + + + + + +X3:e--W2:w + + + - + W3 - - -W3 - -4x - -0.25 mm² - -0.2 m -  -X3:1:GND -     TQ     -X4:1:GND - - - -X3:2:VCC -     PK     -X4:2:VCC - - - -X3:3:SCL -     YE     -X4:3:SCL - - - -X3:4:SDA -     VT     -X4:4:SDA - - - -  + + + +W3 + +4x + +0.25 mm² + +0.2 m +  + X3:1:GND + +TQ + +X4:1:GND + X3:2:VCC + +PK + +X4:2:VCC + X3:3:SCL + +YE + +X4:3:SCL + X3:4:SDA + +VT + +X4:4:SDA +  X3:e--W3:w - - - + + + + + + +X3:e--W3:w + + + X3:e--W3:w - - - + + + + +X3:e--W3:w + + + + + -X3:e--W3:w - - - +W2:e--X2:w + + + - + + +W2:e--X2:w + + + + + -X3:e--W3:w - - - +W2:e--X2:w + + + + + + +W2:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + + + + +W3:e--W3:w + + + - + X4 - - -X4 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA + + + +X4 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + + + + +W3:e--X4:w + + + - + X5 - - -X5 - -Molex KK 254 - -female - -4-pin - -GND - -1 - -VCC - -2 - -SCL - -3 - -SDA - -4 + + + +X5 + +Molex KK 254 + +female + +4-pin + +GND + +1 + +VCC + +2 + +SCL + +3 + +SDA + +4 - + W4 - - -W4 - -4x - -0.25 mm² - -0.2 m -  -X5:1:GND -     TQ     -X4:1:GND - - - -X5:2:VCC -     PK     -X4:2:VCC - - - -X5:3:SCL -     YE     -X4:3:SCL - - - -X5:4:SDA -     VT     -X4:4:SDA - - - -  + + + +W4 + +4x + +0.25 mm² + +0.2 m +  + X5:1:GND + +TQ + +X4:1:GND + X5:2:VCC + +PK + +X4:2:VCC + X5:3:SCL + +YE + +X4:3:SCL + X5:4:SDA + +VT + +X4:4:SDA +  - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + X5:e--W4:w - - - + + + - + W5 - - -W5 - -4x - -0.25 mm² - -0.2 m -  -X5:1:GND -     TQ     -X6:1:GND - - - -X5:2:VCC -     PK     -X6:2:VCC - - - -X5:3:SCL -     YE     -X6:3:SCL - - - -X5:4:SDA -     VT     -X6:4:SDA - - - -  + + + +W5 + +4x + +0.25 mm² + +0.2 m +  + X5:1:GND + +TQ + +X6:1:GND + X5:2:VCC + +PK + +X6:2:VCC + X5:3:SCL + +YE + +X6:3:SCL + X5:4:SDA + +VT + +X6:4:SDA +  - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + - + X5:e--W5:w - - - + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--X4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W4:e--W4:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + + + + +W5:e--W5:w + + + - + X6 - - -X6 - -Molex KK 254 - -female - -4-pin - -1 - -GND - -2 - -VCC - -3 - -SCL - -4 - -SDA - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W2:e--X2:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W3:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - - - - -W4:e--X4:w - - - + + + +X6 + +Molex KK 254 + +female + +4-pin + +1 + +GND + +2 + +VCC + +3 + +SCL + +4 + +SDA - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + - + W5:e--X6:w - - - + + + diff --git a/tutorial/tutorial07_wv_gvpr.gvpr b/tutorial/tutorial07_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tutorial/tutorial07_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file diff --git a/tutorial/tutorial08.bom.tsv b/tutorial/tutorial08.bom.tsv index d425c96..6ad2663 100644 --- a/tutorial/tutorial08.bom.tsv +++ b/tutorial/tutorial08.bom.tsv @@ -1,11 +1,11 @@ -Id Description Qty Unit Designators P/N Manufacturer MPN Supplier SPN -1 Cable, 4 x 0.25 mm² 1 m W1 CAB1 CablesCo ABC123 Cables R Us 999-888-777 -2 Connector, Molex KK 254, female, 4 pins 2 X1, X3 Molex 22013047 Digimouse 1234 -3 Connector, Molex KK 254, female, 4 pins 1 X2 CON4 Molex 22013047 Digimouse 1234 -4 Crimp, Molex KK 254, 22-30 AWG 12 X1, X2, X3 Molex 08500030 -5 Label, pinout information 2 X2, X3 Label-ID-1 Brady B-499 -6 Sleve, Braided nylon, black, 3mm 1 m W2 SLV-1 -7 Test 3 X1, X2, X3 ABC Molex 45454 Mousikey 9999 -8 Wire, 0.25 mm², BK 2 m W2 WIRE2 WiresCo W1-BK WireShack 1002 -9 Wire, 0.25 mm², RD 1 m W2 WIRE3 WiresCo W1-RD WireShack 1009 -10 Wire, 0.25 mm², YE 1 m W2 WIRE1 WiresCo W1-YE WireShack 1001 +# Qty Unit Description Designators P/N Manufacturer MPN Supplier SPN +1 2 Connector, Molex KK 254, female, 4 pins X1, X3 Molex 22013047 Digimouse 1234 +2 1 Connector, Molex KK 254, female, 4 pins X2 CON4 Molex 22013047 Digimouse 1234 +3 1 m Cable, 4 x 0.25 mm² W1 CAB1 CablesCo ABC123 Cables R Us 999-888-777 +4 2 m Wire, 0.25 mm², BK W2 WIRE2 WiresCo W1-BK WireShack 1002 +5 1 m Wire, 0.25 mm², RD W2 WIRE3 WiresCo W1-RD WireShack 1009 +6 1 m Wire, 0.25 mm², YE W2 WIRE1 WiresCo W1-YE WireShack 1001 +7 12 Crimp, Molex KK 254, 22-30 AWG X1, X2, X3 Molex 08500030 +8 1 m Sleeve, Braided nylon, black, 3mm W2 SLV-1 +9 3 Test X1, X2, X3 ABC Molex 45454 Mousikey 9999 +10 2 Label, pinout information Label-ID-1 Brady B-499 diff --git a/tutorial/tutorial08.gv b/tutorial/tutorial08.gv index 761ccb8..64c7294 100644 --- a/tutorial/tutorial08.gv +++ b/tutorial/tutorial08.gv @@ -1,275 +1,514 @@ graph { -// Graph generated by WireViz 0.4.1 +// Graph generated by WireViz 0.5-dev+refactor // https://github.com/wireviz/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] X1 [label=< - - - - - - - - +
- - -
X1
-
- - - -
Molex: 22013047Digimouse: 1234
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - -
1
2
3
4
-
- - -
Additional components
-
- - -
4 x Crimp, Molex KK 254, 22-30 AWG
Molex: 08500030
-
- - -
1 x Test
P/N: ABC, Molex: 45454, Mousikey: 9999
-
+ + + + + + + + + + + + + + +
+ + + + +
X1
+
+ + + + + +
Molex: 22013047Digimouse: 1234
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1
2
3
4
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
4xCrimp, Molex KK 254, 22-30 AWG
Molex: 08500030
1xTest
P/N: ABC, Molex: 45454, Mousikey: 9999
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X2 [label=< - - - - - - - - +
- - -
X2
-
- - - - -
P/N: CON4Molex: 22013047Digimouse: 1234
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - -
1
2
3
4
-
- - -
Additional components
-
- - -
4 x Crimp, Molex KK 254, 22-30 AWG
Molex: 08500030
-
- - -
1 x Test
P/N: ABC, Molex: 45454, Mousikey: 9999
-
+ + + + + + + + + + + + + + +
+ + + + +
X2
+
+ + + + + + +
P/N: CON4Molex: 22013047Digimouse: 1234
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1
2
3
4
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
4xCrimp, Molex KK 254, 22-30 AWG
Molex: 08500030
1xTest
P/N: ABC, Molex: 45454, Mousikey: 9999
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] X3 [label=< - - - - - - - - +
- - -
X3
-
- - - -
Molex: 22013047Digimouse: 1234
-
- - - - -
Molex KK 254female4-pin
-
- - - - - - - - - - - - - -
1
2
3
4
-
- - -
Additional components
-
- - -
4 x Crimp, Molex KK 254, 22-30 AWG
Molex: 08500030
-
- - -
1 x Test
P/N: ABC, Molex: 45454, Mousikey: 9999
-
+ + + + + + + + + + + + + + +
+ + + + +
X3
+
+ + + + + +
Molex: 22013047Digimouse: 1234
+
+ + + + + + +
Molex KK 254female4-pin
+
+ + + + + + + + + + + + + + + + + +
1
2
3
4
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
4xCrimp, Molex KK 254, 22-30 AWG
Molex: 08500030
1xTest
P/N: ABC, Molex: 45454, Mousikey: 9999
+
-> fillcolor="#FFFFFF" shape=box style=filled] +> shape=box style=filled] + W1 [label=< + + + + + + + + + + + + + +
+ + + + +
W1
+
+ + + + + + +
P/N: CAB1CablesCo: ABC123Cables R Us: 999-888-777
+
+ + + + + + +
4x0.25 mm²1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1 1:BN X2:1
X1:2 2:RD X2:2
X1:3 3:OG X2:3
X1:4 4:YE X2:4
 
+
+> 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"] + edge [color="#000000:#FF0000:#000000"] X1:p2r:e -- W1:w2:w W1:w2:e -- X2:p2l:w - edge [color="#000000:#ff8000:#000000"] + edge [color="#000000:#FF8000:#000000"] X1:p3r:e -- W1:w3:w W1:w3:e -- X2:p3l:w - edge [color="#000000:#ffff00:#000000"] + edge [color="#000000:#FFFF00:#000000"] X1:p4r:e -- W1:w4:w W1:w4:e -- X2:p4l:w - W1 [label=< - - - - - + W1:w1:e -- W1:w1:w [color="#000000:#895956:#000000" straight=straight] + W1:w2:e -- W1:w2:w [color="#000000:#FF0000:#000000" straight=straight] + W1:w3:e -- W1:w3:w [color="#000000:#FF8000:#000000" straight=straight] + W1:w4:e -- W1:w4:w [color="#000000:#FFFF00:#000000" straight=straight] + W2 [label=< +
- - -
W1
-
- - - - -
P/N: CAB1CablesCo: ABC123Cables R Us: 999-888-777
-
- - - - -
4x0.25 mm²1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1 - 1:BN - X2:1
- - - - -
-
X1:2 - 2:RD - X2:2
- - - - -
-
X1:3 - 3:OG - X2:3
- - - - -
-
X1:4 - 4:YE - X2:4
- - - - -
-
 
-
+ + + + + + + + + + + +
+ + + + +
W2
+
+ + + + + + +
4x0.25 mm²1 m
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
X1:1 YE X3:1
+ + + + + + +
P/N: WIRE1WiresCo: W1-YEWireShack: 1001
+
X1:2 BK X3:2
+ + + + + + +
P/N: WIRE2WiresCo: W1-BKWireShack: 1002
+
X1:3 BK X3:3
+ + + + + + +
P/N: WIRE2WiresCo: W1-BKWireShack: 1002
+
X1:4 RD X3:4
+ + + + + + +
P/N: WIRE3WiresCo: W1-RDWireShack: 1009
+
 
+
+ + + + + + + + + + + + + +
1mSleeve, Braided nylon, black, 3mm
P/N: SLV-1
+
-> fillcolor="#FFFFFF" shape=box style=filled] - edge [color="#000000:#ffff00:#000000"] +> shape=box style="filled,dashed"] + edge [color="#000000:#FFFF00:#000000"] X1:p1r:e -- W2:w1:w W2:w1:e -- X3:p1l:w edge [color="#000000:#000000:#000000"] @@ -278,131 +517,11 @@ graph { edge [color="#000000:#000000:#000000"] X1:p3r:e -- W2:w3:w W2:w3:e -- X3:p3l:w - edge [color="#000000:#ff0000:#000000"] + edge [color="#000000:#FF0000:#000000"] X1:p4r:e -- W2:w4:w W2:w4:e -- X3:p4l:w - W2 [label=< - - - - - - -
- - -
W2
-
- - - - -
4x0.25 mm²1 m
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
X1:1 - YE - X3:1
- - - - -
-
- - - - -
P/N: WIRE1WiresCo: W1-YEWireShack: 1001
-
X1:2 - BK - X3:2
- - - - -
-
- - - - -
P/N: WIRE2WiresCo: W1-BKWireShack: 1002
-
X1:3 - BK - X3:3
- - - - -
-
- - - - -
P/N: WIRE2WiresCo: W1-BKWireShack: 1002
-
X1:4 - RD - X3:4
- - - - -
-
- - - - -
P/N: WIRE3WiresCo: W1-RDWireShack: 1009
-
 
-
- - -
Additional components
-
- - -
1 m x Sleve, Braided nylon, black, 3mm
P/N: SLV-1
-
-> fillcolor="#FFFFFF" shape=box style="filled,dashed"] + W2:w1:e -- W2:w1:w [color="#000000:#FFFF00:#000000" straight=straight] + W2:w2:e -- W2:w2:w [color="#000000:#000000:#000000" straight=straight] + W2:w3:e -- W2:w3:w [color="#000000:#000000:#000000" straight=straight] + W2:w4:e -- W2:w4:w [color="#000000:#FF0000:#000000" straight=straight] } diff --git a/tutorial/tutorial08.html b/tutorial/tutorial08.html index cbdc4fe..c86264c 100644 --- a/tutorial/tutorial08.html +++ b/tutorial/tutorial08.html @@ -1,7 +1,7 @@ - + tutorial08 - +

tutorial08

Diagram

@@ -30,326 +30,382 @@
- - - - + + + X1 - - -X1 - -Molex: 22013047 - -Digimouse: 1234 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -Additional components - -4 x Crimp, Molex KK 254, 22-30 AWG -Molex: 08500030 - -1 x Test -P/N: ABC, Molex: 45454, Mousikey: 9999 + + + +X1 + +Molex: 22013047 + +Digimouse: 1234 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 +4 +x +Crimp, Molex KK 254, 22-30 AWG +Molex: 08500030 +1 +x +Test +P/N: ABC, Molex: 45454, Mousikey: 9999 + - + W1 - - -W1 - -P/N: CAB1 - -CablesCo: ABC123 - -Cables R Us: 999-888-777 - -4x - -0.25 mm² - -1 m -  -X1:1 -     1:BN     -X2:1 - - - -X1:2 -     2:RD     -X2:2 - - - -X1:3 -     3:OG     -X2:3 - - - -X1:4 -     4:YE     -X2:4 - - - -  + + + +W1 + +P/N: CAB1 + +CablesCo: ABC123 + +Cables R Us: 999-888-777 + +4x + +0.25 mm² + +1 m +  + X1:1 + +1:BN + +X2:1 + X1:2 + +2:RD + +X2:2 + X1:3 + +3:OG + +X2:3 + X1:4 + +4:YE + +X2:4 +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + - + X1:e--W1:w - - - - - - -X1:e--W1:w - - - + + + - + W2 - - -W2 - -4x - -0.25 mm² - -1 m -  -X1:1 -     YE     -X3:1 - - - -P/N: WIRE1 -WiresCo: W1-YE -WireShack: 1001 -X1:2 -     BK     -X3:2 - - - -P/N: WIRE2 -WiresCo: W1-BK -WireShack: 1002 -X1:3 -     BK     -X3:3 - - - -P/N: WIRE2 -WiresCo: W1-BK -WireShack: 1002 -X1:4 -     RD     -X3:4 - - - -P/N: WIRE3 -WiresCo: W1-RD -WireShack: 1009 -  - -Additional components - -1 m x Sleve, Braided nylon, black, 3mm -P/N: SLV-1 + + + +W2 + +4x + +0.25 mm² + +1 m +  + X1:1 + +YE + +X3:1 +P/N: WIRE1 +WiresCo: W1-YE +WireShack: 1001 + X1:2 + +BK + +X3:2 +P/N: WIRE2 +WiresCo: W1-BK +WireShack: 1002 + X1:3 + +BK + +X3:3 +P/N: WIRE2 +WiresCo: W1-BK +WireShack: 1002 + X1:4 + +RD + +X3:4 +P/N: WIRE3 +WiresCo: W1-RD +WireShack: 1009 +  +1 +m +Sleeve, Braided nylon, black, 3mm +P/N: SLV-1 + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + -X1:e--W2:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W2:w - - - +W1:e--W1:w + + + - - -X1:e--W2:w - - - - - - -X1:e--W2:w - - - + + +W1:e--W1:w + + + - + X2 - - -X2 - -P/N: CON4 - -Molex: 22013047 - -Digimouse: 1234 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -Additional components - -4 x Crimp, Molex KK 254, 22-30 AWG -Molex: 08500030 - -1 x Test -P/N: ABC, Molex: 45454, Mousikey: 9999 + + + +X2 + +P/N: CON4 + +Molex: 22013047 + +Digimouse: 1234 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 +4 +x +Crimp, Molex KK 254, 22-30 AWG +Molex: 08500030 +1 +x +Test +P/N: ABC, Molex: 45454, Mousikey: 9999 + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex: 22013047 - -Digimouse: 1234 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -Additional components - -4 x Crimp, Molex KK 254, 22-30 AWG -Molex: 08500030 - -1 x Test -P/N: ABC, Molex: 45454, Mousikey: 9999 - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - + + + +X3 + +Molex: 22013047 + +Digimouse: 1234 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 +4 +x +Crimp, Molex KK 254, 22-30 AWG +Molex: 08500030 +1 +x +Test +P/N: ABC, Molex: 45454, Mousikey: 9999 + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + @@ -365,10 +421,10 @@
- - + + @@ -377,10 +433,34 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -389,82 +469,10 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -473,10 +481,10 @@ - - + + @@ -485,10 +493,10 @@ - - + + @@ -496,6 +504,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdDescription# Qty UnitDescription Designators P/N ManufacturerSPN
1Cable, 4 x 0.25 mm²12Connector, Molex KK 254, female, 4 pinsX1, X3Molex22013047Digimouse1234
21Connector, Molex KK 254, female, 4 pinsX2CON4Molex22013047Digimouse1234
3 1 mCable, 4 x 0.25 mm² W1 CAB1 CablesCo999-888-777
2Connector, Molex KK 254, female, 4 pins4 2X1, X3Molex22013047Digimouse1234
3Connector, Molex KK 254, female, 4 pins1X2CON4Molex22013047Digimouse1234
4Crimp, Molex KK 254, 22-30 AWG12X1, X2, X3Molex08500030
5Label, pinout information2X2, X3Label-ID-1BradyB-499
6Sleve, Braided nylon, black, 3mm1 mW2SLV-1
7Test3X1, X2, X3ABCMolex45454Mousikey9999
8 Wire, 0.25 mm², BK2m W2 WIRE2 WiresCo1002
9Wire, 0.25 mm², RD5 1 mWire, 0.25 mm², RD W2 WIRE3 WiresCo1009
10Wire, 0.25 mm², YE6 1 mWire, 0.25 mm², YE W2 WIRE1 WiresCoWireShack 1001
712Crimp, Molex KK 254, 22-30 AWGX1, X2, X3Molex08500030
81mSleeve, Braided nylon, black, 3mmW2SLV-1
93TestX1, X2, X3ABCMolex45454Mousikey9999
102Label, pinout informationLabel-ID-1BradyB-499
diff --git a/tutorial/tutorial08.png b/tutorial/tutorial08.png index 8f9d65e..cc9aa77 100644 Binary files a/tutorial/tutorial08.png and b/tutorial/tutorial08.png differ diff --git a/tutorial/tutorial08.svg b/tutorial/tutorial08.svg index ad900af..67cc7ba 100644 --- a/tutorial/tutorial08.svg +++ b/tutorial/tutorial08.svg @@ -1,326 +1,382 @@ - - - - + + + X1 - - -X1 - -Molex: 22013047 - -Digimouse: 1234 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -Additional components - -4 x Crimp, Molex KK 254, 22-30 AWG -Molex: 08500030 - -1 x Test -P/N: ABC, Molex: 45454, Mousikey: 9999 + + + +X1 + +Molex: 22013047 + +Digimouse: 1234 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 +4 +x +Crimp, Molex KK 254, 22-30 AWG +Molex: 08500030 +1 +x +Test +P/N: ABC, Molex: 45454, Mousikey: 9999 + - + W1 - - -W1 - -P/N: CAB1 - -CablesCo: ABC123 - -Cables R Us: 999-888-777 - -4x - -0.25 mm² - -1 m -  -X1:1 -     1:BN     -X2:1 - - - -X1:2 -     2:RD     -X2:2 - - - -X1:3 -     3:OG     -X2:3 - - - -X1:4 -     4:YE     -X2:4 - - - -  + + + +W1 + +P/N: CAB1 + +CablesCo: ABC123 + +Cables R Us: 999-888-777 + +4x + +0.25 mm² + +1 m +  + X1:1 + +1:BN + +X2:1 + X1:2 + +2:RD + +X2:2 + X1:3 + +3:OG + +X2:3 + X1:4 + +4:YE + +X2:4 +  X1:e--W1:w - - - + + + + + + +X1:e--W1:w + + + X1:e--W1:w - - - + + + - + X1:e--W1:w - - - - - - -X1:e--W1:w - - - + + + - + W2 - - -W2 - -4x - -0.25 mm² - -1 m -  -X1:1 -     YE     -X3:1 - - - -P/N: WIRE1 -WiresCo: W1-YE -WireShack: 1001 -X1:2 -     BK     -X3:2 - - - -P/N: WIRE2 -WiresCo: W1-BK -WireShack: 1002 -X1:3 -     BK     -X3:3 - - - -P/N: WIRE2 -WiresCo: W1-BK -WireShack: 1002 -X1:4 -     RD     -X3:4 - - - -P/N: WIRE3 -WiresCo: W1-RD -WireShack: 1009 -  - -Additional components - -1 m x Sleve, Braided nylon, black, 3mm -P/N: SLV-1 + + + +W2 + +4x + +0.25 mm² + +1 m +  + X1:1 + +YE + +X3:1 +P/N: WIRE1 +WiresCo: W1-YE +WireShack: 1001 + X1:2 + +BK + +X3:2 +P/N: WIRE2 +WiresCo: W1-BK +WireShack: 1002 + X1:3 + +BK + +X3:3 +P/N: WIRE2 +WiresCo: W1-BK +WireShack: 1002 + X1:4 + +RD + +X3:4 +P/N: WIRE3 +WiresCo: W1-RD +WireShack: 1009 +  +1 +m +Sleeve, Braided nylon, black, 3mm +P/N: SLV-1 + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + + +X1:e--W2:w + + + + + -X1:e--W2:w - - - +W1:e--W1:w + + + - + + +W1:e--W1:w + + + + + -X1:e--W2:w - - - +W1:e--W1:w + + + - - -X1:e--W2:w - - - - - - -X1:e--W2:w - - - + + +W1:e--W1:w + + + - + X2 - - -X2 - -P/N: CON4 - -Molex: 22013047 - -Digimouse: 1234 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -Additional components - -4 x Crimp, Molex KK 254, 22-30 AWG -Molex: 08500030 - -1 x Test -P/N: ABC, Molex: 45454, Mousikey: 9999 + + + +X2 + +P/N: CON4 + +Molex: 22013047 + +Digimouse: 1234 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 +4 +x +Crimp, Molex KK 254, 22-30 AWG +Molex: 08500030 +1 +x +Test +P/N: ABC, Molex: 45454, Mousikey: 9999 + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W1:e--X2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + + + + +W2:e--W2:w + + + - + X3 - - -X3 - -Molex: 22013047 - -Digimouse: 1234 - -Molex KK 254 - -female - -4-pin - -1 - -2 - -3 - -4 - -Additional components - -4 x Crimp, Molex KK 254, 22-30 AWG -Molex: 08500030 - -1 x Test -P/N: ABC, Molex: 45454, Mousikey: 9999 - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - - - - -W1:e--X2:w - - - + + + +X3 + +Molex: 22013047 + +Digimouse: 1234 + +Molex KK 254 + +female + +4-pin + +1 + +2 + +3 + +4 +4 +x +Crimp, Molex KK 254, 22-30 AWG +Molex: 08500030 +1 +x +Test +P/N: ABC, Molex: 45454, Mousikey: 9999 + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + - + W2:e--X3:w - - - + + + diff --git a/tutorial/tutorial08.yml b/tutorial/tutorial08.yml index ad25a83..f0351a2 100644 --- a/tutorial/tutorial08.yml +++ b/tutorial/tutorial08.yml @@ -53,10 +53,9 @@ cables: pn: [WIRE1, WIRE2, WIRE2, WIRE3] # add a list of additional components to a part (shown in graph) additional_components: - - type: Sleve # short identifier used in graph + - type: Sleeve # short identifier used in graph subtype: Braided nylon, black, 3mm # extra information added to type in bom qty_multiplier: length # multipier for quantity (length of cable) - unit: m pn: SLV-1 connections: @@ -69,7 +68,7 @@ connections: additional_bom_items: - # define an additional item to add to the bill of materials (does not appear in graph) - description: Label, pinout information + type: Label, pinout information qty: 2 designators: - X2 diff --git a/tutorial/tutorial08_wv_gvpr.gvpr b/tutorial/tutorial08_wv_gvpr.gvpr new file mode 100644 index 0000000..7bfced7 --- /dev/null +++ b/tutorial/tutorial08_wv_gvpr.gvpr @@ -0,0 +1,64 @@ +/******************************************************************* + + see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196 and https://forum.graphviz.org/t/way-of-drawing-a-black-circle-inside-a-table-field/2273/12 + input must include pos values (must be output from one of the engines w/ -Tdot)# + Thanks to steveroush and FeRDNYC + +*******************************************************************/ +BEG_G{ + double x1,y1,x2,y2,x3,y3,x4,y4; + string ptSize, tok[int], pt[]; + int cnt, circ, i; + node_t aNode; + + circ=0; + +/*************************************** + $G.bb=""; + $G.nodesep=""; + $G.ranksep=""; + $G.splines="true"; +****************************************/ +} + +// This removes the label text but keeps the position +E[noLabel] { + $.label=""; // remove pesky label + // $.lp=""; // remove peskier label pos +} + +E[straight] { + cnt=tokens($.pos,tok," "); + $.oldpos=$.pos; + x1 = xOf(tok[0]); + y1 = yOf(tok[0]); + x4 = xOf(tok[cnt-1]); + y4 = yOf(tok[cnt-1]); + x2 = x1 + (x4-x1)/3.; + y2 = y1 + (y4-y1)/3.; + x3 = x1 + 2.*(x4-x1)/3.; + y3 = y1 + 2.*(y4-y1)/3.; + pos=sprintf("%.3f,%.3f %.3f,%.3f %.3f,%.3f %.3f,%.3f", x1,y1, x2,y2, x3,y3, x4,y4); + $.label=""; // remove pesky label + $.lp=""; // remove peskier label pos + + if (hasAttr($, "addPTS") && $.addPTS!="" && $.colorPTS!=""){ + // now we place point nodes at the edge ends + pt[1] = tok[0]; + pt[2] = tok[cnt-1]; + ptSize=$.addPTS; + for (pt[i]) { + if (i==2 && pt[1]==pt[2]) + continue; + aNode=node($G, "__CIRCLE__" + (string)++circ); + aNode.pos=pt[i]; + aNode.shape="point"; + aNode.width=ptSize; + aNode.height=ptSize; + aNode.style="filled"; + aNode.fillcolor=$.colorPTS; + aNode.color=$.colorPTS; + } + } + +} \ No newline at end of file