Skip to content

Commit

Permalink
Address some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Sep 5, 2024
1 parent c404df7 commit 5625375
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 270 deletions.
5 changes: 5 additions & 0 deletions scss/color_schemes/default.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

$sdfv-diff-added: rgba(93, 186, 76, 0.5);
$sdfv-diff-removed: rgba(255, 109, 69, 0.5);
$sdfv-diff-changed: rgba(255, 204, 84, 0.5);
18 changes: 12 additions & 6 deletions scss/sdfv.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
$material-symbols-font-path: "~material-symbols/";
@import "~material-symbols";

@import "./color_schemes/default";

.sdfv {
@import "~bootstrap/scss/bootstrap";
}
Expand Down Expand Up @@ -245,26 +247,26 @@ body.sdfv {
color: rgba(20, 20, 20, 1.0);

&.removed {
background-color: rgba(255, 109, 69, 0.5);
background-color: $sdfv-diff-removed;

&:hover {
background-color: darken(rgba(212, 92, 59, 0.5), 5%);
background-color: darken($sdfv-diff-removed, 5%);
}
}

&.added {
background-color: rgba(93, 186, 76, 0.5);
background-color: $sdfv-diff-added;

&:hover {
background-color: darken(rgba(93, 186, 76, 0.8), 5%);
background-color: darken($sdfv-diff-added, 5%);
}
}

&.changed {
background-color: rgba(255, 204, 84, 0.5);
background-color: $sdfv-diff-changed;

&:hover {
background-color: darken(rgba(255, 192, 43, 0.5), 5%);
background-color: darken($sdfv-diff-changed, 5%);
}
}

Expand Down Expand Up @@ -400,6 +402,10 @@ body.sdfv {
--local-view-edge-overlay-width: 10;
--local-view-edge-overlay-arrowhead-length: 30;
--local-view-edge-overlay-fontsize: 20;

--color-diff-added: #{$sdfv-diff-added};
--color-diff-removed: #{$sdfv-diff-removed};
--color-diff-changed: #{$sdfv-diff-changed};
}

#access-pattern-button-box .button {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export * from './utils/sanitization';
export * from './utils/utils';
export * from './overlay_manager';
export * from './sdfv';
export * from './sdfv_ui';

export type SymbolMap = {
[symbol: string]: number | undefined,
Expand Down
21 changes: 14 additions & 7 deletions src/overlays/diff_overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SDFGElementType,
Edge,
} from '../renderer/renderer_elements';
import { DiffMap } from '../sdfg_diff_viewr';
import { DiffMap } from '../sdfg_diff_viewer';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

export class DiffOverlay extends GenericSdfgOverlay {
Expand Down Expand Up @@ -47,12 +47,19 @@ export class DiffOverlay extends GenericSdfgOverlay {
public shadeElem(
elem: Edge | SDFGNode, ctx: CanvasRenderingContext2D
): void {
if (this.diffMap?.addedKeys.has(elem.attributes().guid))
elem.shade(this.renderer, ctx, this.ADDED_COLOR);
else if (this.diffMap?.removedKeys.has(elem.attributes().guid))
elem.shade(this.renderer, ctx, this.REMOVED_COLOR);
else if (this.diffMap?.changedKeys.has(elem.attributes().guid))
elem.shade(this.renderer, ctx, this.CHANGED_COLOR);
if (this.diffMap?.addedKeys.has(elem.guid())) {
elem.shade(this.renderer, ctx, this.renderer.getCssProperty(
'--color-diff-added'
), 1);
} else if (this.diffMap?.removedKeys.has(elem.guid())) {
elem.shade(this.renderer, ctx, this.renderer.getCssProperty(
'--color-diff-removed'
), 1);
} else if (this.diffMap?.changedKeys.has(elem.guid())) {
elem.shade(this.renderer, ctx, this.renderer.getCssProperty(
'--color-diff-changed'
), 1);
}
}

public recursivelyShadeCFG(
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/renderer_elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ export class SDFGElement {
}

public guid(): string {
if (this.attributes().guid)
return this.attributes().guid;
// If GUID does not exist, fall back to element ID
return this.cfg?.cfg_list_id + '/' + (
return (this.cfg?.cfg_list_id ?? 0) + '/' + (
this.parent_id ?? -1) + '/' + this.id;
}

Expand Down
20 changes: 11 additions & 9 deletions src/sdfg_diff_viewr.ts → src/sdfg_diff_viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,25 +180,25 @@ export abstract class SDFGDiffViewer implements ISDFV {
const addedIDs: Map<string, [any, SDFGRenderer][]> = new Map();
const mergedResults: string[] = [];
for (const res of lResults) {
const existing = addedIDs.get(res.attributes().guid);
const existing = addedIDs.get(res.guid());
if (existing) {
existing.push([res, this.leftRenderer]);
} else {
const newEntry: [any, SDFGRenderer][] =
[[res, this.leftRenderer]];
addedIDs.set(res.attributes().guid, newEntry);
mergedResults.push(res.attributes().guid);
addedIDs.set(res.guid(), newEntry);
mergedResults.push(res.guid());
}
}
for (const res of rResults) {
const existing = addedIDs.get(res.attributes().guid);
const existing = addedIDs.get(res.guid());
if (existing) {
existing.push([res, this.rightRenderer]);
} else {
const newEntry: [any, SDFGRenderer][] =
[[res, this.rightRenderer]];
addedIDs.set(res.attributes().guid, newEntry);
mergedResults.push(res.attributes().guid);
addedIDs.set(res.guid(), newEntry);
mergedResults.push(res.guid());
}
}

Expand All @@ -212,7 +212,7 @@ export abstract class SDFGDiffViewer implements ISDFV {
continue;

let status: ChangeState = 'nodiff';
const guid = res[0][0].attributes().guid;
const guid = res[0][0].guid();
if (this.diffMap?.changedKeys.has(guid))
status = 'changed';
else if (this.diffMap?.removedKeys.has(guid))
Expand Down Expand Up @@ -392,6 +392,8 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer {
rendererSelectionChange(rightRenderer);
});

console.log(leftRenderer.get_graph());
console.log(rightRenderer.get_graph());
SDFGDiffViewer.diff(graphA, graphB).then(diff => {
viewer.diffMap = diff;
const leftOverlay = new DiffOverlay(leftRenderer, diff);
Expand All @@ -412,7 +414,7 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer {
): (localGraphDiffStackEntry | null)[] {
const elemClass = (elem: SDFGElement | JsonSDFG): ChangeState => {
const guid = elem instanceof SDFGElement ?
elem.attributes().guid : elem.attributes.guid;
elem.guid() : elem.attributes.guid;
if (this.diffMap?.addedKeys.has(guid))
return 'added';
else if (this.diffMap?.removedKeys.has(guid))
Expand Down Expand Up @@ -456,7 +458,7 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer {

// Create element
const elemEntry = {
guid: node.attributes().guid,
guid: node.guid(),
htmlLabel: htmlSanitize`
${node_type} ${node.label()}${is_collapsed ? ' (collapsed)' : ''}
`,
Expand Down
Loading

0 comments on commit 5625375

Please sign in to comment.