diff --git a/src/renderer/renderer.ts b/src/renderer/renderer.ts index 286bdb62..c08d18ae 100644 --- a/src/renderer/renderer.ts +++ b/src/renderer/renderer.ts @@ -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; diff --git a/src/renderer/renderer_elements.ts b/src/renderer/renderer_elements.ts index 43a16960..c342cc56 100644 --- a/src/renderer/renderer_elements.ts +++ b/src/renderer/renderer_elements.ts @@ -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) { @@ -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 + ); + } } } }