diff --git a/.gitignore b/.gitignore index b4dd87e..1274ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ __pycache__/ gym/ -*.onnx \ No newline at end of file +res_onnx/*.onnx \ No newline at end of file diff --git a/static/onnx.js b/static/onnx.js index 133f315..0cb6143 100644 --- a/static/onnx.js +++ b/static/onnx.js @@ -530,6 +530,11 @@ onnx.Argument = class { return this._name; } + // https://bobbyhadz.com/blog/javascript-cannot-set-property-which-has-only-getter + set name(name) { + this._name = name; + } + get type() { return this._type; } diff --git a/static/view-sidebar.js b/static/view-sidebar.js index 4bad45e..fcea5ec 100644 --- a/static/view-sidebar.js +++ b/static/view-sidebar.js @@ -240,10 +240,16 @@ sidebar.NodeSidebar = class { origNameElement.innerHTML = argument.name + " => "; const newNameElement = this._host.document.createElement('input'); newNameElement.setAttribute('type', 'text'); + // reload the existed renamed value + if (this._host._view._graph._renameMap.get(this._modelNodeName) && + this._host._view._graph._renameMap.get(this._modelNodeName).get(argument.name)) + { + newNameElement.setAttribute('value', this._host._view._graph._renameMap.get(this._modelNodeName).get(argument.name)); + } newNameElement.addEventListener('input', (e) => { // console.log(e.target.value); this._host._view._graph.recordRenameInfo(this._modelNodeName, argument.name, e.target.value); - console.log(this._host._view._graph._renameMap); + // console.log(this._host._view._graph._renameMap); }); @@ -259,8 +265,8 @@ sidebar.NodeSidebar = class { } render() { - console.log(this._elements) - console.log(this._renameAuxelements) + // console.log(this._elements) + // console.log(this._renameAuxelements) // return this._elements; return this._elements.concat(this._renameAuxelements); } @@ -577,7 +583,7 @@ sidebar.ValueTextView = class { } render() { - console.log(this._elements) + // console.log(this._elements) return this._elements; } diff --git a/static/view.js b/static/view.js index e44f9eb..6e73012 100644 --- a/static/view.js +++ b/static/view.js @@ -589,6 +589,8 @@ view.View = class { // console.log(this.lastViewGraph._modelNodeName2State) // console.log('node state of lastViewGraph is loaded') viewGraph._modelNodeName2State = this.lastViewGraph._modelNodeName2State; + viewGraph._renameMap = this.lastViewGraph._renameMap; + // console.log(viewGraph._renameMap); } // console.log(viewGraph._modelNodeName2State) viewGraph.add(graph); @@ -953,6 +955,15 @@ view.Graph = class extends grapher.Graph { for (const input of inputs) { for (const argument of input.arguments) { if (argument.name != '' && !argument.initializer) { + // if this argument has been renamed + if ( + this._renameMap.get(viewNode.modelNodeName) && + this._renameMap.get(viewNode.modelNodeName).get(argument.name) + ) + { + argument.name = this._renameMap.get(viewNode.modelNodeName).get(argument.name); + } + this.createArgument(argument).to(viewNode); } } @@ -970,6 +981,17 @@ view.Graph = class extends grapher.Graph { throw new view.Error("Invalid null argument in '" + this.model.identifier + "'."); } if (argument.name != '') { + // if this argument has been renamed + if ( + this._renameMap.get(viewNode.modelNodeName) && + this._renameMap.get(viewNode.modelNodeName).get(argument.name) + ) + { + console.log(argument.name) + console.log(this._renameMap.get(viewNode.modelNodeName).get(argument.name)) + argument.name = this._renameMap.get(viewNode.modelNodeName).get(argument.name); + } + this.createArgument(argument).from(viewNode); } }