Skip to content

Commit

Permalink
[MPQEditor] Introduce VISQ data
Browse files Browse the repository at this point in the history
This draft introduces VISQ data.

ONE-vscode-DCO-1.0-Signed-off-by: s.malakhov <[email protected]>
  • Loading branch information
stamalakhov committed May 24, 2023
1 parent b3ecd48 commit c42aed9
Showing 1 changed file with 54 additions and 21 deletions.
75 changes: 54 additions & 21 deletions media/CircleGraph/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,23 @@ view.View = class {
}
}

updateSelectionNodes() {
if (this._selectionNodes.length > 0) {
let names = [];
for (let node of this._selectionNodes) {
node.value._outputs.forEach((output) => {
output._arguments.forEach((arg) => {
// NOTE name is tensor_name + tensor_index, in circle.js
const mixed = arg._name.split(/\n/);
const name = mixed[0];
names.push(name);
});
});
}
this.setSelectionByNames(names);
}
}

/**
* @brief turn on selection for nodes with selection.names array
*/
Expand All @@ -653,32 +670,39 @@ view.View = class {
if (Object.prototype.hasOwnProperty.call(selection, "names")) {
// selection is by names
const names = selection.names;
let scrollToSelects = []; // elements to make visible by scroll to
this.setSelectionByNames(names);
}
// TODO select with others
}

for (const nodeId of this._graph.nodes.keys()) {
const node = this._graph.node(nodeId);
if (node.label.value._outputs) {
node.label.value._outputs.forEach((output) => {
output._arguments.forEach((arg) => {
// NOTE name is tensor_name + tensor_index, in circle.js
const mixed = arg._name.split(/\n/);
const name = mixed[0];
if (names.includes(name)) {
this.selectViewNode(node.label);
if (this._scrollToSelected) {
scrollToSelects.push(node.label.element);
}
/**
* @brief turn on selection for nodes with names array
*/
setSelectionByNames(names) {
let scrollToSelects = []; // elements to make visible by scroll to

for (const nodeId of this._graph.nodes.keys()) {
const node = this._graph.node(nodeId);
if (node.label.value._outputs) {
node.label.value._outputs.forEach((output) => {
output._arguments.forEach((arg) => {
// NOTE name is tensor_name + tensor_index, in circle.js
const mixed = arg._name.split(/\n/);
const name = mixed[0];
if (names.includes(name)) {
this.selectViewNode(node.label);
if (this._scrollToSelected) {
scrollToSelects.push(node.label.element);
}
});
}
});
}
}
if (this._scrollToSelected) {
// make elements to be visible
this.scrollToSelection(scrollToSelects);
});
}
}
// TODO select with others
if (this._scrollToSelected) {
// make elements to be visible
this.scrollToSelection(scrollToSelects);
}
}

setNodeBackend(node, backend) {
Expand Down Expand Up @@ -902,6 +926,7 @@ view.View = class {
backButton.style.opacity = 0;
nameButton.style.opacity = 0;
}
this.updateSelectionNodes();
};
return this.renderGraph(this._model, this.activeGraph)
.then(() => {
Expand Down Expand Up @@ -1650,7 +1675,15 @@ view.Node = class extends grapher.Node {
const list = this.list();
if (host._mode === viewMode.viewer || host._mode === viewMode.visq) {
list.on("click", () => this.context.view.showNodeProperties(node));
} else if (
host._mode === viewMode.selector ||
host._mode === viewMode.visqselector
) {
list.on("click", () => {
this.context.view.toggleSelect(this);
});
}

for (const initializer of initializers) {
const argument = initializer.arguments[0];
const type = argument.type;
Expand Down

0 comments on commit c42aed9

Please sign in to comment.