Browse Source

ONNX function support (#773)

Lutz Roeder 4 years ago
parent
commit
8b8887f20d
2 changed files with 16 additions and 8 deletions
  1. 1 1
      source/view-sidebar.js
  2. 15 7
      source/view.js

+ 1 - 1
source/view-sidebar.js

@@ -139,7 +139,7 @@ sidebar.NodeSidebar = class {
             const type = node.type;
             if (type && (type.description || type.inputs || type.outputs || type.attributes)) {
                 showDocumentation = {};
-                showDocumentation.text = '?';
+                showDocumentation.text = type.nodes ? '\u0192': '?';
                 showDocumentation.callback = () => {
                     this._raise('show-documentation', null);
                 };

+ 15 - 7
source/view.js

@@ -463,7 +463,10 @@ view.View = class {
     }
 
     _updateGraph(model, graphs) {
-        const graph = Array.isArray(graphs) && graphs.length > 0 ? graphs[0] : null;
+        const active = (graphs) => {
+            return Array.isArray(graphs) && graphs.length > 0 ? graphs[0] : null;
+        };
+        const graph = active(graphs);
         return this._timeout(100).then(() => {
             if (graph && graph != this._graphs[0]) {
                 const nodes = graph.nodes;
@@ -483,7 +486,7 @@ view.View = class {
                 }
                 return this._model;
             }).catch((error) => {
-                return this.renderGraph(this._model, this._graphs[0]).then(() => {
+                return this.renderGraph(this._model, active(this._graphs)).then(() => {
                     if (!graphs || graphs.length <= 1) {
                         this.show('default');
                     }
@@ -495,14 +498,14 @@ view.View = class {
         });
     }
 
-    _pushGraph(graph) {
+    pushGraph(graph) {
         if (graph !== this._graphs[0]) {
             return this._updateGraph(this._model, [ graph ].concat(this._graphs));
         }
         return Promise.resolve();
     }
 
-    _popGraph() {
+    popGraph() {
         if (this._graphs.length > 1) {
             return this._updateGraph(this._model, this._graphs.subarray(1));
         }
@@ -935,7 +938,7 @@ view.View = class {
         const type = node.type;
         if (type && (type.description || type.inputs || type.outputs || type.attributes)) {
             if (type.nodes) {
-                this._pushGraph(type);
+                this.pushGraph(type);
             }
             const documentationSidebar = new sidebar.DocumentationSidebar(this._host, type);
             documentationSidebar.on('navigate', (sender, e) => {
@@ -1033,8 +1036,13 @@ view.Node = class extends grapher.Node {
         header.add(null, styles, content, tooltip, () => {
             this.context.view.showNodeProperties(node, null);
         });
-        if (node.function) {
-            header.add(null, [ 'node-item-function' ], '+', null, () => {
+        if (node.type.nodes) {
+            header.add(null, styles, '\u238B', 'Show Function Definition', () => {
+                this.context.view.pushGraph(node.type);
+            });
+        }
+        if (node.nodes) {
+            header.add(null, styles, '+', null, () => {
                 // debugger;
             });
         }