Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ add excludeHiddenNodes for manhattan router #1400

Merged
merged 1 commit into from
Oct 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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