@antv/g6 5.0.0-beta.26 → 5.0.0-beta.27
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/g6.min.js +2 -2
- package/esm/constant/shape.d.ts +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.d.ts +6 -4
- package/esm/item/combo.js +10 -3
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +12 -4
- package/esm/item/edge.js +100 -17
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +18 -8
- package/esm/item/item.js +103 -59
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +10 -4
- package/esm/item/node.js +92 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +5 -1
- package/esm/runtime/controller/data.js +38 -1
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/index.d.ts +1 -1
- package/esm/runtime/controller/index.js +1 -1
- package/esm/runtime/controller/index.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +22 -11
- package/esm/runtime/controller/item.js +241 -96
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.d.ts +3 -0
- package/esm/runtime/controller/layout.js +178 -98
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.d.ts +3 -0
- package/esm/runtime/controller/plugin.js +66 -24
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/controller/viewport.js +9 -2
- package/esm/runtime/controller/viewport.js.map +1 -1
- package/esm/runtime/graph.d.ts +57 -26
- package/esm/runtime/graph.js +263 -139
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +9 -3
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +6 -3
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.js +8 -8
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +4 -0
- package/esm/stdlib/behavior/drag-node.js +121 -27
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.js +3 -3
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +3 -3
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/validateData.js +2 -2
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +2 -0
- package/esm/stdlib/index.js +3 -1
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +2 -11
- package/esm/stdlib/item/edge/base.js +12 -105
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +2 -20
- package/esm/stdlib/item/node/base.js +10 -150
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/esm/stdlib/plugin/fisheye/index.js +3 -2
- package/esm/stdlib/plugin/fisheye/index.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/hull/index.d.ts +1 -1
- package/esm/stdlib/plugin/index.d.ts +1 -0
- package/esm/stdlib/plugin/index.js +1 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/lodController/index.d.ts +73 -0
- package/esm/stdlib/plugin/lodController/index.js +556 -0
- package/esm/stdlib/plugin/lodController/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.js +12 -14
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/esm/stdlib/plugin/toolbar/index.js +27 -29
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/theme/dark.js +32 -35
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +27 -30
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/stdlib/themeSolver/spec.js +2 -2
- package/esm/stdlib/themeSolver/spec.js.map +1 -1
- package/esm/types/animate.d.ts +1 -1
- package/esm/types/combo.d.ts +2 -2
- package/esm/types/edge.d.ts +2 -2
- package/esm/types/graph.d.ts +62 -43
- package/esm/types/hook.d.ts +5 -0
- package/esm/types/item.d.ts +9 -15
- package/esm/types/layout.d.ts +7 -2
- package/esm/types/layout.js.map +1 -1
- package/esm/types/node.d.ts +3 -2
- package/esm/types/plugin.d.ts +1 -0
- package/esm/types/plugin.js +1 -0
- package/esm/types/plugin.js.map +1 -1
- package/esm/types/spec.d.ts +1 -0
- package/esm/types/theme.d.ts +7 -7
- package/esm/util/animate.d.ts +7 -2
- package/esm/util/animate.js +37 -23
- package/esm/util/animate.js.map +1 -1
- package/esm/util/bbox.d.ts +7 -1
- package/esm/util/bbox.js +16 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/data.d.ts +7 -1
- package/esm/util/data.js +17 -5
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.js +5 -5
- package/esm/util/dom.js.map +1 -1
- package/esm/util/item.d.ts +1 -1
- package/esm/util/item.js +8 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/mapper.js +1 -1
- package/esm/util/mapper.js.map +1 -1
- package/esm/util/path.d.ts +6 -1
- package/esm/util/path.js +72 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/polyline.d.ts +10 -0
- package/esm/util/polyline.js +22 -17
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/router.js +19 -18
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +1 -1
- package/esm/util/shape.js +28 -13
- package/esm/util/shape.js.map +1 -1
- package/esm/util/zoom.d.ts +5 -8
- package/esm/util/zoom.js +15 -20
- package/esm/util/zoom.js.map +1 -1
- package/lib/constant/shape.d.ts +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.d.ts +6 -4
- package/lib/item/combo.js +10 -3
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +12 -4
- package/lib/item/edge.js +99 -16
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +18 -8
- package/lib/item/item.js +101 -57
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +10 -4
- package/lib/item/node.js +92 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +5 -1
- package/lib/runtime/controller/data.js +38 -1
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/index.d.ts +1 -1
- package/lib/runtime/controller/index.js +1 -1
- package/lib/runtime/controller/index.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +22 -11
- package/lib/runtime/controller/item.js +238 -93
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.d.ts +3 -0
- package/lib/runtime/controller/layout.js +178 -98
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.d.ts +3 -0
- package/lib/runtime/controller/plugin.js +66 -24
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/controller/viewport.js +9 -2
- package/lib/runtime/controller/viewport.js.map +1 -1
- package/lib/runtime/graph.d.ts +57 -26
- package/lib/runtime/graph.js +263 -139
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +9 -3
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +6 -3
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.js +8 -8
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +4 -0
- package/lib/stdlib/behavior/drag-node.js +121 -27
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.js +3 -3
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +3 -3
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/validateData.js +2 -2
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +2 -0
- package/lib/stdlib/index.js +3 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +2 -11
- package/lib/stdlib/item/edge/base.js +12 -105
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +2 -20
- package/lib/stdlib/item/node/base.js +10 -150
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/lib/stdlib/plugin/fisheye/index.js +2 -1
- package/lib/stdlib/plugin/fisheye/index.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/hull/index.d.ts +1 -1
- package/lib/stdlib/plugin/index.d.ts +1 -0
- package/lib/stdlib/plugin/index.js +1 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/lodController/index.d.ts +73 -0
- package/lib/stdlib/plugin/lodController/index.js +560 -0
- package/lib/stdlib/plugin/lodController/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.js +12 -14
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/lib/stdlib/plugin/toolbar/index.js +27 -29
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/theme/dark.js +32 -35
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +27 -30
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/stdlib/themeSolver/spec.js +2 -2
- package/lib/stdlib/themeSolver/spec.js.map +1 -1
- package/lib/types/animate.d.ts +1 -1
- package/lib/types/combo.d.ts +2 -2
- package/lib/types/edge.d.ts +2 -2
- package/lib/types/graph.d.ts +62 -43
- package/lib/types/hook.d.ts +5 -0
- package/lib/types/item.d.ts +9 -15
- package/lib/types/layout.d.ts +7 -2
- package/lib/types/layout.js.map +1 -1
- package/lib/types/node.d.ts +3 -2
- package/lib/types/plugin.d.ts +1 -0
- package/lib/types/plugin.js +1 -0
- package/lib/types/plugin.js.map +1 -1
- package/lib/types/spec.d.ts +1 -0
- package/lib/types/theme.d.ts +7 -7
- package/lib/util/animate.d.ts +7 -2
- package/lib/util/animate.js +37 -23
- package/lib/util/animate.js.map +1 -1
- package/lib/util/bbox.d.ts +7 -1
- package/lib/util/bbox.js +18 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/data.d.ts +7 -1
- package/lib/util/data.js +19 -6
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.js +5 -5
- package/lib/util/dom.js.map +1 -1
- package/lib/util/item.d.ts +1 -1
- package/lib/util/item.js +8 -8
- package/lib/util/item.js.map +1 -1
- package/lib/util/mapper.js +1 -1
- package/lib/util/mapper.js.map +1 -1
- package/lib/util/path.d.ts +6 -1
- package/lib/util/path.js +72 -1
- package/lib/util/path.js.map +1 -1
- package/lib/util/polyline.d.ts +10 -0
- package/lib/util/polyline.js +25 -18
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/router.js +19 -18
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +1 -1
- package/lib/util/shape.js +27 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/zoom.d.ts +5 -8
- package/lib/util/zoom.js +17 -22
- package/lib/util/zoom.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/item/combo.ts +13 -5
- package/src/item/edge.ts +126 -17
- package/src/item/item.ts +119 -57
- package/src/item/node.ts +108 -11
- package/src/runtime/controller/data.ts +64 -3
- package/src/runtime/controller/index.ts +1 -1
- package/src/runtime/controller/item.ts +321 -135
- package/src/runtime/controller/layout.ts +254 -113
- package/src/runtime/controller/plugin.ts +86 -33
- package/src/runtime/controller/viewport.ts +8 -2
- package/src/runtime/graph.ts +383 -158
- package/src/stdlib/behavior/click-select.ts +8 -3
- package/src/stdlib/behavior/drag-canvas.ts +6 -3
- package/src/stdlib/behavior/drag-combo.ts +8 -8
- package/src/stdlib/behavior/drag-node.ts +165 -50
- package/src/stdlib/behavior/scroll-canvas.ts +3 -3
- package/src/stdlib/behavior/zoom-canvas.ts +3 -3
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/validateData.ts +2 -2
- package/src/stdlib/index.ts +3 -0
- package/src/stdlib/item/edge/base.ts +15 -139
- package/src/stdlib/item/node/base.ts +20 -215
- package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
- package/src/stdlib/plugin/fisheye/index.ts +3 -2
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/lodController/index.ts +602 -0
- package/src/stdlib/plugin/minimap/index.ts +12 -14
- package/src/stdlib/plugin/toolbar/index.ts +29 -31
- package/src/stdlib/theme/dark.ts +32 -34
- package/src/stdlib/theme/light.ts +27 -29
- package/src/stdlib/themeSolver/spec.ts +2 -2
- package/src/types/animate.ts +1 -1
- package/src/types/combo.ts +2 -2
- package/src/types/edge.ts +2 -2
- package/src/types/graph.ts +65 -53
- package/src/types/hook.ts +5 -0
- package/src/types/item.ts +8 -14
- package/src/types/layout.ts +20 -15
- package/src/types/node.ts +3 -2
- package/src/types/plugin.ts +2 -0
- package/src/types/spec.ts +1 -0
- package/src/types/theme.ts +7 -7
- package/src/util/animate.ts +104 -78
- package/src/util/bbox.ts +26 -1
- package/src/util/data.ts +15 -6
- package/src/util/dom.ts +6 -6
- package/src/util/item.ts +15 -1
- package/src/util/mapper.ts +1 -1
- package/src/util/path.ts +72 -2
- package/src/util/polyline.ts +30 -23
- package/src/util/router.ts +21 -19
- package/src/util/shape.ts +27 -12
- package/src/util/zoom.ts +19 -25
- package/esm/runtime/controller/extension.d.ts +0 -9
- package/esm/runtime/controller/extension.js +0 -11
- package/esm/runtime/controller/extension.js.map +0 -1
- package/lib/runtime/controller/extension.d.ts +0 -9
- package/lib/runtime/controller/extension.js +0 -15
- package/lib/runtime/controller/extension.js.map +0 -1
- package/src/runtime/controller/extension.ts +0 -14
|
@@ -32,14 +32,18 @@ import {
|
|
|
32
32
|
import Node from '../../item/node';
|
|
33
33
|
import Edge from '../../item/edge';
|
|
34
34
|
import Combo from '../../item/combo';
|
|
35
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
getCombinedBoundsByData,
|
|
37
|
+
intersectBBox,
|
|
38
|
+
upsertShape,
|
|
39
|
+
} from '../../util/shape';
|
|
36
40
|
import { getExtension } from '../../util/extension';
|
|
37
41
|
import { upsertTransientItem } from '../../util/item';
|
|
38
42
|
import {
|
|
39
43
|
ITEM_TYPE,
|
|
40
44
|
ShapeStyle,
|
|
41
45
|
SHAPE_TYPE,
|
|
42
|
-
|
|
46
|
+
LodLevelRanges,
|
|
43
47
|
DisplayMapper,
|
|
44
48
|
} from '../../types/item';
|
|
45
49
|
import {
|
|
@@ -52,7 +56,7 @@ import {
|
|
|
52
56
|
ComboStyleSet,
|
|
53
57
|
} from '../../types/theme';
|
|
54
58
|
import { ViewportChangeHookParams } from '../../types/hook';
|
|
55
|
-
import {
|
|
59
|
+
import { formatLodLevels } from '../../util/zoom';
|
|
56
60
|
import {
|
|
57
61
|
deconstructData,
|
|
58
62
|
graphComboTreeDfs,
|
|
@@ -64,10 +68,56 @@ import {
|
|
|
64
68
|
import { getGroupedChanges } from '../../util/event';
|
|
65
69
|
import { BaseNode } from '../../stdlib/item/node/base';
|
|
66
70
|
import { BaseEdge } from '../../stdlib/item/edge/base';
|
|
67
|
-
import { EdgeCollisionChecker, QuadTree } from '../../util/polyline';
|
|
68
71
|
import { isBBoxInBBox, isPointInBBox } from '../../util/bbox';
|
|
69
72
|
import { convertToNumber } from '../../util/type';
|
|
73
|
+
import {
|
|
74
|
+
isPointPreventPolylineOverlap,
|
|
75
|
+
isPolylineWithObstacleAvoidance,
|
|
76
|
+
} from '../../util/polyline';
|
|
77
|
+
|
|
78
|
+
enum WARN_TYPE {
|
|
79
|
+
FAIL_GET_BBOX,
|
|
80
|
+
FAIL_GET_VISIBLE,
|
|
81
|
+
FAIL_SET_STATE,
|
|
82
|
+
FAIL_GET_STATE,
|
|
83
|
+
FAIL_SET_VISIBLE,
|
|
84
|
+
FAIL_DRAW_TRANSIENT,
|
|
85
|
+
SOURCE_NOT_EXIST,
|
|
86
|
+
TARGET_NOT_EXIST,
|
|
87
|
+
}
|
|
70
88
|
|
|
89
|
+
const getWarnMsg = {
|
|
90
|
+
[WARN_TYPE.FAIL_GET_BBOX]: (ids) =>
|
|
91
|
+
`Fail to get items' bboxes, the items with ids ${ids.join(
|
|
92
|
+
', ',
|
|
93
|
+
)} do not exist.`,
|
|
94
|
+
[WARN_TYPE.FAIL_GET_VISIBLE]: (ids) =>
|
|
95
|
+
`Fail to get items' visible, the items with ids ${ids.join(
|
|
96
|
+
', ',
|
|
97
|
+
)} do not exist.`,
|
|
98
|
+
[WARN_TYPE.FAIL_SET_STATE]: (ids) =>
|
|
99
|
+
`Fail to set states for items ${ids.join(', ')}, which do not exist.`,
|
|
100
|
+
[WARN_TYPE.FAIL_SET_VISIBLE]: (ids) =>
|
|
101
|
+
`Fail to set visibility for items ${ids.join(', ')}, which do not exist.`,
|
|
102
|
+
[WARN_TYPE.FAIL_DRAW_TRANSIENT]: (ids) =>
|
|
103
|
+
`Fail to draw transient items of ${ids}, which do not exist.`,
|
|
104
|
+
[WARN_TYPE.SOURCE_NOT_EXIST]: (params) =>
|
|
105
|
+
`The source nodes ${params
|
|
106
|
+
.map((p) => p.source)
|
|
107
|
+
.join(', ')} do not exist in the graph for edges ${params
|
|
108
|
+
.map((p) => p.id)
|
|
109
|
+
.join(', ')}, please add the nodes first`,
|
|
110
|
+
[WARN_TYPE.TARGET_NOT_EXIST]: (params) =>
|
|
111
|
+
`The target nodes ${params
|
|
112
|
+
.map((p) => p.target)
|
|
113
|
+
.join(', ')} do not exist in the graph for edges ${params
|
|
114
|
+
.map((p) => p.id)
|
|
115
|
+
.join(', ')}, please add the nodes first`,
|
|
116
|
+
[WARN_TYPE.FAIL_GET_STATE]: (ids) =>
|
|
117
|
+
`Fail to get items' states, the items with ids ${ids.join(
|
|
118
|
+
', ',
|
|
119
|
+
)} do not exist.`,
|
|
120
|
+
};
|
|
71
121
|
/**
|
|
72
122
|
* Manages and stores the node / edge / combo items.
|
|
73
123
|
*/
|
|
@@ -117,11 +167,15 @@ export class ItemController {
|
|
|
117
167
|
|
|
118
168
|
// if the graph has combos, nodeGroup/edgeGroup/comboGroup point to the same group, so as transient groups.
|
|
119
169
|
private nodeGroup: Group;
|
|
170
|
+
private nodeLabelGroup: Group;
|
|
171
|
+
private edgeLabelGroup: Group;
|
|
120
172
|
private edgeGroup: Group;
|
|
121
173
|
private comboGroup: Group;
|
|
122
174
|
private transientNodeGroup: Group;
|
|
123
175
|
private transientEdgeGroup: Group;
|
|
124
176
|
private transientComboGroup: Group;
|
|
177
|
+
private transientNodeLabelGroup: Group;
|
|
178
|
+
private transientEdgeLabelGroup: Group;
|
|
125
179
|
|
|
126
180
|
private nodeDataTypeSet: Set<string> = new Set();
|
|
127
181
|
private edgeDataTypeSet: Set<string> = new Set();
|
|
@@ -136,6 +190,15 @@ export class ItemController {
|
|
|
136
190
|
ID,
|
|
137
191
|
Node | Edge | Combo | Group
|
|
138
192
|
>();
|
|
193
|
+
/** Caches */
|
|
194
|
+
private nearEdgesCache: Map<ID, EdgeModel[]> = new Map<ID, EdgeModel[]>();
|
|
195
|
+
|
|
196
|
+
private cacheViewItems: {
|
|
197
|
+
inView: (Node | Edge | Combo)[];
|
|
198
|
+
outView: (Node | Edge | Combo)[];
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
private cacheWarnMsg = {};
|
|
139
202
|
|
|
140
203
|
constructor(graph: IGraph<any, any>) {
|
|
141
204
|
this.graph = graph;
|
|
@@ -215,25 +278,43 @@ export class ItemController {
|
|
|
215
278
|
graphCore: GraphCore;
|
|
216
279
|
theme: ThemeSpecification;
|
|
217
280
|
transientCanvas: Canvas;
|
|
281
|
+
transientLabelCanvas: Canvas;
|
|
218
282
|
tileOptimize?: {
|
|
219
283
|
tileFirstRender?: boolean | number;
|
|
220
284
|
tileFirstRenderSize?: number;
|
|
221
285
|
};
|
|
222
286
|
}) {
|
|
223
|
-
const {
|
|
287
|
+
const {
|
|
288
|
+
graphCore,
|
|
289
|
+
theme = {},
|
|
290
|
+
transientCanvas,
|
|
291
|
+
transientLabelCanvas,
|
|
292
|
+
tileOptimize = {},
|
|
293
|
+
} = param;
|
|
224
294
|
const { graph } = this;
|
|
225
295
|
|
|
226
296
|
// 0. clear groups on canvas, and create new groups
|
|
227
297
|
graph.canvas.removeChildren();
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.nodeGroup =
|
|
235
|
-
this.
|
|
236
|
-
|
|
298
|
+
graph.labelCanvas.removeChildren();
|
|
299
|
+
graph.transientCanvas.removeChildren();
|
|
300
|
+
this.itemMap.forEach((item) => item.destroy());
|
|
301
|
+
this.itemMap.clear();
|
|
302
|
+
this.comboGroup = new Group({ id: 'combo-group', style: { zIndex: 0 } });
|
|
303
|
+
this.edgeGroup = new Group({ id: 'edge-group', style: { zIndex: 1 } });
|
|
304
|
+
this.nodeGroup = new Group({ id: 'node-group', style: { zIndex: 2 } });
|
|
305
|
+
this.edgeLabelGroup = new Group({
|
|
306
|
+
id: 'node-label-group',
|
|
307
|
+
style: { zIndex: 0 },
|
|
308
|
+
});
|
|
309
|
+
this.nodeLabelGroup = new Group({
|
|
310
|
+
id: 'node-label-group',
|
|
311
|
+
style: { zIndex: 1 },
|
|
312
|
+
});
|
|
313
|
+
graph.canvas.appendChild(this.comboGroup);
|
|
314
|
+
graph.canvas.appendChild(this.edgeGroup);
|
|
315
|
+
graph.canvas.appendChild(this.nodeGroup);
|
|
316
|
+
graph.labelCanvas.appendChild(this.edgeLabelGroup);
|
|
317
|
+
graph.labelCanvas.appendChild(this.nodeLabelGroup);
|
|
237
318
|
|
|
238
319
|
// Also create transient groups on transient canvas.
|
|
239
320
|
transientCanvas.removeChildren();
|
|
@@ -252,6 +333,16 @@ export class ItemController {
|
|
|
252
333
|
transientCanvas.appendChild(this.transientComboGroup);
|
|
253
334
|
transientCanvas.appendChild(this.transientEdgeGroup);
|
|
254
335
|
transientCanvas.appendChild(this.transientNodeGroup);
|
|
336
|
+
this.transientEdgeLabelGroup = new Group({
|
|
337
|
+
id: 'node-label-group',
|
|
338
|
+
style: { zIndex: 0 },
|
|
339
|
+
});
|
|
340
|
+
this.transientNodeLabelGroup = new Group({
|
|
341
|
+
id: 'node-label-group',
|
|
342
|
+
style: { zIndex: 1 },
|
|
343
|
+
});
|
|
344
|
+
transientLabelCanvas.appendChild(this.transientEdgeLabelGroup);
|
|
345
|
+
transientLabelCanvas.appendChild(this.transientNodeLabelGroup);
|
|
255
346
|
|
|
256
347
|
// 1. create lights for webgl 3d rendering
|
|
257
348
|
if (graph.rendererType === 'webgl-3d') {
|
|
@@ -521,15 +612,19 @@ export class ItemController {
|
|
|
521
612
|
);
|
|
522
613
|
}
|
|
523
614
|
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
615
|
+
const adjacentEdgeInnerModels = graphCore.getRelatedEdges(id);
|
|
616
|
+
|
|
617
|
+
if (isPointPreventPolylineOverlap(innerModel)) {
|
|
618
|
+
const newNearEdges = this.graph.getNearEdgesData(id, (edge) =>
|
|
619
|
+
isPolylineWithObstacleAvoidance(edge),
|
|
620
|
+
);
|
|
621
|
+
const prevNearEdges = this.nearEdgesCache.get(id) || [];
|
|
622
|
+
adjacentEdgeInnerModels.push(...newNearEdges);
|
|
623
|
+
adjacentEdgeInnerModels.push(...prevNearEdges);
|
|
624
|
+
this.nearEdgesCache.set(id, newNearEdges);
|
|
625
|
+
}
|
|
531
626
|
|
|
532
|
-
|
|
627
|
+
adjacentEdgeInnerModels.forEach((edge) => {
|
|
533
628
|
edgeIdsToUpdate.add(edge.id);
|
|
534
629
|
nodeRelatedIdsToUpdate.add(edge.id);
|
|
535
630
|
});
|
|
@@ -573,7 +668,7 @@ export class ItemController {
|
|
|
573
668
|
const parentItem = this.itemMap.get(current.parentId);
|
|
574
669
|
if (current.parentId && parentItem?.model.data.collapsed) {
|
|
575
670
|
this.graph.executeWithNoStack(() => {
|
|
576
|
-
this.graph.hideItem(innerModel.id, false);
|
|
671
|
+
this.graph.hideItem(innerModel.id, { disableAnimate: false });
|
|
577
672
|
});
|
|
578
673
|
}
|
|
579
674
|
});
|
|
@@ -656,7 +751,7 @@ export class ItemController {
|
|
|
656
751
|
let parent = graphCore.getParent(nodeId, 'tree');
|
|
657
752
|
while (parent) {
|
|
658
753
|
if (parent.data.collapsed) {
|
|
659
|
-
this.graph.hideItem(nodeId, true);
|
|
754
|
+
this.graph.hideItem(nodeId, { disableAnimate: true });
|
|
660
755
|
break;
|
|
661
756
|
}
|
|
662
757
|
parent = graphCore.getParent(parent.id, 'tree');
|
|
@@ -683,7 +778,11 @@ export class ItemController {
|
|
|
683
778
|
ids.forEach((id) => {
|
|
684
779
|
const item = this.itemMap.get(id);
|
|
685
780
|
if (!item) {
|
|
686
|
-
|
|
781
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_SET_STATE] =
|
|
782
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_SET_STATE] || [];
|
|
783
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_SET_STATE].push(id);
|
|
784
|
+
// @ts-ignore
|
|
785
|
+
this.debounceWarn(WARN_TYPE.FAIL_SET_STATE);
|
|
687
786
|
return;
|
|
688
787
|
}
|
|
689
788
|
if (!states || !value) {
|
|
@@ -697,30 +796,45 @@ export class ItemController {
|
|
|
697
796
|
|
|
698
797
|
private onItemVisibilityChange(param: {
|
|
699
798
|
ids: ID[];
|
|
799
|
+
shapeIds: string[];
|
|
700
800
|
value: boolean;
|
|
701
801
|
graphCore: GraphCore;
|
|
702
802
|
animate?: boolean;
|
|
703
803
|
keepKeyShape?: boolean;
|
|
804
|
+
keepRelated?: boolean;
|
|
704
805
|
}) {
|
|
705
806
|
const {
|
|
706
807
|
ids,
|
|
808
|
+
shapeIds,
|
|
707
809
|
value,
|
|
708
810
|
graphCore,
|
|
709
811
|
animate = true,
|
|
710
812
|
keepKeyShape = false,
|
|
813
|
+
keepRelated = false,
|
|
711
814
|
} = param;
|
|
712
815
|
ids.forEach((id) => {
|
|
713
816
|
const item = this.itemMap.get(id);
|
|
714
817
|
if (!item) {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
);
|
|
818
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_SET_VISIBLE] =
|
|
819
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_SET_VISIBLE] || [];
|
|
820
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_SET_VISIBLE].push(id);
|
|
821
|
+
// @ts-ignore
|
|
822
|
+
this.debounceWarn(WARN_TYPE.FAIL_SET_VISIBLE);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if (shapeIds?.length) {
|
|
826
|
+
if (value) {
|
|
827
|
+
item.show(animate, shapeIds);
|
|
828
|
+
} else {
|
|
829
|
+
item.hide(animate, false, shapeIds);
|
|
830
|
+
}
|
|
718
831
|
return;
|
|
719
832
|
}
|
|
720
833
|
const type = item.getType();
|
|
721
834
|
if (value) {
|
|
722
835
|
if (type === 'edge') {
|
|
723
836
|
item.show(animate);
|
|
837
|
+
(item as Edge).forceUpdate();
|
|
724
838
|
} else {
|
|
725
839
|
if (graphCore.hasTreeStructure('combo')) {
|
|
726
840
|
let anccestorCollapsed = false;
|
|
@@ -739,7 +853,7 @@ export class ItemController {
|
|
|
739
853
|
}
|
|
740
854
|
} else {
|
|
741
855
|
item.hide(animate, keepKeyShape);
|
|
742
|
-
if (type !== 'edge') {
|
|
856
|
+
if (type !== 'edge' && !keepRelated) {
|
|
743
857
|
const relatedEdges = graphCore.getRelatedEdges(id);
|
|
744
858
|
relatedEdges.forEach(({ id: edgeId }) => {
|
|
745
859
|
this.itemMap.get(edgeId)?.hide(animate);
|
|
@@ -784,6 +898,59 @@ export class ItemController {
|
|
|
784
898
|
});
|
|
785
899
|
}
|
|
786
900
|
|
|
901
|
+
/**
|
|
902
|
+
* get the items inside viewport
|
|
903
|
+
* @returns
|
|
904
|
+
*/
|
|
905
|
+
private groupItemsByView = (
|
|
906
|
+
containType: 'inside' | 'intersect' = 'inside',
|
|
907
|
+
ratio: number = 1,
|
|
908
|
+
) => {
|
|
909
|
+
const range = this.graph.getCanvasRange();
|
|
910
|
+
const items = Array.from(this.itemMap, ([key, value]) => value);
|
|
911
|
+
const containFunc =
|
|
912
|
+
containType === 'intersect' ? intersectBBox : isBBoxInBBox;
|
|
913
|
+
let { inView: itemsInView, outView: itemsOutView } =
|
|
914
|
+
this.cacheViewItems || {};
|
|
915
|
+
if (!ratio || ratio === 1 || !this.cacheViewItems) {
|
|
916
|
+
itemsInView = [];
|
|
917
|
+
itemsOutView = [];
|
|
918
|
+
items.forEach((item) => {
|
|
919
|
+
const { keyShape } = item.shapeMap;
|
|
920
|
+
if (!keyShape) return;
|
|
921
|
+
const renderBounds = keyShape.getRenderBounds();
|
|
922
|
+
if (containFunc(renderBounds, range, 0.4)) itemsInView.push(item);
|
|
923
|
+
else itemsOutView.push(item);
|
|
924
|
+
});
|
|
925
|
+
} else if (ratio < 1) {
|
|
926
|
+
// zoom-out
|
|
927
|
+
itemsOutView.forEach((item) => {
|
|
928
|
+
const { keyShape } = item.shapeMap;
|
|
929
|
+
if (!keyShape) return;
|
|
930
|
+
const renderBounds = keyShape.getRenderBounds();
|
|
931
|
+
if (containFunc(renderBounds, range, 0.4)) {
|
|
932
|
+
itemsInView.push(item);
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
} else if (ratio > 1) {
|
|
936
|
+
// zoom-in
|
|
937
|
+
itemsInView.forEach((item) => {
|
|
938
|
+
const { keyShape } = item.shapeMap;
|
|
939
|
+
if (!keyShape) return;
|
|
940
|
+
const renderBounds = keyShape.getRenderBounds();
|
|
941
|
+
if (!containFunc(renderBounds, range, 0.4)) {
|
|
942
|
+
itemsOutView.push(item);
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
this.cacheViewItems = { inView: itemsInView, outView: itemsOutView };
|
|
947
|
+
return {
|
|
948
|
+
items,
|
|
949
|
+
inView: itemsInView,
|
|
950
|
+
outView: itemsOutView,
|
|
951
|
+
};
|
|
952
|
+
};
|
|
953
|
+
|
|
787
954
|
private onViewportChange = debounce(
|
|
788
955
|
({
|
|
789
956
|
transform,
|
|
@@ -793,20 +960,13 @@ export class ItemController {
|
|
|
793
960
|
const { zoom } = transform;
|
|
794
961
|
if (zoom) {
|
|
795
962
|
const zoomRatio = this.graph.getZoom();
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
const renderBounds = keyShape.getRenderBounds();
|
|
804
|
-
if (isBBoxInBBox(renderBounds, range, 0.4))
|
|
805
|
-
itemsInViewport.push(item);
|
|
806
|
-
else itemsOutViewport.push(item);
|
|
807
|
-
});
|
|
808
|
-
const sortedItems = itemsInViewport.concat(itemsOutViewport);
|
|
809
|
-
const sections = Math.ceil(nodeItems.length / tileLodSize);
|
|
963
|
+
const {
|
|
964
|
+
items,
|
|
965
|
+
inView: itemsInview,
|
|
966
|
+
outView: itemsOutView,
|
|
967
|
+
} = this.groupItemsByView();
|
|
968
|
+
const sortedItems = itemsInview.concat(itemsOutView);
|
|
969
|
+
const sections = Math.ceil(items.length / tileLodSize);
|
|
810
970
|
const itemSections = Array.from({ length: sections }, (v, i) =>
|
|
811
971
|
sortedItems.slice(i * tileLodSize, i * tileLodSize + tileLodSize),
|
|
812
972
|
);
|
|
@@ -820,7 +980,6 @@ export class ItemController {
|
|
|
820
980
|
requestId = requestAnimationFrame(update);
|
|
821
981
|
};
|
|
822
982
|
requestId = requestAnimationFrame(update);
|
|
823
|
-
// this.itemMap.forEach((item) => item.updateZoom(zoomRatio));
|
|
824
983
|
this.zoom = zoomRatio;
|
|
825
984
|
}
|
|
826
985
|
},
|
|
@@ -852,7 +1011,7 @@ export class ItemController {
|
|
|
852
1011
|
false,
|
|
853
1012
|
itemTheme as {
|
|
854
1013
|
styles: NodeStyleSet;
|
|
855
|
-
|
|
1014
|
+
lodLevels: LodLevelRanges;
|
|
856
1015
|
},
|
|
857
1016
|
);
|
|
858
1017
|
});
|
|
@@ -948,9 +1107,11 @@ export class ItemController {
|
|
|
948
1107
|
if (isItemType) {
|
|
949
1108
|
const item = this.itemMap.get(id);
|
|
950
1109
|
if (!item) {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
);
|
|
1110
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_DRAW_TRANSIENT] =
|
|
1111
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_DRAW_TRANSIENT] || [];
|
|
1112
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_DRAW_TRANSIENT].push(id);
|
|
1113
|
+
// @ts-ignore
|
|
1114
|
+
this.debounceWarn(WARN_TYPE.FAIL_DRAW_TRANSIENT);
|
|
954
1115
|
return;
|
|
955
1116
|
}
|
|
956
1117
|
const transientItem = upsertTransientItem(
|
|
@@ -958,13 +1119,14 @@ export class ItemController {
|
|
|
958
1119
|
this.transientNodeGroup,
|
|
959
1120
|
this.transientEdgeGroup,
|
|
960
1121
|
this.transientComboGroup,
|
|
1122
|
+
this.transientNodeLabelGroup,
|
|
1123
|
+
this.transientEdgeLabelGroup,
|
|
961
1124
|
this.transientItemMap,
|
|
962
1125
|
this.itemMap,
|
|
963
1126
|
graphCore,
|
|
964
1127
|
{ shapeIds, drawSource, drawTarget, visible },
|
|
965
1128
|
upsertAncestors,
|
|
966
1129
|
);
|
|
967
|
-
|
|
968
1130
|
if (shapeIds) {
|
|
969
1131
|
// only update node positions to cloned node container(group)
|
|
970
1132
|
if (
|
|
@@ -1033,6 +1195,15 @@ export class ItemController {
|
|
|
1033
1195
|
...data,
|
|
1034
1196
|
},
|
|
1035
1197
|
});
|
|
1198
|
+
if (type !== 'edge') {
|
|
1199
|
+
const relatedEdges = graphCore.getRelatedEdges(transItem.model.id);
|
|
1200
|
+
relatedEdges.forEach((relatedEdge) => {
|
|
1201
|
+
const transientEdge = this.transientItemMap.get(
|
|
1202
|
+
relatedEdge.id,
|
|
1203
|
+
) as Edge;
|
|
1204
|
+
if (transientEdge) transientEdge.forceUpdate();
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1036
1207
|
}
|
|
1037
1208
|
return;
|
|
1038
1209
|
}
|
|
@@ -1053,11 +1224,26 @@ export class ItemController {
|
|
|
1053
1224
|
}
|
|
1054
1225
|
|
|
1055
1226
|
public getTransientItem(id: ID) {
|
|
1056
|
-
return this.transientItemMap
|
|
1227
|
+
return this.transientItemMap.get(id);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
public getItemMap() {
|
|
1231
|
+
return this.itemMap;
|
|
1057
1232
|
}
|
|
1058
1233
|
|
|
1059
|
-
public findDisplayModel(
|
|
1060
|
-
|
|
1234
|
+
public findDisplayModel(
|
|
1235
|
+
id: ID,
|
|
1236
|
+
): NodeDisplayModel | EdgeDisplayModel | ComboDisplayModel {
|
|
1237
|
+
const item = this.itemMap.get(id);
|
|
1238
|
+
if (!item) return { id, data: {} };
|
|
1239
|
+
return {
|
|
1240
|
+
id,
|
|
1241
|
+
data: {
|
|
1242
|
+
...item.displayModel.data,
|
|
1243
|
+
...item.renderExt.mergedStyles,
|
|
1244
|
+
lodLevels: item.lodLevels,
|
|
1245
|
+
},
|
|
1246
|
+
};
|
|
1061
1247
|
}
|
|
1062
1248
|
|
|
1063
1249
|
/**
|
|
@@ -1072,7 +1258,13 @@ export class ItemController {
|
|
|
1072
1258
|
tileFirstRenderSize?: number;
|
|
1073
1259
|
},
|
|
1074
1260
|
): Promise<any> | undefined {
|
|
1075
|
-
const {
|
|
1261
|
+
const {
|
|
1262
|
+
nodeExtensions,
|
|
1263
|
+
nodeGroup,
|
|
1264
|
+
nodeLabelGroup,
|
|
1265
|
+
nodeDataTypeSet,
|
|
1266
|
+
graph,
|
|
1267
|
+
} = this;
|
|
1076
1268
|
const { dataTypeField = '' } = nodeTheme;
|
|
1077
1269
|
const { tileFirstRender, tileFirstRenderSize = 1000 } = tileOptimize || {};
|
|
1078
1270
|
const zoom = graph.getZoom();
|
|
@@ -1094,16 +1286,18 @@ export class ItemController {
|
|
|
1094
1286
|
);
|
|
1095
1287
|
|
|
1096
1288
|
const nodeItem = new Node({
|
|
1289
|
+
graph,
|
|
1097
1290
|
delayFirstDraw,
|
|
1098
1291
|
model: node,
|
|
1099
1292
|
renderExtensions: nodeExtensions,
|
|
1100
1293
|
containerGroup: nodeGroup,
|
|
1294
|
+
labelContainerGroup: nodeLabelGroup,
|
|
1101
1295
|
mapper: this.nodeMapper,
|
|
1102
1296
|
stateMapper: this.nodeStateMapper,
|
|
1103
1297
|
zoom,
|
|
1104
1298
|
theme: itemTheme as {
|
|
1105
1299
|
styles: NodeStyleSet;
|
|
1106
|
-
|
|
1300
|
+
lodLevels: LodLevelRanges;
|
|
1107
1301
|
},
|
|
1108
1302
|
device:
|
|
1109
1303
|
graph.rendererType === 'webgl-3d'
|
|
@@ -1195,10 +1389,12 @@ export class ItemController {
|
|
|
1195
1389
|
};
|
|
1196
1390
|
const comboItem = new Combo({
|
|
1197
1391
|
model: combo,
|
|
1392
|
+
graph: this.graph,
|
|
1198
1393
|
getCombinedBounds,
|
|
1199
1394
|
getChildren,
|
|
1200
1395
|
renderExtensions: comboExtensions,
|
|
1201
1396
|
containerGroup: comboGroup,
|
|
1397
|
+
labelContainerGroup: this.nodeLabelGroup,
|
|
1202
1398
|
mapper: this.comboMapper as DisplayMapper,
|
|
1203
1399
|
stateMapper: this.comboStateMapper as {
|
|
1204
1400
|
[stateName: string]: DisplayMapper;
|
|
@@ -1206,7 +1402,7 @@ export class ItemController {
|
|
|
1206
1402
|
zoom,
|
|
1207
1403
|
theme: itemTheme as {
|
|
1208
1404
|
styles: ComboStyleSet;
|
|
1209
|
-
|
|
1405
|
+
lodLevels: LodLevelRanges;
|
|
1210
1406
|
},
|
|
1211
1407
|
device:
|
|
1212
1408
|
graph.rendererType === 'webgl-3d'
|
|
@@ -1236,7 +1432,14 @@ export class ItemController {
|
|
|
1236
1432
|
},
|
|
1237
1433
|
nodesInView?: Node[],
|
|
1238
1434
|
): Promise<any> | undefined {
|
|
1239
|
-
const {
|
|
1435
|
+
const {
|
|
1436
|
+
edgeExtensions,
|
|
1437
|
+
edgeGroup,
|
|
1438
|
+
edgeLabelGroup,
|
|
1439
|
+
itemMap,
|
|
1440
|
+
edgeDataTypeSet,
|
|
1441
|
+
graph,
|
|
1442
|
+
} = this;
|
|
1240
1443
|
const { dataTypeField = '' } = edgeTheme;
|
|
1241
1444
|
const { tileFirstRender, tileFirstRenderSize = 1000 } = tileOptimize || {};
|
|
1242
1445
|
const zoom = graph.getZoom();
|
|
@@ -1252,15 +1455,19 @@ export class ItemController {
|
|
|
1252
1455
|
const sourceItem = itemMap.get(source) as Node;
|
|
1253
1456
|
const targetItem = itemMap.get(target) as Node;
|
|
1254
1457
|
if (!sourceItem) {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
);
|
|
1458
|
+
this.cacheWarnMsg[WARN_TYPE.SOURCE_NOT_EXIST] =
|
|
1459
|
+
this.cacheWarnMsg[WARN_TYPE.SOURCE_NOT_EXIST] || [];
|
|
1460
|
+
this.cacheWarnMsg[WARN_TYPE.SOURCE_NOT_EXIST].push({ id, source });
|
|
1461
|
+
// @ts-ignore
|
|
1462
|
+
this.debounceWarn(WARN_TYPE.SOURCE_NOT_EXIST);
|
|
1258
1463
|
return;
|
|
1259
1464
|
}
|
|
1260
1465
|
if (!targetItem) {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
);
|
|
1466
|
+
this.cacheWarnMsg[WARN_TYPE.TARGET_NOT_EXIST] =
|
|
1467
|
+
this.cacheWarnMsg[WARN_TYPE.TARGET_NOT_EXIST] || [];
|
|
1468
|
+
this.cacheWarnMsg[WARN_TYPE.TARGET_NOT_EXIST].push({ id, source });
|
|
1469
|
+
// @ts-ignore
|
|
1470
|
+
this.debounceWarn(WARN_TYPE.TARGET_NOT_EXIST);
|
|
1264
1471
|
return;
|
|
1265
1472
|
}
|
|
1266
1473
|
// get the base styles from theme
|
|
@@ -1272,12 +1479,13 @@ export class ItemController {
|
|
|
1272
1479
|
dataType,
|
|
1273
1480
|
edgeTheme,
|
|
1274
1481
|
);
|
|
1275
|
-
|
|
1276
1482
|
const edgeItem = new Edge({
|
|
1483
|
+
graph,
|
|
1277
1484
|
delayFirstDraw,
|
|
1278
1485
|
model: edge,
|
|
1279
1486
|
renderExtensions: edgeExtensions,
|
|
1280
1487
|
containerGroup: edgeGroup,
|
|
1488
|
+
labelContainerGroup: edgeLabelGroup,
|
|
1281
1489
|
mapper: this.edgeMapper as DisplayMapper,
|
|
1282
1490
|
stateMapper: this.edgeStateMapper as {
|
|
1283
1491
|
[stateName: string]: DisplayMapper;
|
|
@@ -1288,7 +1496,7 @@ export class ItemController {
|
|
|
1288
1496
|
zoom,
|
|
1289
1497
|
theme: itemTheme as {
|
|
1290
1498
|
styles: EdgeStyleSet;
|
|
1291
|
-
|
|
1499
|
+
lodLevels: LodLevelRanges;
|
|
1292
1500
|
},
|
|
1293
1501
|
});
|
|
1294
1502
|
|
|
@@ -1352,9 +1560,11 @@ export class ItemController {
|
|
|
1352
1560
|
public getItemState(id: ID, state: string) {
|
|
1353
1561
|
const item = this.itemMap.get(id);
|
|
1354
1562
|
if (!item) {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
);
|
|
1563
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE] =
|
|
1564
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE] || [];
|
|
1565
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE].push(id);
|
|
1566
|
+
// @ts-ignore
|
|
1567
|
+
this.debounceWarn(WARN_TYPE.FAIL_GET_STATE);
|
|
1358
1568
|
return false;
|
|
1359
1569
|
}
|
|
1360
1570
|
return item.hasState(state);
|
|
@@ -1363,9 +1573,11 @@ export class ItemController {
|
|
|
1363
1573
|
public getItemAllStates(id: ID): string[] {
|
|
1364
1574
|
const item = this.itemMap.get(id);
|
|
1365
1575
|
if (!item) {
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
);
|
|
1576
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE] =
|
|
1577
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE] || [];
|
|
1578
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_STATE].push(id);
|
|
1579
|
+
// @ts-ignore
|
|
1580
|
+
this.debounceWarn(WARN_TYPE.FAIL_GET_STATE);
|
|
1369
1581
|
return [];
|
|
1370
1582
|
}
|
|
1371
1583
|
return item
|
|
@@ -1387,76 +1599,51 @@ export class ItemController {
|
|
|
1387
1599
|
? this.transientItemMap.get(id)
|
|
1388
1600
|
: this.itemMap.get(id);
|
|
1389
1601
|
if (!item) {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
);
|
|
1602
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_BBOX] =
|
|
1603
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_BBOX] || [];
|
|
1604
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_BBOX].push(id);
|
|
1605
|
+
// @ts-ignore
|
|
1606
|
+
this.debounceWarn(WARN_TYPE.FAIL_GET_BBOX);
|
|
1393
1607
|
return false;
|
|
1394
1608
|
}
|
|
1395
1609
|
if (item instanceof Group) return item.getRenderBounds();
|
|
1396
1610
|
return isKeyShape ? item.getKeyBBox() : item.getBBox();
|
|
1397
1611
|
}
|
|
1398
1612
|
|
|
1613
|
+
public getItemVisibleShapeIds(id: ID) {
|
|
1614
|
+
const item = this.itemMap.get(id);
|
|
1615
|
+
const shapeIds = [];
|
|
1616
|
+
Object.keys(item.shapeMap).forEach((shapeId) => {
|
|
1617
|
+
if (item.shapeMap[shapeId]?.attributes.visibility !== 'hidden')
|
|
1618
|
+
shapeIds.push(shapeId);
|
|
1619
|
+
});
|
|
1620
|
+
return shapeIds;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
private debounceWarn = debounce(
|
|
1624
|
+
(type) => {
|
|
1625
|
+
const msg = getWarnMsg[type](this.cacheWarnMsg[type]);
|
|
1626
|
+
console.warn(msg);
|
|
1627
|
+
this.cacheWarnMsg[type] = [];
|
|
1628
|
+
},
|
|
1629
|
+
16,
|
|
1630
|
+
false,
|
|
1631
|
+
);
|
|
1632
|
+
|
|
1399
1633
|
public getItemVisible(id: ID) {
|
|
1400
1634
|
const item = this.itemMap.get(id);
|
|
1401
1635
|
if (!item) {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
);
|
|
1636
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_VISIBLE] =
|
|
1637
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_VISIBLE] || [];
|
|
1638
|
+
this.cacheWarnMsg[WARN_TYPE.FAIL_GET_VISIBLE].push(id);
|
|
1639
|
+
// @ts-ignore
|
|
1640
|
+
this.debounceWarn(WARN_TYPE.FAIL_GET_VISIBLE);
|
|
1641
|
+
|
|
1405
1642
|
return false;
|
|
1406
1643
|
}
|
|
1407
1644
|
return item.isVisible();
|
|
1408
1645
|
}
|
|
1409
1646
|
|
|
1410
|
-
/**
|
|
1411
|
-
* Identify edges that are intersected by a particular node
|
|
1412
|
-
* @param nodeId node id
|
|
1413
|
-
* @param graphCore
|
|
1414
|
-
* @returns
|
|
1415
|
-
*/
|
|
1416
|
-
public findNearEdgesByNode(nodeId: ID, graphCore: GraphCore) {
|
|
1417
|
-
const edges = graphCore.getAllEdges();
|
|
1418
|
-
|
|
1419
|
-
const canvasBBox = this.graph.getRenderBBox(undefined) as AABB;
|
|
1420
|
-
const quadTree = new QuadTree(canvasBBox, 4);
|
|
1421
|
-
|
|
1422
|
-
each(edges, (edge) => {
|
|
1423
|
-
const {
|
|
1424
|
-
data: { x: sourceX, y: sourceY },
|
|
1425
|
-
} = graphCore.getNode(edge.source);
|
|
1426
|
-
const {
|
|
1427
|
-
data: { x: targetX, y: targetY },
|
|
1428
|
-
} = graphCore.getNode(edge.target);
|
|
1429
|
-
|
|
1430
|
-
quadTree.insert({
|
|
1431
|
-
id: edge.id,
|
|
1432
|
-
p1: { x: sourceX, y: sourceY },
|
|
1433
|
-
p2: { x: targetX, y: targetY },
|
|
1434
|
-
bbox: this.graph.getRenderBBox(edge.id) as AABB,
|
|
1435
|
-
});
|
|
1436
|
-
});
|
|
1437
|
-
|
|
1438
|
-
// update node position
|
|
1439
|
-
const node = (this.getTransientItem(nodeId) ||
|
|
1440
|
-
this.getItemById(nodeId)) as Node;
|
|
1441
|
-
const nodeBBox = this.graph.getRenderBBox(nodeId) as AABB;
|
|
1442
|
-
const nodeData = node?.model?.data;
|
|
1443
|
-
if (nodeData) {
|
|
1444
|
-
nodeBBox.update(
|
|
1445
|
-
[nodeData.x as number, nodeData.y as number, 0],
|
|
1446
|
-
nodeBBox.halfExtents,
|
|
1447
|
-
);
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
const checker = new EdgeCollisionChecker(quadTree);
|
|
1451
|
-
const collisions = checker.getCollidingEdges(nodeBBox);
|
|
1452
|
-
|
|
1453
|
-
const collidingEdges = map(collisions, (collision) =>
|
|
1454
|
-
graphCore.getEdge(collision.id),
|
|
1455
|
-
);
|
|
1456
|
-
|
|
1457
|
-
return collidingEdges;
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
1647
|
public sortByComboTree(graphCore: GraphCore) {
|
|
1461
1648
|
if (!graphCore.hasTreeStructure('combo')) return;
|
|
1462
1649
|
graphCoreTreeDfs(graphCore, graphCore.getRoots('combo'), (node) => {
|
|
@@ -1474,7 +1661,7 @@ export class ItemController {
|
|
|
1474
1661
|
graphComboTreeDfs(this.graph, [comboModel], (child) => {
|
|
1475
1662
|
if (child.id !== comboModel.id) {
|
|
1476
1663
|
this.graph.executeWithNoStack(() => {
|
|
1477
|
-
this.graph.hideItem(child.id, false);
|
|
1664
|
+
this.graph.hideItem(child.id, { disableAnimate: false });
|
|
1478
1665
|
});
|
|
1479
1666
|
}
|
|
1480
1667
|
relatedEdges = relatedEdges.concat(graphCore.getRelatedEdges(child.id));
|
|
@@ -1658,9 +1845,8 @@ export class ItemController {
|
|
|
1658
1845
|
undefined,
|
|
1659
1846
|
!animate,
|
|
1660
1847
|
(model, canceled) => {
|
|
1661
|
-
this.graph.hideItem(model.id, canceled);
|
|
1848
|
+
this.graph.hideItem(model.id, { disableAnimate: canceled });
|
|
1662
1849
|
},
|
|
1663
|
-
undefined,
|
|
1664
1850
|
);
|
|
1665
1851
|
}
|
|
1666
1852
|
|
|
@@ -1707,7 +1893,7 @@ export class ItemController {
|
|
|
1707
1893
|
allNodeIds = allNodeIds.concat(nodeIds.filter((id) => id !== root.id));
|
|
1708
1894
|
});
|
|
1709
1895
|
const ids = uniq(allNodeIds.concat(allEdgeIds));
|
|
1710
|
-
this.graph.showItem(ids, !animate);
|
|
1896
|
+
this.graph.showItem(ids, { disableAnimate: !animate });
|
|
1711
1897
|
await this.graph.layout(undefined, !animate);
|
|
1712
1898
|
}
|
|
1713
1899
|
}
|
|
@@ -1722,16 +1908,16 @@ const getItemTheme = (
|
|
|
1722
1908
|
| ComboThemeSpecifications,
|
|
1723
1909
|
): {
|
|
1724
1910
|
styles: NodeStyleSet | EdgeStyleSet;
|
|
1725
|
-
|
|
1911
|
+
lodLevels?: LodLevelRanges;
|
|
1726
1912
|
} => {
|
|
1727
|
-
const { styles: themeStyles = [],
|
|
1728
|
-
const
|
|
1913
|
+
const { styles: themeStyles = [], lodLevels } = itemTheme;
|
|
1914
|
+
const formattedLodLevels = formatLodLevels(lodLevels);
|
|
1729
1915
|
if (!dataTypeField) {
|
|
1730
1916
|
// dataType field is not assigned
|
|
1731
1917
|
const styles = isArray(themeStyles)
|
|
1732
1918
|
? themeStyles[0]
|
|
1733
1919
|
: Object.values(themeStyles)[0];
|
|
1734
|
-
return { styles,
|
|
1920
|
+
return { styles, lodLevels: formattedLodLevels };
|
|
1735
1921
|
}
|
|
1736
1922
|
dataTypeSet.add(dataType as string);
|
|
1737
1923
|
let themeStyle;
|
|
@@ -1746,7 +1932,7 @@ const getItemTheme = (
|
|
|
1746
1932
|
}
|
|
1747
1933
|
return {
|
|
1748
1934
|
styles: themeStyle,
|
|
1749
|
-
|
|
1935
|
+
lodLevels: formattedLodLevels,
|
|
1750
1936
|
};
|
|
1751
1937
|
};
|
|
1752
1938
|
|