diff --git a/app/assets/html/bzGraflow/nodesTest1.html b/app/assets/html/bzGraflow/nodesTest1.html index 912b37a..ca6356a 100644 --- a/app/assets/html/bzGraflow/nodesTest1.html +++ b/app/assets/html/bzGraflow/nodesTest1.html @@ -38,10 +38,10 @@ .bzgf-node .port[data-type="in"] { background: #0F0; } .bzgf-node .port[data-type="out"] { background: #FF0; } - .bzgf-node [data-direction="w"]{ left: -7px; top: 50%; } - .bzgf-node [data-direction="e"]{ right: -7px; top: 50%;} - .bzgf-node [data-direction="n"]{ top: -7px; left: 50%;} - .bzgf-node [data-direction="s"]{ bottom: -7px; left: 50%;} + .bzgf-node [data-direction="w"]{ left: -7px; top: 50%; transform: translateY(-50%);} + .bzgf-node [data-direction="e"]{ right: -7px; top: 50%; transform: translateY(-50%);} + .bzgf-node [data-direction="n"]{ top: -7px; left: 50%; transform: translateX(-50%);} + .bzgf-node [data-direction="s"]{ bottom: -7px; left: 50%; transform: translateX(-50%);} .bzgf-node[data-nodetype="inc"]{ background: #DFD; diff --git a/app/assets/html/bzGraflow/nodesTest2.html b/app/assets/html/bzGraflow/nodesTest2.html index 912b37a..b6955cd 100644 --- a/app/assets/html/bzGraflow/nodesTest2.html +++ b/app/assets/html/bzGraflow/nodesTest2.html @@ -11,162 +11,203 @@ padding: .5em; } - .bzgf-node .title { - font-weight: bold; + .bzgf-node .text { position: absolute; - top: 0; - left: 0; + top: 50%; + left: 50%; width: 100%; height: 2em; color: white; + transform: translateX(-50%), translateY(-50%); } - .bzgf-node .body { margin-top: 2em; } - .bzgf-node .body input { - width:4em; - font-size: .9em; - border-radius: 6px; - border: 1px solid #CCC; - } - .bzgf-node .body span{ font-size: 12px; text-align: left; line-height: 21px; } + .bzgf-node .port{ position: absolute; - height: 10px; - width: 10px; - border: 1px solid black; - border-radius: 10px; + height: 6px; + width: 6px; + background: #FFF; + z-index: 99; } - .bzgf-node .port[data-type="in"] { background: #0F0; } - .bzgf-node .port[data-type="out"] { background: #FF0; } - .bzgf-node [data-direction="w"]{ left: -7px; top: 50%; } - .bzgf-node [data-direction="e"]{ right: -7px; top: 50%;} - .bzgf-node [data-direction="n"]{ top: -7px; left: 50%;} - .bzgf-node [data-direction="s"]{ bottom: -7px; left: 50%;} + .bzgf-node [data-direction="w"]{ left: -7px; top: 50%; transform: translateY(-50%);} + .bzgf-node [data-direction="e"]{ right: -7px; top: 50%; transform: translateY(-50%);} + .bzgf-node [data-direction="n"]{ top: -7px; left: 50%; transform: translateX(-50%);} + .bzgf-node [data-direction="s"]{ bottom: -7px; left: 50%; transform: translateX(-50%);} - .bzgf-node[data-nodetype="inc"]{ - background: #DFD; - border-color: #090; + .bzgf-node[data-nodetype="start"], + .bzgf-node[data-nodetype="end"]{ + border: 1px solid white; + width: 100px; + height: 30px; + border-radius: 50%; } - .bzgf-node[data-nodetype="inc"] .title{ background: #090; } + .bzgf-node[data-nodetype="condition"]{ + border: none; + width: 100px; + height: 100px; - .bzgf-node[data-nodetype="wadder"]{ - background: #DFD; - border-color: #090; - height:150px } - .bzgf-node[data-nodetype="wadder"] .body{ display: grid; grid-gap: 4px; margin-left:0.5em; grid-template-columns: 1fr 1fr; align-items: center; } - .bzgf-node[data-nodetype="wadder"] .title{ background: #090; } - .bzgf-node[data-nodetype="wadder"] .port[data-id="inp1"] { top:37px; } - .bzgf-node[data-nodetype="wadder"] .port[data-id="inp2"] { top:63px; } - .bzgf-node[data-nodetype="wadder"] .port[data-id="inp3"] { top:89px; } - .bzgf-node[data-nodetype="wadder"] .port[data-id="inp4"] { top:115px; } - .bzgf-node[data-nodetype="wadder"] .port[data-id="inp5"] { top:141px; } - - .bzgf-node[data-nodetype="factor"]{ - background: #DDF; - border-color: #009; + .bzgf-node[data-nodetype="condition"] .frame{ + border: 1px solid white; + transform: rotate(-45deg); + position: absolute; + inset: 0; } - .bzgf-node[data-nodetype="factor"] .title{ background: #009; } + .bzgf-node[data-nodetype="condition"] .text{ transform: rotate(45deg); } + .bzgf-node[data-nodetype="condition"] .port[data-direction="w"]{ left: -28px; } + .bzgf-node[data-nodetype="condition"] [data-direction="e"]{ right: -28px; } + .bzgf-node[data-nodetype="condition"] [data-direction="n"]{ top: -28px; } + .bzgf-node[data-nodetype="condition"] [data-direction="s"]{ bottom: -28px; } - .bzgf-node[data-nodetype="multiplier"]{ - background: #DDF; - border-color: #009; - height:110px + .bzgf-node[data-nodetype="process"]{ + border: 1px solid white; + width: 150px; + height: 70px; + padding: 0; } - .bzgf-node[data-nodetype="multiplier"] .body{ - font-size:40px; - font-weight: bold; - align-items: center; - display: flex; - justify-content: center; - margin-top: 1em; + .bzgf-node[data-nodetype="process"] .dbline{ + border: 1px solid white; + width: 80%; + height: 100%; + position: absolute; + top: -1px; + left: 10%; } - .bzgf-node[data-nodetype="multiplier"] .title{ background: #009; } - .bzgf-node[data-nodetype="multiplier"] .port[data-id="inp1"] { top:37px; } - .bzgf-node[data-nodetype="multiplier"] .port[data-id="inp2"] { top:63px; } - .bzgf-node[data-nodetype="multiplier"] .port[data-id="inp3"] { top:89px; } - - .bzgf-node[data-nodetype="input"], - .bzgf-node[data-nodetype="console"]{ - background: #CCC; - border-color: #555; - } - .bzgf-node[data-nodetype="input"] .title, - .bzgf-node[data-nodetype="console"] .title{ background: #555; } - .bzgf-wire{ stroke: #0AF; stroke-width: 2; } + .bzgf-node[data-nodetype="database"]{ + border: 1px solid white; + width: 100px; + height: 100px; + isolation: isolate; + } + .bzgf-node[data-nodetype="database"] .top{ + z-index: 2; + height: 20%; + border: 1px solid white; + border-radius: 50%; + position: absolute; + top: -10%; + left: 0; + width: 100%; + background: black; + } + .bzgf-node[data-nodetype="database"] .text{ + background: black; + width: 99%; + height: 98%; + z-index: 1; + position: absolute; + inset: 0; + } + .bzgf-node[data-nodetype="database"] .bottom{ + z-index: 0; + height: 20%; + border: 1px solid white; + border-radius: 50%; + position: absolute; + bottom: -10%; + left: 0; + width: 99%; + background: black; + } + .bzgf-node[data-nodetype="database"] [data-direction="n"]{ top: -17px; } + .bzgf-node[data-nodetype="database"] [data-direction="s"]{ bottom: -17px; } + + .bzgf-node[data-nodetype="preparation"]{ + width: 150px; + height: 80px; + padding: 0; + border: none; + } + .bzgf-node[data-nodetype="preparation"] .outerframe{ + width: 100%; + height: 100%; + position: absolute; + background: white; + border: none; + padding: 0; + place-items: center; + clip-path: polygon( + 10% 0%, + 90% 0%, + 100% 50%, + 90% 100%, + 10% 100%, + 0% 50% + ); + } + .bzgf-node[data-nodetype="preparation"] .innerframe{ + width: calc(100% - 2px); + height: calc(100% - 2px); + position: absolute; + top: 1px; + left: 1px; + background: black; + clip-path: inherit; + display: grid; + place-items: center; + color: white; + } + .bzgf-wire{ stroke: #AAA; stroke-width: 4; } + + + + + + - - - - - - \ No newline at end of file diff --git a/app/assets/html/test.html b/app/assets/html/test.html index 342d069..61fc94d 100644 --- a/app/assets/html/test.html +++ b/app/assets/html/test.html @@ -10,29 +10,47 @@ - - - + + + + + + + diff --git a/app/assets/json/bzGraflow/testFlow2.json b/app/assets/json/bzGraflow/testFlow2.json new file mode 100644 index 0000000..44670da --- /dev/null +++ b/app/assets/json/bzGraflow/testFlow2.json @@ -0,0 +1,39 @@ +{ + "nodesFile": "/app/assets/html/bzGraflow/nodesTest2.html", + "flow": { + "nodes":[ + { "nodeType": "start", + "id": "aze", + "coords": { "x": 220, "y": 20} + }, + { "nodeType": "process", + "id": "aze2", + "coords": { "x": 220, "y": 120} + }, + { "nodeType": "condition", + "id": "qsd", + "coords": { "x": 250, "y": 270} + }, + { "nodeType": "preparation", + "id": "qsd2", + "coords": { "x": 250, "y": 470} + }, + { "nodeType": "database", + "id": "wcx", + "coords": { "x": 250, "y": 650} + }, + { "nodeType": "end", + "id": "ert", + "coords": { "x": 250, "y": 850} + } + ], + "links": [ + { "from": ["aze", "out1"], "to": ["aze2", "inout1"] }, + { "from": ["aze2", "inout2"], "to": ["qsd", "inp1"] }, + { "from": ["qsd", "out1"], "to": ["aze2", "inout3"] }, + { "from": ["qsd", "out2"], "to": ["qsd2", "inp1"] }, + { "from": ["qsd2", "out1"], "to": ["wcx", "inout1"] }, + { "from": ["wcx", "inout2"], "to": ["ert", "inp1"] } + ] + } +} \ No newline at end of file diff --git a/app/libs/HelperBot/HelperBot.module.js b/app/libs/HelperBot/HelperBot.module.js index ba1900d..e5a061f 100644 --- a/app/libs/HelperBot/HelperBot.module.js +++ b/app/libs/HelperBot/HelperBot.module.js @@ -56,7 +56,7 @@ class HelperBot{ this.mechaModel.scale.set(5, 5, 5) this.mechaModel.rotation.set(0, 0, 0) - this.mechaModel.position.set(0, -1.5, 0) + this.mechaModel.position.set(0, -5.5, 0) this.mechaModel.updateMatrix() this.mechaModel.rotateY(-Math.PI) // 180deg so facing user diff --git a/app/thirdparty/buildoz/bzGraflow.js b/app/thirdparty/buildoz/bzGraflow.js index a4aaada..466c45d 100644 --- a/app/thirdparty/buildoz/bzGraflow.js +++ b/app/thirdparty/buildoz/bzGraflow.js @@ -18,13 +18,15 @@ class BZgraflow extends Buildoz{ this.loadFlow(flowUrl) // Let it load async while we coat this.mainContainer = document.createElement('div') this.mainContainer.classList.add('bzgf-main-container') + this.shadow = this.mainContainer.attachShadow({ mode: 'open' }) + this.nodesContainer = document.createElement('div') this.nodesContainer.classList.add('bzgf-nodes-container') this.wiresContainer = document.createElementNS('http://www.w3.org/2000/svg', 'svg') this.wiresContainer.setAttribute('overflow','visible') this.wiresContainer.classList.add('bzgf-wires-container') - this.mainContainer.append(this.wiresContainer) - this.mainContainer.append(this.nodesContainer) + this.shadow.append(this.wiresContainer) + this.shadow.append(this.nodesContainer) this.append(this.mainContainer) } @@ -68,7 +70,7 @@ class BZgraflow extends Buildoz{ styles.forEach(styleEl => { const style = document.createElement('style') style.textContent = styleEl.textContent - document.head.appendChild(style) + this.shadow.appendChild(style) }) BZgraflow._loadedNodeStyles.add(url) } @@ -123,6 +125,10 @@ class BZgraflow extends Buildoz{ const port1 = node1.ports[idPort1] const node2 = this.stagedNodes[idNode2] const port2 = node2.ports[idPort2] + if(!node1 || !node2 || !port1 || !port2) { + console.warn('bezier on bad node / port!', idNode1, idPort1, idNode2, idPort2) + return('') + } const bb1 = port1.el.getBoundingClientRect() const bb2 = port2.el.getBoundingClientRect() const x1 = Math.floor(bb1.x + (bb1.width/2)) - svgRect.left @@ -142,6 +148,11 @@ class BZgraflow extends Buildoz{ } autoPlace(orientation = 'horizontal', gapx = 80, gapy = 30){ + if(this.hasAnyLoop(this.flow.nodes, this.flow.links)){ + console.warn('Loop(s) detected... Cannot auto-place !') + return + } + const parents = {} const adj = {} this.flow.nodes.forEach(n => { @@ -299,16 +310,21 @@ class BZgraflow extends Buildoz{ const visiting = new Set(); const visited = new Set() const dfs = (nid) => { - if(visiting.has(nid)) return(true) + if(visiting.has(nid)) { + return(true) + } + if(visited.has(nid)) return(false) visiting.add(nid) for(const m of adj[nid]) { - if(dfs(m)) return(true) + if(dfs(m)) { + return(true) + } } visiting.delete(nid) visited.add(nid) return(false) - } + } return(this.flow.nodes.map(n => n.id).some(dfs)) }