Skip to content
Snippets Groups Projects
Commit b03f3586 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[dome/diagram] more edge attributes

parent dfe65094
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,9 @@ export type Shape =
| 'circle' | 'ellipse'
| 'note' | 'tab' | 'folder' | 'cds';
export type Anchor =
'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_';
export type Arrow = 'none' | 'arrow' | 'tee' | 'box' | 'dot';
export type Line = 'solid' | 'dashed' | 'dotted';
......@@ -94,20 +97,19 @@ export interface Edge {
line?: Line;
/** Default is `dark` */
color?: Color;
/** Default is `arrow` */
head?: Arrow;
/** Default is `none` */
headLabel?: string,
headAnchor?: Anchor;
tail?: Arrow;
/** Label font */
tailLabel?: string,
tailAnchor?: Anchor;
font?: Font;
/** Label */
label?: string;
/** Tooltip */
title?: string;
/** Head label */
headLabel?: string,
/** Tail label */
tailLabel?: string,
/** Edge constraints node placement (default: true). */
constraint?: boolean;
/** Node placement on the same rank (default: false). */
aligned?: boolean;
}
export interface Cluster {
......@@ -319,7 +321,10 @@ class Builder {
}
attr(a: string, v: string | number | boolean | undefined): Builder {
return v ? this.print(' ', a, '=').value(v).print(';') : this;
if (v !== undefined && v !== '')
return this.print(' ', a, '=').value(v).print(';');
else
return this;
}
// --- Node Table Shape
......@@ -405,6 +410,11 @@ class Builder {
edge(e: Edge): void {
const { line = 'solid', head = 'arrow', tail = 'none' } = e;
const tooltip = e.title ?? e.label ?? `${e.source} -> ${e.target}`;
if (e.aligned === true)
this
.print('{ rank=same; ')
.port(e.source).print(' ')
.port(e.target).println(' };');
this
.print(' ')
.port(e.source, e.sourcePort)
......@@ -413,8 +423,11 @@ class Builder {
.print(' [')
.attr('label', e.label)
.attr('fontname', e.font ? FONTNAME[e.font] : undefined)
.attr('headport', e.tailAnchor)
.attr('tailport', e.headAnchor)
.attr('headlabel', e.headLabel)
.attr('taillabel', e.tailLabel)
.attr('constraint', e.constraint === false ? false : undefined)
.attr('labeltooltip', e.label ? tooltip : undefined)
.attr('headtooltip', e.headLabel ? tooltip : undefined)
.attr('tailtooltip', e.tailLabel ? tooltip : undefined)
......
......@@ -45,7 +45,8 @@ function RegionAnalys(): JSX.Element {
const setComputing = Dome.useProtected(setRunning);
const scope = States.useCurrentScope();
const { kind, name } = States.useDeclaration(scope);
const regions = States.useRequest(Region.regions, kf) ?? [];
const regions =
States.useRequest(Region.regions, kf, { pending: null }) ?? [];
React.useEffect(() => {
if (!pinned && kind === 'FUNCTION' && scope !== kf) {
setKf(scope);
......
......@@ -82,7 +82,7 @@ function makeDiagram(regions: readonly Region.region[]): Diagram {
r.labels.forEach(a => {
const lid = `L${a}`;
nodes.push({ ...L, id: lid, label: `${a}:` });
edges.push({ source: lid, target: id });
edges.push({ source: lid, aligned: true, head: 'tee', target: id });
});
// --- Roots
const R: Dot.Node =
......@@ -90,7 +90,7 @@ function makeDiagram(regions: readonly Region.region[]): Diagram {
r.roots.forEach(x => {
const xid = `X${x}`;
nodes.push({ ...R, id: xid, label: x });
edges.push({ source: xid, target: id });
edges.push({ source: xid, headAnchor: "e", target: id });
});
// --- Pointed
if (r.pointed !== undefined) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment