Parcourir la source

移动命令 撤销重做

haojianlong il y a 3 ans
Parent
commit
a28cda13e7
2 fichiers modifiés avec 42 ajouts et 10 suppressions
  1. 6 6
      package.json
  2. 36 4
      src/components/editClass/persagy-edit/PTopoScene.ts

+ 6 - 6
package.json

@@ -15,12 +15,12 @@
     "publish": "node publish.js"
   },
   "dependencies": {
-    "@persagy-web/base": "2.2.1",
-    "@persagy-web/big": "2.2.58",
-    "@persagy-web/draw": "2.2.14",
-    "@persagy-web/graph": "2.2.49",
-    "@persagy-web/big-edit": "2.2.38",
-    "@persagy-web/edit": "2.2.31",
+    "@persagy-web/base": "2.2.2",
+    "@persagy-web/big": "2.2.61",
+    "@persagy-web/draw": "2.2.17",
+    "@persagy-web/graph": "2.2.52",
+    "@persagy-web/big-edit": "2.2.41",
+    "@persagy-web/edit": "2.2.34",
     "@types/uuid": "^8.0.0",
     "ant-design-vue": "^1.6.5",
     "axios": "^0.20.0",

+ 36 - 4
src/components/editClass/persagy-edit/PTopoScene.ts

@@ -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()
+    }
 }