ソースを参照

修改直线外接矩阵算法

zhangyu 5 年 前
コミット
f285086277
1 ファイル変更22 行追加33 行削除
  1. 22 33
      saga-web-big/src/items/SLineItem.ts

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

@@ -31,7 +31,6 @@ export class SLineItem extends SGraphItem {
     }
     set line(arr: SPoint[]) {
         this._line = arr;
-        this._xyzListToSPointList(arr);
         this.update();
     }
 
@@ -147,7 +146,6 @@ export class SLineItem extends SGraphItem {
             this.releaseItem();
             this.$emit("finishCreated");
         }
-        this._xyzListToSPointList(this.line);
         this.update();
     } // Function addPoint()
 
@@ -241,7 +239,6 @@ export class SLineItem extends SGraphItem {
         } else {
             return super.onMouseMove(event);
         }
-        this._xyzListToSPointList(this.line);
         this.update();
         return true;
     } // Function onMouseMove()
@@ -272,36 +269,6 @@ export class SLineItem extends SGraphItem {
     } // Function findNearestPoint()
 
     /**
-     * xyz数据转换为SPoint格式函数;获取外接矩阵参数
-     *
-     * @param arr    外层传入的数据PointList
-     */
-    protected _xyzListToSPointList(arr: SPoint[]): void {
-        if (arr.length) {
-            this.minX = Number.MAX_SAFE_INTEGER;
-            this.maxX = Number.MIN_SAFE_INTEGER;
-            this.minY = Number.MAX_SAFE_INTEGER;
-            this.maxY = Number.MIN_SAFE_INTEGER;
-            arr.forEach(it => {
-                let x = it.x,
-                    y = it.y;
-                if (x < this.minX) {
-                    this.minX = x;
-                }
-                if (y < this.minY) {
-                    this.minY = y;
-                }
-                if (x > this.maxX) {
-                    this.maxX = x;
-                }
-                if (y > this.maxY) {
-                    this.maxY = y;
-                }
-            });
-        }
-    }
-
-    /**
      * 记录相关动作并推入栈中
      *
      * @param	SGraphCommand   相关命令类
@@ -379,6 +346,28 @@ export class SLineItem extends SGraphItem {
      * @return	SRect
      */
     boundingRect(): SRect {
+        if (this.line.length) {
+            this.minX = this.line[0].x;
+            this.maxX = this.line[0].x;
+            this.minY = this.line[0].y;
+            this.maxY = this.line[0].y;
+            this.line.forEach(it => {
+                let x = it.x,
+                    y = it.y;
+                if (x < this.minX) {
+                    this.minX = x;
+                }
+                if (y < this.minY) {
+                    this.minY = y;
+                }
+                if (x > this.maxX) {
+                    this.maxX = x;
+                }
+                if (y > this.maxY) {
+                    this.maxY = y;
+                }
+            });
+        }
         return new SRect(
             this.minX,
             this.minY,