Skip to content

Commit

Permalink
Fixes to edge summarization
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed May 27, 2024
1 parent 7f8d439 commit 6b743e2
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,10 @@ export class SDFGRenderer extends EventEmitter {

// Make all edges of a node visible and remove the edge
// summary symbol.
if (obj.hovered && hover_changed) {
if (obj.hovered && hover_changed &&
obj instanceof SDFGNode &&
(obj.in_summary_has_effect ||
obj.out_summary_has_effect)) {
// Setting these to false will cause the summary
// symbol not to be drawn in renderer_elements.ts
obj.summarize_in_edges = false;
Expand Down
73 changes: 63 additions & 10 deletions src/renderer/renderer_elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,31 @@ export class SDFGElement {
max_connector_x = c.x;
});

// Draw the summary symbol above the node
draw_summary_symbol(
ctx, min_connector_x, max_connector_x,
topleft.y - 8, true
);
let drawInSummarySymbol = true;
const preds = this.parentElem?.data.graph?.predecessors(
this.id
) ?? [];
if (preds.length === 1) {
const predElem = this.parentElem?.data.graph.node(
preds[0]
) as SDFGElement;
if (predElem.summarize_out_edges &&
predElem.out_summary_has_effect) {
// If the previous element has its outgoing edges
// summarized, draw the sumary symbol halfway in
// between them. This is handled by the predecessor.
// noop.
drawInSummarySymbol = false;
}
}

if (drawInSummarySymbol) {
// Draw the summary symbol above the node
draw_summary_symbol(
ctx, min_connector_x, max_connector_x,
topleft.y - 8, true
);
}
}
}
if (this.summarize_out_edges && this.out_summary_has_effect) {
Expand All @@ -327,11 +347,44 @@ export class SDFGElement {
max_connector_x = c.x;
});

// Draw the summary symbol below the node
draw_summary_symbol(
ctx, min_connector_x, max_connector_x,
topleft.y + this.height + 8, false
);
let drawOutSummarySymbol = true;
const succs = this.parentElem?.data.graph?.successors(
this.id
) ?? [];
if (succs.length === 1) {
const succElem = this.parentElem?.data.graph.node(
succs[0]
) as SDFGElement;
if (succElem.summarize_in_edges &&
succElem.in_summary_has_effect) {
// If the next element has its incoming edges
// summarized, draw the sumary symbol halfway in
// between them.
const succTopLeft = succElem.topleft();
const minX = Math.min(succTopLeft.x, topleft.x);
const maxX = Math.max(
succTopLeft.x + succElem.width,
topleft.x + this.width
);
const linePosY = (
(topleft.y + (
succTopLeft.y + succElem.height
)) / 2
) - 8;
draw_summary_symbol(
ctx, minX, maxX, linePosY, false
);
drawOutSummarySymbol = false;
}
}

if (drawOutSummarySymbol) {
// Draw the summary symbol below the node
draw_summary_symbol(
ctx, min_connector_x, max_connector_x,
topleft.y + this.height + 8, false
);
}
}
}
}
Expand Down

0 comments on commit 6b743e2

Please sign in to comment.