graflow: test for all directions
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
<style>
|
||||||
|
.bzgf-node {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
color: black;
|
||||||
|
text-align: center;
|
||||||
|
position: absolute;
|
||||||
|
padding: .5em;
|
||||||
|
}
|
||||||
|
.bzgf-node .body{
|
||||||
|
z-index: 1;
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: var(--eicui-base-color-grey-25);
|
||||||
|
border:2px solid var(--eicui-base-color-grey-50);
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.bzgf-node .title {
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--app-color-black);
|
||||||
|
margin: .5em auto .2em auto;
|
||||||
|
}
|
||||||
|
.bzgf-node .subtitle {
|
||||||
|
font-size: .9em;
|
||||||
|
color: var(--eicui-base-color-primary-100);
|
||||||
|
width: 90%;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
.bzgf-node .port{
|
||||||
|
position: absolute;
|
||||||
|
height: 10px;
|
||||||
|
width: 10px;
|
||||||
|
background: var(--eicui-base-color-info-25);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bzgf-node [data-direction="n"]{ top: -4px; left: 50%; transform: translateX(-50%);}
|
||||||
|
.bzgf-node [data-direction="s"]{ bottom: -4px; left: 50%; transform: translateX(-50%);}
|
||||||
|
.bzgf-node [data-direction="w"]{ left: -4px; top: 50%; transform: translateY(-50%);}
|
||||||
|
.bzgf-node [data-direction="e"]{ right: -4px; top: 50%; transform: translateY(-50%);}
|
||||||
|
|
||||||
|
.bzgf-wire{ stroke: var(--eicui-base-color-info); stroke-width: 4px; stroke-dasharray: 10,5; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="bzgf-node" data-nodetype="square">
|
||||||
|
<div class="body">
|
||||||
|
<div class="title">{title}</div>
|
||||||
|
<div class="subtitle">{subtitle}</div>
|
||||||
|
</div>
|
||||||
|
<div class="port" data-id="w" data-direction="w"></div>
|
||||||
|
<div class="port" data-id="n" data-direction="n"></div>
|
||||||
|
<div class="port" data-id="e" data-direction="e"></div>
|
||||||
|
<div class="port" data-id="s" data-direction="s"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
<li><a target="test4" href="./test4.html">test4 (EIC-ICMP + NON-ISOLATED)</a></li>
|
<li><a target="test4" href="./test4.html">test4 (EIC-ICMP + NON-ISOLATED)</a></li>
|
||||||
<li><a target="test4.5" href="./test4.5.html">test4.5 (EIC-ICMP + NON-ISOLATED + single-port, ortho, oriented, aligned top)</a></li>
|
<li><a target="test4.5" href="./test4.5.html">test4.5 (EIC-ICMP + NON-ISOLATED + single-port, ortho, oriented, aligned top)</a></li>
|
||||||
<li><a target="test5" href="./test5.html">test5 (P42 graph + ISOLATED + EDITABLE)</a></li>
|
<li><a target="test5" href="./test5.html">test5 (P42 graph + ISOLATED + EDITABLE)</a></li>
|
||||||
|
<li><a target="test6" href="./test6.html">test6 (16 port combinations)</a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>graflow</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
||||||
|
<link type="text/css" rel="stylesheet" href="/app/thirdparty/eicui/eicui-2.0.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="../../thirdparty/buildoz/buildoz.css">
|
||||||
|
<script src="../../thirdparty/buildoz/buildoz.js"></script>
|
||||||
|
<script src="../../thirdparty/buildoz/bzGraflow.js"></script>
|
||||||
|
<style>
|
||||||
|
@font-face { /*FF does not indirectly load if inside a shawdow-dom */
|
||||||
|
font-family: 'glyphs';
|
||||||
|
src: url('/app/assets/styles/fonts/glyphs.eot');
|
||||||
|
src: url('/app/assets/styles/fonts/glyphs.eot') format('embedded-opentype'),
|
||||||
|
url('/app/assets/styles/fonts/glyphs.ttf') format('truetype'),
|
||||||
|
url('/app/assets/styles/fonts/glyphs.woff') format('woff'),
|
||||||
|
url('/app/assets/styles/fonts/glyphs.svg') format('svg');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: block;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
display: grid;
|
||||||
|
grid-gap: 5px;
|
||||||
|
background:#888;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.demooptions{
|
||||||
|
padding: 2px;
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
right: 2px;
|
||||||
|
width: 10em;
|
||||||
|
background: #FFFB;
|
||||||
|
border-radius: 5px;
|
||||||
|
text-align: center;
|
||||||
|
z-index:999999;
|
||||||
|
font-size: .7em;
|
||||||
|
border: 1px solid #999;
|
||||||
|
}
|
||||||
|
.demooptions button{
|
||||||
|
text-transform: none;
|
||||||
|
margin: 2px;
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
bz-graflow{
|
||||||
|
overflow: scroll;
|
||||||
|
border: 2px solid black;
|
||||||
|
}
|
||||||
|
bz-graflow.compunet{ grid-column: 1 / -1; width: 100vw; height: 60vh; background:black; }
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
window.addEventListener('load',()=>{
|
||||||
|
let grflw1 = document.querySelector('bz-graflow.compunet')
|
||||||
|
grflw1.addEventListener('subflowLoaded',
|
||||||
|
(evt) => { grflw1 = evt.detail.subflow }
|
||||||
|
)
|
||||||
|
grflw1.addEventListener('subflowExited',
|
||||||
|
(evt) => { grflw1 = evt.target }
|
||||||
|
)
|
||||||
|
document.querySelector('[data-trigger="onAutoplace1H"]').addEventListener('click',
|
||||||
|
(evt) => { grflw1.autoPlace('horizontal', 80, 30, 1000, document.querySelector('[data-id="compunet"]').value) }
|
||||||
|
)
|
||||||
|
document.querySelector('[data-trigger="onAutoplace1V"]').addEventListener('click',
|
||||||
|
(evt) => { grflw1.autoPlace('vertical', 80, 30, 1000, document.querySelector('[data-id="compunet"]').value) }
|
||||||
|
)
|
||||||
|
document.querySelector('input[data-id="compunet"]').addEventListener('change',
|
||||||
|
(evt) => { grflw1.setAttribute('tension', evt.target.value); grflw1.refresh() }
|
||||||
|
)
|
||||||
|
document.querySelector('select[name="wiretype"]').addEventListener('change',
|
||||||
|
(evt) => { grflw1.setAttribute('wiretype', evt.target.value); grflw1.refresh() }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<bz-graflow class="compunet" flow="/app/assets/json/bzGraflow/testFlow16ports.json" tension="60" isolated edit="move" >
|
||||||
|
<div class="demooptions"> <!-- just for demo purposes -->
|
||||||
|
<button data-trigger="onAutoplace1H">Auto-place Horizontal</button>
|
||||||
|
<button data-trigger="onAutoplace1V">Auto-place Vertical</button>
|
||||||
|
<select name="align" data-id="compunet">
|
||||||
|
<option value="center">Center</option>
|
||||||
|
<option value="first">First</option>
|
||||||
|
<option value="last">Last</option>
|
||||||
|
<option value="auto">Auto</option>
|
||||||
|
</select>
|
||||||
|
<select name="wiretype">
|
||||||
|
<option value="ortho">Ortho</option>
|
||||||
|
<option value="straight">Straight</option>
|
||||||
|
<option value="bezier" selected>Bezier</option>
|
||||||
|
</select>
|
||||||
|
<div class-"cols-2"=""><label>tension</label><input data-id="compunet" type="number" size="2" value="60"></div>
|
||||||
|
</div>
|
||||||
|
</bz-graflow>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"nodesFile": "/app/assets/html/bzGraflow/nodes16ports.html",
|
||||||
|
"flow": {
|
||||||
|
"nodes":[
|
||||||
|
{ "nodeType": "square",
|
||||||
|
"id": "p1center",
|
||||||
|
"coords": { "x": 500, "y": 200},
|
||||||
|
"markup": {
|
||||||
|
"title": "Center",
|
||||||
|
"subtitle": "."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "nodeType": "square",
|
||||||
|
"id": "p1west",
|
||||||
|
"coords": { "x": 400, "y": 200},
|
||||||
|
"markup": {
|
||||||
|
"title": "West",
|
||||||
|
"subtitle": "."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "nodeType": "square",
|
||||||
|
"id": "p1north",
|
||||||
|
"coords": { "x": 500, "y": 100},
|
||||||
|
"markup": {
|
||||||
|
"title": "North",
|
||||||
|
"subtitle": "."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "nodeType": "square",
|
||||||
|
"id": "p1east",
|
||||||
|
"coords": { "x": 600, "y": 200},
|
||||||
|
"markup": {
|
||||||
|
"title": "East",
|
||||||
|
"subtitle": "."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "nodeType": "square",
|
||||||
|
"id": "p1south",
|
||||||
|
"coords": { "x": 500, "y": 300},
|
||||||
|
"markup": {
|
||||||
|
"title": "South",
|
||||||
|
"subtitle": "."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"links": [
|
||||||
|
{ "from": ["p1center", "s"], "to": ["p1south", "n"] },
|
||||||
|
{ "from": ["p1center", "e"], "to": ["p1east", "w"] },
|
||||||
|
{ "from": ["p1center", "n"], "to": ["p1north", "s"] },
|
||||||
|
{ "from": ["p1center", "w"], "to": ["p1west", "e"] }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+9
-10
@@ -459,20 +459,18 @@ class BZgraflow extends Buildoz{
|
|||||||
return({ x: x - r.left, y: y - r.top })
|
return({ x: x - r.left, y: y - r.top })
|
||||||
}
|
}
|
||||||
|
|
||||||
emitWireSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, loop=false){
|
buildSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, loop=false){
|
||||||
if(loop) wireType = 'bezier' // loops only use bezier to look good
|
if(loop) wireType = 'bezier' // loops only use bezier to look good
|
||||||
|
|
||||||
if(wireType === 'bezier'){
|
if(wireType == 'bezier'){
|
||||||
return(`C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`)
|
return(`C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`)
|
||||||
}
|
}
|
||||||
if(wireType === 'straight'){
|
if(wireType == 'straight'){
|
||||||
return(`L ${c1x} ${c1y} L ${c2x} ${c2y} L ${x2} ${y2}`)
|
return(`L ${c1x} ${c1y} L ${c2x} ${c2y} L ${x2} ${y2}`)
|
||||||
}
|
}
|
||||||
if(wireType === 'ortho'){
|
if(wireType == 'ortho'){
|
||||||
if(startAxis === 'v'){
|
if(startAxis == 'v') return(`V ${(c1y + c2y) / 2} H ${c2x} V ${y2}`)
|
||||||
return(`V ${(c1y + c2y) / 2} H ${c2x} V ${y2}`)
|
else return(`H ${(c1x + c2x) / 2} V ${c2y} H ${x2}`)
|
||||||
}
|
|
||||||
return(`H ${(c1x + c2x) / 2} V ${c2y} H ${x2}`)
|
|
||||||
}
|
}
|
||||||
return('')
|
return('')
|
||||||
}
|
}
|
||||||
@@ -513,10 +511,11 @@ class BZgraflow extends Buildoz{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const startAxis = ['n', 's'].includes(port1.direction) ? 'v' : 'h'
|
const startAxis = ['n', 's'].includes(port1.direction) ? 'v' : 'h'
|
||||||
const seg = this.emitWireSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, loop)
|
const seg = this.buildSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, loop)
|
||||||
if(!seg) return('')
|
if(!seg) return('')
|
||||||
return(`M ${x1} ${y1} ${seg}`)
|
return(`M ${x1} ${y1} ${seg}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
linkInterNodes(idNode1, idPort1, idNode2, idPort2, interNodes, orientation='horizontal') {
|
linkInterNodes(idNode1, idPort1, idNode2, idPort2, interNodes, orientation='horizontal') {
|
||||||
const tension = parseInt(this.getBZAttribute('tension')) || 60
|
const tension = parseInt(this.getBZAttribute('tension')) || 60
|
||||||
const wireType = this.getBZAttribute('wiretype') || 'bezier'
|
const wireType = this.getBZAttribute('wiretype') || 'bezier'
|
||||||
@@ -546,7 +545,7 @@ class BZgraflow extends Buildoz{
|
|||||||
c2y = Math.floor(y2 - tension)
|
c2y = Math.floor(y2 - tension)
|
||||||
}
|
}
|
||||||
const startAxis = (orientation1=='vertical') ? 'v' : 'h'
|
const startAxis = (orientation1=='vertical') ? 'v' : 'h'
|
||||||
return(this.emitWireSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, false))
|
return(this.buildSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start/end points in SVG coords (works for both bezier and line)
|
// Start/end points in SVG coords (works for both bezier and line)
|
||||||
|
|||||||
Reference in New Issue
Block a user