Commit 78bd811e authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Add show control toolbox item for graph view

This allows to reset the layout to the the inital layout of the graph,
which only contains the control nodes.

Change-Id: I7ab9fb1615057df99983369cd0fcdd42a68e1924
Notry: true
Bug: v8:7327
Reviewed-on: https://chromium-review.googlesource.com/c/1409436
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58814}
parent 441ecad9
This diff was suppressed by a .gitattributes entry.
......@@ -241,6 +241,8 @@ export class GraphView extends View implements PhaseView {
partial(this.layoutAction, this)));
this.toolbox.appendChild(createImgInput("show-all", "show all nodes",
partial(this.showAllAction, this)));
this.toolbox.appendChild(createImgInput("show-control", "show all nodes",
partial(this.showControlAction, this)));
this.toolbox.appendChild(createImgInput("toggle-hide-dead", "show only live nodes",
partial(this.toggleHideDead, this)));
this.toolbox.appendChild(createImgInput("hide-unselected", "show only live nodes",
......@@ -286,15 +288,17 @@ export class GraphView extends View implements PhaseView {
createGraph(data, rememberedSelection) {
this.graph = new Graph(data);
for (const n of this.graph.nodes()) {
n.visible = n.cfg && (!this.state.hideDead || n.isLive());
if (rememberedSelection != undefined && rememberedSelection.has(nodeToStringKey(n))) {
n.visible = true;
this.showControlAction(this);
if (rememberedSelection != undefined) {
for (const n of this.graph.nodes()) {
n.visible = n.visible || rememberedSelection.has(nodeToStringKey(n);
}
}
this.graph.forEachEdge((e: Edge) => {
e.visible = e.type == 'control' && e.source.visible && e.target.visible;
});
this.graph.forEachEdge(e => e.visible = e.source.visible && e.target.visible);
this.layoutGraph();
this.updateGraphVisibility();
}
......@@ -393,6 +397,17 @@ export class GraphView extends View implements PhaseView {
view.viewWholeGraph();
}
showControlAction(view: GraphView) {
for (const n of view.graph.nodes()) {
n.visible = n.cfg && (!view.state.hideDead || n.isLive());
}
view.graph.forEachEdge((e: Edge) => {
e.visible = e.type == 'control' && e.source.visible && e.target.visible;
});
view.updateGraphVisibility();
view.viewWholeGraph();
}
toggleHideDead(view: GraphView) {
view.state.hideDead = !view.state.hideDead;
if (view.state.hideDead) view.hideDead();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment