@@ -3,6 +3,7 @@ import { Line } from "../../../dataStruct/shape/Line";
33import { Vector } from "../../../dataStruct/Vector" ;
44import { Camera } from "../../../stage/Camera" ;
55import { Stage } from "../../../stage/Stage" ;
6+ import { StageObjectSelectCounter } from "../../../stage/stageManager/concreteMethods/StageObjectSelectCounter" ;
67import { StageManager } from "../../../stage/stageManager/StageManager" ;
78import { ConnectableEntity } from "../../../stage/stageObject/abstract/ConnectableEntity" ;
89import { LineCuttingEffect } from "../../feedbackService/effectEngine/concrete/LineCuttingEffect" ;
@@ -35,25 +36,37 @@ export namespace SelectChangeEngine {
3536 }
3637 return ;
3738 }
38- let newSelectedNode : ConnectableEntity | null = null ;
39+ let newSelectedConnectableEntity : ConnectableEntity | null = null ;
3940 const selectedNodeRect = selectedNode . collisionBox . getRectangle ( ) ;
4041 if ( key === "arrowup" ) {
4142 // 在节点上方查找所有节点,并选中距离上方最近的一个
42- newSelectedNode = getMostNearNode ( collectTopNodes ( selectedNode ) , selectedNodeRect . center ) ;
43+ newSelectedConnectableEntity = getMostNearConnectableEntity (
44+ collectTopNodes ( selectedNode ) ,
45+ selectedNodeRect . center ,
46+ ) ;
4347 } else if ( key === "arrowdown" ) {
4448 // 在节点下方查找所有节点,并选中距离下方最近的一个
45- newSelectedNode = getMostNearNode ( collectBottomNodes ( selectedNode ) , selectedNodeRect . center ) ;
49+ newSelectedConnectableEntity = getMostNearConnectableEntity (
50+ collectBottomNodes ( selectedNode ) ,
51+ selectedNodeRect . center ,
52+ ) ;
4653 } else if ( key === "arrowleft" ) {
4754 // 在节点左侧查找所有节点,并选中距离左侧最近的一个
48- newSelectedNode = getMostNearNode ( collectLeftNodes ( selectedNode ) , selectedNodeRect . center ) ;
55+ newSelectedConnectableEntity = getMostNearConnectableEntity (
56+ collectLeftNodes ( selectedNode ) ,
57+ selectedNodeRect . center ,
58+ ) ;
4959 } else if ( key === "arrowright" ) {
5060 // 在节点右侧查找所有节点,并选中距离右侧最近的一个
51- newSelectedNode = getMostNearNode ( collectRightNodes ( selectedNode ) , selectedNodeRect . center ) ;
61+ newSelectedConnectableEntity = getMostNearConnectableEntity (
62+ collectRightNodes ( selectedNode ) ,
63+ selectedNodeRect . center ,
64+ ) ;
5265 }
53- if ( newSelectedNode ) {
66+ if ( newSelectedConnectableEntity ) {
5467 selectedNode . isSelected = false ;
55- newSelectedNode . isSelected = true ;
56- const newSelectNodeRect = newSelectedNode . collisionBox . getRectangle ( ) ;
68+ newSelectedConnectableEntity . isSelected = true ;
69+ const newSelectNodeRect = newSelectedConnectableEntity . collisionBox . getRectangle ( ) ;
5770 const color = StageStyleManager . currentStyle . effects . successShadow ;
5871
5972 if ( Camera . cameraFollowsSelectedNodeOnArrowKeys ) {
@@ -97,10 +110,13 @@ export namespace SelectChangeEngine {
97110 color ,
98111 ) ,
99112 ] ) ;
113+
114+ // 更新选中内容的数量
115+ StageObjectSelectCounter . update ( ) ;
100116 }
101117 }
102118
103- function getMostNearNode ( nodes : ConnectableEntity [ ] , location : Vector ) : ConnectableEntity | null {
119+ function getMostNearConnectableEntity ( nodes : ConnectableEntity [ ] , location : Vector ) : ConnectableEntity | null {
104120 if ( nodes . length === 0 ) return null ;
105121 let currentMinDistance = Infinity ;
106122 let currentNearestNode : ConnectableEntity | null = null ;
0 commit comments