Skip to content

Commit

Permalink
Merge branch 'hierarchical_sdfg_compat' into april_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Apr 17, 2024
2 parents 7ae672e + e72214f commit 1ee6932
Show file tree
Hide file tree
Showing 6 changed files with 1,161 additions and 945 deletions.
2,073 changes: 1,143 additions & 930 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"typescript": "^5.3.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
"webpack-dev-server": "^5.0"
},
"dependencies": {
"@babel/runtime": "^7.20.7",
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class SDFGRenderer extends EventEmitter {
protected bgcolor: string | null = null;
protected visible_rect: SimpleRect | null = null;
protected static cssProps: { [key: string]: string } = {};
public static rendered_elements_count: number = 0;

// Toolbar related fields.
protected toolbar: JQuery<HTMLElement> | null = null;
Expand Down Expand Up @@ -2378,7 +2379,7 @@ export class SDFGRenderer extends EventEmitter {
const visible_rectCenter = {
x: (visible_rect.x + (visible_rect.w / 2)),
y: (visible_rect.y + (visible_rect.h / 2))
}
};

const graphLimits = {
minX: 0,
Expand Down Expand Up @@ -2406,10 +2407,10 @@ export class SDFGRenderer extends EventEmitter {
}

// Take uncorrected mouse event movement as default
let correctedMovement = {
const correctedMovement = {
x: movX,
y: movY
}
};

// Correct mouse movement if necessary
if ((outofboundsX === -1 && correctedMovement.x > 0) ||
Expand Down
17 changes: 8 additions & 9 deletions src/renderer/renderer_elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ export abstract class Edge extends SDFGElement {
y: Math.min(linepoint_0.y, linepoint_1.y),
w: Math.abs(linepoint_1.x - linepoint_0.x),
h: Math.abs(linepoint_1.y - linepoint_0.y)
}
};

// Check if the two rectangles intersect
if (r.x + r.w >= x && r.x <= x+w &&
Expand All @@ -1094,7 +1094,6 @@ export class Memlet extends Edge {
// Straight line can be drawn
ctx.lineTo(this.points[1].x, this.points[1].y);
} else {

let i;
if (SDFVSettings.curvedEdges) {
for (i = 1; i < this.points.length - 2; i++) {
Expand Down Expand Up @@ -2501,12 +2500,10 @@ function too_far_away_for_text(renderer: SDFGRenderer, ctx: CanvasRenderingConte
const canvas_manager = renderer.get_canvas_manager();
const ppp = canvas_manager?.points_per_pixel();
if (ppp) {
if ((ctx as any).lod && ppp > SDFV.TEXT_LOD) {
if ((ctx as any).lod && ppp > SDFV.TEXT_LOD)
return true;
}
else {
else
return false;
}
}

return false;
Expand Down Expand Up @@ -2578,6 +2575,7 @@ function batchedDrawEdges(
labelEdges.push(edge);

edge.create_arrow_line(ctx);
// SDFGRenderer.rendered_elements_count++;
});
ctx.setLineDash([1, 0]);
ctx.fillStyle = ctx.strokeStyle = renderer.getCssProperty(color);
Expand All @@ -2587,7 +2585,6 @@ function batchedDrawEdges(
const canvas_manager = renderer.get_canvas_manager();
const ppp = canvas_manager?.points_per_pixel();
if (!(ctx as any).lod || (ppp && ppp < SDFV.ARROW_LOD)) {

arrowEdges.forEach(e => {
e.drawArrow(
ctx, e.points[e.points.length - 2], e.points[e.points.length - 1], 3
Expand Down Expand Up @@ -2630,12 +2627,14 @@ export function drawStateContents(
) < SDFV.STATE_LOD) {
node.simple_draw(renderer, ctx, mousePos);
node.debug_draw(renderer, ctx);
// SDFGRenderer.rendered_elements_count++;
continue;
}
} else {
if (lod && ppp > SDFV.NODE_LOD) {
node.simple_draw(renderer, ctx, mousePos);
node.debug_draw(renderer, ctx);
// SDFGRenderer.rendered_elements_count++;
continue;
}
}
Expand All @@ -2645,9 +2644,7 @@ export function drawStateContents(

// Only draw connectors when close enough to see them
if (!lod || ppp < SDFV.CONNECTOR_LOD) {

node.in_connectors.forEach((c: Connector) => {

// Only draw connectors if actually visible. This is needed for large
// nodes in the background like NestedSDFGs, that are visible, but their
// connectors are actually not.
Expand Down Expand Up @@ -2727,6 +2724,7 @@ export function drawStateMachine(

block.draw(renderer, ctx, mousePos);
block.debug_draw(renderer, ctx);
// SDFGRenderer.rendered_elements_count++;

const ng = block.data.graph;
if (!block.attributes().is_collapsed && ng) {
Expand Down Expand Up @@ -2754,6 +2752,7 @@ export function drawSDFG(
const ppp = cManager.points_per_pixel();
const visibleRect = renderer.get_visible_rect() ?? undefined;

SDFGRenderer.rendered_elements_count = 0;
drawStateMachine(
g, ctx, renderer, ppp, (ctx as any).lod, visibleRect, mousePos
);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/sdfg/json_serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const propertyReplacements_0_16_0: { [key: string]: {
replaceWith: string,
recursive: boolean,
}} = {
'start_state': {
'start_block': {
replaceWith: 'start_block',
recursive: false,
},
'sdfg_list_id': {
'cfg_list_id': {
replaceWith: 'cfg_list_id',
recursive: true,
},
Expand Down
3 changes: 3 additions & 0 deletions src/utils/sdfg/sdfg_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
SDFGNode,
NestedSDFG,
State,
SDFG,
ControlFlowRegion,
} from '../../renderer/renderer_elements';
import {
DagreSDFG,
Expand Down Expand Up @@ -138,6 +140,7 @@ export function find_graph_element_by_uuid(
p_graph: DagreSDFG | undefined | null, uuid: string
): { parent: DagreSDFG | undefined, element: any } {
const uuid_split = uuid.split('/');
console.log('Trying to find:', uuid);

const graph_id = Number(uuid_split[0]);
const state_id = Number(uuid_split[1]);
Expand Down

0 comments on commit 1ee6932

Please sign in to comment.