@knowvah/dot-engine 2.7.1 → 2.8.1
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.map +2 -2
- package/dist/common/agerr.d.ts +8 -1
- package/dist/common/agerr.d.ts.map +1 -1
- package/dist/common/fma.d.ts.map +1 -1
- package/dist/common/htmltable-emit-fill.d.ts.map +1 -1
- package/dist/common/htmltable-emit.d.ts +6 -11
- package/dist/common/htmltable-emit.d.ts.map +1 -1
- package/dist/common/htmltable-label.d.ts +3 -0
- package/dist/common/htmltable-label.d.ts.map +1 -1
- package/dist/common/htmltable-lex-attvalue.d.ts.map +1 -1
- package/dist/common/htmltable.d.ts +5 -0
- package/dist/common/htmltable.d.ts.map +1 -1
- package/dist/common/layers.d.ts +12 -0
- package/dist/common/layers.d.ts.map +1 -1
- package/dist/common/layout-state.d.ts +8 -0
- package/dist/common/layout-state.d.ts.map +1 -0
- package/dist/common/make-label.d.ts.map +1 -1
- package/dist/common/multicolor.d.ts +6 -3
- package/dist/common/multicolor.d.ts.map +1 -1
- package/dist/common/nodeinit.d.ts.map +1 -1
- package/dist/common/poly-gencode.d.ts.map +1 -1
- package/dist/common/poly-init.d.ts +21 -0
- package/dist/common/poly-init.d.ts.map +1 -1
- package/dist/common/poly-sizing.d.ts +1 -0
- package/dist/common/poly-sizing.d.ts.map +1 -1
- package/dist/common/postproc.d.ts.map +1 -1
- package/dist/common/style-resolve.d.ts +11 -9
- package/dist/common/style-resolve.d.ts.map +1 -1
- package/dist/gvc/device-cluster.d.ts +5 -6
- package/dist/gvc/device-cluster.d.ts.map +1 -1
- package/dist/gvc/device.d.ts.map +1 -1
- package/dist/gvc/first-layer.d.ts +21 -5
- package/dist/gvc/first-layer.d.ts.map +1 -1
- package/dist/gvc/gvrender-set-style.d.ts.map +1 -1
- package/dist/gvc/render-usershape.d.ts +60 -0
- package/dist/gvc/render-usershape.d.ts.map +1 -0
- package/dist/gvc/usershape.d.ts +20 -0
- package/dist/gvc/usershape.d.ts.map +1 -1
- package/dist/index.js +8838 -8465
- package/dist/index.js.map +4 -4
- package/dist/layout/circo/index.d.ts.map +1 -1
- package/dist/layout/dot/init.d.ts +10 -0
- package/dist/layout/dot/init.d.ts.map +1 -1
- package/dist/layout/dot/splines.d.ts.map +1 -1
- package/dist/layout/fdp/init.d.ts.map +1 -1
- package/dist/layout/neato/conjgrad-mkernel.d.ts.map +1 -1
- package/dist/layout/neato/constrained-majorization.d.ts.map +1 -1
- package/dist/layout/neato/edge-len.d.ts +6 -2
- package/dist/layout/neato/edge-len.d.ts.map +1 -1
- package/dist/layout/neato/init.d.ts.map +1 -1
- package/dist/layout/neato/kk.d.ts.map +1 -1
- package/dist/layout/neato/make-graph-data.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/smart-ini-x.d.ts.map +1 -1
- package/dist/layout/neato/splines.d.ts.map +1 -1
- package/dist/layout/neato/start.d.ts.map +1 -1
- package/dist/layout/neato/stress-kernel.d.ts +2 -5
- package/dist/layout/neato/stress-kernel.d.ts.map +1 -1
- package/dist/layout/neato/stress.d.ts +6 -0
- package/dist/layout/neato/stress.d.ts.map +1 -1
- package/dist/layout/osage/index.d.ts.map +1 -1
- package/dist/layout/patchwork/index.d.ts.map +1 -1
- package/dist/layout/sfdp/init.d.ts.map +1 -1
- package/dist/layout/twopi/init.d.ts +12 -6
- package/dist/layout/twopi/init.d.ts.map +1 -1
- package/dist/model/cgraph-ops.d.ts +9 -0
- package/dist/model/cgraph-ops.d.ts.map +1 -1
- package/dist/render/color-resolve.d.ts +7 -0
- package/dist/render/color-resolve.d.ts.map +1 -1
- package/dist/render/dot.d.ts +8 -1
- package/dist/render/dot.d.ts.map +1 -1
- package/dist/render/json.d.ts +17 -2
- package/dist/render/json.d.ts.map +1 -1
- package/dist/render/map.d.ts +3 -5
- package/dist/render/map.d.ts.map +1 -1
- package/dist/render.js +711 -338
- package/dist/render.js.map +4 -4
- package/package.json +1 -1
- package/src/common/agerr.ts +69 -8
- package/src/common/fma.ts +11 -1
- package/src/common/htmltable-emit-fill.ts +11 -7
- package/src/common/htmltable-emit.ts +11 -46
- package/src/common/htmltable-label.ts +6 -3
- package/src/common/htmltable-lex-attvalue.ts +17 -1
- package/src/common/htmltable.ts +10 -5
- package/src/common/layers.ts +31 -2
- package/src/common/layout-state.ts +35 -0
- package/src/common/make-label.ts +6 -2
- package/src/common/multicolor.ts +12 -6
- package/src/common/nodeinit.ts +4 -1
- package/src/common/poly-gencode.ts +51 -2
- package/src/common/poly-init.ts +34 -13
- package/src/common/poly-sizing.ts +4 -4
- package/src/common/postproc.ts +4 -1
- package/src/common/style-resolve.ts +118 -50
- package/src/gvc/device-cluster.ts +33 -40
- package/src/gvc/device.ts +56 -43
- package/src/gvc/first-layer.ts +60 -11
- package/src/gvc/gvrender-set-style.ts +1 -6
- package/src/gvc/render-usershape.ts +209 -0
- package/src/gvc/usershape.ts +40 -0
- package/src/layout/circo/index.ts +4 -0
- package/src/layout/dot/init.ts +32 -0
- package/src/layout/dot/splines.ts +3 -0
- package/src/layout/fdp/init.ts +17 -0
- package/src/layout/neato/conjgrad-mkernel.ts +2 -3
- package/src/layout/neato/constrained-majorization.ts +2 -1
- package/src/layout/neato/edge-len.ts +39 -7
- package/src/layout/neato/init.ts +8 -3
- package/src/layout/neato/kk.ts +2 -1
- package/src/layout/neato/make-graph-data.ts +1 -2
- package/src/layout/neato/matrix-ops.ts +1 -11
- package/src/layout/neato/smart-ini-x.ts +1 -1
- package/src/layout/neato/splines.ts +3 -1
- package/src/layout/neato/start.ts +3 -2
- package/src/layout/neato/stress-kernel.ts +45 -86
- package/src/layout/neato/stress.ts +19 -0
- package/src/layout/osage/index.ts +8 -1
- package/src/layout/patchwork/index.ts +4 -0
- package/src/layout/sfdp/init.ts +3 -0
- package/src/layout/twopi/init.ts +21 -9
- package/src/layout/twopi/pipeline.ts +3 -3
- package/src/model/cgraph-ops.ts +19 -0
- package/src/render/color-resolve.ts +17 -2
- package/src/render/dot.ts +14 -1
- package/src/render/json.ts +9 -10
- package/src/render/map.ts +5 -6
package/src/gvc/device.ts
CHANGED
|
@@ -26,7 +26,7 @@ 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
28
|
import { walkNodesAndEdges } from './emit-walk.js';
|
|
29
|
-
import {
|
|
29
|
+
import { firstLayer, nextLayer, numPhysicalLayers, validLayer } from './first-layer.js';
|
|
30
30
|
import { polyInit } from '../common/poly-init.js';
|
|
31
31
|
import {
|
|
32
32
|
setHtmlAnchorObj,
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
setRendererKnownColors,
|
|
49
49
|
} from '../render/color-resolve.js';
|
|
50
50
|
import { emitRoundedBezier } from '../common/poly-shapes.js';
|
|
51
|
-
import { applyClusterObjState, clusterStyle, clusterPeripheries, isStripedCluster, renderStripedClusterBox } from './device-cluster.js';
|
|
51
|
+
import { applyClusterObjState, clusterAttr, clusterStyle, clusterPeripheries, isStripedCluster, renderStripedClusterBox } from './device-cluster.js';
|
|
52
52
|
import { transformPoint } from './device-transform.js';
|
|
53
53
|
import { gvrenderSetStyle, edgeStyleResets } from './gvrender-set-style.js';
|
|
54
54
|
import { renderOneLabel, renderNodeXLabel, renderClusterLabel, reportEdgeLabelColors } from './device-labels.js';
|
|
@@ -156,7 +156,7 @@ export function renderNode(n: Node, renderer: RendererPlugin, job: RenderJob, do
|
|
|
156
156
|
* Set the edge pen color/type/width on job.obj from the edge's attrs — mirrors
|
|
157
157
|
* emit_edge_graphics. (AD1: style flows through job.obj, not ad-hoc renderer reads.)
|
|
158
158
|
*/
|
|
159
|
-
function setEdgePen(e: Edge, job: RenderJob): void {
|
|
159
|
+
function setEdgePen(e: Edge, job: RenderJob, styles: readonly string[]): void {
|
|
160
160
|
if (job.obj === null) return;
|
|
161
161
|
const obj = job.obj;
|
|
162
162
|
const flags = parseStyleFlags(e.attrs.get('style'));
|
|
@@ -166,7 +166,7 @@ function setEdgePen(e: Edge, job: RenderJob): void {
|
|
|
166
166
|
obj.penWidth = resolvePenWidth(flags, e.attrs.get('penwidth'));
|
|
167
167
|
// Raw style tokens for xdot's `S` ops (e.g. explicit style="solid"); SVG
|
|
168
168
|
// reads only obj.pen, so this is xdot-only. @see gvrender_core_dot.c xdot_style
|
|
169
|
-
obj.rawStyle =
|
|
169
|
+
obj.rawStyle = [...styles];
|
|
170
170
|
// emit_begin_edge: `if (styles && ED_spl(e)) gvrender_set_style(job, styles)`
|
|
171
171
|
// @see lib/common/emit.c:2726
|
|
172
172
|
if (e.info.spl !== undefined) gvrenderSetStyle(obj.rawStyle);
|
|
@@ -178,13 +178,16 @@ export function renderEdge(e: Edge, renderer: RendererPlugin, job: RenderJob): v
|
|
|
178
178
|
// before emit_begin_edge. @see lib/common/emit.c:emit_edge (style "invis" return)
|
|
179
179
|
// The "invisible" alias likewise suppresses all edge draw ops via PEN_NONE
|
|
180
180
|
// (edges never use the point-shape whitelist). @see lib/gvc/gvrender.c:497
|
|
181
|
+
// emit_edge parses the style once (reporting its faults); the rest reuse the list.
|
|
182
|
+
// @see lib/common/emit.c:2013 emit_edge
|
|
181
183
|
const edgeStyle = e.attrs.get('style');
|
|
184
|
+
const styles = styleTokens(edgeStyle);
|
|
182
185
|
if (parseStyleFlags(edgeStyle).invis || styleHasInvisibleAlias(edgeStyle)) return;
|
|
183
186
|
// push_obj_state in emit_begin_edge (line 2715)
|
|
184
187
|
const obj = createObjState(ObjType.Edge);
|
|
185
188
|
obj.emitState = EmitState.EDraw;
|
|
186
189
|
job.pushObj(obj);
|
|
187
|
-
setEdgePen(e, job);
|
|
190
|
+
setEdgePen(e, job, styles);
|
|
188
191
|
try {
|
|
189
192
|
// @see lib/common/emit.c:emit_begin_edge / getObjId
|
|
190
193
|
setHtmlAnchorObj(svgEdgeId(e, job), labelTextOf(e.info.label), job.obj ?? undefined);
|
|
@@ -202,7 +205,6 @@ export function renderEdge(e: Edge, renderer: RendererPlugin, job: RenderJob): v
|
|
|
202
205
|
reportEdgeColors(e);
|
|
203
206
|
// arrow_gen resets the style; C sets the edge's styles again after each
|
|
204
207
|
// flagged bezier of a multi-bezier spline. @see emit.c:2047, :2677
|
|
205
|
-
const styles = styleTokens(e.attrs.get('style'));
|
|
206
208
|
for (let i = edgeStyleResets(e, styles); i > 0; i--) gvrenderSetStyle(styles);
|
|
207
209
|
reportEdgeLabelColors(e);
|
|
208
210
|
renderer.endEdge(e, job);
|
|
@@ -252,6 +254,41 @@ function renderClusterBox(
|
|
|
252
254
|
renderer.polygon(rawPts.map(p => transformPoint(p, job)), filled, job);
|
|
253
255
|
}
|
|
254
256
|
|
|
257
|
+
/**
|
|
258
|
+
* The body of emit_clusters between setColorScheme and its restore.
|
|
259
|
+
* @see lib/common/emit.c:3800-3943 emit_clusters
|
|
260
|
+
*/
|
|
261
|
+
function drawClusterInScheme(sg: Graph, renderer: RendererPlugin, job: RenderJob): void {
|
|
262
|
+
// Resolve and wire cluster fill/pen into job.obj before the polygon.
|
|
263
|
+
// emit_clusters:3805-3874 — must happen before gvrender_box.
|
|
264
|
+
const filled = applyClusterObjState(sg, job);
|
|
265
|
+
// Cluster id is clust<AGSEQ seq> (getObjId); obj.id feeds emitGradientDefs
|
|
266
|
+
// the "clustN_l_0" gradient prefix. seq is stable on the subgraph, so the
|
|
267
|
+
// begin/assign order below is no longer load-bearing.
|
|
268
|
+
// @see lib/common/emit.c:209 getObjId (AGRAPH/cluster: pfx="clust")
|
|
269
|
+
renderer.beginCluster?.(sg, job);
|
|
270
|
+
if (job.obj !== null) job.obj.id = svgClusterId(sg, job);
|
|
271
|
+
// @see lib/common/emit.c:emit_begin_cluster / getObjId
|
|
272
|
+
setHtmlAnchorObj(svgClusterId(sg, job), labelTextOf(sg.info.label), job.obj ?? undefined);
|
|
273
|
+
// Resolve and open the cluster anchor around the box + label (closed before
|
|
274
|
+
// the cluster's child nodes — sibling of them). @see emit.c:3803.
|
|
275
|
+
if (job.obj !== null) {
|
|
276
|
+
resolveObjAnchor(sg, labelTextOf(sg.info.label), svgClusterId(sg, job), job.obj);
|
|
277
|
+
}
|
|
278
|
+
const anchored = beginAnchorIf(renderer, job);
|
|
279
|
+
// C draws the boundary box only when peripheries != 0, or (peripheries == 0
|
|
280
|
+
// and the cluster is filled). peripheries=0 + unfilled emits nothing.
|
|
281
|
+
// style=invis sets PEN_NONE and gvrender_polygon skips the whole box
|
|
282
|
+
// (fill included); the group/title still emit.
|
|
283
|
+
// @see lib/common/emit.c:3907-3917, lib/gvc/gvrender.c:543
|
|
284
|
+
if ((clusterPeripheries(sg) !== 0 || filled || isStripedCluster(sg)) && job.obj?.pen !== PenType.None) {
|
|
285
|
+
renderClusterBox(sg, filled, renderer, job);
|
|
286
|
+
}
|
|
287
|
+
renderClusterLabel(sg, renderer, job);
|
|
288
|
+
if (anchored) renderer.endAnchor?.(job);
|
|
289
|
+
renderer.endCluster?.(sg, job);
|
|
290
|
+
}
|
|
291
|
+
|
|
255
292
|
/**
|
|
256
293
|
* Render one cluster: box, label, endCluster, then recurse into sub-clusters.
|
|
257
294
|
* push_obj_state in emit_begin_cluster (3762); pop in emit_end_cluster (3774).
|
|
@@ -271,34 +308,10 @@ function renderOneCluster(sg: Graph, renderer: RendererPlugin, job: RenderJob):
|
|
|
271
308
|
obj.emitState = EmitState.CDraw;
|
|
272
309
|
job.pushObj(obj);
|
|
273
310
|
try {
|
|
274
|
-
//
|
|
275
|
-
//
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// the "clustN_l_0" gradient prefix. seq is stable on the subgraph, so the
|
|
279
|
-
// begin/assign order below is no longer load-bearing.
|
|
280
|
-
// @see lib/common/emit.c:209 getObjId (AGRAPH/cluster: pfx="clust")
|
|
281
|
-
renderer.beginCluster?.(sg, job);
|
|
282
|
-
if (job.obj !== null) job.obj.id = svgClusterId(sg, job);
|
|
283
|
-
// @see lib/common/emit.c:emit_begin_cluster / getObjId
|
|
284
|
-
setHtmlAnchorObj(svgClusterId(sg, job), labelTextOf(sg.info.label), job.obj ?? undefined);
|
|
285
|
-
// Resolve and open the cluster anchor around the box + label (closed before
|
|
286
|
-
// the cluster's child nodes — sibling of them). @see emit.c:3803.
|
|
287
|
-
if (job.obj !== null) {
|
|
288
|
-
resolveObjAnchor(sg, labelTextOf(sg.info.label), svgClusterId(sg, job), job.obj);
|
|
289
|
-
}
|
|
290
|
-
const anchored = beginAnchorIf(renderer, job);
|
|
291
|
-
// C draws the boundary box only when peripheries != 0, or (peripheries == 0
|
|
292
|
-
// and the cluster is filled). peripheries=0 + unfilled emits nothing.
|
|
293
|
-
// style=invis sets PEN_NONE and gvrender_polygon skips the whole box
|
|
294
|
-
// (fill included); the group/title still emit.
|
|
295
|
-
// @see lib/common/emit.c:3907-3917, lib/gvc/gvrender.c:543
|
|
296
|
-
if ((clusterPeripheries(sg) !== 0 || filled || isStripedCluster(sg)) && job.obj?.pen !== PenType.None) {
|
|
297
|
-
renderClusterBox(sg, filled, renderer, job);
|
|
298
|
-
}
|
|
299
|
-
renderClusterLabel(sg, renderer, job);
|
|
300
|
-
if (anchored) renderer.endAnchor?.(job);
|
|
301
|
-
renderer.endCluster?.(sg, job);
|
|
311
|
+
// C opens setColorScheme right after emit_begin_cluster and restores it after
|
|
312
|
+
// emit_label(EMIT_CLABEL): the window spans fill, pen, box and label.
|
|
313
|
+
// @see lib/common/emit.c:3800 / :3943 emit_clusters
|
|
314
|
+
withColorScheme(clusterAttr(sg, 'colorscheme'), () => drawClusterInScheme(sg, renderer, job));
|
|
302
315
|
} finally {
|
|
303
316
|
// pop_obj_state in emit_end_cluster (line 3774), before sub-cluster recursion
|
|
304
317
|
job.popObj();
|
|
@@ -341,18 +354,17 @@ export function renderGraph(g: Graph, job: RenderJob, renderer: RendererPlugin):
|
|
|
341
354
|
job.pushObj(obj);
|
|
342
355
|
try {
|
|
343
356
|
const info = parseLayers(g);
|
|
344
|
-
//
|
|
345
|
-
|
|
346
|
-
const layered = renderer.beginLayer !== undefined && info.numLayers > 1;
|
|
347
|
-
job.numLayers = layered ? info.numLayers : 1;
|
|
357
|
+
// emit_graph sets job->layerNum = 0 before emit_begin_graph.
|
|
358
|
+
job.layerNum = 0;
|
|
348
359
|
job.layerIDs = info.layerIDs;
|
|
349
360
|
renderer.beginGraph(g, job);
|
|
350
|
-
|
|
351
|
-
for (
|
|
352
|
-
|
|
353
|
-
|
|
361
|
+
const cur = firstLayer(job, info, renderer.beginLayer !== undefined);
|
|
362
|
+
for (; validLayer(job); nextLayer(job, cur)) {
|
|
363
|
+
const layered = numPhysicalLayers(job, info) > 1;
|
|
364
|
+
// gvrender_begin_layer/end_layer are no-ops without a plugin callback.
|
|
365
|
+
if (layered) renderer.beginLayer?.(info.layerIDs[job.layerNum]!, job);
|
|
354
366
|
renderPage(g, renderer, job, info);
|
|
355
|
-
if (layered) renderer.endLayer
|
|
367
|
+
if (layered) renderer.endLayer?.(job);
|
|
356
368
|
}
|
|
357
369
|
renderer.endGraph(g, job);
|
|
358
370
|
} finally {
|
|
@@ -414,6 +426,7 @@ export function render(ctx: GvcContext, g: Graph, format: string, inlineImages =
|
|
|
414
426
|
const job = new RenderJob(format, ctx.textMeasurer);
|
|
415
427
|
job.inlineImages = inlineImages;
|
|
416
428
|
if (ctx.imageResolver !== undefined) job.imageResolver = ctx.imageResolver;
|
|
429
|
+
if (ctx.imageSizer !== undefined) job.imageSizer = ctx.imageSizer;
|
|
417
430
|
// gvc->bb = GD_bb(g) verbatim -- no recompute fallback. Every layout engine
|
|
418
431
|
// sets g.info.bb itself before render() runs (set_aspect for dot,
|
|
419
432
|
// compute_bb-equivalent computeSubgraphBB calls in neato/circo/sfdp/fdp/
|
package/src/gvc/first-layer.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EPL-2.0
|
|
2
2
|
/**
|
|
3
|
-
* The
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* The layer walk of `emit_graph`: `for (firstlayer; validlayer; nextlayer)`
|
|
4
|
+
* over either every layer or the `layerselect` list, plus the
|
|
5
|
+
* `GVDEVICE_DOES_LAYERS` warning. `GVDEVICE_DOES_LAYERS` is
|
|
6
|
+
* `renderer.beginLayer !== undefined`.
|
|
7
7
|
*/
|
|
8
8
|
import { agwarningf } from '../common/agerr.js';
|
|
9
|
+
import type { LayerInfo } from '../common/layers.js';
|
|
10
|
+
import type { RenderJob } from './job.js';
|
|
9
11
|
|
|
10
12
|
/** Port format ids that spell a native `-T` name differently (`output_langname`). */
|
|
11
13
|
const NATIVE_LANGNAME: ReadonlyMap<string, string> = new Map([
|
|
@@ -13,14 +15,61 @@ const NATIVE_LANGNAME: ReadonlyMap<string, string> = new Map([
|
|
|
13
15
|
['imap-np', 'imap_np'],
|
|
14
16
|
]);
|
|
15
17
|
|
|
18
|
+
/** C's `int **listp`: the selected-layer list and the read position in it. */
|
|
19
|
+
export interface LayerCursor {
|
|
20
|
+
list: number[] | null;
|
|
21
|
+
pos: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function warnUnsupported(job: RenderJob): void {
|
|
25
|
+
agwarningf(`layers not supported in ${NATIVE_LANGNAME.get(job.format) ?? job.format} output`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Number of layers emitted (begin/end layer wrap them only when above one).
|
|
30
|
+
* @see lib/common/emit.c:numPhysicalLayers
|
|
31
|
+
*/
|
|
32
|
+
export function numPhysicalLayers(job: RenderJob, info: LayerInfo): number {
|
|
33
|
+
return info.layerList !== null ? info.layerList[0]! : job.numLayers;
|
|
34
|
+
}
|
|
35
|
+
|
|
16
36
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
37
|
+
* Called after beginGraph, as emit_graph calls firstlayer after
|
|
38
|
+
* emit_begin_graph: for `-Tjson` the nested xdot render in json_begin_graph
|
|
39
|
+
* therefore warns first. With a list, a device without layers keeps only the
|
|
40
|
+
* first entry by overwriting the second with the sentinel (as C does, in place).
|
|
21
41
|
* @see lib/common/emit.c:firstlayer
|
|
22
42
|
*/
|
|
23
|
-
export function
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
export function firstLayer(job: RenderJob, info: LayerInfo, doesLayers: boolean): LayerCursor {
|
|
44
|
+
job.numLayers = info.numLayers;
|
|
45
|
+
const list = info.layerList;
|
|
46
|
+
if (list !== null) {
|
|
47
|
+
if (list[0]! > 1 && !doesLayers) {
|
|
48
|
+
warnUnsupported(job);
|
|
49
|
+
list[2] = job.numLayers + 1; // only one layer printed
|
|
50
|
+
}
|
|
51
|
+
job.layerNum = list[1]!;
|
|
52
|
+
return { list, pos: 2 };
|
|
53
|
+
}
|
|
54
|
+
if (job.numLayers > 1 && !doesLayers) {
|
|
55
|
+
warnUnsupported(job);
|
|
56
|
+
job.numLayers = 1;
|
|
57
|
+
}
|
|
58
|
+
job.layerNum = 1;
|
|
59
|
+
return { list: null, pos: 0 };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @see lib/common/emit.c:validlayer */
|
|
63
|
+
export function validLayer(job: RenderJob): boolean {
|
|
64
|
+
return job.layerNum <= job.numLayers;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** @see lib/common/emit.c:nextlayer */
|
|
68
|
+
export function nextLayer(job: RenderJob, cur: LayerCursor): void {
|
|
69
|
+
if (cur.list !== null) {
|
|
70
|
+
job.layerNum = cur.list[cur.pos]!;
|
|
71
|
+
cur.pos++;
|
|
72
|
+
} else {
|
|
73
|
+
job.layerNum++;
|
|
74
|
+
}
|
|
26
75
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import { agwarningf } from '../common/agerr.js';
|
|
15
15
|
import { parseSegsSilent } from '../common/multicolor.js';
|
|
16
|
+
import { styleName } from '../common/style-resolve.js';
|
|
16
17
|
import type { PolygonT } from '../common/types.js';
|
|
17
18
|
import type { Edge } from '../model/edge.js';
|
|
18
19
|
|
|
@@ -29,12 +30,6 @@ const BOX_SIDES = 4;
|
|
|
29
30
|
/** polygon_t.sides bound of shapes.c:isEllipse. @see lib/common/shapes.c:isEllipse */
|
|
30
31
|
const ELLIPSE_MAX_SIDES = 2;
|
|
31
32
|
|
|
32
|
-
/** The name C compares: parse_style stores a token's `(args)` after its NUL. */
|
|
33
|
-
function styleName(token: string): string {
|
|
34
|
-
const paren = token.indexOf('(');
|
|
35
|
-
return paren < 0 ? token : token.slice(0, paren);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
33
|
/**
|
|
39
34
|
* Warn for every token the render engine cannot map, on every call.
|
|
40
35
|
* @see lib/gvc/gvrender.c:480 gvrender_set_style
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `gvrender_usershape`: fit an image (node `image=`, HTML `<IMG>`) into the
|
|
5
|
+
* bounding box of a polygon according to `imagescale` / `imagepos`, then hand
|
|
6
|
+
* the resulting box to the renderer's loadimage hook (`usershape`).
|
|
7
|
+
*
|
|
8
|
+
* @see lib/gvc/gvrender.c:gvrender_usershape (670-790)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Box, Point } from '../model/geom.js';
|
|
12
|
+
import type { RenderJob } from './job.js';
|
|
13
|
+
import { imageIsSupplied, usershapeSizePts, type ImageSizer } from './usershape.js';
|
|
14
|
+
import { mapbool } from '../layout/dot/rank.js';
|
|
15
|
+
|
|
16
|
+
/** @see lib/gvc/gvcjob.h:imagescale_t */
|
|
17
|
+
export const ImageScale = {
|
|
18
|
+
False: 'false',
|
|
19
|
+
True: 'true',
|
|
20
|
+
Width: 'width',
|
|
21
|
+
Height: 'height',
|
|
22
|
+
Both: 'both',
|
|
23
|
+
} as const;
|
|
24
|
+
export type ImageScale = (typeof ImageScale)[keyof typeof ImageScale];
|
|
25
|
+
|
|
26
|
+
/** @see lib/gvc/gvcjob.h:imagepos_t */
|
|
27
|
+
export const ImagePos = {
|
|
28
|
+
TopLeft: 'tl',
|
|
29
|
+
TopCenter: 'tc',
|
|
30
|
+
TopRight: 'tr',
|
|
31
|
+
MiddleLeft: 'ml',
|
|
32
|
+
MiddleCenter: 'mc',
|
|
33
|
+
MiddleRight: 'mr',
|
|
34
|
+
BottomLeft: 'bl',
|
|
35
|
+
BottomCenter: 'bc',
|
|
36
|
+
BottomRight: 'br',
|
|
37
|
+
} as const;
|
|
38
|
+
export type ImagePos = (typeof ImagePos)[keyof typeof ImagePos];
|
|
39
|
+
|
|
40
|
+
const IMAGE_POSITIONS: ReadonlySet<string> = new Set(Object.values(ImagePos));
|
|
41
|
+
|
|
42
|
+
/** @see lib/gvc/gvrender.c:get_imagescale */
|
|
43
|
+
export function getImagescale(s: string): ImageScale {
|
|
44
|
+
if (s === '') return ImageScale.False;
|
|
45
|
+
const l = s.toLowerCase();
|
|
46
|
+
if (l === 'width') return ImageScale.Width;
|
|
47
|
+
if (l === 'height') return ImageScale.Height;
|
|
48
|
+
if (l === 'both') return ImageScale.Both;
|
|
49
|
+
if (mapbool(s)) return ImageScale.True;
|
|
50
|
+
return ImageScale.False;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @see lib/gvc/gvrender.c:get_imagepos */
|
|
54
|
+
export function getImagepos(s: string): ImagePos {
|
|
55
|
+
if (s === '') return ImagePos.MiddleCenter;
|
|
56
|
+
const l = s.toLowerCase();
|
|
57
|
+
return IMAGE_POSITIONS.has(l) ? (l as ImagePos) : ImagePos.MiddleCenter;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Scale `isz` toward the polygon extent (pw, ph) per `imagescale`. */
|
|
61
|
+
function scaleImage(
|
|
62
|
+
mode: ImageScale, isz: { w: number; h: number }, pw: number, ph: number,
|
|
63
|
+
): { iw: number; ih: number } {
|
|
64
|
+
let iw = isz.w;
|
|
65
|
+
let ih = isz.h;
|
|
66
|
+
const scalex = pw / iw;
|
|
67
|
+
const scaley = ph / ih;
|
|
68
|
+
switch (mode) {
|
|
69
|
+
case ImageScale.True:
|
|
70
|
+
// keep aspect ratio fixed by just using the smaller scale
|
|
71
|
+
if (scalex < scaley) {
|
|
72
|
+
iw *= scalex;
|
|
73
|
+
ih *= scalex;
|
|
74
|
+
} else {
|
|
75
|
+
iw *= scaley;
|
|
76
|
+
ih *= scaley;
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case ImageScale.Width:
|
|
80
|
+
iw *= scalex;
|
|
81
|
+
break;
|
|
82
|
+
case ImageScale.Height:
|
|
83
|
+
ih *= scaley;
|
|
84
|
+
break;
|
|
85
|
+
case ImageScale.Both:
|
|
86
|
+
iw *= scalex;
|
|
87
|
+
ih *= scaley;
|
|
88
|
+
break;
|
|
89
|
+
case ImageScale.False:
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
return { iw, ih };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Apply `imagepos` to the target box when the image is narrower than it. */
|
|
96
|
+
function positionX(b: Box, position: ImagePos, iw: number, pw: number): void {
|
|
97
|
+
if (!(iw < pw)) return;
|
|
98
|
+
switch (position) {
|
|
99
|
+
case ImagePos.TopLeft:
|
|
100
|
+
case ImagePos.MiddleLeft:
|
|
101
|
+
case ImagePos.BottomLeft:
|
|
102
|
+
b.ur.x = b.ll.x + iw;
|
|
103
|
+
break;
|
|
104
|
+
case ImagePos.TopRight:
|
|
105
|
+
case ImagePos.MiddleRight:
|
|
106
|
+
case ImagePos.BottomRight:
|
|
107
|
+
b.ll.x += pw - iw;
|
|
108
|
+
b.ur.x = b.ll.x + iw;
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
b.ll.x += (pw - iw) / 2.0;
|
|
112
|
+
b.ur.x -= (pw - iw) / 2.0;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Apply `imagepos` to the target box when the image is shorter than it. */
|
|
118
|
+
function positionY(b: Box, position: ImagePos, ih: number, ph: number): void {
|
|
119
|
+
if (!(ih < ph)) return;
|
|
120
|
+
switch (position) {
|
|
121
|
+
case ImagePos.TopLeft:
|
|
122
|
+
case ImagePos.TopCenter:
|
|
123
|
+
case ImagePos.TopRight:
|
|
124
|
+
b.ll.y = b.ur.y - ih;
|
|
125
|
+
break;
|
|
126
|
+
case ImagePos.BottomLeft:
|
|
127
|
+
case ImagePos.BottomCenter:
|
|
128
|
+
case ImagePos.BottomRight:
|
|
129
|
+
// Kept as C writes it: ll moves up by ih, ur lands on the old ll; the
|
|
130
|
+
// LL/UR swap below restores order.
|
|
131
|
+
b.ll.y += ih;
|
|
132
|
+
b.ur.y = b.ll.y - ih;
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
b.ll.y += (ph - ih) / 2.0;
|
|
136
|
+
b.ur.y -= (ph - ih) / 2.0;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Bounding box of the polygon `a` (expandbp over every vertex). */
|
|
142
|
+
function polygonBox(a: readonly Point[]): Box {
|
|
143
|
+
const first = a[0]!;
|
|
144
|
+
const b: Box = { ll: { x: first.x, y: first.y }, ur: { x: first.x, y: first.y } };
|
|
145
|
+
for (let i = 1; i < a.length; i++) {
|
|
146
|
+
const p = a[i]!;
|
|
147
|
+
if (p.x < b.ll.x) b.ll.x = p.x;
|
|
148
|
+
if (p.x > b.ur.x) b.ur.x = p.x;
|
|
149
|
+
if (p.y < b.ll.y) b.ll.y = p.y;
|
|
150
|
+
if (p.y > b.ur.y) b.ur.y = p.y;
|
|
151
|
+
}
|
|
152
|
+
return b;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The rendering context's image sizer (the port's gvusershape dictionary),
|
|
157
|
+
* set on the job by `render` beside `imageResolver`; undefined means the
|
|
158
|
+
* global `setImageSizer`.
|
|
159
|
+
*/
|
|
160
|
+
declare module './job.js' {
|
|
161
|
+
interface RenderJob {
|
|
162
|
+
imageSizer?: ImageSizer | undefined;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Scale the image `name` to the bounding box of polygon `a` per `imagescale`,
|
|
168
|
+
* place it per `imagepos`, convert to device coordinates unless the renderer
|
|
169
|
+
* transforms, and pass the box to the renderer's `usershape` (gvloadimage).
|
|
170
|
+
*
|
|
171
|
+
* `gvusershape_find` is "the caller supplies `name`" (sizer or resolver); the
|
|
172
|
+
* `find_user_shape` / `library_shape` branch is a no-op because no renderer
|
|
173
|
+
* has `library_shape`. `filled` is only read by loadimage plugins that paint a
|
|
174
|
+
* background (none of svg/xdot), so it is not forwarded.
|
|
175
|
+
*
|
|
176
|
+
* @see lib/gvc/gvrender.c:gvrender_usershape
|
|
177
|
+
*/
|
|
178
|
+
export function gvrenderUsershape(
|
|
179
|
+
job: RenderJob, name: string, a: readonly Point[], _filled: boolean,
|
|
180
|
+
imagescale: string, imagepos: string,
|
|
181
|
+
): void {
|
|
182
|
+
const sizer = job.imageSizer;
|
|
183
|
+
if (!imageIsSupplied(name, sizer, job.imageResolver)) return;
|
|
184
|
+
|
|
185
|
+
// gvusershape_size_dpi(us, job->dpi)
|
|
186
|
+
const isz = usershapeSizePts(name, job.dpi.x, sizer);
|
|
187
|
+
if (isz === null || (isz.x <= 0 && isz.y <= 0)) return;
|
|
188
|
+
|
|
189
|
+
const b = polygonBox(a);
|
|
190
|
+
const pw = b.ur.x - b.ll.x;
|
|
191
|
+
const ph = b.ur.y - b.ll.y;
|
|
192
|
+
const { iw, ih } = scaleImage(getImagescale(imagescale), { w: isz.x, h: isz.y }, pw, ph);
|
|
193
|
+
|
|
194
|
+
// if image is smaller in any dimension, apply the specified positioning
|
|
195
|
+
const position = getImagepos(imagepos);
|
|
196
|
+
positionX(b, position, iw, pw);
|
|
197
|
+
positionY(b, position, ih, ph);
|
|
198
|
+
|
|
199
|
+
// C converts graph to device coordinates here (gvrender_ptf) unless the
|
|
200
|
+
// renderer has GVRENDER_DOES_TRANSFORM. The port never sets that flag: its
|
|
201
|
+
// y-flip lives in transformPoint (devscale), applied by the callers of the
|
|
202
|
+
// primitives. Both renderers with a `usershape` (svg, xdot) are
|
|
203
|
+
// DOES_TRANSFORM in C and take graph coordinates (RendererPlugin.usershape
|
|
204
|
+
// contract), so the ptf branch is dead for every registered renderer.
|
|
205
|
+
|
|
206
|
+
if (b.ll.x > b.ur.x) [b.ll.x, b.ur.x] = [b.ur.x, b.ll.x];
|
|
207
|
+
if (b.ll.y > b.ur.y) [b.ll.y, b.ur.y] = [b.ur.y, b.ll.y];
|
|
208
|
+
job.renderer?.usershape?.(name, b, job);
|
|
209
|
+
}
|
package/src/gvc/usershape.ts
CHANGED
|
@@ -63,3 +63,43 @@ export function imageIsSupplied(name: string, sizer?: ImageSizer, resolver?: Ima
|
|
|
63
63
|
export function imageOpenWarning(name: string): string {
|
|
64
64
|
return `${STRERROR_ENOENT} while opening ${name}`;
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
/** @see lib/gvc/gvusershape.c:DEFAULT_DPI */
|
|
68
|
+
export const DEFAULT_DPI = 96;
|
|
69
|
+
/** @see lib/common/geom.h:POINTS_PER_INCH */
|
|
70
|
+
const POINTS_PER_INCH = 72;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The graph's `dpi` as `gvusershape_size` reads it: GD_drawing->dpi is
|
|
74
|
+
* late_double(dpi, resolution, 0) (input.c:705), and a value below 1 means
|
|
75
|
+
* the 96 default.
|
|
76
|
+
* @see lib/common/input.c:graph_init (dpi), lib/gvc/gvusershape.c:gvusershape_size
|
|
77
|
+
*/
|
|
78
|
+
export function usershapeDpi(attrs: ReadonlyMap<string, string>): number {
|
|
79
|
+
const lateDouble = (s: string | undefined, dflt: number): number => {
|
|
80
|
+
if (s === undefined || s === '') return dflt;
|
|
81
|
+
const v = Number(s);
|
|
82
|
+
return Number.isNaN(v) || s.trim() === '' ? dflt : Math.max(v, 0);
|
|
83
|
+
};
|
|
84
|
+
const dpi = lateDouble(attrs.get('dpi'), lateDouble(attrs.get('resolution'), 0));
|
|
85
|
+
return dpi >= 1 ? dpi : DEFAULT_DPI;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Image size in points: `gvusershape_size`. The caller's sizer reports pixels;
|
|
90
|
+
* the result is `(int)(px * 72 / dpi)` (the file's own dpi is unknown to a
|
|
91
|
+
* sizer, so `us->dpi` is 0 as for most formats). Null stands for C's (-1,-1):
|
|
92
|
+
* empty name or an image nobody supplies.
|
|
93
|
+
* @see lib/gvc/gvusershape.c:gvusershape_size, gvusershape_size_dpi
|
|
94
|
+
*/
|
|
95
|
+
export function usershapeSizePts(
|
|
96
|
+
name: string | undefined, dpi: number, sizer?: ImageSizer,
|
|
97
|
+
): { x: number; y: number } | null {
|
|
98
|
+
if (name === undefined || name === '') return null;
|
|
99
|
+
const px = sizer !== undefined ? sizer(name) : findImageSize(name);
|
|
100
|
+
if (px === null) return null;
|
|
101
|
+
return {
|
|
102
|
+
x: Math.trunc((px.w * POINTS_PER_INCH) / dpi),
|
|
103
|
+
y: Math.trunc((px.h * POINTS_PER_INCH) / dpi),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { Graph } from '../../model/graph.js';
|
|
21
|
+
import { gvCleanupEdgeLabels, gvCleanupNodeLabels } from '../dot/init.js';
|
|
21
22
|
import type { LayoutEngine } from '../../gvc/context.js';
|
|
22
23
|
import { circoInitGraph, freeNData } from './init.js';
|
|
23
24
|
import { circoLayout } from './circular.js';
|
|
@@ -72,6 +73,9 @@ export function circoLayoutFull(g: Graph): void {
|
|
|
72
73
|
|
|
73
74
|
/** @see lib/circogen/circularinit.c:circo_cleanup */
|
|
74
75
|
export function circoCleanup(g: Graph): void {
|
|
76
|
+
if (g.nodes.size === 0) return; // C: g is empty
|
|
77
|
+
for (const e of g.edges) gvCleanupEdgeLabels(e); // gv_cleanup_edge: per-node agfstout, all edges of root g
|
|
78
|
+
for (const n of g.nodes.values()) gvCleanupNodeLabels(n); // gv_cleanup_node
|
|
75
79
|
// Derived graph was stored in g.info.alg during circoLayout; clear it.
|
|
76
80
|
g.info.alg = undefined;
|
|
77
81
|
g.info.neato_nlist = undefined;
|
package/src/layout/dot/init.ts
CHANGED
|
@@ -275,6 +275,35 @@ export function removeFill(g: Graph): void {
|
|
|
275
275
|
// dotCleanup
|
|
276
276
|
// ---------------------------------------------------------------------------
|
|
277
277
|
|
|
278
|
+
/**
|
|
279
|
+
* The label frees shared by every engine's per-edge cleanup.
|
|
280
|
+
* @see lib/common/utils.c:gv_cleanup_edge
|
|
281
|
+
*/
|
|
282
|
+
export function gvCleanupEdgeLabels(e: Edge): void {
|
|
283
|
+
e.info.label = undefined;
|
|
284
|
+
e.info.xlabel = undefined;
|
|
285
|
+
e.info.head_label = undefined;
|
|
286
|
+
e.info.tail_label = undefined;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The label frees shared by every non-dot engine's per-node cleanup.
|
|
291
|
+
* @see lib/common/utils.c:gv_cleanup_node
|
|
292
|
+
*/
|
|
293
|
+
export function gvCleanupNodeLabels(n: Node): void {
|
|
294
|
+
n.info.label = undefined;
|
|
295
|
+
n.info.xlabel = undefined;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Frees non-root subgraph labels, recursing into every subgraph first.
|
|
300
|
+
* @see lib/dotgen/dotinit.c:dot_cleanup_graph
|
|
301
|
+
*/
|
|
302
|
+
function dotCleanupGraph(g: Graph): void {
|
|
303
|
+
for (const subg of g.subgraphs.values()) dotCleanupGraph(subg);
|
|
304
|
+
if (g !== g.root) g.info.label = undefined;
|
|
305
|
+
}
|
|
306
|
+
|
|
278
307
|
/**
|
|
279
308
|
* Clears all edge lists and linked-list pointers from nodes in the fast-graph,
|
|
280
309
|
* releasing layout state without destroying the underlying graph structure.
|
|
@@ -284,6 +313,9 @@ export function removeFill(g: Graph): void {
|
|
|
284
313
|
* @see lib/dotgen/dotinit.c:dot_cleanup
|
|
285
314
|
*/
|
|
286
315
|
export function dotCleanup(g: Graph): void {
|
|
316
|
+
for (const e of g.edges) gvCleanupEdgeLabels(e); // gv_cleanup_edge (all out-edges)
|
|
317
|
+
for (const n of g.nodes.values()) gvCleanupNodeLabels(n); // dot_cleanup_node
|
|
318
|
+
dotCleanupGraph(g);
|
|
287
319
|
let n: Node | undefined = g.info.nlist;
|
|
288
320
|
while (n !== undefined) {
|
|
289
321
|
const next: Node | undefined = n.info.next;
|
|
@@ -27,6 +27,7 @@ import { routeEdgeGroups } from './splines-groups.js';
|
|
|
27
27
|
import { placePortLabels, placeRegularEdgeLabels, setEdgeLabelPos } from './splines-label.js';
|
|
28
28
|
import { nodesInSeq } from './decomp.js';
|
|
29
29
|
import { agerrLineOn } from '../../common/agerr.js';
|
|
30
|
+
import { setState, GVSPLINES } from '../../common/layout-state.js';
|
|
30
31
|
|
|
31
32
|
// ---------------------------------------------------------------------------
|
|
32
33
|
// Edge-type flag constants
|
|
@@ -462,6 +463,7 @@ function orthoDispatch(g: Graph): number {
|
|
|
462
463
|
// are placed via place_portlabel for ortho too. Skipping this left the
|
|
463
464
|
// labels unset, so the xlabels pass placed them instead (144_ortho).
|
|
464
465
|
placePortLabels(g);
|
|
466
|
+
setState(GVSPLINES); // @see dotsplines.c:477 (reached via goto finish)
|
|
465
467
|
g.info.edgeLabelsDone = true;
|
|
466
468
|
return 0;
|
|
467
469
|
}
|
|
@@ -487,6 +489,7 @@ function finalizeSplines(g: Graph, et: number, normalize: boolean): void {
|
|
|
487
489
|
if (normalize) edgeNormalize(g);
|
|
488
490
|
if (et !== EDGETYPE_CURVED) routeDotEdges(g);
|
|
489
491
|
placePortLabels(g);
|
|
492
|
+
setState(GVSPLINES); // @see dotsplines.c:477
|
|
490
493
|
g.info.edgeLabelsDone = true; // @see dotsplines.c:471 (EdgeLabelsDone = 1)
|
|
491
494
|
}
|
|
492
495
|
|
package/src/layout/fdp/init.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import type { Graph } from '../../model/graph.js';
|
|
17
|
+
import { gvCleanupEdgeLabels, gvCleanupNodeLabels } from '../dot/init.js';
|
|
17
18
|
import type { Node } from '../../model/node.js';
|
|
18
19
|
import type { Edge } from '../../model/edge.js';
|
|
19
20
|
import { commonInitNodeEdge, lateDouble, layoutMeasurer } from '../../common/nodeinit.js';
|
|
@@ -99,12 +100,28 @@ export function fdpInitNodeEdge(g: Graph): void {
|
|
|
99
100
|
initialPositions(g);
|
|
100
101
|
}
|
|
101
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Frees each cluster label, recursively.
|
|
105
|
+
* @see lib/fdpgen/fdpinit.c:cleanup_subgs
|
|
106
|
+
*/
|
|
107
|
+
function fdpCleanupSubgs(g: Graph): void {
|
|
108
|
+
const nClust = g.info.n_cluster ?? 0;
|
|
109
|
+
for (let i = 1; i <= nClust; i++) {
|
|
110
|
+
const subg = g.info.clust![i - 1];
|
|
111
|
+
subg.info.label = undefined;
|
|
112
|
+
fdpCleanupSubgs(subg);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
102
116
|
/**
|
|
103
117
|
* Release fdp layout state (gv_cleanup analogue; the render pipeline
|
|
104
118
|
* runs before cleanup per the M2 ordering fix).
|
|
105
119
|
* @see lib/fdpgen/fdpinit.c:fdp_cleanup
|
|
106
120
|
*/
|
|
107
121
|
export function fdpCleanup(g: Graph): void {
|
|
122
|
+
for (const e of g.edges) gvCleanupEdgeLabels(e); // gv_cleanup_edge: per-node agfstout, all edges of root g
|
|
123
|
+
for (const n of g.nodes.values()) gvCleanupNodeLabels(n); // gv_cleanup_node
|
|
124
|
+
fdpCleanupSubgs(g);
|
|
108
125
|
for (const n of g.nodes.values()) {
|
|
109
126
|
n.info.alg = undefined;
|
|
110
127
|
n.info.pos = undefined;
|