@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
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import type {
|
|
11
11
|
HtmlCell,
|
|
12
12
|
HtmlCellContent,
|
|
13
|
-
HtmlImage,
|
|
14
13
|
HtmlLabel,
|
|
15
14
|
HtmlRow,
|
|
16
15
|
HtmlTable,
|
|
@@ -22,8 +21,9 @@ import type {
|
|
|
22
21
|
import { HtmlParseError } from './htmltable-types.js';
|
|
23
22
|
import { StderrLines } from './htmltable-attr-warn.js';
|
|
24
23
|
import type { ParseState } from './htmltable-parse-state.js';
|
|
25
|
-
import { consume, emitEof, emitWarnings, peek } from './htmltable-parse-state.js';
|
|
26
|
-
import { htmlErrorAtToken, tokenizeDeferred } from './htmltable-lex.js';
|
|
24
|
+
import { consume, consumedTag, emitEof, emitWarnings, peek } from './htmltable-parse-state.js';
|
|
25
|
+
import { HtmlLexError, htmlErrorAtToken, tokenizeDeferred } from './htmltable-lex.js';
|
|
26
|
+
import { scanCellImage } from './htmltable-parse-image.js';
|
|
27
27
|
import type { FontState } from './htmltable-parse-font.js';
|
|
28
28
|
import {
|
|
29
29
|
fontItemProps, inlineFontState, isInlineTag, mergeFontState, tableFont, wrapperFont,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from './htmltable-parse-attrs.js';
|
|
39
39
|
|
|
40
40
|
/** bison's default message for an unexpected token. @see lib/common/htmlparse.y */
|
|
41
|
-
const MSG_SYNTAX_ERROR = 'syntax error';
|
|
41
|
+
export const MSG_SYNTAX_ERROR = 'syntax error';
|
|
42
42
|
/** @see lib/common/htmlparse.y:288 (table rule) */
|
|
43
43
|
const MSG_TEXT_BEFORE_TABLE = 'Syntax error: non-space string used before <TABLE>';
|
|
44
44
|
/** @see lib/common/htmlparse.y:298 (table rule) */
|
|
@@ -50,17 +50,25 @@ const nonSpace = (text: string): boolean => /[^ ]/.test(text);
|
|
|
50
50
|
/** Text in `ctx->xb` that no token carried, which the table rule's nonSpace also reads. */
|
|
51
51
|
const heldNonSpace = (tbl: Token | undefined): boolean => tbl?.type === 'open' && nonSpace(tbl.heldText ?? '');
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* `e` as C prints it once `ctx->error` is set: htmlerror and the expat path
|
|
55
|
+
* print nothing more (a silent HtmlParseError); only lexerror still does.
|
|
56
|
+
* @see lib/common/htmllex.c:htmlerror
|
|
57
|
+
*/
|
|
58
|
+
const guarded = (s: ParseState, e: HtmlParseError): HtmlParseError =>
|
|
59
|
+
s.error === true && !(e instanceof HtmlLexError && e.unguarded) ? new HtmlParseError(e.tag) : e;
|
|
60
|
+
|
|
53
61
|
/**
|
|
54
62
|
* The parse failure C reports through `htmlerror` when the lexer last returned
|
|
55
63
|
* `tok`. At end of input the deferred lexical error is what C would hit next.
|
|
56
64
|
* A token without a recorded chunk yields a plain, silent HtmlParseError.
|
|
57
65
|
* @see lib/common/htmllex.c:htmlerror
|
|
58
66
|
*/
|
|
59
|
-
const parseError = (s: ParseState, tok: Token | undefined, message: string): HtmlParseError => {
|
|
67
|
+
export const parseError = (s: ParseState, tok: Token | undefined, message: string): HtmlParseError => {
|
|
60
68
|
// The lexer already ran for the token the error is reported at.
|
|
61
69
|
if (tok !== undefined) emitWarnings(s, tok);
|
|
62
70
|
else emitEof(s);
|
|
63
|
-
return (tok === undefined ? s.pending : htmlErrorAtToken(message, tok)) ?? new HtmlParseError(message);
|
|
71
|
+
return guarded(s, (tok === undefined ? s.pending : htmlErrorAtToken(message, tok)) ?? new HtmlParseError(message));
|
|
64
72
|
};
|
|
65
73
|
|
|
66
74
|
// ---------------------------------------------------------------------------
|
|
@@ -73,7 +81,7 @@ const parseError = (s: ParseState, tok: Token | undefined, message: string): Htm
|
|
|
73
81
|
* syntax error at that token.
|
|
74
82
|
* @see lib/common/htmlparse.y:br, image
|
|
75
83
|
*/
|
|
76
|
-
const consumeClose = (s: ParseState, tag: string): void => {
|
|
84
|
+
export const consumeClose = (s: ParseState, tag: string): void => {
|
|
77
85
|
const nxt = peek(s);
|
|
78
86
|
if (nxt === undefined) return;
|
|
79
87
|
if (nxt.type === 'close' && nxt.tag === tag) {
|
|
@@ -172,7 +180,7 @@ const fontTableWrapper = (s: ParseState): OpenToken | undefined => {
|
|
|
172
180
|
};
|
|
173
181
|
|
|
174
182
|
/** Consume strings; true when any is non-space (the table rule's nonSpace check). */
|
|
175
|
-
const skipStrings = (s: ParseState): boolean => {
|
|
183
|
+
export const skipStrings = (s: ParseState): boolean => {
|
|
176
184
|
let found = false;
|
|
177
185
|
for (let t = peek(s); t?.type === 'text'; t = peek(s)) {
|
|
178
186
|
consume(s);
|
|
@@ -210,29 +218,18 @@ const parseFontTable = (s: ParseState, open: OpenToken, fontStack: FontState[]):
|
|
|
210
218
|
const rejectTableAfterTag = (s: ParseState, start: number): void => {
|
|
211
219
|
const nxt = peek(s);
|
|
212
220
|
if (nxt?.type !== 'open' || nxt.tag !== 'TABLE') return;
|
|
213
|
-
if (s
|
|
214
|
-
throw parseError(s, nxt, MSG_SYNTAX_ERROR);
|
|
215
|
-
}
|
|
221
|
+
if (consumedTag(s, start)) throw parseError(s, nxt, MSG_SYNTAX_ERROR);
|
|
216
222
|
};
|
|
217
223
|
|
|
218
224
|
// ---------------------------------------------------------------------------
|
|
219
225
|
// Cell content helpers — mirrors htmlparse.y cell rule
|
|
220
226
|
// ---------------------------------------------------------------------------
|
|
221
227
|
|
|
222
|
-
const parseImgContent = (s: ParseState, t: OpenToken): HtmlImage => {
|
|
223
|
-
consume(s);
|
|
224
|
-
const img: HtmlImage = {
|
|
225
|
-
kind: 'image',
|
|
226
|
-
src: t.attrs['src'] ?? '',
|
|
227
|
-
scale: t.attrs['scale'],
|
|
228
|
-
};
|
|
229
|
-
consumeClose(s, 'IMG');
|
|
230
|
-
return img;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
228
|
/** What a cell holds so far: C's cell has exactly one child. */
|
|
234
|
-
interface CellScan {
|
|
229
|
+
export interface CellScan {
|
|
235
230
|
kind: 'none' | 'text' | 'table' | 'fonttable' | 'image';
|
|
231
|
+
/** Index of the cell's first token. */
|
|
232
|
+
start: number;
|
|
236
233
|
/** Non-space text before the nested table (checked when the table opens). */
|
|
237
234
|
textNonSpace: boolean;
|
|
238
235
|
/** Non-space text after the nested table (checked when the run ends). */
|
|
@@ -243,7 +240,6 @@ interface CellScan {
|
|
|
243
240
|
const scanCellTable = (
|
|
244
241
|
s: ParseState, t: Token, fontStack: FontState[], st: CellScan,
|
|
245
242
|
): HtmlCellContent[] => {
|
|
246
|
-
if (st.kind === 'image' || st.kind === 'table') throw parseError(s, t, MSG_SYNTAX_ERROR);
|
|
247
243
|
if (st.textNonSpace || heldNonSpace(t)) throw parseError(s, t, MSG_TEXT_BEFORE_TABLE);
|
|
248
244
|
const tbl = parseTable(s, fontStack);
|
|
249
245
|
st.kind = 'table';
|
|
@@ -269,18 +265,12 @@ const scanAfterTable = (s: ParseState, t: Token, st: CellScan): HtmlCellContent[
|
|
|
269
265
|
return [];
|
|
270
266
|
};
|
|
271
267
|
|
|
272
|
-
/** `image` as the cell's only child. */
|
|
273
|
-
const scanCellImage = (s: ParseState, t: OpenToken, st: CellScan): HtmlCellContent[] => {
|
|
274
|
-
if (st.kind !== 'none') throw parseError(s, t, MSG_SYNTAX_ERROR);
|
|
275
|
-
st.kind = 'image';
|
|
276
|
-
return [parseImgContent(s, t)];
|
|
277
|
-
};
|
|
278
|
-
|
|
279
268
|
/** One step of `cell: T_cell (fonttable | fonttext | image) T_end_cell`. */
|
|
280
269
|
const scanCellItem = (
|
|
281
270
|
s: ParseState, t: Token, fontStack: FontState[], st: CellScan,
|
|
282
271
|
): HtmlCellContent[] => {
|
|
283
|
-
|
|
272
|
+
// After an image only the cell's close may come: its opt_space took the strings.
|
|
273
|
+
if (st.kind === 'fonttable' || st.kind === 'image') throw parseError(s, t, MSG_SYNTAX_ERROR);
|
|
284
274
|
if (st.kind === 'table') return scanAfterTable(s, t, st);
|
|
285
275
|
const wrapper = st.kind === 'none' ? fontTableWrapper(s) : undefined;
|
|
286
276
|
if (wrapper !== undefined) {
|
|
@@ -289,7 +279,6 @@ const scanCellItem = (
|
|
|
289
279
|
}
|
|
290
280
|
if (t.type === 'open' && t.tag === 'TABLE') return scanCellTable(s, t, fontStack, st);
|
|
291
281
|
if (t.type === 'open' && t.tag === 'IMG') return scanCellImage(s, t, st);
|
|
292
|
-
if (st.kind === 'image') throw parseError(s, t, MSG_SYNTAX_ERROR);
|
|
293
282
|
return scanCellText(s, t, fontStack, st);
|
|
294
283
|
};
|
|
295
284
|
|
|
@@ -303,19 +292,18 @@ const endsCell = (s: ParseState, t: Token, st: CellScan): boolean => {
|
|
|
303
292
|
|
|
304
293
|
const parseCellContent = (s: ParseState, fontStack: FontState[]): HtmlCellContent[] => {
|
|
305
294
|
const content: HtmlCellContent[] = [];
|
|
306
|
-
const st: CellScan = { kind: 'none', textNonSpace: false, afterNonSpace: false };
|
|
295
|
+
const st: CellScan = { kind: 'none', start: s.pos, textNonSpace: false, afterNonSpace: false };
|
|
307
296
|
for (let t = peek(s); t !== undefined; t = peek(s)) {
|
|
308
297
|
if (endsCell(s, t, st)) break;
|
|
309
298
|
content.push(...scanCellItem(s, t, fontStack, st));
|
|
310
299
|
}
|
|
311
300
|
const nxt = peek(s);
|
|
312
301
|
if (nxt?.type === 'close' && nxt.tag === 'TD') consume(s);
|
|
313
|
-
// C models a cell child as a single object; the
|
|
314
|
-
//
|
|
315
|
-
// @see lib/common/htmltable.h:htmlcell_t.child
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
return content;
|
|
302
|
+
// C models a cell child as a single object; the table and image rules take
|
|
303
|
+
// the strings around them (opt_space), so a table or image IS the cell's
|
|
304
|
+
// sole content. @see lib/common/htmltable.h:htmlcell_t.child
|
|
305
|
+
const sole = content.find((c) => c.kind === 'table' || c.kind === 'image');
|
|
306
|
+
return sole !== undefined ? [sole] : content;
|
|
319
307
|
};
|
|
320
308
|
|
|
321
309
|
/** @see lib/common/htmlparse.y:cell rule / lib/common/htmllex.c:mkCell */
|
|
@@ -547,10 +535,12 @@ const parseTokens = (s: ParseState): HtmlLabel => {
|
|
|
547
535
|
return parseTextLabel(s, fontStack);
|
|
548
536
|
};
|
|
549
537
|
|
|
550
|
-
/** A parsed label and `ctx->
|
|
538
|
+
/** A parsed label with `ctx->warn` and `ctx->error`, from which `clearHTMLlexer` makes parseHTML's rv. */
|
|
551
539
|
export interface ParsedHtmlLabel {
|
|
552
540
|
label: HtmlLabel;
|
|
553
541
|
warn: boolean;
|
|
542
|
+
/** htmlerror printed but the parse went on: rv 3 with a label. */
|
|
543
|
+
error: boolean;
|
|
554
544
|
}
|
|
555
545
|
|
|
556
546
|
/**
|
|
@@ -566,11 +556,11 @@ export const parseHtmlLabelRv = (src: string, stderr: StderrLines): ParsedHtmlLa
|
|
|
566
556
|
const s: ParseState = { tokens, pos: 0, pending: error, stderr, emitted: new WeakSet(), warn: false, eof };
|
|
567
557
|
try {
|
|
568
558
|
const label = parseTokens(s);
|
|
569
|
-
if (error !== undefined) throw error;
|
|
570
|
-
return { label, warn: s.warn === true };
|
|
559
|
+
if (error !== undefined) throw guarded(s, error);
|
|
560
|
+
return { label, warn: s.warn === true, error: s.error === true };
|
|
571
561
|
} catch (e) {
|
|
572
562
|
// Running off the truncated stream means C's lexer would have hit the error.
|
|
573
|
-
if (error !== undefined && s.pos >= tokens.length) { emitEof(s); throw error; }
|
|
563
|
+
if (error !== undefined && s.pos >= tokens.length) { emitEof(s); throw guarded(s, error); }
|
|
574
564
|
throw e;
|
|
575
565
|
}
|
|
576
566
|
};
|
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
|
}
|
|
@@ -20,6 +20,7 @@ import type { PolygonT } from './types.js';
|
|
|
20
20
|
import type { InsideContext } from './splines-geom.js';
|
|
21
21
|
import { polygonOutlineRing } from './poly-sizing.js';
|
|
22
22
|
import { ccwrotatepf } from '../model/geom.js';
|
|
23
|
+
import { fdivOverflow } from '../util/overflow.js';
|
|
23
24
|
|
|
24
25
|
/** Test if p0 and p1 are on the same side of the line L0-L1. @see shapes.c:same_side */
|
|
25
26
|
export function sameSide(p0: Point, p1: Point, L0: Point, L1: Point): boolean {
|
|
@@ -60,7 +61,12 @@ function insideDims(n: Node, xsize: number, ysize: number):
|
|
|
60
61
|
return { w, h, ow: 72 * n.info.outline_width || w, oh: 72 * n.info.outline_height || h };
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* C assigns `scalex = n_width` and then lets `fdiv_overflow` overwrite it
|
|
66
|
+
* with `n_width / xsize` when that quotient is finite (likewise `scaley`):
|
|
67
|
+
* `fdivOverflow(w, xsize) ?? w`.
|
|
68
|
+
* @see lib/common/shapes.c:poly_inside (scale setup, 2465-2469)
|
|
69
|
+
*/
|
|
64
70
|
function insideScale(n: Node, poly: PolygonT): InsideScale {
|
|
65
71
|
// C swaps the node extents for flipped (LR/RL) layouts. @see poly_inside (GD_flip)
|
|
66
72
|
const flip = n.root.info.flip === true;
|
|
@@ -74,8 +80,8 @@ function insideScale(n: Node, poly: PolygonT): InsideScale {
|
|
|
74
80
|
const xsize = flip ? h : w;
|
|
75
81
|
const ysize = flip ? w : h;
|
|
76
82
|
return {
|
|
77
|
-
scalex:
|
|
78
|
-
scaley:
|
|
83
|
+
scalex: fdivOverflow(w, xsize) ?? w,
|
|
84
|
+
scaley: fdivOverflow(h, ysize) ?? h,
|
|
79
85
|
boxURx: w / 2,
|
|
80
86
|
boxURy: h / 2,
|
|
81
87
|
};
|
|
@@ -85,8 +91,8 @@ function insideScale(n: Node, poly: PolygonT): InsideScale {
|
|
|
85
91
|
const ysize = flip ? lwrw : n.info.ht;
|
|
86
92
|
const { w, h, ow, oh } = insideDims(n, xsize, ysize);
|
|
87
93
|
return {
|
|
88
|
-
scalex:
|
|
89
|
-
scaley:
|
|
94
|
+
scalex: fdivOverflow(w, xsize) ?? w,
|
|
95
|
+
scaley: fdivOverflow(h, ysize) ?? h,
|
|
90
96
|
boxURx: ow / 2,
|
|
91
97
|
boxURy: oh / 2,
|
|
92
98
|
};
|
|
@@ -91,21 +91,39 @@ function expandByPoints(bb: Box, cp: Point[]): void {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @see lib/common/emit.c:update_bb_bz
|
|
94
|
+
* How many times update_bb_bz attempts refinement of the control points.
|
|
95
|
+
* @see lib/common/emit.c:update_bb_bz (ATTEMPTS)
|
|
97
96
|
*/
|
|
98
|
-
|
|
97
|
+
const UPDATE_BB_BZ_ATTEMPTS = 10;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Expands bb by the segment cp, halving it until it is sufficiently refined.
|
|
101
|
+
* A segment still unrefined when `recurse` reaches 0 leaves bb as it is
|
|
102
|
+
* (graphviz 16.1.1, upstream issue 2780: huge coordinates never refine).
|
|
103
|
+
* @see lib/common/emit.c:update_bb_bz_core
|
|
104
|
+
*/
|
|
105
|
+
function updateBbBzCore(bb: Box, cp: Point[], recurse: number): void {
|
|
99
106
|
if (!anyOutside(bb, cp)) return;
|
|
100
107
|
if (checkControlPoints(cp)) {
|
|
101
108
|
expandByPoints(bb, cp);
|
|
102
109
|
return;
|
|
103
110
|
}
|
|
111
|
+
if (recurse === 0) return;
|
|
104
112
|
const left: Point[] = [];
|
|
105
113
|
const right: Point[] = [];
|
|
106
114
|
evalBezier(cp, 0.5, left, right);
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
updateBbBzCore(bb, left, recurse - 1);
|
|
116
|
+
updateBbBzCore(bb, right, recurse - 1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Expands bb to contain the cubic Bezier segment cp by adaptively refining the
|
|
121
|
+
* segment to its true curve extent (not the control hull). Refinement stops
|
|
122
|
+
* after UPDATE_BB_BZ_ATTEMPTS levels (upstream issue 2780).
|
|
123
|
+
* @see lib/common/emit.c:update_bb_bz
|
|
124
|
+
*/
|
|
125
|
+
export function updateBbBz(bb: Box, cp: Point[]): void {
|
|
126
|
+
updateBbBzCore(bb, cp, UPDATE_BB_BZ_ATTEMPTS);
|
|
109
127
|
}
|
|
110
128
|
|
|
111
129
|
// ---------------------------------------------------------------------------
|
|
@@ -16,6 +16,7 @@ import type { Poly } from '../pathplan/types.js';
|
|
|
16
16
|
import { INIT_DELTA, LOOP_TRIES, ROUTESPL_FUDGE } from './splines-constants.js';
|
|
17
17
|
import { fma } from './fma.js';
|
|
18
18
|
import { agerrorf } from './agerr.js';
|
|
19
|
+
import { gfmt5 } from '../render/dot/xdot-ops.js';
|
|
19
20
|
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
21
22
|
// Stage-dump hook (diagnosis only; null in production — same pattern as
|
|
@@ -158,15 +159,46 @@ function clampPoint(p: Point, box: Box): void {
|
|
|
158
159
|
// checkPath
|
|
159
160
|
// ---------------------------------------------------------------------------
|
|
160
161
|
|
|
162
|
+
/** One port line of printpath: `(%.5g, %.5g), tangent angle: %.5g, %s`. */
|
|
163
|
+
function portText(port: Path['start']): string {
|
|
164
|
+
const constrained = port.constrained ? 'constrained' : 'not constrained';
|
|
165
|
+
return `(${gfmt5(port.p.x)}, ${gfmt5(port.p.y)}), tangent angle: ${gfmt5(port.theta)}, ${constrained}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Dump a path: its box count, each box, and both ports. C writes these with
|
|
170
|
+
* plain `fprintf(stderr)`, not agerr, so they go straight to `console.error`
|
|
171
|
+
* (the channel of the `Error:` line checkpath prints just before them) and a
|
|
172
|
+
* caller-set `agseterrf` function does not receive them.
|
|
173
|
+
* @see lib/common/routespl.c:printpath
|
|
174
|
+
*/
|
|
175
|
+
function printPath(pp: Path): void {
|
|
176
|
+
console.error(`${pp.nbox} boxes:`);
|
|
177
|
+
for (let bi = 0; bi < pp.nbox; bi++) {
|
|
178
|
+
const { ll, ur } = pp.boxes[bi];
|
|
179
|
+
console.error(`${bi} (${gfmt5(ll.x)}, ${gfmt5(ll.y)}), (${gfmt5(ur.x)}, ${gfmt5(ur.y)})`);
|
|
180
|
+
}
|
|
181
|
+
console.error(`start port: ${portText(pp.start)}`);
|
|
182
|
+
console.error(`end port: ${portText(pp.end)}`);
|
|
183
|
+
}
|
|
184
|
+
|
|
161
185
|
/**
|
|
162
186
|
* Repairs minor errors in the box path (gaps, slight overlaps).
|
|
163
187
|
* Returns true on hard failure; false on success.
|
|
164
188
|
* Mutates boxes[] and pp in place.
|
|
165
189
|
*
|
|
190
|
+
* A path with no box left after the degenerate-box filter is a hard failure
|
|
191
|
+
* that reports the path (graphviz 16.1.1, upstream 2773, 2774, 2776, 2778).
|
|
192
|
+
*
|
|
166
193
|
* @see lib/common/routespl.c:checkpath
|
|
167
194
|
*/
|
|
168
195
|
export function checkPath(boxn: number, boxes: Box[], pp: Path): boolean {
|
|
169
196
|
const bn = removeDegenerateBoxes(boxes, boxn);
|
|
197
|
+
if (bn === 0) {
|
|
198
|
+
agerrorf('in checkpath, all bounding boxes are below threshold');
|
|
199
|
+
printPath(pp);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
170
202
|
if (boxes[0].ll.x > boxes[0].ur.x || boxes[0].ll.y > boxes[0].ur.y) return true;
|
|
171
203
|
|
|
172
204
|
for (let bi = 0; bi + 1 < bn; bi++) {
|
|
@@ -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
|
/**
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
graph 1 6.
|
|
2
|
-
node a
|
|
3
|
-
node b
|
|
4
|
-
node e
|
|
5
|
-
node c 1.
|
|
6
|
-
node d 1.
|
|
7
|
-
node p
|
|
8
|
-
node q
|
|
9
|
-
node r
|
|
10
|
-
node s
|
|
11
|
-
edge a a 7
|
|
12
|
-
edge a b
|
|
13
|
-
edge a e
|
|
14
|
-
edge a c 4
|
|
15
|
-
edge b c 4
|
|
16
|
-
edge c d 4 1.
|
|
17
|
-
edge p q
|
|
18
|
-
edge p r
|
|
19
|
-
edge p s 4
|
|
1
|
+
graph 1 6.8472 3.9
|
|
2
|
+
node a 2.4722 2.9167 0.75 0.5 a solid ellipse black lightgrey
|
|
3
|
+
node b 1.375 2.9167 0.75 0.5 b solid ellipse black lightgrey
|
|
4
|
+
node e 0.375 2.9167 0.75 0.5 e solid ellipse black lightgrey
|
|
5
|
+
node c 1.9167 1.9167 0.75 0.5 c solid ellipse black lightgrey
|
|
6
|
+
node d 1.9167 0.91667 0.75 0.5 d solid ellipse black lightgrey
|
|
7
|
+
node p 6.4722 1.25 0.75 0.5 p solid ellipse black lightgrey
|
|
8
|
+
node q 5.375 1.25 0.75 0.5 q solid ellipse black lightgrey
|
|
9
|
+
node r 4.375 1.25 0.75 0.5 r solid ellipse black lightgrey
|
|
10
|
+
node s 6.4722 0.25 0.75 0.5 s solid ellipse black lightgrey
|
|
11
|
+
edge a a 7 2.7745 3.0714 2.9425 3.1003 3.0972 3.0487 3.0972 2.9167 3.0972 2.828 3.0274 2.7756 2.9306 2.7595 solid black
|
|
12
|
+
edge a b 4 2.0939 2.9167 2.0353 2.9167 1.9738 2.9167 1.9124 2.9167 x 1.9236 3.075 solid black
|
|
13
|
+
edge a e 7 2.2964 3.1413 2.1207 3.3457 1.8304 3.6335 1.503 3.7556 1.1535 3.8858 0.81939 3.5617 0.60677 3.2792 zz 1.4167 3.7833 solid black
|
|
14
|
+
edge a c 4 2.3434 2.6773 2.2782 2.5632 2.1974 2.4218 2.1238 2.293 y 0.36111 0.66667 solid black
|
|
15
|
+
edge b c 4 1.5006 2.6773 1.5642 2.5632 1.6429 2.4218 1.7148 2.293 solid black
|
|
16
|
+
edge c d 4 1.9167 1.6625 1.9167 1.5612 1.9167 1.4406 1.9167 1.3269 solid black
|
|
17
|
+
edge p q 4 6.0939 1.25 6.0353 1.25 5.9738 1.25 5.9124 1.25 k 5.9236 1.4083 solid black
|
|
18
|
+
edge p r 7 6.2939 1.4747 6.1159 1.6791 5.8221 1.967 5.4923 2.0889 5.1466 2.2166 4.8177 1.8973 4.6074 1.6165 m 5.4167 2.1167 solid black
|
|
19
|
+
edge p s 4 6.4722 0.99579 6.4722 0.89454 6.4722 0.77398 6.4722 0.66022 solid black
|
|
20
20
|
stop
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
graph 1
|
|
2
|
-
node a
|
|
3
|
-
node b
|
|
4
|
-
node e
|
|
5
|
-
node c
|
|
6
|
-
node d
|
|
7
|
-
node p
|
|
8
|
-
node q
|
|
9
|
-
node r
|
|
10
|
-
node s
|
|
11
|
-
edge a a 14 8.
|
|
12
|
-
edge a b
|
|
13
|
-
edge a e
|
|
14
|
-
edge a c 11
|
|
15
|
-
edge b c 8
|
|
16
|
-
edge c d 8
|
|
17
|
-
edge p q
|
|
18
|
-
edge p r
|
|
19
|
-
edge p s
|
|
1
|
+
graph 1 10.444 7.2886
|
|
2
|
+
node a 9.8194 3.6528 0.75 0.5 a solid ellipse black lightgrey
|
|
3
|
+
node b 8.7222 3.6528 0.75 0.5 b solid ellipse black lightgrey
|
|
4
|
+
node e 5.7222 3.6528 0.75 0.5 e solid ellipse black lightgrey
|
|
5
|
+
node c 7.7222 3.6528 0.75 0.5 c solid ellipse black lightgrey
|
|
6
|
+
node d 6.7222 3.6528 0.75 0.5 d solid ellipse black lightgrey
|
|
7
|
+
node p 3.4722 0.25 0.75 0.5 p solid ellipse black lightgrey
|
|
8
|
+
node q 2.375 0.25 0.75 0.5 q solid ellipse black lightgrey
|
|
9
|
+
node r 1.375 0.25 0.75 0.5 r solid ellipse black lightgrey
|
|
10
|
+
node s 0.375 0.25 0.75 0.5 s solid ellipse black lightgrey
|
|
11
|
+
edge a a 14 8.4828 6.4742 8.6508 6.5031 8.8056 6.4515 8.8056 6.3194 8.8056 6.2307 8.7357 6.1783 8.6389 6.1623 10.173 3.7457 10.32 3.7521 10.444 3.7211 10.444 3.6528 10.444 3.6111 10.398 3.5833 10.329 3.5695 solid black
|
|
12
|
+
edge a b 8 9.4411 3.6528 9.3825 3.6528 9.321 3.6528 9.2596 3.6528 7.6208 6.3194 7.6821 6.3194 7.7436 6.3194 7.8023 6.3194 x 9.2708 3.8111 solid black
|
|
13
|
+
edge a e 17 9.6983 3.895 9.5826 4.0965 9.3874 4.3693 9.128 4.4917 8.5321 4.7727 6.8438 4.1212 6.2222 3.9028 6.2005 3.8951 6.1785 3.8868 6.1564 3.8779 6.3151 6.682 6.5277 6.9645 6.8619 7.2886 7.2113 7.1583 7.5387 7.0363 7.8291 6.7484 8.0047 6.544 zz 9.0417 4.5194 solid black
|
|
14
|
+
edge a c 11 9.6172 3.8703 9.4101 4.0756 9.0674 4.3696 8.7014 4.4917 8.3867 4.5966 8.1083 4.299 7.9296 4.0297 7.8321 5.6957 7.9057 5.8246 7.9865 5.9659 8.0517 6.0801 y 8.6528 4.5194 solid black
|
|
15
|
+
edge b c 8 8.3437 3.6528 8.3159 3.6528 8.2881 3.6528 8.2603 3.6528 7.4231 5.6957 7.3513 5.8246 7.2725 5.9659 7.209 6.0801 solid black
|
|
16
|
+
edge c d 8 7.3437 3.6528 7.3159 3.6528 7.2881 3.6528 7.2603 3.6528 7.625 4.7297 7.625 4.8434 7.625 4.964 7.625 5.0652 solid black
|
|
17
|
+
edge p q 8 3.0939 0.25 3.0353 0.25 2.9738 0.25 2.9124 0.25 6.2874 1.25 6.3488 1.25 6.4103 1.25 6.4689 1.25 k 2.9236 0.40833 solid black
|
|
18
|
+
edge p r 14 3.2939 0.47465 3.1159 0.6791 2.8221 0.967 2.4923 1.0889 2.1466 1.2166 1.8177 0.89726 1.6074 0.61649 4.9824 1.6165 5.1927 1.8973 5.5216 2.2166 5.8673 2.0889 6.1971 1.967 6.4909 1.6791 6.6689 1.4747 m 2.4167 1.1167 solid black
|
|
19
|
+
edge p s 14 3.2509 0.45635 3.1169 0.5668 2.9363 0.6918 2.75 0.75 2.0076 0.98191 1.7339 1.0074 1 0.75 0.88822 0.71079 0.78157 0.64225 0.68904 0.56825 6.8472 0.66022 6.8472 0.77398 6.8472 0.89454 6.8472 0.99579 solid black
|
|
20
20
|
stop
|