Skip to content

Commit

Permalink
Allow diff maps to be precomputed
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Sep 13, 2024
1 parent 8bc9be4 commit 27174b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/sdfg_diff_viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer {
);
}

public static init(graphA: JsonSDFG, graphB: JsonSDFG): WebSDFGDiffViewer {
public static init(graphA: JsonSDFG, graphB: JsonSDFG, precomputedDiff?: DiffMap): WebSDFGDiffViewer {
const leftContainer = document.getElementById('diff-contents-A');
const rightContainer = document.getElementById('diff-contents-B');
if (!leftContainer || !rightContainer)
Expand Down Expand Up @@ -426,7 +426,8 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer {
lSDFG.sdfgDagreGraph = leftRenderer.get_graph() ?? undefined;
const rSDFG = new SDFG(graphB);
rSDFG.sdfgDagreGraph = rightRenderer.get_graph() ?? undefined;
SDFGDiffViewer.diff(lSDFG, rSDFG).then(diff => {

const onDiffCreated = (diff: DiffMap) => {
viewer.diffMap = diff;
const leftOverlay = new DiffOverlay(leftRenderer, diff);
const rightOverlay = new DiffOverlay(rightRenderer, diff);
Expand All @@ -436,7 +437,15 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer {
rightRenderer.overlayManager.register_overlay_instance(
rightOverlay
);
});
};

if (precomputedDiff) {
onDiffCreated(precomputedDiff);
} else {
SDFGDiffViewer.diff(lSDFG, rSDFG).then(diff => {
onDiffCreated(diff);
});
}

return viewer;
}
Expand Down
6 changes: 3 additions & 3 deletions src/sdfv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
stringify_sdfg,
} from './utils/sdfg/json_serializer';
import { SDFVSettings } from './utils/sdfv_settings';
import { WebSDFGDiffViewer } from './sdfg_diff_viewer';
import { DiffMap, WebSDFGDiffViewer } from './sdfg_diff_viewer';
import { ISDFVUserInterface, SDFVWebUI } from './sdfv_ui';

declare const vscode: any;
Expand Down Expand Up @@ -244,15 +244,15 @@ export class WebSDFV extends SDFV {
fileReader.readAsArrayBuffer(this.currentSDFGFile);
}

public enterDiffView(sdfgA: JsonSDFG, sdfgB: JsonSDFG): void {
public enterDiffView(sdfgA: JsonSDFG, sdfgB: JsonSDFG, precomputedDiff?: DiffMap): void {
$('#contents').hide();

this.renderer?.destroy();

this.UI.infoClear();
this.deregisterEventListeners();

WebSDFGDiffViewer.init(sdfgA, sdfgB);
WebSDFGDiffViewer.init(sdfgA, sdfgB, precomputedDiff);

$('#diff-container').show();
}
Expand Down

0 comments on commit 27174b1

Please sign in to comment.