Skip to content

Commit 0e5e3e4

Browse files
committed
🚸 增加宏观视野下拖拽巨大框的便携性,仅需点击或拖拽含有巨大化标题的框内部空白区域即可选择该框。
1 parent 0355b36 commit 0e5e3e4

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

app/src/core/service/controlService/controller/concrete/ControllerEntityClickSelectAndMove.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { RectangleNoteEffect } from "../../../feedbackService/effectEngine/concr
1010
import { RectangleRenderEffect } from "../../../feedbackService/effectEngine/concrete/RectangleRenderEffect";
1111
import { Controller } from "../Controller";
1212
import { ControllerClass } from "../ControllerClass";
13+
import { getClickedStageObject } from "./utilsControl";
1314

1415
/**
1516
* 拖拽节点使其移动的控制器
@@ -31,7 +32,8 @@ class ControllerEntityClickSelectAndMoveClass extends ControllerClass {
3132

3233
const pressWorldLocation = Renderer.transformView2World(this.mouseDownViewLocation);
3334
this.lastMoveLocation = pressWorldLocation.clone();
34-
const clickedEntity = StageManager.findEntityByLocation(pressWorldLocation);
35+
36+
const clickedEntity = getClickedStageObject(pressWorldLocation);
3537

3638
// 防止跳跃式移动的时候改变选中内容
3739
if (Controller.pressingKeySet.has("alt")) {

app/src/core/service/controlService/controller/concrete/ControllerRectangleSelect.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { StageObject } from "../../../../stage/stageObject/abstract/StageObject"
88
import { Section } from "../../../../stage/stageObject/entity/Section";
99
import { Controller } from "../Controller";
1010
import { ControllerClass } from "../ControllerClass";
11+
import { getClickedStageObject } from "./utilsControl";
1112

1213
class ControllerRectangleSelectClass extends ControllerClass {
1314
/**
@@ -54,10 +55,7 @@ class ControllerRectangleSelectClass extends ControllerClass {
5455
}
5556
const pressWorldLocation = Renderer.transformView2World(new Vector(event.clientX, event.clientY));
5657

57-
if (
58-
StageManager.isEntityOnLocation(pressWorldLocation) ||
59-
StageManager.isAssociationOnLocation(pressWorldLocation)
60-
) {
58+
if (getClickedStageObject(pressWorldLocation) !== null) {
6159
// 不是点击在空白处
6260
return;
6361
}

app/src/core/service/controlService/controller/concrete/utilsControl.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { StageNodeAdder } from "../../../../stage/stageManager/concreteMethods/s
1010
import { StageHistoryManager } from "../../../../stage/stageManager/StageHistoryManager";
1111
import { StageManager } from "../../../../stage/stageManager/StageManager";
1212
import { Entity } from "../../../../stage/stageObject/abstract/StageEntity";
13+
import { StageObject } from "../../../../stage/stageObject/abstract/StageObject";
1314
import { LineEdge } from "../../../../stage/stageObject/association/LineEdge";
1415
import { PortalNode } from "../../../../stage/stageObject/entity/PortalNode";
1516
import { Section } from "../../../../stage/stageObject/entity/Section";
@@ -239,3 +240,32 @@ function textNodeInEditModeByUUID(uuid: string) {
239240
editTextNode(createNode);
240241
}
241242
}
243+
244+
/**
245+
* 检测鼠标是否点击到了某个stage对象上
246+
* @param clickedLocation
247+
*/
248+
export function getClickedStageObject(clickedLocation: Vector) {
249+
let clickedStageObject: StageObject | null = StageManager.findEntityByLocation(clickedLocation);
250+
// 补充:在宏观视野下,框应该被很轻松的点击
251+
if (clickedStageObject === null && Camera.currentScale < Section.bigTitleCameraScale) {
252+
const clickedSections = SectionMethods.getSectionsByInnerLocation(clickedLocation);
253+
if (clickedSections.length > 0) {
254+
clickedStageObject = clickedSections[0];
255+
}
256+
}
257+
if (clickedStageObject === null) {
258+
for (const association of StageManager.getAssociations()) {
259+
if (association instanceof LineEdge) {
260+
if (association.target.isHiddenBySectionCollapse && association.source.isHiddenBySectionCollapse) {
261+
continue;
262+
}
263+
}
264+
if (association.collisionBox.isContainsPoint(clickedLocation)) {
265+
clickedStageObject = association;
266+
break;
267+
}
268+
}
269+
}
270+
return clickedStageObject;
271+
}

0 commit comments

Comments
 (0)