Skip to content

Commit

Permalink
feat: ✨ add excludeHiddenNodes for manhattan router (#1400)
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector authored Oct 2, 2021
1 parent 8a3c439 commit 28a472a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/x6/src/registry/router/manhattan/obstacle-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export class ObstacleMap {
const excType = shape ? excludeShapes.includes(shape) : false
const excTerminal = excludedTerminals.some((cell) => cell.id === node.id)
const excAncestor = excludedAncestors.includes(node.id)
const excluded = excType || excTerminal || excAncestor
const excHidden = options.excludeHiddenNodes && !node.isVisible()
const excluded = excType || excTerminal || excAncestor || excHidden

if (!excluded) {
const bbox = node.getBBox().moveAndExpand(options.paddingBox)
Expand Down
6 changes: 6 additions & 0 deletions packages/x6/src/registry/router/manhattan/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export interface ResolvedOptions {
*/
excludeShapes: string[]

/**
* Should certain hidden nodes not be considered as obstacles?
*/
excludeHiddenNodes: boolean

/**
* Possible starting directions from a node.
*/
Expand Down Expand Up @@ -136,6 +141,7 @@ export const defaults: ManhattanRouterOptions = {
perpendicular: true,
excludeTerminals: [],
excludeShapes: [], // ['text']
excludeHiddenNodes: false,
startDirections: ['top', 'right', 'bottom', 'left'],
endDirections: ['top', 'right', 'bottom', 'left'],
directionMap: {
Expand Down
4 changes: 3 additions & 1 deletion sites/x6-sites/docs/api/registry/router.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@ graph.addEdge({
| maximumLoops | number || `2000` | 最大迭代次数,到达最大迭代次数后将使用候补路由。 |
| maxDirectionChange | number || `90` | 最大旋转角度。 |
| excludeTerminals | ('source' \| 'target')[] || `[]` | 忽略起始或终止节点,忽略后不参与障碍物计算。 |
| excludeShapes | string[] || `[]` | 忽略指定节点名的节点,忽略后不参与障碍物计算。 |
| excludeShapes | string[] || `[]` | 忽略指定形状的节点,忽略后不参与障碍物计算。 |
| excludeHiddenNodes | boolean || `false` | 忽略隐藏的节点,忽略后不参与障碍物计算。 |
| startDirections | string[] || `['top', 'right', 'bottom', 'left']` | 支持从哪些方向开始路由。 |
| endDirections | string[] || `['top', 'right', 'bottom', 'left']` | 支持从哪些方向结束路由。 |


例如:

```ts
Expand Down
3 changes: 2 additions & 1 deletion sites/x6-sites/docs/api/registry/router.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ graph.addEdge({
| maximumLoops | number || `2000` | 最大迭代次数,到达最大迭代次数后将使用候补路由。 |
| maxDirectionChange | number || `90` | 最大旋转角度。 |
| excludeTerminals | ('source' \| 'target')[] || `[]` | 忽略起始或终止节点,忽略后不参与障碍物计算。 |
| excludeShapes | string[] || `[]` | 忽略指定节点名的节点,忽略后不参与障碍物计算。 |
| excludeShapes | string[] || `[]` | 忽略指定形状的节点,忽略后不参与障碍物计算。 |
| excludeHiddenNodes | boolean || `false` | 忽略隐藏的节点,忽略后不参与障碍物计算。 |
| startDirections | string[] || `['top', 'right', 'bottom', 'left']` | 支持从哪些方向开始路由。 |
| endDirections | string[] || `['top', 'right', 'bottom', 'left']` | 支持从哪些方向结束路由。 |

Expand Down

0 comments on commit 28a472a

Please sign in to comment.