Skip to content

Commit c76a23b

Browse files
authored
fix: add excludeShapes options for manhattan router (#3334)
1 parent 2285e55 commit c76a23b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

packages/x6/src/registry/router/manhattan/obstacle-map.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,18 @@ export class ObstacleMap {
7474
const excludedTerminal = excludedTerminals.some(
7575
(cell) => cell.id === node.id,
7676
)
77+
const excludedShape = node.shape
78+
? options.excludeShapes.includes(node.shape)
79+
: false
7780
const excludedNode = options.excludeNodes.some((item) => {
7881
if (typeof item === 'string') {
7982
return node.id === item
8083
}
8184
return item === node
8285
})
8386
const excludedAncestor = excludedAncestors.includes(node.id)
84-
const excluded = excludedTerminal || excludedNode || excludedAncestor
87+
const excluded =
88+
excludedShape || excludedTerminal || excludedNode || excludedAncestor
8589

8690
if (!excluded) {
8791
const bbox = node.getBBox().moveAndExpand(options.paddingBox)

packages/x6/src/registry/router/manhattan/options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export interface ResolvedOptions {
4646
*/
4747
excludeNodes: (Node | string)[]
4848

49+
/**
50+
* Should certain types of nodes not be considered as obstacles?
51+
*/
52+
excludeShapes: string[]
53+
4954
/**
5055
* Possible starting directions from a node.
5156
*/
@@ -139,6 +144,7 @@ export const defaults: ManhattanRouterOptions = {
139144
perpendicular: true,
140145
excludeTerminals: [],
141146
excludeNodes: [],
147+
excludeShapes: [],
142148
startDirections: ['top', 'right', 'bottom', 'left'],
143149
endDirections: ['top', 'right', 'bottom', 'left'],
144150
directionMap: {

sites/x6-sites/docs/api/registry/router.zh.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ graph.addEdge({
170170
| excludeTerminals | ('source' \| 'target')[] || `[]` | 忽略起始或终止节点,忽略后不参与障碍物计算。 |
171171
| excludeShapes | string[] || `[]` | 忽略指定形状的节点,忽略后不参与障碍物计算。 |
172172
| excludeNodes | Node[] || `[]` | 忽略的节点,忽略后不参与障碍物计算。 |
173-
| excludeHiddenNodes | boolean || `false` | 忽略隐藏的节点,忽略后不参与障碍物计算。 |
174173
| startDirections | string[] || `['top', 'right', 'bottom', 'left']` | 支持从哪些方向开始路由。 |
175174
| endDirections | string[] || `['top', 'right', 'bottom', 'left']` | 支持从哪些方向结束路由。 |
176175
| padding | SideOptions || 20 | 设置锚点距离转角的最小距离,和 orth 路由配置一致。 |

0 commit comments

Comments
 (0)