|
@@ -25,8 +25,8 @@
|
|
|
|
|
|
import { SBaseEditScene, SBasePipe, SBaseEquipment } from "@persagy-web/big-edit";
|
|
|
import { SGraphEdit } from "@persagy-web/edit";
|
|
|
-import { SMouseEvent } from "@persagy-web/base/lib";
|
|
|
-import { SGraphAddCommand, SGraphItem, SGraphMoveCommand, SGraphPropertyCommand, SGraphSelectContainer, SLineStyle } from "@persagy-web/graph";
|
|
|
+import { SMouseEvent, SObject } from "@persagy-web/base/lib";
|
|
|
+import { SGraphAddCommand, SGraphGroupMoveCommand, SGraphItem, SGraphMoveCommand, SGraphPropertyCommand, SGraphSelectContainer, SLineStyle } from "@persagy-web/graph";
|
|
|
import { rgbaNum } from "@persagy-web/big-edit/lib/until";
|
|
|
// 引入命令
|
|
|
import { SColor, SFont, SArrowStyleType, SPoint } from '@persagy-web/draw/lib';
|
|
@@ -57,6 +57,8 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
super()
|
|
|
// 选择绑定选额item事件
|
|
|
this.selectContainer.connect("listChange", this, this.listChange);
|
|
|
+ this.selectContainer.connect("groupMove", this, this.groupMove);
|
|
|
+ this.undoStack.connect("cmdListChange", this, this.stackChange)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -560,13 +562,43 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
*/
|
|
|
addItem(item: SGraphItem): void {
|
|
|
super.addItem(item);
|
|
|
- item.connect('onMove', this, this.onItemMove.bind(this));
|
|
|
+ if (!(item instanceof SGraphSelectContainer)) {
|
|
|
+ item.connect('moveEnd', this, this.onItemMove.bind(this));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加移动命令到命令栈
|
|
|
*/
|
|
|
- onItemMove(item: SGraphItem, arg: SPoint[]) {
|
|
|
+ onItemMove(item: SGraphItem, arg: SPoint[]): void {
|
|
|
this.undoStack.push(new SGraphMoveCommand(this, item, arg[0], arg[1]));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 接收选择器抛出的批量移动的事件
|
|
|
+ *
|
|
|
+ * @param sender 事件发送者
|
|
|
+ * @param args 返回的参数
|
|
|
+ */
|
|
|
+ groupMove(sender: SGraphItem, args: []): void {
|
|
|
+ if (args.length > 2) {
|
|
|
+ // @ts-ignore
|
|
|
+ const itemList = args[0] as SGraphItem[];
|
|
|
+ // @ts-ignore
|
|
|
+ const oldList = args[1] as SPoint[];
|
|
|
+ // @ts-ignore
|
|
|
+ const newList = args[2] as SPoint[];
|
|
|
+ this.undoStack.push(new SGraphGroupMoveCommand(this, itemList, oldList, newList))
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 命令栈当前命令索引发生变化
|
|
|
+ *
|
|
|
+ * @param sender 事件发送者
|
|
|
+ */
|
|
|
+ stackChange(sender: SObject): void {
|
|
|
+ this.selectContainer.getSize()
|
|
|
+ }
|
|
|
}
|