From aa2541f6e35b0b48909c6cbe5326db764f232747 Mon Sep 17 00:00:00 2001 From: ZhangGe6 Date: Fri, 29 Apr 2022 14:56:48 +0800 Subject: [PATCH] fix bug in delete_backtrack() --- __pycache__/app.cpython-38.pyc | Bin 366 -> 0 bytes app.py | 2 +- static/index.js | 4 ++-- static/view-grapher.js | 2 +- static/view-sidebar.js | 4 ++-- static/view.js | 32 ++++++++++++++++++++------------ 6 files changed, 26 insertions(+), 18 deletions(-) delete mode 100644 __pycache__/app.cpython-38.pyc diff --git a/__pycache__/app.cpython-38.pyc b/__pycache__/app.cpython-38.pyc deleted file mode 100644 index 330c705d9f5ec85d2aa64c6fc57fb4beaf0d4977..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 366 zcmYjLu};G<5cN568da*`H?jn=B7~5NVC#aqM3JJjK1fwNiEKv#*75;-LK*oW7OzbF zLZ_a?K%aE){7(1$ZaJGx8R2`sT76Le3E~tHiCZe06G5;@A-0sX`m zZ_^EVU-HIjm4OLoeK8}bjdZx2UzJOX#+F4>x6cn)-l5&Pt}k13rfVy^(WUJMv&ORS z`@DbkqCus)ID~~%#?6FykxdHm6z(-)IwtwFs@hs(Rr!d_UYKrhIIjPn@b^l{mfpH2?qr diff --git a/app.py b/app.py index a6c82ce..618c8d7 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,5 @@ -from flask import Flask, render_template, request import json +from flask import Flask, render_template, request from onnx_modifier import onnxModifier app = Flask(__name__) diff --git a/static/index.js b/static/index.js index b50f1ef..48ce9b8 100644 --- a/static/index.js +++ b/static/index.js @@ -270,8 +270,8 @@ host.BrowserHost = class { openFileDialog.click(); }); openFileDialog.addEventListener('change', (e) => { - console.log(e) - console.log(e.target.value) + // console.log(e) + // console.log(e.target.value) if (e.target && e.target.files && e.target.files.length > 0) { const files = Array.from(e.target.files); const file = files.find((file) => this._view.accept(file.name)); diff --git a/static/view-grapher.js b/static/view-grapher.js index 1c0aad5..0670271 100644 --- a/static/view-grapher.js +++ b/static/view-grapher.js @@ -176,7 +176,7 @@ grapher.Graph = class { edgePathGroupDefs.appendChild(marker("arrowhead-vee-select")); // <==== 显示 边上的箭头 - console.log(this._modelNodeName2State) + // console.log(this._modelNodeName2State) // console.log(this.nodes) for (const nodeId of this.nodes.keys()) { const node = this.node(nodeId); diff --git a/static/view-sidebar.js b/static/view-sidebar.js index 35216a0..3aeb865 100644 --- a/static/view-sidebar.js +++ b/static/view-sidebar.js @@ -137,7 +137,7 @@ sidebar.NodeSidebar = class { this.add_span('between-delete') this._addButton('Delete Single Node'); this.add_separator('line_DR') - this._addButton('Recover Node'); + this._addButton('Reset Node'); if (node.type) { let showDocumentation = null; @@ -287,7 +287,7 @@ sidebar.NodeSidebar = class { this._host._view._graph.delete_node_with_children(this._modelNodeName) }); } - if (title === 'Recover Node') { + if (title === 'Reset Node') { // console.log('pressed') buttonElement.addEventListener('click', () => { this._host._view._graph.recover_node(this._modelNodeName) diff --git a/static/view.js b/static/view.js index f46fa88..0ec2e89 100644 --- a/static/view.js +++ b/static/view.js @@ -484,12 +484,12 @@ view.View = class { this.lastViewGraph = this._graph; // console.log("this.lastViewGraph") // console.log(this.lastViewGraph) - if (this.lastViewGraph) { - // console.log(this._graph) - // this.lastModelNodeName2State = lastViewGraph._modelNodeName2State; - console.log('lastViewGraph _modelNodeName2State') - console.log(this.lastViewGraph._modelNodeName2State) - } + // if (this.lastViewGraph) { + // // console.log(this._graph) + // // this.lastModelNodeName2State = lastViewGraph._modelNodeName2State; + // console.log('lastViewGraph _modelNodeName2State') + // console.log(this.lastViewGraph._modelNodeName2State) + // } // console.log("_updateGraph is called"); return this._timeout(100).then(() => { @@ -1048,7 +1048,7 @@ view.Graph = class extends grapher.Graph { this._modelNodeName2ViewNode.get(node_name).element.style.opacity = 0.3; } - recover_node(node_name) { + reset_node(node_name) { this._modelNodeName2State.set(node_name, 'Existed'); this._modelNodeName2ViewNode.get(node_name).element.style.opacity = 1; } @@ -1063,13 +1063,20 @@ view.Graph = class extends grapher.Graph { delete_backtrack(node_name) { // console.log(this._modelNodeName2ViewNode) // console.log(node_name) // empty - this._modelNodeName2State.set(node_name, 'Deleted'); - this._modelNodeName2ViewNode.get(node_name).element.style.opacity = 0.3; - if (!this._namedEdges.has(node_name)) { + if (this._modelNodeName2State.get(node_name) == 'Deleted' || + !this._namedEdges.has(node_name) // for output node + ) + { return; } + this._modelNodeName2State.set(node_name, 'Deleted'); + this._modelNodeName2ViewNode.get(node_name).element.style.opacity = 0.3; + + // console.log('deleting') + // console.log(node_name) + for (var i = 0; i < this._namedEdges.get(node_name).length; i++) { this.delete_backtrack(this._namedEdges.get(node_name)[i]) } @@ -1078,11 +1085,11 @@ view.Graph = class extends grapher.Graph { resetGraph() { for (const nodeId of this.nodes.keys()) { const node = this.node(nodeId); - console.log(node.label.modelNodeName) + // console.log(node.label.modelNodeName) this._modelNodeName2State.set(node.label.modelNodeName, 'Exist') } - console.log(this._modelNodeName2State) + // console.log(this._modelNodeName2State) } @@ -1091,6 +1098,7 @@ view.Graph = class extends grapher.Graph { for (const argument of this._arguments.values()) { argument.build(); } + console.log(this._namedEdges) super.build(document, origin); } };