Skip to content

Commit 672264b

Browse files
committed
🐛 向右自动树形布局时,根节点不再移动
1 parent 7dd819e commit 672264b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/src/core/service/controlService/autoLayoutEngine/autoLayoutFastTreeMode.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Rectangle } from "../../../dataStruct/shape/Rectangle";
88
import { Vector } from "../../../dataStruct/Vector";
99
import { GraphMethods } from "../../../stage/stageManager/basicMethods/GraphMethods";
1010
import { StageEntityMoveManager } from "../../../stage/stageManager/concreteMethods/StageEntityMoveManager";
11+
import { StageManager } from "../../../stage/stageManager/StageManager";
1112
import { ConnectableEntity } from "../../../stage/stageObject/abstract/ConnectableEntity";
1213
export namespace AutoLayoutFastTree {
1314
/**
@@ -102,6 +103,8 @@ export namespace AutoLayoutFastTree {
102103
* @param rootNode
103104
*/
104105
export function autoLayoutFastTreeModeRight(rootNode: ConnectableEntity) {
106+
const initLocation = rootNode.collisionBox.getRectangle().leftTop.clone();
107+
105108
const dfs = (node: ConnectableEntity) => {
106109
const childList = GraphMethods.nodeChildrenArray(node);
107110
for (const child of childList) {
@@ -114,5 +117,11 @@ export namespace AutoLayoutFastTree {
114117
};
115118

116119
dfs(rootNode);
120+
// rootNode.moveTo(initLocation);
121+
const delta = initLocation.subtract(rootNode.collisionBox.getRectangle().leftTop);
122+
// 选中根节点
123+
StageManager.clearSelectAll();
124+
rootNode.isSelected = true;
125+
StageManager.moveConnectableEntitiesWithChildren(delta);
117126
}
118127
}

0 commit comments

Comments
 (0)