Sfoglia il codice sorgente

item增加处理 移动后原点处理

haojianlong 5 anni fa
parent
commit
893031fbf7

+ 2 - 2
saga-web-big/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.45",
+    "version": "1.0.46",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -42,6 +42,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/graph": "2.1.88"
+        "@saga-web/graph": "2.1.90"
     }
 }

+ 22 - 2
saga-web-big/src/items/SLineItem.ts

@@ -200,7 +200,7 @@ export class SLineItem extends SGraphItem {
         this.curPoint = null;
         if (event.buttons == SMouseButton.LeftButton) {
             if (this.status == SItemStatus.Normal) {
-                return false;
+                return super.onMouseDown(event);
             } else if (this.status == SItemStatus.Edit) {
                 // 判断是否点击到端点上(获取端点索引值)
                 this.findNearestPoint(new SPoint(event.x, event.y));
@@ -232,6 +232,9 @@ export class SLineItem extends SGraphItem {
                     this.curIndex
                 ]);
             }
+        } else if (this.status == SItemStatus.Normal) {
+            this.moveToOrigin(this.x, this.y);
+            return super.onMouseUp(event);
         }
         this.curIndex = -1;
         this.curPoint = null;
@@ -255,7 +258,7 @@ export class SLineItem extends SGraphItem {
                 this.line[this.curIndex].y = event.y;
             }
         } else {
-            return false;
+            return super.onMouseMove(event);
         }
         this.update();
         return true;
@@ -298,6 +301,23 @@ export class SLineItem extends SGraphItem {
     } // Function recordAction()
 
     /**
+     * 移动后处理所有坐标,并肩原点置为场景原点
+     *
+     * @param   x   x坐标
+     * @param   y   y坐标
+     * */
+    moveToOrigin(x: number, y: number): void {
+        super.moveToOrigin(x, y);
+        this.line = this.line.map(t => {
+            t.x = t.x + x;
+            t.y = t.y + y;
+            return t;
+        });
+        this.x = 0;
+        this.y = 0;
+    } // Function moveToOrigin()
+
+    /**
      * 判断点是否在区域内
      *
      * @param   x

+ 18 - 2
saga-web-big/src/items/SPolygonItem.ts

@@ -642,18 +642,35 @@ export class SPolygonItem extends SGraphItem {
                 ]);
             }
         } else if (this.status == SItemStatus.Normal) {
+            this.moveToOrigin(this.x, this.y);
             return super.onMouseUp(event);
         }
         return true;
     } // Function onMouseUp()
 
     /**
+     * 移动后处理所有坐标,并肩原点置为场景原点
+     *
+     * @param   x   x坐标
+     * @param   y   y坐标
+     * */
+    moveToOrigin(x: number, y: number): void {
+        super.moveToOrigin(x, y);
+        this.pointList = this.pointList.map(t => {
+            t.x = t.x + x;
+            t.y = t.y + y;
+            return t;
+        });
+        this.x = 0;
+        this.y = 0;
+    } // Function moveToOrigin()
+
+    /**
      * 适配事件
      *
      * @param	event         事件参数
      * @return	boolean
      */
-
     onResize(event: SMouseEvent): boolean {
         return true;
     } // Function onResize()
@@ -661,7 +678,6 @@ export class SPolygonItem extends SGraphItem {
     /**
      * 取消操作
      *
-     * @param   painter       painter对象
      */
     cancelOperate(): void {
         // 当状态为展示状态

+ 18 - 0
saga-web-big/src/items/SPolylineItem.ts

@@ -243,6 +243,7 @@ export class SPolylineItem extends SGraphItem {
                 ]);
             }
         } else if (this.status == SItemStatus.Normal) {
+            this.moveToOrigin(this.x, this.y);
             return super.onMouseUp(event);
         }
         return true;
@@ -289,6 +290,23 @@ export class SPolylineItem extends SGraphItem {
     } // Function onKeyUp()
 
     /**
+     * 移动后处理所有坐标,并肩原点置为场景原点
+     *
+     * @param   x   x坐标
+     * @param   y   y坐标
+     * */
+    moveToOrigin(x: number, y: number): void {
+        super.moveToOrigin(x, y);
+        this.pointList = this.pointList.map(t => {
+            t.x = t.x + x;
+            t.y = t.y + y;
+            return t;
+        });
+        this.x = 0;
+        this.y = 0;
+    } // Function moveToOrigin()
+
+    /**
      * 获取点击点与点集中距离最近点
      *
      * @param   p   鼠标点击点

+ 1 - 1
saga-web-graph/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.89",
+    "version": "2.1.90",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 1 - 1
saga-web-graph/src/items/STextItem.ts

@@ -111,7 +111,7 @@ export class STextItem extends SObjectItem {
      * @param   y   y坐标
      * */
     moveToOrigin(x: number, y: number): void {
-        this.moveTo(x, y);
+        this.moveTo(this.x + x, this.y + y);
     } // Function moveToOrigin()
 
     /**