@knowvah/dot-engine 2.12.3 → 2.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +12 -2
- package/dist/api.js.map +2 -2
- package/dist/common/clust-map.d.ts +16 -0
- package/dist/common/clust-map.d.ts.map +1 -0
- package/dist/common/htmltable-emit.d.ts +9 -6
- package/dist/common/htmltable-emit.d.ts.map +1 -1
- package/dist/common/layers.d.ts +9 -0
- package/dist/common/layers.d.ts.map +1 -1
- package/dist/common/poly-gencode.d.ts.map +1 -1
- package/dist/common/xlabels-place.d.ts.map +1 -1
- package/dist/gvc/anchor.d.ts +17 -19
- package/dist/gvc/anchor.d.ts.map +1 -1
- package/dist/gvc/device-cluster.d.ts +9 -0
- package/dist/gvc/device-cluster.d.ts.map +1 -1
- package/dist/gvc/device.d.ts +2 -1
- package/dist/gvc/device.d.ts.map +1 -1
- package/dist/gvc/emit-walk.d.ts +7 -0
- package/dist/gvc/emit-walk.d.ts.map +1 -1
- package/dist/gvc/job.d.ts +13 -6
- package/dist/gvc/job.d.ts.map +1 -1
- package/dist/gvc/viewport.d.ts +14 -0
- package/dist/gvc/viewport.d.ts.map +1 -1
- package/dist/index.js +557 -469
- package/dist/index.js.map +4 -4
- package/dist/layout/dot/compound.d.ts +0 -4
- package/dist/layout/dot/compound.d.ts.map +1 -1
- package/dist/layout/fdp/cluster-edges.d.ts.map +1 -1
- package/dist/model/cgraph-ops.d.ts +7 -0
- package/dist/model/cgraph-ops.d.ts.map +1 -1
- package/dist/model/graph.d.ts +12 -2
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/parser/builder.d.ts +11 -10
- package/dist/parser/builder.d.ts.map +1 -1
- package/dist/parser/graph-attr-syms.d.ts +35 -0
- package/dist/parser/graph-attr-syms.d.ts.map +1 -0
- package/dist/render/dot/agwrite.d.ts +6 -7
- package/dist/render/dot/agwrite.d.ts.map +1 -1
- package/dist/render/dot/attrs.d.ts +5 -0
- package/dist/render/dot/attrs.d.ts.map +1 -1
- package/dist/render/json-cluster-edge.d.ts +3 -2
- package/dist/render/json-cluster-edge.d.ts.map +1 -1
- package/dist/render/json.d.ts +7 -1
- package/dist/render/json.d.ts.map +1 -1
- package/dist/render/map.d.ts +14 -10
- package/dist/render/map.d.ts.map +1 -1
- package/dist/render/svg-graph.d.ts.map +1 -1
- package/dist/render/svg-id.d.ts +9 -0
- package/dist/render/svg-id.d.ts.map +1 -1
- package/dist/render.js +643 -555
- package/dist/render.js.map +4 -4
- package/dist/util/printf-round.d.ts +8 -0
- package/dist/util/printf-round.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/clust-map.ts +58 -0
- package/src/common/htmltable-emit.ts +87 -7
- package/src/common/layers.ts +25 -4
- package/src/common/poly-gencode.ts +3 -11
- package/src/common/xlabels-place.ts +22 -4
- package/src/gvc/anchor.ts +18 -30
- package/src/gvc/device-cluster.ts +16 -0
- package/src/gvc/device.ts +20 -20
- package/src/gvc/emit-walk.ts +11 -1
- package/src/gvc/job.ts +17 -9
- package/src/gvc/viewport.ts +27 -6
- package/src/layout/dot/compound.ts +1 -21
- package/src/layout/fdp/cluster-edges.ts +2 -23
- package/src/model/cgraph-ops.ts +12 -0
- package/src/model/graph.ts +13 -2
- package/src/parser/builder.ts +67 -100
- package/src/parser/graph-attr-syms.ts +62 -0
- package/src/render/dot/agwrite.ts +12 -12
- package/src/render/dot/attrs.ts +6 -2
- package/src/render/json-cluster-edge.ts +8 -4
- package/src/render/json.ts +15 -8
- package/src/render/map.ts +49 -58
- package/src/render/svg-cluster.ts +3 -3
- package/src/render/svg-graph.ts +1 -3
- package/src/render/svg-helpers.ts +6 -6
- package/src/render/svg-id.ts +23 -5
- package/src/util/printf-round.ts +11 -0
|
@@ -28,6 +28,14 @@
|
|
|
28
28
|
* @see lib/gvc/gvdevice.c:gvprintdouble
|
|
29
29
|
*/
|
|
30
30
|
export declare function printfFixed(v: number, decimals: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* Format `v` as C's `%.0f` would: `printfFixed(v, 0)`, except that an exact
|
|
33
|
+
* negative zero keeps its sign and prints `-0`, as printf does. A negative
|
|
34
|
+
* value that rounds to zero already prints `-0` in both.
|
|
35
|
+
*
|
|
36
|
+
* @see plugin/core/gvrender_core_map.c:map_output_shape ("%.0f")
|
|
37
|
+
*/
|
|
38
|
+
export declare function printfFixed0(v: number): string;
|
|
31
39
|
/**
|
|
32
40
|
* Format `v` with `sig` significant digits, using the same notational
|
|
33
41
|
* contract as `Number.prototype.toPrecision(sig)` — fixed form when the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printf-round.d.ts","sourceRoot":"","sources":["../../src/util/printf-round.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAuEH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkB/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAmCxD"}
|
|
1
|
+
{"version":3,"file":"printf-round.d.ts","sourceRoot":"","sources":["../../src/util/printf-round.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAuEH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkB/D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAmCxD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knowvah/dot-engine",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.4",
|
|
4
4
|
"description": "Faithful TypeScript port of Graphviz (dot, neato, fdp, sfdp, circo, twopi, osage, patchwork) — no C: no native binary, no WASM. Oracle-verified against the C implementation, runs in the browser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphviz",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The flat cluster-name map dot's compound edges and fdp's cluster edges look
|
|
5
|
+
* cluster endpoints up in. cgraph keeps subgraph names per parent, so two
|
|
6
|
+
* clusters in the tree can share a name; C keeps the first and warns.
|
|
7
|
+
*
|
|
8
|
+
* @see lib/common/utils.c:fillMap, mkClustMap (1498-1525)
|
|
9
|
+
* @see lib/cgraph/id.c:agnameof
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { Graph } from '../model/graph.js';
|
|
13
|
+
import { LOCALNAMEPREFIX } from '../model/cgraph-ops.js';
|
|
14
|
+
import { agwarningf } from './agerr.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* fillMap's state across the recursion. `anonKeyed` stands for C's key alias:
|
|
18
|
+
* agnameof returns one static buffer for every anonymous graph, and fillMap
|
|
19
|
+
* stores that pointer as the key, so once an anonymous cluster is in the map,
|
|
20
|
+
* every later anonymous cluster's dtmatch finds it. A cluster is anonymous
|
|
21
|
+
* here when its name starts with LOCALNAMEPREFIX, the test the dot writer
|
|
22
|
+
* uses; a source name `"%x"` is stored by cgraph and not aliased in C (#194).
|
|
23
|
+
* @see lib/cgraph/id.c:agnameof (static buf, 161-164)
|
|
24
|
+
*/
|
|
25
|
+
interface ClustMapState { map: Map<string, Graph>; anonKeyed: boolean }
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Map every cluster's name to its subgraph, preorder over the cluster tree
|
|
29
|
+
* (info.clust, 0-based here for C's GD_clust[1..n]). A second cluster with a
|
|
30
|
+
* name already in the map is ignored, with a warning.
|
|
31
|
+
* @see lib/common/utils.c:fillMap
|
|
32
|
+
*/
|
|
33
|
+
function fillMap(g: Graph, st: ClustMapState): void {
|
|
34
|
+
const n = g.info.n_cluster ?? 0;
|
|
35
|
+
for (let c = 0; c < n; c++) {
|
|
36
|
+
const cl = g.info.clust![c]!;
|
|
37
|
+
const s = cl.name;
|
|
38
|
+
const anon = s.startsWith(LOCALNAMEPREFIX);
|
|
39
|
+
if (st.map.has(s) || (anon && st.anonKeyed)) {
|
|
40
|
+
agwarningf(`Two clusters named ${s} - the second will be ignored`);
|
|
41
|
+
} else {
|
|
42
|
+
st.map.set(s, cl);
|
|
43
|
+
if (anon) st.anonKeyed = true;
|
|
44
|
+
}
|
|
45
|
+
fillMap(cl, st);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Build the name-to-cluster map for g's cluster tree. Assumes g's cluster
|
|
51
|
+
* tree (info.n_cluster, info.clust) is already built.
|
|
52
|
+
* @see lib/common/utils.c:mkClustMap
|
|
53
|
+
*/
|
|
54
|
+
export function mkClustMap(g: Graph): Map<string, Graph> {
|
|
55
|
+
const st: ClustMapState = { map: new Map<string, Graph>(), anonKeyed: false };
|
|
56
|
+
fillMap(g, st);
|
|
57
|
+
return st.map;
|
|
58
|
+
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* HTML label rendering: emits a positioned HTML label (cell borders,
|
|
5
5
|
* text runs, table border) through the renderer plugin.
|
|
6
6
|
*
|
|
7
|
-
* emitHtmlLabel is the port of
|
|
7
|
+
* emitHtmlLabel is the port of emit_html_label (its obj push and pop).
|
|
8
|
+
* emitHtmlTbl is the port of emit_html_tbl.
|
|
8
9
|
* emitHtmlCell is the port of emit_html_cell.
|
|
9
10
|
*
|
|
10
11
|
* Decoration (bgcolor fill, per-side borders, anchors, rules) fires
|
|
@@ -12,6 +13,9 @@
|
|
|
12
13
|
* PlacedCell / PlacedHtml — mirroring C's conditional structure.
|
|
13
14
|
* Undecorated tables emit identically to before T6.
|
|
14
15
|
*
|
|
16
|
+
* @see lib/common/htmltable.c:emit_html_label
|
|
17
|
+
* @see lib/common/htmltable.c:allocObj
|
|
18
|
+
* @see lib/common/htmltable.c:freeObj
|
|
15
19
|
* @see lib/common/htmltable.c:emit_html_tbl
|
|
16
20
|
* @see lib/common/htmltable.c:emit_html_cell
|
|
17
21
|
* @see lib/common/htmltable.c:emit_htextspans
|
|
@@ -23,8 +27,8 @@
|
|
|
23
27
|
*/
|
|
24
28
|
|
|
25
29
|
import type { Point, Box } from '../model/geom.js';
|
|
26
|
-
import type { RenderJob } from '../gvc/job.js';
|
|
27
|
-
import { EMIT_CLUSTERS_LAST } from '../gvc/job.js';
|
|
30
|
+
import type { RenderJob, ObjState } from '../gvc/job.js';
|
|
31
|
+
import { EMIT_CLUSTERS_LAST, createObjState } from '../gvc/job.js';
|
|
28
32
|
import type { RendererPlugin } from '../gvc/context.js';
|
|
29
33
|
import type { TextSpan } from './emit-types.js';
|
|
30
34
|
import type { PlacedHtml, PlacedCell, PlacedLine, PlacedImage } from './htmltable-pos.js';
|
|
@@ -244,7 +248,7 @@ export function emitHtmlCell(
|
|
|
244
248
|
if (cell.nested !== undefined) {
|
|
245
249
|
// C: emit_html_cell recurses emit_html_tbl for an HTML_TBL child.
|
|
246
250
|
// @see lib/common/htmltable.c:emit_html_cell
|
|
247
|
-
|
|
251
|
+
emitHtmlTbl(cell.nested, pos, renderer, job);
|
|
248
252
|
} else if (cell.image !== undefined) {
|
|
249
253
|
emitHtmlImg(cell.image, pos, renderer, job);
|
|
250
254
|
} else {
|
|
@@ -254,7 +258,7 @@ export function emitHtmlCell(
|
|
|
254
258
|
}
|
|
255
259
|
|
|
256
260
|
// ---------------------------------------------------------------------------
|
|
257
|
-
//
|
|
261
|
+
// emitHtmlTbl — port of emit_html_tbl
|
|
258
262
|
// ---------------------------------------------------------------------------
|
|
259
263
|
|
|
260
264
|
/** Emit vrule/hrule rules for all ruled cells. */
|
|
@@ -276,14 +280,15 @@ function emitTableRules(
|
|
|
276
280
|
}
|
|
277
281
|
|
|
278
282
|
/**
|
|
279
|
-
* Emit a fully positioned HTML table label
|
|
283
|
+
* Emit a fully positioned HTML table: a label's top-level table, or one
|
|
284
|
+
* nested in a cell.
|
|
280
285
|
*
|
|
281
286
|
* Draw order mirrors C emit_html_tbl:
|
|
282
287
|
* 1. Open anchor 2. Table BGCOLOR 3. Rules 4. Border 5. Cells 6. Close anchor
|
|
283
288
|
*
|
|
284
289
|
* @see lib/common/htmltable.c:emit_html_tbl
|
|
285
290
|
*/
|
|
286
|
-
|
|
291
|
+
function emitHtmlTbl(
|
|
287
292
|
placed: PlacedHtml,
|
|
288
293
|
pos: Point,
|
|
289
294
|
renderer: RendererPlugin,
|
|
@@ -322,3 +327,78 @@ export function emitHtmlLabel(
|
|
|
322
327
|
endHtmlAnchor(renderer, job);
|
|
323
328
|
}
|
|
324
329
|
}
|
|
330
|
+
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
// emitHtmlLabel — port of emit_html_label
|
|
333
|
+
// ---------------------------------------------------------------------------
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Push a new obj on the stack, used in common by all the label's html
|
|
337
|
+
* elements with anchors. It takes the paint fields push_obj_state defaults to
|
|
338
|
+
* the parent's, and inherits the parent's type, emit_state and object, and its
|
|
339
|
+
* url, tooltip, target and explicit_tooltip. Not its id, label or map points:
|
|
340
|
+
* a cell's emit_map_rect writes this obj's points, never the owner's.
|
|
341
|
+
* `parent` is job.obj (C reads it back as obj->parent), narrowed by the caller.
|
|
342
|
+
*
|
|
343
|
+
* @see lib/common/htmltable.c:allocObj
|
|
344
|
+
* @see lib/common/emit.c:push_obj_state
|
|
345
|
+
*/
|
|
346
|
+
function allocObj(job: RenderJob, parent: ObjState): void {
|
|
347
|
+
const obj = createObjState(parent.type);
|
|
348
|
+
obj.parent = parent;
|
|
349
|
+
obj.penColor = parent.penColor;
|
|
350
|
+
obj.fillColor = parent.fillColor;
|
|
351
|
+
obj.pen = parent.pen;
|
|
352
|
+
obj.fill = parent.fill;
|
|
353
|
+
obj.penWidth = parent.penWidth;
|
|
354
|
+
obj.gradientAngle = parent.gradientAngle;
|
|
355
|
+
obj.stopColor = parent.stopColor;
|
|
356
|
+
obj.emitState = parent.emitState;
|
|
357
|
+
obj.graphObj = parent.graphObj;
|
|
358
|
+
obj.url = parent.url;
|
|
359
|
+
obj.tooltip = parent.tooltip;
|
|
360
|
+
obj.target = parent.target;
|
|
361
|
+
obj.explicitTooltip = parent.explicitTooltip;
|
|
362
|
+
job.pushObj(obj);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Pop the label's obj. C clears url, tooltip, target and id first so that
|
|
367
|
+
* pop_obj_state does not free the parent's strings; nothing to do here.
|
|
368
|
+
*
|
|
369
|
+
* @see lib/common/htmltable.c:freeObj
|
|
370
|
+
*/
|
|
371
|
+
function freeObj(job: RenderJob): void {
|
|
372
|
+
job.popObj();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Emit a fully positioned HTML table label in its own obj state, so nothing
|
|
377
|
+
* the label writes on the obj (a cell's map rect) reaches the label's owner.
|
|
378
|
+
* The obj stack is as deep on return as on entry, even when the label throws.
|
|
379
|
+
*
|
|
380
|
+
* @see lib/common/htmltable.c:emit_html_label
|
|
381
|
+
*/
|
|
382
|
+
export function emitHtmlLabel(
|
|
383
|
+
placed: PlacedHtml,
|
|
384
|
+
pos: Point,
|
|
385
|
+
renderer: RendererPlugin,
|
|
386
|
+
job: RenderJob,
|
|
387
|
+
): void {
|
|
388
|
+
const parent = job.obj;
|
|
389
|
+
if (parent === null) {
|
|
390
|
+
// C always has an enclosing obj here (root, cluster, node or edge). The
|
|
391
|
+
// port's label emitters also run on a bare job with an empty obj stack
|
|
392
|
+
// (withLabelEmitState and gvrenderTextspan take `job.obj === null`; the
|
|
393
|
+
// renderOneLabel and renderClusterLabel cases of device.test.ts): with no
|
|
394
|
+
// owner there is nothing to shield, so emit without a push.
|
|
395
|
+
emitHtmlTbl(placed, pos, renderer, job);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
allocObj(job, parent);
|
|
399
|
+
try {
|
|
400
|
+
emitHtmlTbl(placed, pos, renderer, job);
|
|
401
|
+
} finally {
|
|
402
|
+
freeObj(job);
|
|
403
|
+
}
|
|
404
|
+
}
|
package/src/common/layers.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EPL-2.0
|
|
2
2
|
//
|
|
3
3
|
// Output-layer support, ported from lib/common/emit.c (parse_layers,
|
|
4
|
-
// layer_index, selectedLayer, node_in_layer, edge_in_layer).
|
|
5
|
-
// `layers="a:b:c"` attribute renders once per layer; each
|
|
6
|
-
// only in the layers it belongs to (its `layer`
|
|
7
|
-
// it has none
|
|
4
|
+
// layer_index, selectedLayer, node_in_layer, edge_in_layer, clust_in_layer).
|
|
5
|
+
// A graph with a `layers="a:b:c"` attribute renders once per layer; each
|
|
6
|
+
// node/edge/cluster appears only in the layers it belongs to (its `layer`
|
|
7
|
+
// attribute, or all layers when it has none; a cluster with none follows its
|
|
8
|
+
// nodes). All of this is inert unless numLayers > 1.
|
|
8
9
|
|
|
9
10
|
import { agwarningf } from './agerr.js';
|
|
10
11
|
import type { Graph } from '../model/graph.js';
|
|
11
12
|
import type { Node } from '../model/node.js';
|
|
12
13
|
import type { Edge } from '../model/edge.js';
|
|
14
|
+
import { graphAttrInherited } from './attr-get.js';
|
|
13
15
|
|
|
14
16
|
/** @see lib/common/const.h:82-83 */
|
|
15
17
|
const DEFAULT_LAYERSEP = ':\t ';
|
|
@@ -121,6 +123,25 @@ export function edgeInLayer(info: LayerInfo, layerNum: number, e: Edge): boolean
|
|
|
121
123
|
});
|
|
122
124
|
}
|
|
123
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Whether cluster `sg` is drawn in layer `layerNum`. Its own `layer` decides
|
|
128
|
+
* when it has one (C reads it with `agattr_text(sg, AGRAPH, "layer", 0)`: the
|
|
129
|
+
* cluster's value, or the default it was created under). With none, the
|
|
130
|
+
* cluster is in the layer when any of its nodes is, and `node_in_layer` is
|
|
131
|
+
* handed `sg`, so only the edges of the cluster itself count.
|
|
132
|
+
* @see lib/common/emit.c:1593 clust_in_layer
|
|
133
|
+
*/
|
|
134
|
+
export function clustInLayer(info: LayerInfo, layerNum: number, sg: Graph): boolean {
|
|
135
|
+
if (info.numLayers <= 1) return true;
|
|
136
|
+
const pg = graphAttrInherited(sg, 'layer') ?? '';
|
|
137
|
+
if (selectedLayer(info, layerNum, pg)) return true;
|
|
138
|
+
if (pg !== '') return false;
|
|
139
|
+
for (const n of sg.nodes.values()) {
|
|
140
|
+
if (nodeInLayer(info, layerNum, n, sg)) return true;
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
124
145
|
/**
|
|
125
146
|
* Walk each layer index and keep those `selectedLayer` matches against `p`.
|
|
126
147
|
* Returns `[n, l1..ln, numLayers + 1]`, or null (after a warning) when nothing
|
|
@@ -536,24 +536,16 @@ export function polyGencode(rawJob: unknown, rawNode: unknown): void {
|
|
|
536
536
|
if (ctx === null) return;
|
|
537
537
|
// EMIT_CLUSTERS_LAST (map device): the node's own anchor <area> is emitted
|
|
538
538
|
// AFTER its shape and label, so an inner HTML cell's area precedes the
|
|
539
|
-
// node's.
|
|
540
|
-
//
|
|
539
|
+
// node's. The hot spot is still emit_begin_node's: the label's cells write
|
|
540
|
+
// their map rects on the label's own obj (allocObj), not on the node's.
|
|
541
541
|
// @see lib/common/shapes.c:poly_gencode (2936, 3087-3092)
|
|
542
542
|
const clustersLast = (job.flags & EMIT_CLUSTERS_LAST) !== 0;
|
|
543
|
-
const savedShape = job.obj?.urlMapShape;
|
|
544
|
-
const savedPts = job.obj?.urlMapPts;
|
|
545
543
|
let inAnchor = clustersLast ? false : beginNodeAnchor(n, renderer, job);
|
|
546
544
|
renderPeripheries(ctx.poly, ctx.coord, ctx.filled, ctx.ringCtx);
|
|
547
545
|
// point_gencode has no usershape branch.
|
|
548
546
|
if (!isPointNode(n)) renderUsershape(n, ctx);
|
|
549
547
|
// point_gencode never emits a label (AD-3).
|
|
550
548
|
if (!isPointNode(n)) renderNodeLabel(n, ctx.coord, renderer, job);
|
|
551
|
-
if (clustersLast)
|
|
552
|
-
if (job.obj && savedPts !== undefined && savedShape !== undefined) {
|
|
553
|
-
job.obj.urlMapShape = savedShape;
|
|
554
|
-
job.obj.urlMapPts = savedPts;
|
|
555
|
-
}
|
|
556
|
-
inAnchor = beginNodeAnchor(n, renderer, job);
|
|
557
|
-
}
|
|
549
|
+
if (clustersLast) inAnchor = beginNodeAnchor(n, renderer, job);
|
|
558
550
|
if (inAnchor) renderer.endAnchor?.(job);
|
|
559
551
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import type { Graph } from '../model/graph.js';
|
|
13
13
|
import type { Point } from '../model/geom.js';
|
|
14
14
|
import type { TextlabelT } from './types.js';
|
|
15
|
+
import { agwarningf } from './agerr.js';
|
|
15
16
|
import {
|
|
16
17
|
EDGE_LABEL, HEAD_LABEL, TAIL_LABEL, NODE_XLABEL, EDGE_XLABEL, mapbool,
|
|
17
18
|
} from '../layout/dot/rank.js';
|
|
@@ -418,17 +419,25 @@ function buildArrays(
|
|
|
418
419
|
return { ctx };
|
|
419
420
|
}
|
|
420
421
|
|
|
421
|
-
/**
|
|
422
|
-
|
|
422
|
+
/**
|
|
423
|
+
* Write placed label positions back to the graph; update bb. Returns C's
|
|
424
|
+
* `cnt`, the number of labels placed.
|
|
425
|
+
*
|
|
426
|
+
* @see lib/common/postproc.c:addXLabels (569-580)
|
|
427
|
+
*/
|
|
428
|
+
function writeBackLabels(gp: Graph, lbls: XLabelT[], nLbls: number): number {
|
|
429
|
+
let cnt = 0;
|
|
423
430
|
for (let i = 0; i < nLbls; i++) {
|
|
424
431
|
const xlp = lbls[i];
|
|
425
432
|
if (xlp.set) {
|
|
433
|
+
cnt++;
|
|
426
434
|
const lp = xlp.lbl as TextlabelT;
|
|
427
435
|
lp.set = true;
|
|
428
436
|
lp.pos = centerPt(xlp);
|
|
429
437
|
updateBBForLabel(gp, lp);
|
|
430
438
|
}
|
|
431
439
|
}
|
|
440
|
+
return cnt;
|
|
432
441
|
}
|
|
433
442
|
|
|
434
443
|
// ---------------------------------------------------------------------------
|
|
@@ -444,7 +453,13 @@ function needsXLabelWork(gp: Graph): boolean {
|
|
|
444
453
|
return !!(h & EDGE_LABEL) && !(gp.info.edgeLabelsDone ?? false);
|
|
445
454
|
}
|
|
446
455
|
|
|
447
|
-
/**
|
|
456
|
+
/**
|
|
457
|
+
* Run one placeLabels pass: count slots, build arrays, place, write back, and
|
|
458
|
+
* warn when a label is left unplaced. Not ported: the `Verbose`
|
|
459
|
+
* `labels positioned` line; the port has no `Verbose`.
|
|
460
|
+
*
|
|
461
|
+
* @see lib/common/postproc.c:addXLabels (569-587)
|
|
462
|
+
*/
|
|
448
463
|
function runPlacement(gp: Graph): void {
|
|
449
464
|
const hasLabels = gp.info.has_labels ?? 0;
|
|
450
465
|
const et = edgeType(gp);
|
|
@@ -460,7 +475,10 @@ function runPlacement(gp: Graph): void {
|
|
|
460
475
|
const force = forceStr === undefined ? true : mapbool(forceStr);
|
|
461
476
|
const params: LabelParamsT = { bb: { ll: ctx.bb.ll, ur: ctx.bb.ur }, force };
|
|
462
477
|
placeLabels(ctx.objs, ctx.lbls, params);
|
|
463
|
-
writeBackLabels(gp, ctx.lbls, nLbls);
|
|
478
|
+
const cnt = writeBackLabels(gp, ctx.lbls, nLbls);
|
|
479
|
+
if (cnt !== nLbls) {
|
|
480
|
+
agwarningf(`${cnt} out of ${nLbls} exterior labels positioned.`);
|
|
481
|
+
}
|
|
464
482
|
}
|
|
465
483
|
|
|
466
484
|
/**
|
package/src/gvc/anchor.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { bezier } from '../common/bezier.js';
|
|
|
24
24
|
import { ptToLine2 } from '../common/splines-geom.js';
|
|
25
25
|
import type { RendererPlugin } from './context.js';
|
|
26
26
|
import { MapShape, type ObjState, type RenderJob } from './job.js';
|
|
27
|
+
import { applyScale } from './device-transform.js';
|
|
27
28
|
|
|
28
29
|
/** Non-empty attr value, or undefined. C: `(s = agget(o, k)) && s[0]`. */
|
|
29
30
|
function attr(attrs: Map<string, string>, key: string): string | undefined {
|
|
@@ -234,28 +235,21 @@ const DFLT_SAMPLE = 20;
|
|
|
234
235
|
const MAP_HW = 2.0;
|
|
235
236
|
|
|
236
237
|
/**
|
|
237
|
-
* Coordinate-transform context for the imagemap device. `
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* gvrender_ptf.
|
|
238
|
+
* Coordinate-transform context for the imagemap device. `pageBox` is
|
|
239
|
+
* job->pageBox (the root graph's area). `translation` and `scale` are
|
|
240
|
+
* gvrender_ptf_A's: job->translation, and zoom * devscale with `scale.y`
|
|
241
|
+
* negative, because the map device is GVRENDER_Y_GOES_DOWN.
|
|
242
242
|
*/
|
|
243
|
-
export interface MapCtx {
|
|
243
|
+
export interface MapCtx { pageBox: Box; translation: Point; scale: Point; mapPolygon: boolean; }
|
|
244
244
|
|
|
245
245
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* translation, which after the `* scale` becomes `margin * dpi/72` in device
|
|
251
|
-
* units (`marginOff`) — matching svgBeginPage's `+ margin / z` term.
|
|
252
|
-
* @see lib/gvc/gvrender.c:gvrender_ptf ; lib/common/emit.c:setup_page (1566-1581)
|
|
246
|
+
* gvrender_ptf_A's no-rotation branch: (p + translation) * scale. The negative
|
|
247
|
+
* y scale makes the page top -0.0, which "%.0f" prints as `-0` (issue #175).
|
|
248
|
+
* buildMapCtx fills the context; rotate=90 is not ported for maps (#247).
|
|
249
|
+
* @see lib/gvc/gvrender.c:gvrender_ptf_A ; lib/common/emit.c:setup_page (1548-1555)
|
|
253
250
|
*/
|
|
254
251
|
export function mapTransform(p: Point, ctx: MapCtx): Point {
|
|
255
|
-
return
|
|
256
|
-
x: (p.x + ctx.pad.x - ctx.bb.ll.x) * ctx.scale + ctx.marginOff.x,
|
|
257
|
-
y: (ctx.bb.ur.y + ctx.pad.y - p.y) * ctx.scale + ctx.marginOff.y,
|
|
258
|
-
};
|
|
252
|
+
return applyScale(p, ctx.translation.x, ctx.translation.y, ctx.scale.x, ctx.scale.y);
|
|
259
253
|
}
|
|
260
254
|
|
|
261
255
|
/** isFilled: node style contains "filled". @see lib/common/emit.c:705 */
|
|
@@ -388,21 +382,15 @@ export function computeNodeUrlMap(n: Node, obj: ObjState, ctx: MapCtx): void {
|
|
|
388
382
|
}
|
|
389
383
|
|
|
390
384
|
/**
|
|
391
|
-
* Graph-level (root) hot spot:
|
|
392
|
-
*
|
|
393
|
-
*
|
|
385
|
+
* Graph-level (root) hot spot: job->pageBox, as emit_page maps it for
|
|
386
|
+
* GVRENDER_DOES_MAP_RECTANGLE devices. The page box starts at -pad (not at
|
|
387
|
+
* bb.LL - pad: fdp graph labels keep a negative bb.LL, and native url.gv fdp
|
|
388
|
+
* emits 0,-33,539,374), and the translation is built from job->clip, so under
|
|
389
|
+
* `size=` the corner can land a few ulps below zero and print `-0`.
|
|
390
|
+
* @see lib/common/emit.c:emit_page (3570-3589)
|
|
394
391
|
*/
|
|
395
392
|
export function computeGraphUrlMap(obj: ObjState, ctx: MapCtx): void {
|
|
396
|
-
|
|
397
|
-
// coords), not bb±pad. Identical when bb.LL is the origin, but engines that
|
|
398
|
-
// keep a negative bb.LL (fdp graph labels: bb "0,-24.8,...") shift the root
|
|
399
|
-
// rect: native url.gv fdp emits 0,-33,539,374 where bb±pad would give
|
|
400
|
-
// 0,0,539,407. @see lib/common/emit.c:3652 emit_map_rect(job, job->clip)
|
|
401
|
-
const ll = { x: -ctx.pad.x, y: -ctx.pad.y };
|
|
402
|
-
const ur = {
|
|
403
|
-
x: ctx.bb.ur.x - ctx.bb.ll.x + ctx.pad.x,
|
|
404
|
-
y: ctx.bb.ur.y - ctx.bb.ll.y + ctx.pad.y,
|
|
405
|
-
};
|
|
393
|
+
const { ll, ur } = ctx.pageBox;
|
|
406
394
|
obj.urlMapShape = MapShape.Rectangle;
|
|
407
395
|
obj.urlMapPts = [mapTransform(ll, ctx), mapTransform(ur, ctx)];
|
|
408
396
|
}
|
|
@@ -20,6 +20,7 @@ import { gvrenderSetStyle, checkClusterStyleTokens } from './gvrender-set-style.
|
|
|
20
20
|
import { resolveFillColorName, resolveRenderColor, reportColorNames } from '../render/color-resolve.js';
|
|
21
21
|
import { parseSegs } from '../common/multicolor.js';
|
|
22
22
|
import { graphAttrInherited } from '../common/attr-get.js';
|
|
23
|
+
import { beginAnchorIf } from './anchor.js';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Copy gradient fields from a linear/radial ResolvedFill onto obj.
|
|
@@ -188,3 +189,18 @@ function applyClusterFill(obj: ObjState, fillRes: ResolvedFill): boolean {
|
|
|
188
189
|
applyClusterGradient(obj, fillRes);
|
|
189
190
|
return true;
|
|
190
191
|
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* `if (doAnchor) { emit_map_rect(job, GD_bb(sg)); gvrender_begin_anchor(...) }`:
|
|
195
|
+
* record the cluster box as the pending hot spot, then open the anchor.
|
|
196
|
+
* Drawing devices run it before the box, the map device (EMIT_CLUSTERS_LAST)
|
|
197
|
+
* after the label. Returns doAnchor (obj->url || obj->explicit_tooltip); when
|
|
198
|
+
* true the caller closes the anchor with renderer.endAnchor.
|
|
199
|
+
* @see lib/common/emit.c:emit_clusters:3743-3747, 3861-3868
|
|
200
|
+
*/
|
|
201
|
+
export function beginClusterAnchor(sg: Graph, renderer: RendererPlugin, job: RenderJob): boolean {
|
|
202
|
+
const obj = job.obj;
|
|
203
|
+
if (obj === null || (obj.url === null && !obj.explicitTooltip)) return false;
|
|
204
|
+
renderer.emitMapRect?.(sg.info.bb!, job);
|
|
205
|
+
return beginAnchorIf(renderer, job);
|
|
206
|
+
}
|
package/src/gvc/device.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { resolveEdgeAnchor, resolveObjAnchor, beginAnchorIf } from './anchor.js'
|
|
|
25
25
|
import type { ShapeDesc, TextlabelT } from '../common/types.js';
|
|
26
26
|
import { type LayerInfo, parseLayers } from '../common/layers.js';
|
|
27
27
|
import { RenderJob, EMIT_CLUSTERS_LAST, createObjState, ObjType, EmitState } from './job.js';
|
|
28
|
-
import { walkNodesAndEdges } from './emit-walk.js';
|
|
28
|
+
import { walkNodesAndEdges, clusterShown } from './emit-walk.js';
|
|
29
29
|
import { initBb } from '../common/emit-bb.js';
|
|
30
30
|
import { firstLayer, nextLayer, numPhysicalLayers, validLayer } from './first-layer.js';
|
|
31
31
|
import { polyInit } from '../common/poly-init.js';
|
|
@@ -49,14 +49,14 @@ import {
|
|
|
49
49
|
setRendererKnownColors,
|
|
50
50
|
} from '../render/color-resolve.js';
|
|
51
51
|
import { emitRoundedBezier } from '../common/poly-shapes.js';
|
|
52
|
-
import { applyClusterObjState, clusterAttr, clusterStyle, clusterPeripheries, isStripedCluster, renderStripedClusterBox } from './device-cluster.js';
|
|
52
|
+
import { applyClusterObjState, clusterAttr, clusterStyle, clusterPeripheries, isStripedCluster, renderStripedClusterBox, beginClusterAnchor } from './device-cluster.js';
|
|
53
53
|
import { transformPoint } from './device-transform.js';
|
|
54
54
|
import { deviceClip, emitXdot } from './emit-xdot.js';
|
|
55
55
|
import { gvrenderSetStyle, edgeStyleResets } from './gvrender-set-style.js';
|
|
56
56
|
import { renderOneLabel, renderNodeXLabel, renderClusterLabel, reportEdgeLabelColors } from './device-labels.js';
|
|
57
57
|
export { transformPoint, applyRotation, applyScale, buildPoint } from './device-transform.js';
|
|
58
58
|
export { renderOneLabel, renderNodeXLabel, renderClusterLabel } from './device-labels.js';
|
|
59
|
-
import { svgNodeId, svgEdgeId, svgClusterId, svgGraphId } from '../render/svg-id.js';
|
|
59
|
+
import { svgNodeId, svgEdgeId, svgClusterId, svgGraphId, drawingIdOf } from '../render/svg-id.js';
|
|
60
60
|
import { nodeInBox, emitNodeComments, emitEdgeComments } from './emit-gates.js';
|
|
61
61
|
|
|
62
62
|
// ---------------------------------------------------------------------------
|
|
@@ -279,12 +279,12 @@ function drawClusterInScheme(sg: Graph, renderer: RendererPlugin, job: RenderJob
|
|
|
279
279
|
if (job.obj !== null) job.obj.id = svgClusterId(sg, job);
|
|
280
280
|
// @see lib/common/emit.c:emit_begin_cluster / getObjId
|
|
281
281
|
setHtmlAnchorObj(svgClusterId(sg, job), labelTextOf(sg.info.label), job.obj ?? undefined);
|
|
282
|
-
// Resolve
|
|
283
|
-
// the
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const anchored =
|
|
282
|
+
// Resolve the cluster anchor. Drawing devices open it around the box + label;
|
|
283
|
+
// the map device (EMIT_CLUSTERS_LAST) opens it after the label, so the
|
|
284
|
+
// cluster's <area> follows its label's cell areas. @see emit.c:3743, 3861
|
|
285
|
+
if (job.obj !== null) resolveObjAnchor(sg, labelTextOf(sg.info.label), svgClusterId(sg, job), job.obj);
|
|
286
|
+
const late = (job.flags & EMIT_CLUSTERS_LAST) !== 0;
|
|
287
|
+
const anchored = !late && beginClusterAnchor(sg, renderer, job);
|
|
288
288
|
// C draws the boundary box only when peripheries != 0, or (peripheries == 0
|
|
289
289
|
// and the cluster is filled). peripheries=0 + unfilled emits nothing.
|
|
290
290
|
// style=invis sets PEN_NONE and gvrender_polygon skips the whole box
|
|
@@ -294,7 +294,7 @@ function drawClusterInScheme(sg: Graph, renderer: RendererPlugin, job: RenderJob
|
|
|
294
294
|
renderClusterBox(sg, filled, renderer, job);
|
|
295
295
|
}
|
|
296
296
|
renderClusterLabel(sg, renderer, job);
|
|
297
|
-
if (anchored) renderer.endAnchor?.(job);
|
|
297
|
+
if (anchored || (late && beginClusterAnchor(sg, renderer, job))) renderer.endAnchor?.(job);
|
|
298
298
|
renderer.endCluster?.(sg, job);
|
|
299
299
|
}
|
|
300
300
|
|
|
@@ -305,13 +305,13 @@ function drawClusterInScheme(sg: Graph, renderer: RendererPlugin, job: RenderJob
|
|
|
305
305
|
* completes before recursing; sub-clusters are separate pushes on a clean stack.
|
|
306
306
|
* @see lib/common/emit.c:emit_clusters:3777
|
|
307
307
|
*/
|
|
308
|
-
function renderOneCluster(sg: Graph, renderer: RendererPlugin, job: RenderJob): void {
|
|
308
|
+
function renderOneCluster(sg: Graph, renderer: RendererPlugin, job: RenderJob, info?: LayerInfo): void {
|
|
309
309
|
// EMIT_CLUSTERS_LAST (map device): recurse into sub-clusters BEFORE emitting
|
|
310
310
|
// this cluster's anchor, so an inner cluster's <area> precedes its parent's
|
|
311
311
|
// (child-first). Drawing devices recurse AFTER (parent-first), below.
|
|
312
312
|
// @see lib/common/emit.c:emit_clusters (3795 vs 3940)
|
|
313
313
|
const clustersLast = (job.flags & EMIT_CLUSTERS_LAST) !== 0;
|
|
314
|
-
if (clustersLast) renderClusters(sg, renderer, job);
|
|
314
|
+
if (clustersLast) renderClusters(sg, renderer, job, info);
|
|
315
315
|
// push_obj_state in emit_begin_cluster (line 3762), before beginCluster
|
|
316
316
|
const obj = createObjState(ObjType.Cluster);
|
|
317
317
|
obj.emitState = EmitState.CDraw;
|
|
@@ -328,7 +328,7 @@ function renderOneCluster(sg: Graph, renderer: RendererPlugin, job: RenderJob):
|
|
|
328
328
|
// C recurses AFTER emit_end_cluster (line 3940-3941): sub-clusters are drawn
|
|
329
329
|
// with the parent already popped — each has its own independent push/pop.
|
|
330
330
|
// The map device recursed first (child-first), above.
|
|
331
|
-
if (!clustersLast) renderClusters(sg, renderer, job);
|
|
331
|
+
if (!clustersLast) renderClusters(sg, renderer, job, info);
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
/**
|
|
@@ -337,13 +337,13 @@ function renderOneCluster(sg: Graph, renderer: RendererPlugin, job: RenderJob):
|
|
|
337
337
|
* @see lib/gvc/gvrender.c:gvrender_box
|
|
338
338
|
* @see lib/common/emit.c:emit_clusters
|
|
339
339
|
*/
|
|
340
|
-
export function renderClusters(g: Graph, renderer: RendererPlugin, job: RenderJob): void {
|
|
340
|
+
export function renderClusters(g: Graph, renderer: RendererPlugin, job: RenderJob, info?: LayerInfo): void {
|
|
341
341
|
const nClust = g.info.n_cluster ?? 0;
|
|
342
342
|
const clust = g.info.clust;
|
|
343
343
|
if (nClust === 0 || !clust) return;
|
|
344
344
|
for (let c = 0; c < nClust; c++) {
|
|
345
345
|
const sg = clust[c];
|
|
346
|
-
if (sg) renderOneCluster(sg, renderer, job);
|
|
346
|
+
if (sg && clusterShown(info, job, sg)) renderOneCluster(sg, renderer, job, info);
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
@@ -404,9 +404,9 @@ function renderPage(g: Graph, renderer: RendererPlugin, job: RenderJob, info: La
|
|
|
404
404
|
// device (EMIT_CLUSTERS_LAST) emits their <area> AFTER, so a node/edge area
|
|
405
405
|
// precedes its enclosing cluster's. @see lib/common/emit.c:emit_view (3513-3565)
|
|
406
406
|
const clustersLast = (job.flags & EMIT_CLUSTERS_LAST) !== 0;
|
|
407
|
-
if (!clustersLast) renderClusters(g, renderer, job);
|
|
407
|
+
if (!clustersLast) renderClusters(g, renderer, job, info);
|
|
408
408
|
walkNodesAndEdges(g, renderer, job, info);
|
|
409
|
-
if (clustersLast) renderClusters(g, renderer, job);
|
|
409
|
+
if (clustersLast) renderClusters(g, renderer, job, info);
|
|
410
410
|
renderer.endPage?.(g, job);
|
|
411
411
|
}
|
|
412
412
|
|
|
@@ -497,12 +497,12 @@ export function render(ctx: GvcContext, g: Graph, format: string, inlineImages =
|
|
|
497
497
|
const dpiScale = jobDpi / POINTS_PER_INCH;
|
|
498
498
|
job.scale = { x: z * dpiScale, y: z * dpiScale };
|
|
499
499
|
// init_job_viewport: job->rotation = gvc->rotation (= 90 for landscape, set in
|
|
500
|
-
// emit_graph from GD_drawing->landscape). Emit-only
|
|
501
|
-
// transform + dim swap (T2), never layout/routing (ADR-1).
|
|
502
|
-
// guarded against the ptf rotation branch (ADR-2).
|
|
500
|
+
// emit_graph from GD_drawing->landscape). Emit-only: drives the SVG group
|
|
501
|
+
// transform + dim swap (T2), never layout/routing (ADR-1; ptf guard: ADR-2).
|
|
503
502
|
// @see lib/common/emit.c:3260 (gvc->rotation=90); :3390 (job->rotation)
|
|
504
503
|
job.rotation = parseLandscape(g) ? 90 : 0;
|
|
505
504
|
job.renderer = renderer;
|
|
505
|
+
job.drawingId = drawingIdOf(g); // GD_drawing(g)->id. @see lib/common/input.c:graph_init
|
|
506
506
|
setRendererKnownColors(renderer.type === 'svg'); // svg_knowncolors; others have none
|
|
507
507
|
resetHtmlAnchorIds(); // C: fresh anchorId per dot invocation
|
|
508
508
|
for (const n of g.nodes.values()) polyInit(n, g, job.measurer);
|
package/src/gvc/emit-walk.ts
CHANGED
|
@@ -19,7 +19,7 @@ import type { Edge } from '../model/edge.js';
|
|
|
19
19
|
import { buildOutEdgeIndex } from '../model/node.js';
|
|
20
20
|
import type { RendererPlugin } from './context.js';
|
|
21
21
|
import type { RenderJob } from './job.js';
|
|
22
|
-
import { type LayerInfo, nodeInLayer, edgeInLayer } from '../common/layers.js';
|
|
22
|
+
import { type LayerInfo, nodeInLayer, edgeInLayer, clustInLayer } from '../common/layers.js';
|
|
23
23
|
import { renderNode, renderEdge } from './device.js';
|
|
24
24
|
|
|
25
25
|
/** Whether a node is shown in the current layer (always true off-layer). */
|
|
@@ -32,6 +32,16 @@ function edgeShown(info: LayerInfo | undefined, job: RenderJob, e: Edge): boolea
|
|
|
32
32
|
return info === undefined || job.numLayers <= 1 || edgeInLayer(info, job.layerNum, e);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Whether a cluster is drawn in the current layer (always true off-layer).
|
|
37
|
+
* C tests this in emit_clusters' loop, before drawing the cluster or
|
|
38
|
+
* recursing into it, so a skipped cluster's sub-clusters are skipped too.
|
|
39
|
+
* @see lib/common/emit.c:emit_clusters
|
|
40
|
+
*/
|
|
41
|
+
export function clusterShown(info: LayerInfo | undefined, job: RenderJob, sg: Graph): boolean {
|
|
42
|
+
return info === undefined || job.numLayers <= 1 || clustInLayer(info, job.layerNum, sg);
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
/**
|
|
36
46
|
* Output order from the `outputorder` graph attr, mirroring C's chkOrder:
|
|
37
47
|
* `nodesfirst` → EMIT_SORTED, `edgesfirst` → EMIT_EDGE_SORTED, else breadth-first.
|