@knowvah/dot-engine 2.12.2 → 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/compass-port.d.ts.map +1 -1
- package/dist/common/graph-init.d.ts.map +1 -1
- package/dist/common/htmltable-emit.d.ts +9 -6
- package/dist/common/htmltable-emit.d.ts.map +1 -1
- package/dist/common/htmltable-label.d.ts.map +1 -1
- package/dist/common/htmltable-lex.d.ts +3 -1
- package/dist/common/htmltable-lex.d.ts.map +1 -1
- package/dist/common/htmltable-parse-image.d.ts +23 -0
- package/dist/common/htmltable-parse-image.d.ts.map +1 -0
- package/dist/common/htmltable-parse-state.d.ts +4 -0
- package/dist/common/htmltable-parse-state.d.ts.map +1 -1
- package/dist/common/htmltable-parse.d.ts +33 -2
- package/dist/common/htmltable-parse.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/poly-inside.d.ts.map +1 -1
- package/dist/common/splines-geom.d.ts +2 -1
- package/dist/common/splines-geom.d.ts.map +1 -1
- package/dist/common/splines-routespl.d.ts +3 -0
- package/dist/common/splines-routespl.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 +21767 -21607
- package/dist/index.js.map +4 -4
- package/dist/layout/dot/classify.d.ts.map +1 -1
- package/dist/layout/dot/compound.d.ts +0 -4
- package/dist/layout/dot/compound.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-chain-views.d.ts +35 -0
- package/dist/layout/dot/edge-route-chain-views.d.ts.map +1 -0
- package/dist/layout/dot/edge-route-chain.d.ts +20 -16
- package/dist/layout/dot/edge-route-chain.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-faithful.d.ts.map +1 -1
- package/dist/layout/dot/flat.d.ts +22 -7
- package/dist/layout/dot/flat.d.ts.map +1 -1
- package/dist/layout/dot/mincross-flat.d.ts +10 -1
- package/dist/layout/dot/mincross-flat.d.ts.map +1 -1
- package/dist/layout/dot/mincross.d.ts +6 -1
- package/dist/layout/dot/mincross.d.ts.map +1 -1
- package/dist/layout/dot/ns-subtree.d.ts +9 -6
- package/dist/layout/dot/ns-subtree.d.ts.map +1 -1
- package/dist/layout/dot/pack-components.d.ts +4 -3
- package/dist/layout/dot/pack-components.d.ts.map +1 -1
- package/dist/layout/dot/position-aux.d.ts +62 -20
- package/dist/layout/dot/position-aux.d.ts.map +1 -1
- package/dist/layout/dot/position-bbox.d.ts.map +1 -1
- package/dist/layout/dot/position-ycoords.d.ts.map +1 -1
- package/dist/layout/dot/position.d.ts.map +1 -1
- package/dist/layout/dot/rank-dot2.d.ts +7 -25
- package/dist/layout/dot/rank-dot2.d.ts.map +1 -1
- package/dist/layout/dot/self-loop.d.ts +11 -4
- package/dist/layout/dot/self-loop.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat-multi.d.ts +11 -3
- package/dist/layout/dot/splines-flat-multi.d.ts.map +1 -1
- package/dist/layout/dot/splines-route.d.ts +6 -3
- package/dist/layout/dot/splines-route.d.ts.map +1 -1
- package/dist/layout/dot/straight-edges.d.ts.map +1 -1
- package/dist/layout/fdp/cluster-edges.d.ts.map +1 -1
- package/dist/layout/fdp/tlayout.d.ts +3 -0
- package/dist/layout/fdp/tlayout.d.ts.map +1 -1
- package/dist/layout/neato/__fixtures__/hier-imds.d.ts +5 -4
- package/dist/layout/neato/__fixtures__/hier-imds.d.ts.map +1 -1
- package/dist/layout/neato/__fixtures__/hier-majorization.d.ts +6 -5
- package/dist/layout/neato/__fixtures__/hier-majorization.d.ts.map +1 -1
- package/dist/layout/neato/conjgrad.d.ts +7 -6
- package/dist/layout/neato/conjgrad.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops-dense.d.ts +1 -6
- package/dist/layout/neato/matrix-ops-dense.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops.d.ts +0 -6
- package/dist/layout/neato/matrix-ops.d.ts.map +1 -1
- package/dist/layout/neato/quad-prog-vpsc.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/model/rankEntry.d.ts +3 -1
- package/dist/model/rankEntry.d.ts.map +1 -1
- package/dist/ortho/index.d.ts +0 -1
- package/dist/ortho/index.d.ts.map +1 -1
- package/dist/ortho/partition.d.ts +2 -4
- package/dist/ortho/partition.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/pathplan/route.d.ts +93 -0
- package/dist/pathplan/route.d.ts.map +1 -1
- package/dist/render/dot/agwrite.d.ts +27 -16
- 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/dot/types.d.ts +7 -2
- package/dist/render/dot/types.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 +22009 -21849
- package/dist/render.js.map +4 -4
- package/dist/util/overflow.d.ts +37 -0
- package/dist/util/overflow.d.ts.map +1 -0
- package/dist/util/printf-round.d.ts +8 -0
- package/dist/util/printf-round.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/common/clust-map.ts +58 -0
- package/src/common/compass-port.ts +36 -20
- package/src/common/graph-init.ts +11 -1
- package/src/common/htmltable-emit.ts +87 -7
- package/src/common/htmltable-label.ts +9 -4
- package/src/common/htmltable-lex.ts +5 -2
- package/src/common/htmltable-parse-image.ts +69 -0
- package/src/common/htmltable-parse-state.ts +6 -0
- package/src/common/htmltable-parse.ts +34 -44
- package/src/common/layers.ts +25 -4
- package/src/common/poly-gencode.ts +3 -11
- package/src/common/poly-inside.ts +11 -5
- package/src/common/splines-geom.ts +24 -6
- package/src/common/splines-routespl.ts +32 -0
- package/src/common/xlabels-place.ts +22 -4
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.1 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.2 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.3 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.2 +18 -18
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.3 +12 -12
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.1 +20 -20
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.2 +31 -31
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.3 +33 -33
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.1 +10 -10
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.2 +28 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.3 +28 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.1 +21 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.2 +100 -102
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.3 +137 -139
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.1 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.2 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.3 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.1 +3 -3
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.2 +3 -3
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.3 +3 -3
- package/src/gvc/__fixtures__/rerender/regen.sh +6 -0
- 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/classify.ts +5 -2
- package/src/layout/dot/compound.ts +1 -21
- package/src/layout/dot/edge-route-chain-views.ts +120 -0
- package/src/layout/dot/edge-route-chain.ts +103 -117
- package/src/layout/dot/edge-route-faithful.ts +20 -5
- package/src/layout/dot/flat.ts +38 -17
- package/src/layout/dot/mincross-flat.ts +15 -5
- package/src/layout/dot/mincross.ts +6 -2
- package/src/layout/dot/ns-subtree.ts +11 -7
- package/src/layout/dot/pack-components.ts +6 -4
- package/src/layout/dot/position-aux.ts +112 -39
- package/src/layout/dot/position-bbox.ts +14 -1
- package/src/layout/dot/position-ycoords.ts +7 -1
- package/src/layout/dot/position.ts +4 -1
- package/src/layout/dot/rank-dot2.ts +13 -94
- package/src/layout/dot/self-loop.ts +29 -11
- package/src/layout/dot/splines-flat-multi.ts +12 -4
- package/src/layout/dot/splines-route.ts +10 -11
- package/src/layout/dot/straight-edges.ts +5 -3
- package/src/layout/fdp/cluster-edges.ts +2 -23
- package/src/layout/fdp/tlayout.ts +6 -5
- package/src/layout/neato/__fixtures__/conjgrad-d.json +1 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.dot +141 -141
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.xdot +339 -339
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.dot +140 -140
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.xdot +323 -323
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.dot +141 -141
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.xdot +339 -339
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.dot +251 -251
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.xdot +535 -535
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.dot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.xdot +32 -32
- package/src/layout/neato/__fixtures__/dim/hier-dim4.dot +8 -8
- package/src/layout/neato/__fixtures__/dim/hier-dim4.xdot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.dot +17 -17
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.xdot +35 -35
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.dot +2 -2
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.xdot +2 -2
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.dot +11 -11
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.xdot +21 -21
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.dot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.xdot +26 -26
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.dot +13 -13
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.xdot +30 -30
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.dot +10 -10
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.xdot +19 -19
- package/src/layout/neato/__fixtures__/dim/smart-units.json +1 -1
- package/src/layout/neato/__fixtures__/hier/cases/dirnone.plain +10 -10
- package/src/layout/neato/__fixtures__/hier/cases/tdist.plain +12 -12
- package/src/layout/neato/__fixtures__/hier/hier-probe.plain +1 -1
- package/src/layout/neato/__fixtures__/hier/hier-probe.xdot +19 -19
- package/src/layout/neato/__fixtures__/hier-imds.ts +14 -13
- package/src/layout/neato/__fixtures__/hier-majorization.ts +24 -23
- package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot +20 -20
- package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot +8 -8
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot +34 -34
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot +32 -32
- package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot +18 -18
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot +13 -13
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot +12 -12
- package/src/layout/neato/__fixtures__/models/hier-circuit.xdot +33 -33
- package/src/layout/neato/__fixtures__/models/hier-default.xdot +30 -30
- package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot +30 -30
- package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot +35 -35
- package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot +30 -30
- package/src/layout/neato/conjgrad.ts +38 -35
- package/src/layout/neato/matrix-ops-dense.ts +2 -20
- package/src/layout/neato/matrix-ops.ts +0 -20
- package/src/layout/neato/quad-prog-vpsc.ts +7 -5
- package/src/layout/neato/smart-ini-x.ts +15 -15
- package/src/layout/neato/stress-subspace.ts +5 -5
- package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/dim3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/regen.sh +2 -0
- package/src/model/cgraph-ops.ts +12 -0
- package/src/model/graph.ts +13 -2
- package/src/model/rankEntry.ts +3 -1
- package/src/ortho/index.ts +0 -1
- package/src/ortho/partition.ts +10 -22
- package/src/parser/builder.ts +67 -100
- package/src/parser/graph-attr-syms.ts +62 -0
- package/src/pathplan/route.ts +14 -4
- package/src/render/dot/agwrite.ts +47 -27
- package/src/render/dot/attrs.ts +6 -2
- package/src/render/dot/types.ts +7 -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/overflow.ts +74 -0
- package/src/util/printf-round.ts +11 -0
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.
|
package/src/gvc/job.ts
CHANGED
|
@@ -309,20 +309,28 @@ export class RenderJob {
|
|
|
309
309
|
/** GD_fontnames of the root graph — selects which PostScript-alias fields the
|
|
310
310
|
* SVG emitter uses. @see plugin/core/gvrender_core_svg.c:464 */
|
|
311
311
|
fontnames: FontnameKind = FontnameKind.NativeFonts;
|
|
312
|
-
/**
|
|
313
|
-
* the `<gid>_` prefix
|
|
312
|
+
/** GD_drawing(root)->id: the root graph's `id`, substituted, '' if unset. Set
|
|
313
|
+
* by render() for every renderer (drawingIdOf); the `<gid>_` prefix of
|
|
314
|
+
* non-root object ids. @see lib/common/emit.c:getObjId */
|
|
314
315
|
drawingId: string = '';
|
|
315
316
|
|
|
316
317
|
/**
|
|
317
|
-
* Resolve an object's
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
318
|
+
* Resolve an object's id like C's getObjId. The layer half of
|
|
319
|
+
* layerPagePrefix comes first (`<layer>_` after the first layer), ahead of
|
|
320
|
+
* every other step. Then a non-empty DOT `id` attr wins verbatim; otherwise
|
|
321
|
+
* non-root objects are prefixed with `<drawingId>_` when the root graph has
|
|
322
|
+
* an id. The root's id gets the same prefix in emit_page (NotFirstPage).
|
|
323
|
+
* The page half (`page<x>,<y>_`) is left out: only ps and quartz page, and
|
|
324
|
+
* neither prints an id.
|
|
325
|
+
* @see lib/common/emit.c:getObjId
|
|
326
|
+
* @see lib/common/emit.c:layerPagePrefix
|
|
327
|
+
* @see lib/common/emit.c:emit_page
|
|
321
328
|
*/
|
|
322
329
|
objId(idAttr: string | undefined, defaultId: string, isRoot = false): string {
|
|
323
|
-
|
|
324
|
-
if (
|
|
325
|
-
return defaultId;
|
|
330
|
+
const pfx = this.idLayerPrefix();
|
|
331
|
+
if (idAttr !== undefined && idAttr.length > 0) return pfx + idAttr;
|
|
332
|
+
if (!isRoot && this.drawingId.length > 0) return pfx + this.drawingId + '_' + defaultId;
|
|
333
|
+
return pfx + defaultId;
|
|
326
334
|
}
|
|
327
335
|
|
|
328
336
|
/** Active renderer plugin; set by render() before walkNodes. */
|
package/src/gvc/viewport.ts
CHANGED
|
@@ -190,6 +190,22 @@ export function initJobViewportZoom(bb: Box, size: DrawingSize | null, pad: Poin
|
|
|
190
190
|
* @see lib/common/emit.c:init_job_viewport, init_job_pagination, setup_page
|
|
191
191
|
*/
|
|
192
192
|
export function setupPageClip(bb: Box, size: DrawingSize | null, pad: Point, z: number): Box {
|
|
193
|
+
const focus = { x: 0.5 * (bb.ll.x + bb.ur.x), y: 0.5 * (bb.ll.y + bb.ur.y) };
|
|
194
|
+
const pageSize = setupPageSize(bb, size, pad, z);
|
|
195
|
+
const ll = {
|
|
196
|
+
x: focus.x + pageSize.x * (0 - 1 / 2.0),
|
|
197
|
+
y: focus.y + pageSize.y * (0 - 1 / 2.0),
|
|
198
|
+
};
|
|
199
|
+
return { ll, ur: { x: ll.x + pageSize.x, y: ll.y + pageSize.y } };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* job->pageSize, the size of one page in graph units: imageSize / zoom, where
|
|
204
|
+
* imageSize = view = Z * sz and sz is the padded bb's extent (see
|
|
205
|
+
* setupPageClip). Not always sz: (Z * sz) / Z can round one ulp away from it.
|
|
206
|
+
* @see lib/common/emit.c:init_job_viewport, init_job_pagination
|
|
207
|
+
*/
|
|
208
|
+
export function setupPageSize(bb: Box, size: DrawingSize | null, pad: Point, z: number): Point {
|
|
193
209
|
const jbLL = { x: bb.ll.x - pad.x, y: bb.ll.y - pad.y };
|
|
194
210
|
const jbUR = { x: bb.ur.x + pad.x, y: bb.ur.y + pad.y };
|
|
195
211
|
const sz = { x: jbUR.x - jbLL.x, y: jbUR.y - jbLL.y };
|
|
@@ -197,11 +213,16 @@ export function setupPageClip(bb: Box, size: DrawingSize | null, pad: Point, z:
|
|
|
197
213
|
if (sz.x <= 0.001) sz.x = size.x;
|
|
198
214
|
if (sz.y <= 0.001) sz.y = size.y;
|
|
199
215
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
216
|
+
return { x: (z * sz.x) / z, y: (z * sz.y) / z };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* job->pageBox for the single page (pagesArrayElem 0): LL = elem * pageSize -
|
|
221
|
+
* pad, UR = LL + pageSize. Its origin is -pad whatever the bb's is, and it is
|
|
222
|
+
* derived apart from job->clip, so the two can differ in their last bits.
|
|
223
|
+
* @see lib/common/emit.c:setup_page (1515-1518)
|
|
224
|
+
*/
|
|
225
|
+
export function setupPageBox(pageSize: Point, pad: Point): Box {
|
|
226
|
+
const ll = { x: 0 * pageSize.x - pad.x, y: 0 * pageSize.y - pad.y };
|
|
206
227
|
return { ll, ur: { x: ll.x + pageSize.x, y: ll.y + pageSize.y } };
|
|
207
228
|
}
|
|
@@ -112,8 +112,11 @@ function interclust1(g: Graph, t: Node, h: Node, e: Edge): void {
|
|
|
112
112
|
const t0 = ufFind(t);
|
|
113
113
|
const h0 = ufFind(h);
|
|
114
114
|
const w = e.info.weight ?? 1;
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
// C writes ED_to_orig on both results without a NULL test. make_aux_edge
|
|
116
|
+
// refuses only a length above INT_MAX (16.1.1), and these lengths are C
|
|
117
|
+
// `int`s (`offset = ED_minlen(e) + t_rank - h_rank`), so neither is null.
|
|
118
|
+
const rt = makeAuxEdge(v, t0, tLen, CL_BACK * w)!;
|
|
119
|
+
const rh = makeAuxEdge(v, h0, hLen, w)!;
|
|
117
120
|
rt.info.to_orig = e;
|
|
118
121
|
rh.info.to_orig = e;
|
|
119
122
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { arrowEndClip, tailArrowEndClip, arrowClipLength, distFused } from './edge-route-clip.js';
|
|
16
16
|
import { arrowDrawOpsForEnd, edgeArrowName, edgeArrowsize } from './edge-route-arrow.js';
|
|
17
17
|
import { edgePenwidthAttr, edgeRenderPenwidth } from './edge-route-helpers.js';
|
|
18
|
+
import { mkClustMap } from '../../common/clust-map.js';
|
|
18
19
|
|
|
19
20
|
// Re-export geometry helpers so existing callers (tests) import from one place.
|
|
20
21
|
export {
|
|
@@ -24,27 +25,6 @@ export {
|
|
|
24
25
|
tryLeftSide, tryRightSide, tryBottomSide, tryTopSide, boxIntersectf,
|
|
25
26
|
} from './compound-clip.js';
|
|
26
27
|
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
// Cluster map
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
|
|
31
|
-
/** Recursively populate name→cluster map. @see lib/common/utils.c:fillMap */
|
|
32
|
-
export function fillClustMap(g: Graph, map: Map<string, Graph>): void {
|
|
33
|
-
const nc = g.info.n_cluster ?? 0;
|
|
34
|
-
for (let c = 1; c <= nc; c++) {
|
|
35
|
-
const cl = g.info.clust![c - 1];
|
|
36
|
-
if (!map.has(cl.name)) map.set(cl.name, cl);
|
|
37
|
-
fillClustMap(cl, map);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Build a name→cluster map for all clusters reachable from g. @see lib/common/utils.c:mkClustMap */
|
|
42
|
-
export function mkClustMap(g: Graph): Map<string, Graph> {
|
|
43
|
-
const map = new Map<string, Graph>();
|
|
44
|
-
fillClustMap(g, map);
|
|
45
|
-
return map;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
28
|
// ---------------------------------------------------------------------------
|
|
49
29
|
// ClipState — shared between head/tail clip helpers
|
|
50
30
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Edge views make_regular_edge routes instead of the edge itself: the forward
|
|
5
|
+
* view of a back edge (`makefwdedge`) and the two hackflag views of an edge
|
|
6
|
+
* routed on another edge's virtual chain (`fwdedgea`, `fwdedgeb`). Split from
|
|
7
|
+
* edge-route-chain.ts, which walks the chain these views drive.
|
|
8
|
+
*
|
|
9
|
+
* @see lib/dotgen/dotsplines.c:makefwdedge
|
|
10
|
+
* @see lib/dotgen/dotsplines.c:make_regular_edge (hackflag)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { Edge as GraphEdge } from '../../model/edge.js';
|
|
14
|
+
import type { Port } from '../../model/geom.js';
|
|
15
|
+
import type { Node } from '../../model/node.js';
|
|
16
|
+
import { VIRTUAL } from './fastgr.js';
|
|
17
|
+
import { makePort } from '../../model/edgeInfo.js';
|
|
18
|
+
import { resolveOrigEdge } from './splines.js';
|
|
19
|
+
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Forward view
|
|
22
|
+
// @see lib/dotgen/dotsplines.c:makefwdedge
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Forward view of any edge (C `makefwdedge`): tail/head swapped when the edge
|
|
27
|
+
* runs high→low rank (a back edge), fresh portless ends. `beginPath`/`endPath`
|
|
28
|
+
* read `e.tail`/`e.head`, so the chain must be driven by an edge that runs
|
|
29
|
+
* low→high rank. Sets `to_orig`/`edge_type=VIRTUAL` so `clipAndInstall`→
|
|
30
|
+
* `newSpline` installs the spline on the ORIGINAL edge (its `to_orig` loop) and
|
|
31
|
+
* the post-routing `swapSpline` pass reverses it back to tail→head. Shares
|
|
32
|
+
* `attrs`/`root`/`to_virt` with `e`. Consumed by T3 for parallel back-members.
|
|
33
|
+
* @see lib/dotgen/dotsplines.c:makefwdedge
|
|
34
|
+
* @see lib/common/splines.c:clip_and_install (to_orig install loop)
|
|
35
|
+
*/
|
|
36
|
+
export function makeFwdEdge(e: GraphEdge): GraphEdge {
|
|
37
|
+
const back = (e.head.info.rank ?? 0) < (e.tail.info.rank ?? 0);
|
|
38
|
+
const [tail, head] = back ? [e.head, e.tail] : [e.tail, e.head];
|
|
39
|
+
return {
|
|
40
|
+
...e,
|
|
41
|
+
tail,
|
|
42
|
+
head,
|
|
43
|
+
info: {
|
|
44
|
+
...e.info,
|
|
45
|
+
// C makefwdedge SWAPS the ports (does not strip them): a back edge keeps
|
|
46
|
+
// its corner ports across the forward view so make_regular_edge curls it
|
|
47
|
+
// (e.g. #241_0 aux back-edge clone sw/se → size 7). Stripping to an empty
|
|
48
|
+
// Center port straightened every port-bearing back edge (size 4).
|
|
49
|
+
// @see lib/dotgen/dotsplines.c:makefwdedge (ED_tail_port(new)=ED_head_port(old))
|
|
50
|
+
tail_port: e.info.head_port ?? makePort(),
|
|
51
|
+
head_port: e.info.tail_port ?? makePort(),
|
|
52
|
+
to_orig: e,
|
|
53
|
+
edge_type: VIRTUAL,
|
|
54
|
+
},
|
|
55
|
+
} as GraphEdge;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Hackflag views for an edge routed on another edge's chain
|
|
60
|
+
// @see lib/dotgen/dotsplines.c:make_regular_edge (abs(rank diff) > 1)
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
/** A port copied by value, as C's struct assignment copies `port`. */
|
|
64
|
+
function copyPort(p: Port): Port {
|
|
65
|
+
return { ...p, p: { ...p.p } };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* C's `fwdedgea`: a copy of `e` from its rank-low end to the first vnode of the
|
|
70
|
+
* chain, head port undefined at (0,0), VIRTUAL with `to_orig = e`. beginpath's
|
|
71
|
+
* side-port clip reset therefore lands on `e` itself.
|
|
72
|
+
*/
|
|
73
|
+
function hackflagBeginView(e: GraphEdge, back: boolean, firstVnode: Node): GraphEdge {
|
|
74
|
+
const tailPort = back ? e.info.head_port : e.info.tail_port;
|
|
75
|
+
return {
|
|
76
|
+
...e,
|
|
77
|
+
tail: back ? e.head : e.tail,
|
|
78
|
+
head: firstVnode,
|
|
79
|
+
info: {
|
|
80
|
+
...e.info,
|
|
81
|
+
tail_port: copyPort(tailPort),
|
|
82
|
+
head_port: { ...copyPort(e.info.head_port), defined: false, p: { x: 0, y: 0 } },
|
|
83
|
+
edge_type: VIRTUAL,
|
|
84
|
+
to_orig: e,
|
|
85
|
+
},
|
|
86
|
+
} as GraphEdge;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* C's `fwdedgeb`: for a back edge, `makefwdedge(e)` (VIRTUAL, `to_orig = e`);
|
|
91
|
+
* otherwise a plain struct copy of `e` that stays NORMAL, so endpath's
|
|
92
|
+
* side-port clip reset lands on the copy and `e` keeps its head clip.
|
|
93
|
+
*/
|
|
94
|
+
function hackflagEndView(e: GraphEdge, back: boolean): GraphEdge {
|
|
95
|
+
if (back) return makeFwdEdge(e);
|
|
96
|
+
return {
|
|
97
|
+
...e,
|
|
98
|
+
info: { ...e.info, tail_port: copyPort(e.info.tail_port), head_port: copyPort(e.info.head_port) },
|
|
99
|
+
} as GraphEdge;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The edges that drive the chain's first beginpath and last endpath. A chain
|
|
104
|
+
* owned by `e` itself is C's ordinary walk from the first to the last fast
|
|
105
|
+
* edge. A chain owned by another edge means class2 merged `e` into it
|
|
106
|
+
* (`merge_chain`), so `e` sits in ND_other and C's group loop hands the real
|
|
107
|
+
* edge to make_regular_edge, which takes the hackflag branch: beginpath on
|
|
108
|
+
* `fwdedgea`, endpath on `fwdedgeb`. Driving those calls with the owner's
|
|
109
|
+
* segments reset the owner's clip flags instead of `e`'s (plantuml-ts 41).
|
|
110
|
+
* @see lib/dotgen/dotsplines.c:make_regular_edge (hackflag)
|
|
111
|
+
* @see lib/dotgen/class2.c:class2 (merge_chain, other_edge)
|
|
112
|
+
*/
|
|
113
|
+
export function chainEnds(e: GraphEdge, segs: GraphEdge[]): [GraphEdge, GraphEdge] {
|
|
114
|
+
const first = segs[0];
|
|
115
|
+
const last = segs[segs.length - 1];
|
|
116
|
+
const orig = resolveOrigEdge(e);
|
|
117
|
+
if (resolveOrigEdge(first) === orig) return [first, last];
|
|
118
|
+
const back = (orig.head.info.rank ?? 0) < (orig.tail.info.rank ?? 0);
|
|
119
|
+
return [hackflagBeginView(orig, back, first.head), hackflagEndView(orig, back)];
|
|
120
|
+
}
|