Browse Source

Merge branch 'master' of http://39.106.8.246:3003/web/persagy-web

YaolongHan 4 years ago
parent
commit
f0cc1cfe6e
32 changed files with 616 additions and 473 deletions
  1. 6 0
      persagy-web-big/README.md
  2. 2 2
      persagy-web-big/package.json
  3. 26 10
      persagy-web-big/src/index.ts
  4. 2 2
      persagy-web-big/src/items/floor/SHighlightItem.ts
  5. 3 3
      persagy-web-big/src/items/SEquipItem.ts
  6. 3 3
      persagy-web-big/src/items/SPipeItem.ts
  7. 0 0
      persagy-web-big/src/items/floor/SZoneItem.ts
  8. 3 3
      persagy-web-big/src/items/SIconTextItem.ts
  9. 2 2
      persagy-web-big/src/items/SArrowItem.ts
  10. 2 2
      persagy-web-big/src/items/SArrowPoly.ts
  11. 0 0
      persagy-web-big/src/items/shape/SCircleCornerPolylineItem.ts
  12. 3 3
      persagy-web-big/src/items/SLineItem.ts
  13. 16 15
      persagy-web-big/src/items/SPolygonItem.ts
  14. 7 45
      persagy-web-big/src/items/SPolylineItem.ts
  15. 7 6
      persagy-web-big/src/utils/SMathUtil.ts
  16. 8 2
      persagy-web-big/src/utils/getJsonz.ts
  17. 4 3
      persagy-web-big/src/utils/unzip.ts
  18. 3 0
      persagy-web-draw/README.md
  19. 1 1
      persagy-web-draw/package.json
  20. 1 1
      persagy-web-draw/src/engines/SCanvasPaintEngine.ts
  21. 10 8
      persagy-web-edit/src/commands/SGraphAddListCommand.ts
  22. 15 7
      persagy-web-edit/src/commands/SGraphDeleteListCommand.ts
  23. 1 0
      persagy-web-edit/src/commands/SGraphMoveCommand.ts
  24. 5 0
      persagy-web-edit/src/commands/SGraphPointListDelete.ts
  25. 4 0
      persagy-web-edit/src/commands/SGraphPointListInsert.ts
  26. 362 303
      persagy-web-edit/src/items/SBaseArrowEdit.ts
  27. 27 2
      persagy-web-edit/src/items/SBaseCircleEdit.ts
  28. 44 5
      persagy-web-edit/src/items/SBaseCirclePolylineEdit.ts
  29. 20 19
      persagy-web-edit/src/items/SBasePolygonEdit.ts
  30. 26 24
      persagy-web-edit/src/items/SBasePolylineEdit.ts
  31. 2 2
      persagy-web-graph/package.json
  32. 1 0
      persagy-web-graph/src/types/SGraphRect.ts

+ 6 - 0
persagy-web-big/README.md

@@ -6,6 +6,12 @@ item 展示类及楼层平面图展示
     无特殊说明单版本为跟随依赖版本升级
     |
     |
+    |-- 2.2.51 | -- 获取json文件和解压工具增加传参,是否返回的是原始数据
+    |
+    |
+    |-- 2.2.50 | -- 数学计算工具类 计算数组中每一项的交集,并返回外轮廓与内轮廓 算法修改
+    |
+    |
     |-- 2.2.48 | -- 修改门画法
     |
     |

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

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/big",
-    "version": "2.2.48",
+    "version": "2.2.51",
     "description": "博锐尚格建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -41,7 +41,7 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@persagy-web/graph": "2.2.44",
+        "@persagy-web/graph": "2.2.45",
         "axios": "^0.18.0",
         "pako": "^1.0.10",
         "crypto-js": "^4.0.0",

+ 26 - 10
persagy-web-big/src/index.ts

@@ -33,28 +33,36 @@ import { SItemFactory } from "./factories/SItemFactory";
 import { SZoneParser } from "./parser/SZoneParser";
 import { SFloorParser } from "./parser/SFloorParser";
 import { SParser } from "./parser/SParser";
-import { SIconTextItem } from "./items/SIconTextItem";
-import { SPolylineItem } from "./items/SPolylineItem";
-import { SLineItem } from "./items/SLineItem";
+import { SIconTextItem } from "./items/icon/SIconTextItem";
+import { SPolylineItem } from "./items/shape/SPolylineItem";
+import { SLineItem } from "./items/shape/SLineItem";
 import { SRelationState } from "./enums/SRelationState";
 import { SItemStatus } from "./enums/SItemStatus";
-import { SPolygonItem } from "./items/SPolygonItem";
+import { SPolygonItem } from "./items/shape/SPolygonItem";
 import { SRectSelectItem } from "./items/SRectSelectItem";
 import { SBoardItem } from "./items/floor/SBoardItem";
-import { SArrowItem } from "./items/SArrowItem";
-import { SArrowPoly } from "./items/SArrowPoly";
+import { SArrowItem } from "./items/shape/SArrowItem";
+import { SArrowPoly } from "./items/shape/SArrowPoly";
 import getJsonz from "./utils/getJsonz";
 import unzip from "./utils/unzip";
 import unzipBase64 from "./utils/unzipBase64";
-import { SPipeItem } from "./items/SPipeItem";
-import { SEquipItem } from "./items/SEquipItem";
+import { SPipeItem } from "./items/equip/SPipeItem";
+import { SEquipItem } from "./items/equip/SEquipItem";
 import { SSceneMaskItem } from "./items/SSceneMaskItem";
 import { ElementData } from "./types/ElementData";
 import { Legend } from "./types/Legend";
 import { Marker } from "./types/Marker";
 import { Relation } from "./types/Relation";
-import SCircleCornerPolylineItem from "./items/SCircleCornerPolylineItem";
+import SCircleCornerPolylineItem from "./items/shape/SCircleCornerPolylineItem";
 import SMaskItem from "./items/SMaskItem";
+import { SColumnItem } from "./items/floor/SColumnItem";
+import { SDoorItem } from "./items/floor/SDoorItem";
+import { SSpaceItem } from "./items/floor/SSpaceItem";
+import { SVirtualWallItem } from "./items/floor/SVirtualWallItem";
+import { SWallItem } from "./items/floor/SWallItem";
+import { SWindowItem } from "./items/floor/SWindowItem";
+import { SZoneItem } from "./items/floor/SZoneItem";
+import { SHighlightItem } from "./items/SHighlightItem";
 
 export {
     ElementData,
@@ -87,5 +95,13 @@ export {
     SEquipItem,
     SSceneMaskItem,
     SCircleCornerPolylineItem,
-    SMaskItem
+    SMaskItem,
+    SColumnItem,
+    SDoorItem,
+    SSpaceItem,
+    SVirtualWallItem,
+    SWallItem,
+    SWindowItem,
+    SZoneItem,
+    SHighlightItem,
 };

+ 2 - 2
persagy-web-big/src/items/floor/SHighlightItem.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -25,7 +25,7 @@
  */
 
 import { SColor, SLine, SPainter, SPoint, SRect } from "@persagy-web/draw";
-import { ItemOrder, ItemColor } from "../..";
+import { ItemOrder, ItemColor } from "../index";
 import { SGraphItem } from "@persagy-web/graph";
 
 /**

+ 3 - 3
persagy-web-big/src/items/SEquipItem.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2016-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -27,8 +27,8 @@
 import { SGraphItem } from "@persagy-web/graph/lib";
 import { STextItem } from "@persagy-web/graph";
 import { SColor } from "@persagy-web/draw/lib";
-import { SIconTextItem } from "./SIconTextItem";
-import { svgTobase64 } from "../utils/svgTobase64";
+import { SIconTextItem } from "../icon/SIconTextItem";
+import { svgTobase64 } from "../../utils/svgTobase64";
 
 /**
  * 编辑基础设备类

+ 3 - 3
persagy-web-big/src/items/SPipeItem.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2016-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -28,8 +28,8 @@ import { SGraphItem, SAnchorItem } from "@persagy-web/graph/lib/";
 import { SMouseEvent } from "@persagy-web/base/lib";
 import { SPoint, SColor } from "@persagy-web/draw";
 import { SLineStyle } from "@persagy-web/graph/";
-import { SPolylineItem } from "./SPolylineItem";
-import { SRelation } from "../enums/SRelation";
+import { SPolylineItem } from "../shape/SPolylineItem";
+import { SRelation } from "../../enums/SRelation";
 
 /**
  * 编辑基础管道

persagy-web-big/src/items/floor/ZoneItem.ts → persagy-web-big/src/items/floor/SZoneItem.ts


+ 3 - 3
persagy-web-big/src/items/SIconTextItem.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -31,7 +31,7 @@ import {
     SAnchorItem,
     SGraphItem
 } from "@persagy-web/graph";
-import { SItemStatus, ItemOrder } from "..";
+import { SItemStatus, ItemOrder } from "../../index";
 import { SMouseEvent } from "@persagy-web/base";
 import {
     SSize,
@@ -41,7 +41,7 @@ import {
     SFont,
     SPoint
 } from "@persagy-web/draw";
-import { Anchor } from "../types/topology/Anchor";
+import { Anchor } from "../../types/topology/Anchor";
 
 /**
  * 图例 item

+ 2 - 2
persagy-web-big/src/items/SArrowItem.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -25,7 +25,7 @@
  */
 
 import { SPainter, SArrowStyleType } from "@persagy-web/draw";
-import { SPolylineItem } from "..";
+import { SPolylineItem } from "../../index";
 import { SLineStyle } from "@persagy-web/graph";
 
 /**

+ 2 - 2
persagy-web-big/src/items/SArrowPoly.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -27,7 +27,7 @@
 import { SLineItem } from "./SLineItem";
 import { SColor, SLine, SPainter, SPoint } from "@persagy-web/draw";
 import { SMathUtil } from "@persagy-web/graph/lib/utils/SMathUtil";
-import { SItemStatus } from "..";
+import { SItemStatus } from "../../index";
 
 /**
  * 箭头多边形类型

persagy-web-big/src/items/SCircleCornerPolylineItem.ts → persagy-web-big/src/items/shape/SCircleCornerPolylineItem.ts


+ 3 - 3
persagy-web-big/src/items/SLineItem.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -26,8 +26,8 @@
 
 import { SColor, SLine, SPainter, SPoint, SRect } from "@persagy-web/draw";
 import { SMouseButton, SMouseEvent, SUndoStack } from "@persagy-web/base";
-import { SMathUtil } from "../utils/SMathUtil";
-import { SItemStatus } from "..";
+import { SMathUtil } from "../../utils/SMathUtil";
+import { SItemStatus } from "../../index";
 import {
     SGraphItem,
     SGraphPointListInsert,

+ 16 - 15
persagy-web-big/src/items/SPolygonItem.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -40,8 +40,8 @@ import {
     SPolygonUtil,
     SRect
 } from "@persagy-web/draw";
-import { SItemStatus } from "..";
-import { SMathUtil } from "../utils/SMathUtil";
+import { SItemStatus } from "../../index";
+import { SMathUtil } from "../../utils/SMathUtil";
 import { SGraphStyleItem } from "@persagy-web/graph/lib";
 
 /**
@@ -92,8 +92,8 @@ export class SPolygonItem extends SGraphStyleItem {
     /** 灵敏像素 */
     private len: number = 10;
     /** 场景像素 内部将灵敏像素换算为场景实际距离 */
-    private scenceLen: number = 15;
-    /** 场景像素 */
+    private sceneLen: number = 15;
+    /** shift键是否按下 */
     private isAlt: boolean = false;
     /** undo/redo 堆栈 */
     protected undoStack: SUndoStack = new SUndoStack();
@@ -265,7 +265,7 @@ export class SPolygonItem extends SGraphStyleItem {
                         this.lastPoint.y,
                         this.pointList[0].x,
                         this.pointList[0].y
-                    ) < this.scenceLen
+                    ) < this.sceneLen
                 ) {
                     // 绘制第一个点的顶点块
                     painter.pen.color = SColor.Black;
@@ -318,7 +318,7 @@ export class SPolygonItem extends SGraphStyleItem {
         if (this.isAlt) {
             // 1 判断是否点击在多边形顶点
             let lenIndex = -1; // 当前点击到的点位索引;
-            let curenLen = this.scenceLen; // 当前的灵敏度
+            let curLen = this.sceneLen; // 当前的灵敏度
             this.pointList.forEach((item, index): void => {
                 let dis = SMathUtil.pointDistance(
                     event.x,
@@ -326,8 +326,8 @@ export class SPolygonItem extends SGraphStyleItem {
                     item.x,
                     item.y
                 );
-                if (dis < curenLen) {
-                    curenLen = dis;
+                if (dis < curLen) {
+                    curLen = dis;
                     lenIndex = index;
                 }
             });
@@ -354,7 +354,7 @@ export class SPolygonItem extends SGraphStyleItem {
             this.curIndex = -1;
             this.curPoint = null;
             let lenIndex = -1; // 当前点击到的点位索引;
-            let curenLen = this.scenceLen; // 当前的灵敏度
+            let curLen = this.sceneLen; // 当前的灵敏度
             this.pointList.forEach((item, index): void => {
                 let dis = SMathUtil.pointDistance(
                     event.x,
@@ -362,8 +362,8 @@ export class SPolygonItem extends SGraphStyleItem {
                     item.x,
                     item.y
                 );
-                if (dis < curenLen) {
-                    curenLen = dis;
+                if (dis < curLen) {
+                    curLen = dis;
                     lenIndex = index;
                 }
             });
@@ -398,7 +398,7 @@ export class SPolygonItem extends SGraphStyleItem {
                 // 判断是否有点
                 if (len.Point) {
                     // 点在了多边形的边上
-                    if (len.MinDis <= this.scenceLen) {
+                    if (len.MinDis <= this.sceneLen) {
                         this.pointList.splice(index + 1, 0, len.Point);
                         // 记录新增顶点操作记录压入堆栈
                         this.recordAction(SGraphPointListInsert, [
@@ -576,7 +576,8 @@ export class SPolygonItem extends SGraphStyleItem {
             this.pointList.forEach((it): void => {
                 let x = it.x,
                     y = it.y;
-                if (x < this.minX) {this.minX = x;
+                if (x < this.minX) {
+                    this.minX = x;
                 }
 
                 if (y < this.minY) {
@@ -624,7 +625,7 @@ export class SPolygonItem extends SGraphStyleItem {
      * @param painter   绘制对象
      */
     onDraw(painter: SPainter): void {
-        this.scenceLen = painter.toPx(this.len);
+        this.sceneLen = painter.toPx(this.len);
         // 当状态为展示状态
         if (this.status == SItemStatus.Normal) {
             // 闭合多边形

+ 7 - 45
persagy-web-big/src/items/SPolylineItem.ts

@@ -17,7 +17,7 @@
  *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
  *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
  *      .:R888888I
- *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *      .&888888I                                          Copyright (c) 2009-2021.  博锐尚格科技股份有限公司
  *        ~8888'
  *        .!88~                                                                     All rights reserved.
  *
@@ -25,23 +25,23 @@
  */
 
 import { SColor, SLine, SPainter, SPoint, SRect } from "@persagy-web/draw";
-import { SKeyCode, SMouseEvent, SUndoStack } from "@persagy-web/base";
-import { SItemStatus } from "..";
-import { SMathUtil } from "../utils/SMathUtil";
+import { SMouseEvent, SUndoStack } from "@persagy-web/base";
+import { SItemStatus } from "../../index";
+import { SMathUtil } from "../../utils/SMathUtil";
 import {
     SGraphItem,
     SGraphPointListDelete,
     SGraphPointListInsert,
-    SGraphPointListUpdate,
     SLineStyle
 } from "@persagy-web/graph";
+import { SGraphStyleItem } from "@persagy-web/graph/lib";
 
 /**
  * 折线 item
  *
  * @author  郝建龙 <haojianlong@sagacloud.cn>
  */
-export class SPolylineItem extends SGraphItem {
+export class SPolylineItem extends SGraphStyleItem {
     /** X 坐标最小值 */
     private minX = Number.MAX_SAFE_INTEGER;
     /** X 坐标最大值 */
@@ -65,45 +65,6 @@ export class SPolylineItem extends SGraphItem {
 
     /** 鼠标移动时的点 */
     protected lastPoint: SPoint | null = null;
-    /** 线条颜色 */
-    _strokeColor: SColor = SColor.Black;
-    get strokeColor(): SColor {
-        return this._strokeColor;
-    }
-    set strokeColor(v: SColor) {
-        this._strokeColor = v;
-        this.update();
-    }
-
-    /** 填充色 */
-    _fillColor: SColor = new SColor("#2196f3");
-    get fillColor(): SColor {
-        return this._fillColor;
-    }
-    set fillColor(v: SColor) {
-        this._fillColor = v;
-        this.update();
-    }
-
-    /** 线条宽度 */
-    _lineWidth: number = 1;
-    get lineWidth(): number {
-        return this._lineWidth;
-    }
-    set lineWidth(v: number) {
-        this._lineWidth = v;
-        this.update();
-    }
-
-    /** 边框样式 */
-    _lineStyle: SLineStyle = SLineStyle.Solid;
-    get lineStyle(): SLineStyle {
-        return this._lineStyle;
-    }
-    set lineStyle(v: SLineStyle) {
-        this._lineStyle = v;
-        this.update();
-    }
 
     /** 全局灵敏度 */
     dis: number = 10;
@@ -146,6 +107,7 @@ export class SPolylineItem extends SGraphItem {
         } else {
             this.pointList = list;
         }
+        this.fillColor = new SColor("#2196f3");
     }
 
     /**

+ 7 - 6
persagy-web-big/src/utils/SMathUtil.ts

@@ -296,8 +296,9 @@ export class SMathUtil {
             };
             // @ts-ignore
             poly2.regions.push(array[array.length - 1]);
+            // 存储外轮廓索引
             let indexArr: number[] = [array.length - 1];
-            for (let i = array.length - 2; i > 0; i--) {
+            for (let i = array.length - 2; i >= 0; i--) {
                 let poly1 = {
                     regions: [],
                     inverted: false
@@ -312,17 +313,17 @@ export class SMathUtil {
                     poly2.regions.push(array[i]);
                 }
             }
-            indexArr.unshift(0);
-            for (let i = 0; i < indexArr.length - 1; i++) {
+            for (let i = 0; i < indexArr.length; i++) {
+                // 从已有的数组中返回选定的元素
                 let axArr = array.slice(
-                    i == 0 ? 0 : indexArr[i] + 1,
-                    indexArr[i + 1]
+                    i == 0 ? 0 : indexArr[i - 1],
+                    indexArr[i]
                 );
                 let outline: Outline = {
                     Outer: [],
                     Inner: []
                 };
-                outline.Outer = array[indexArr[i + 1]].map(
+                outline.Outer = array[indexArr[i]].map(
                     (t): SPoint => new SPoint(t[0], t[1])
                 );
                 outline.Inner = axArr.map((t): SPoint[] =>

+ 8 - 2
persagy-web-big/src/utils/getJsonz.ts

@@ -27,7 +27,13 @@
 import Axios from "axios";
 import unzip from "./unzip";
 
-export default function getJsonz(url: string) {
+/**
+ * 通过路径获取文件
+ *
+ * @param url 文件的路径
+ * @param flag 是否为原始数据
+ */
+export default function getJsonz(url: string, flag = false) {
     return new Promise((resolve, reject): void => {
         Axios({
             method: "get",
@@ -37,7 +43,7 @@ export default function getJsonz(url: string) {
         })
             .then((res: any) => {
                 let blob = res.data;
-                unzip(blob)
+                unzip(blob, flag)
                     .then((jsonData: any) => {
                         resolve(jsonData);
                     })

+ 4 - 3
persagy-web-big/src/utils/unzip.ts

@@ -29,10 +29,11 @@ import unzipBase64 from "./unzipBase64";
 /**
  * 解压数据
  *
- * @param blob     文件
+ * @param blob 文件
+ * @param flag 是否返回原始文件数据
  * @return 解压后的数据
  */
-export default function unzip(blob: any): any {
+export default function unzip(blob: any, flag = false): any {
     let reader = new FileReader();
     reader.readAsBinaryString(blob);
     return new Promise(resolve => {
@@ -45,7 +46,7 @@ export default function unzip(blob: any): any {
                 const data = unGzipData.entityList
                     ? unGzipData.entityList[0].Elements
                     : unGzipData.EntityList[0].Elements;
-                resolve(data);
+                resolve(flag ? unGzipData : data);
             } catch (e) {
                 console.log(e);
                 resolve("error");

+ 3 - 0
persagy-web-draw/README.md

@@ -6,6 +6,9 @@
     无特殊说明单版本为跟随依赖版本升级
     |
     |
+    |-- 2.2.13 修复绘制区域时掏洞bug,(现未知将fill移出去会导致的问题)
+    |
+    |
     |-- 2.2.12 view层增加滚轮抛出事件
     |
     |

+ 1 - 1
persagy-web-draw/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/draw",
-    "version": "2.2.12",
+    "version": "2.2.13",
     "description": "博锐尚格绘制引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 1 - 1
persagy-web-draw/src/engines/SCanvasPaintEngine.ts

@@ -648,7 +648,6 @@ export class SCanvasPaintEngine extends SPaintEngine {
             } else if (cmd.command == "Z") {
                 // 闭合路径
                 this._canvas.closePath();
-                this._canvas.fill();
             } else if (cmd.command == "Q") {
                 // 二次贝塞尔曲线
                 this._canvas.quadraticCurveTo(
@@ -699,6 +698,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
                 );
             }
         });
+        this._canvas.fill();
         this._canvas.stroke();
     }
 }

+ 10 - 8
persagy-web-edit/src/commands/SGraphAddListCommand.ts

@@ -24,8 +24,8 @@
  * *********************************************************************************************************************
  */
 
-import { SUndoCommand } from '@persagy-web/base/lib';
-import { SGraphCommand, SGraphItem, SGraphScene } from '@persagy-web/graph/lib';
+import { SUndoCommand } from "@persagy-web/base/lib";
+import { SGraphCommand, SGraphItem, SGraphScene } from "@persagy-web/graph/lib";
 
 /**
  * 批量添加 item 命令
@@ -36,7 +36,7 @@ export class SGraphAddListCommand extends SGraphCommand {
     /** 命令item对象    */
     itemList: SGraphItem[];
     /** 命令名称    */
-    readonly command: string = "AddListCommand"
+    readonly command: string = "AddListCommand";
     /** 命令item的父类   */
     parent: SGraphItem | null;
     constructor(scene: SGraphScene, itemList: SGraphItem[]) {
@@ -60,9 +60,10 @@ export class SGraphAddListCommand extends SGraphCommand {
      *
      */
     redo(): void {
-        this.itemList.map((item) => {
+        // 遍历批量添加的 item 列表
+        this.itemList.map(item => {
             item.parent = this.parent;
-        })
+        });
         // @ts-ignore
         this.parent.update();
     }
@@ -72,10 +73,11 @@ export class SGraphAddListCommand extends SGraphCommand {
      *
      */
     undo(): void {
-        this.itemList.map((item) => {
+        // 遍历批量添加的 item 列表
+        this.itemList.map(item => {
             item.parent = null;
-        })
+        });
         // @ts-ignore
         this.parent.update();
     }
-}
+}

+ 15 - 7
persagy-web-edit/src/commands/SGraphDeleteListCommand.ts

@@ -38,11 +38,18 @@ import { SGraphScene } from "@persagy-web/graph/";
 export class SGraphDeleteListCommand extends SGraphCommand {
     /** 命令item对象    */
     itemList: SGraphItem[];
-    desc: string = 'DeleteCommandList'
+    desc: string = "DeleteCommandList";
     /** 命令名称    */
-    readonly command: string = "DeleteCommandList"
+    readonly command: string = "DeleteCommandList";
     /** 命令item的父类   */
     parent: SGraphItem | null;
+
+    /**
+     * 构造函数
+     *
+     * @param scene     item 所在场景
+     * @param itemList  批量处理的 item 列表
+     */
     constructor(scene: SGraphScene, itemList: SGraphItem[]) {
         super(scene);
         this.itemList = itemList;
@@ -62,9 +69,10 @@ export class SGraphDeleteListCommand extends SGraphCommand {
      * 重做
      */
     undo(): void {
-        this.itemList.map((item) => {
+        // 遍历批量处理的 item 列表
+        this.itemList.map(item => {
             item.parent = this.parent;
-        })
+        });
         // @ts-ignore
         this.parent.update();
     }
@@ -73,10 +81,10 @@ export class SGraphDeleteListCommand extends SGraphCommand {
      * 撤销
      */
     redo(): void {
-        this.itemList.map((item) => {
+        this.itemList.map(item => {
             item.parent = null;
-        })
+        });
         // @ts-ignore
         this.parent.update();
     }
-}
+}

+ 1 - 0
persagy-web-edit/src/commands/SGraphMoveCommand.ts

@@ -74,6 +74,7 @@ export class SGraphMoveCommand extends SGraphCommand {
      * @return 是否已执行合并命令
      */
     mergeWith(command: SUndoCommand): boolean {
+        // 合并的命令与当前的命令是一种,而且执行命令的对象与当前对象是一个
         if (command instanceof SGraphMoveCommand && command.item == this.item) {
             command.pos = this.pos;
             return true;

+ 5 - 0
persagy-web-edit/src/commands/SGraphPointListDelete.ts

@@ -73,9 +73,11 @@ export class SGraphPointListDelete extends SGraphCommand {
      * 执行重做操作执行
      */
     redo(): void {
+        // 不传索引则执行命令的索引指向最后一个
         if (this.index == null) {
             this.pointList.pop();
         } else {
+            // 否则
             this.pointList.splice(this.index, 1);
         }
 
@@ -86,11 +88,14 @@ export class SGraphPointListDelete extends SGraphCommand {
      * 执行取消操作执行
      */
     undo(): void {
+        // 没有删除的点
         if (this.pos == null) return;
 
+        // 不传索引则执行命令的索引指向最后一个
         if (this.index == null) {
             this.pointList.push(this.pos);
         } else {
+            // 否则
             this.pointList.splice(this.index, 0, this.pos);
         }
 

+ 4 - 0
persagy-web-edit/src/commands/SGraphPointListInsert.ts

@@ -74,9 +74,11 @@ export class SGraphPointListInsert extends SGraphCommand {
      */
     redo(): void {
         const point = new SPoint(this.pos.x, this.pos.y);
+        // 不传索引则执行命令的索引指向最后一个
         if (this.index == null) {
             this.pointList.push(point);
         } else {
+            // 否则
             this.pointList.splice(this.index, 0, point);
         }
 
@@ -87,9 +89,11 @@ export class SGraphPointListInsert extends SGraphCommand {
      * 执行取消操作执行
      */
     undo(): void {
+        // 不传索引则执行命令的索引指向最后一个
         if (this.index == null) {
             this.pointList.pop();
         } else {
+            // 否则
             this.pointList.splice(this.index, 1);
         }
 

+ 362 - 303
persagy-web-edit/src/items/SBaseArrowEdit.ts

@@ -24,18 +24,26 @@
  * *********************************************************************************************************************
  */
 
-import {SArrowStyleType, SColor, SLine, SPainter, SPoint, SRect} from "@persagy-web/draw";
-import {SMouseButton, SMouseEvent, SUndoStack} from "@persagy-web/base";
-import {SItemStatus} from "@persagy-web/big";
-
+import {
+    SArrowStyleType,
+    SColor,
+    SLine,
+    SPainter,
+    SPoint,
+    SRect
+} from "@persagy-web/draw";
+import { SMouseButton, SMouseEvent, SUndoStack } from "@persagy-web/base";
+import { SItemStatus } from "@persagy-web/big";
 
 import {
     SLineStyle,
-    SGraphItem, SGraphPointListInsert, SGraphPointListUpdate
+    SGraphItem,
+    SGraphPointListInsert,
+    SGraphPointListUpdate
 } from "@persagy-web/graph/";
-import {SGraphEdit} from "..";
-import {SMathUtil} from '@persagy-web/big/lib/utils/SMathUtil';
-import {Marker} from "./../type/Marker";
+import { SGraphEdit } from "..";
+import { SMathUtil } from "@persagy-web/big/lib/utils/SMathUtil";
+import { Marker } from "./../type/Marker";
 
 /**
  * 折线编辑类
@@ -50,25 +58,26 @@ export class SBaseArrowEdit extends SGraphEdit {
     /** 是否绘制完成 */
     _status: SItemStatus = SItemStatus.Normal;
     get status(): SItemStatus {
-      return this._status;
+        return this._status;
     } // Get status
     set status(v: SItemStatus) {
-      this._status = v;
-      if (this.undoStack) {
-        this.undoStack.clear();
-      }
+        this._status = v;
+        // 命令栈存在
+        if (this.undoStack) {
+            this.undoStack.clear();
+        }
 
-      this.update();
+        this.update();
     } // Set status
 
     /** 矩形两个对角 */
     private _line: SPoint[] = [];
     get line(): SPoint[] {
-      return this._line;
+        return this._line;
     } // Get line
     set line(arr: SPoint[]) {
-      this._line = arr;
-      this.update();
+        this._line = arr;
+        this.update();
     } // Get line
 
     /** 矩形左上角 */
@@ -80,13 +89,13 @@ export class SBaseArrowEdit extends SGraphEdit {
     /** 拖动灵敏度 */
     private sceneDis: number = 5;
     /** 是否垂直水平绘制  */
-    private _verAndLeve: Boolean = false;
-    get verAndLeve(): Boolean {
-      return this._verAndLeve;
+    private _verAndLeve: boolean = false;
+    get verAndLeve(): boolean {
+        return this._verAndLeve;
     } // Get verAndLeve
-    set verAndLeve(bool: Boolean) {
-      this._verAndLeve = bool;
-      this.update();
+    set verAndLeve(bool: boolean) {
+        this._verAndLeve = bool;
+        this.update();
     } // Set verAndLeve
 
     /** 当前点索引 */
@@ -96,51 +105,51 @@ export class SBaseArrowEdit extends SGraphEdit {
     /** 线条颜色 */
     _strokeColor: SColor = SColor.Black;
     get strokeColor(): SColor {
-      return this._strokeColor;
+        return this._strokeColor;
     } // Get strokeColor
     set strokeColor(v: SColor) {
-      this._strokeColor = v;
-      this.update();
+        this._strokeColor = v;
+        this.update();
     } // Set strokeColor
 
     /** 填充色 */
     _fillColor: SColor = new SColor("#2196f3");
     get fillColor(): SColor {
-      return this._fillColor;
+        return this._fillColor;
     } // Get fillColor
     set fillColor(v: SColor) {
-      this._fillColor = v;
-      this.update();
+        this._fillColor = v;
+        this.update();
     } // Set fillColor
 
     /** 选中端点填充色 */
     private _activeFillColor: SColor = new SColor("#2196f3");
     get activeFillColor(): SColor {
-      return this._activeFillColor;
+        return this._activeFillColor;
     } // Get activeFillColor
     set activeFillColor(v: SColor) {
-      this._activeFillColor = v;
-      this.update();
+        this._activeFillColor = v;
+        this.update();
     } // Set activeFillColor
 
     /** 边框样式 */
     _lineStyle: SLineStyle = SLineStyle.Solid;
     get lineStyle(): SLineStyle {
-      return this._lineStyle;
+        return this._lineStyle;
     } // Get lineStyle
     set lineStyle(v: SLineStyle) {
-      this._lineStyle = v;
-      this.update();
+        this._lineStyle = v;
+        this.update();
     } // Set lineStyle
 
     /** 线条宽度 */
     _lineWidth: number = 1;
     get lineWidth(): number {
-      return this._lineWidth;
+        return this._lineWidth;
     } // Get lineWidth
     set lineWidth(v: number) {
-      this._lineWidth = v;
-      this.update();
+        this._lineWidth = v;
+        this.update();
     } // Set lineWidth
 
     /**
@@ -150,34 +159,35 @@ export class SBaseArrowEdit extends SGraphEdit {
      * @param data      数据
      */
     constructor(parent: SGraphItem | null, data: Marker) {
-      super(parent);
-      this.showSelect = false;
-      this.data = data;
-      if (data.style && data.style.default) {
-        // 关于顶点
-        if (data.style.default.line) {
-          let setPointList: SPoint[];
-          setPointList = data.style.default.line.map(i => {
-            return new SPoint(i.x, i.y)
-          });
-          this.line = setPointList;
-        }
+        super(parent);
+        this.showSelect = false;
+        this.data = data;
+        // data 中存在该属性
+        if (data.style && data.style.default) {
+            // 关于顶点
+            if (data.style.default.line) {
+                let setPointList: SPoint[];
+                setPointList = data.style.default.line.map(i => {
+                    return new SPoint(i.x, i.y);
+                });
+                this.line = setPointList;
+            }
 
-        // 颜色
-        if (data.style.default.strokeColor) {
-          this.strokeColor = new SColor(data.style.default.strokeColor)
-        }
+            // 线条颜色
+            if (data.style.default.strokeColor) {
+                this.strokeColor = new SColor(data.style.default.strokeColor);
+            }
 
-        // 线宽
-        if (data.style.default.LineWidth) {
-          this.lineWidth = data.style.default.lineWidth
-        }
+            // 线宽
+            if (data.style.default.LineWidth) {
+                this.lineWidth = data.style.default.lineWidth;
+            }
 
-        // 线样式
-        if (data.style.default.LineStyle) {
-          this.lineStyle = data.style.default.lineStyle
+            // 线样式
+            if (data.style.default.LineStyle) {
+                this.lineStyle = data.style.default.lineStyle;
+            }
         }
-      }
     } // Constructor
 
     /**
@@ -185,18 +195,20 @@ export class SBaseArrowEdit extends SGraphEdit {
      *
      * @param	event   事件参数
      * @return 是否处理该事件
-    */
+     */
     onDoubleClick(event: SMouseEvent): boolean {
-      if (this.status == SItemStatus.Normal) {
-        this.status = SItemStatus.Edit;
-        this.grabItem(this);
-      } else if (this.status == SItemStatus.Edit) {
-        this.status = SItemStatus.Normal;
-        this.releaseItem();
-      }
-
-      this.update();
-      return true;
+        // 当前处于正常状态
+        if (this.status == SItemStatus.Normal) {
+            this.status = SItemStatus.Edit;
+            this.grabItem(this);
+        } else if (this.status == SItemStatus.Edit) {
+            // 当前处于编辑态
+            this.status = SItemStatus.Normal;
+            this.releaseItem();
+        }
+
+        this.update();
+        return true;
     } // Function onDoubleClick()
 
     /**
@@ -204,27 +216,31 @@ export class SBaseArrowEdit extends SGraphEdit {
      *
      * @param event   鼠标事件
      * @return  是否处理该事件
-    */
+     */
     onMouseDown(event: SMouseEvent): boolean {
-      this.curIndex = -1;
-      this.curPoint = null;
-      if (event.shiftKey || this._verAndLeve) {
-        event = this.compare(event);
-      }
+        this.curIndex = -1;
+        this.curPoint = null;
+        if (event.shiftKey || this._verAndLeve) {
+            // 按下了 shift 键 或者模拟 shift 键功能开启
+            event = this.compare(event);
+        }
 
-      if (event.buttons == SMouseButton.LeftButton) {
-        if (this.status == SItemStatus.Normal) {
-          return super.onMouseDown(event);
-        } else if (this.status == SItemStatus.Edit) {
-          // 判断是否点击到端点上(获取端点索引值)
-          this.findNearestPoint(new SPoint(event.x, event.y));
-        } else if (this.status == SItemStatus.Create) {
-          this.addPoint(new SPoint(event.x, event.y));
-          return true;
+        if (event.buttons == SMouseButton.LeftButton) {
+            // 按下的是左键
+            if (this.status == SItemStatus.Normal) {
+                // 当前处于正常状态
+                return super.onMouseDown(event);
+            } else if (this.status == SItemStatus.Edit) {
+                // 处于编辑态时, 计算点击到的端点(获取端点索引值)
+                this.findNearestPoint(new SPoint(event.x, event.y));
+            } else if (this.status == SItemStatus.Create) {
+                // 处于创建态
+                this.addPoint(new SPoint(event.x, event.y));
+                return true;
+            }
         }
-      }
 
-      return true;
+        return true;
     } // Function onMouseDown()
 
     /**
@@ -232,52 +248,61 @@ export class SBaseArrowEdit extends SGraphEdit {
      *
      * @param event   事件
      * @return  返回鼠标事件
-    */
+     */
     compare(event: SMouseEvent): SMouseEvent {
-      if (this.line.length) {
-        let last = new SPoint(event.x, event.y);
-        if (this.status == SItemStatus.Create) {
-          last = this.line[0];
-        } else if (this.status == SItemStatus.Edit) {
-          if (this.curIndex == 1) {
-            last = this.line[0];
-          } else if (this.curIndex == 0) {
-            last = this.line[1];
-          }
-        }
+        if (this.line.length) {
+            // 当前对象有效
+            let last = new SPoint(event.x, event.y);
+            if (this.status == SItemStatus.Create) {
+                // 处于创建态
+                last = this.line[0];
+            } else if (this.status == SItemStatus.Edit) {
+                // 处于编辑态
+                if (this.curIndex == 1) {
+                    // 如果选中的是第二个点,则以第一个点为基准
+                    last = this.line[0];
+                } else if (this.curIndex == 0) {
+                    // 如果选中的是第一个点,则以第二个点为基准
+                    last = this.line[1];
+                }
+            }
 
-        const dx = Math.abs(event.x - last.x);
-        const dy = Math.abs(event.y - last.y);
-        if (dy > dx) {
-          event.x = last.x;
-        } else {
-          event.y = last.y;
+            const dx = Math.abs(event.x - last.x);
+            const dy = Math.abs(event.y - last.y);
+            if (dy > dx) {
+                // y 轴方向偏移量较大,则锁定 x 坐标
+                event.x = last.x;
+            } else {
+                // x 轴方向偏移量较大,则锁定 y 坐标
+                event.y = last.y;
+            }
         }
-      }
 
-      return event;
+        return event;
     } // Function compare()
 
     /**
      * 获取点击点与 Point[] 中的点距离最近点
      *
      * @param p   鼠标点击点
-    */
+     */
     findNearestPoint(p: SPoint): void {
-      let len = this.sceneDis;
-      for (let i = 0; i < this.line.length; i++) {
-        let dis = SMathUtil.pointDistance(
-          p.x,
-          p.y,
-          this.line[i].x,
-          this.line[i].y
-        );
-        if (dis < len) {
-          len = dis;
-          this.curIndex = i;
-          this.curPoint = new SPoint(this.line[this.curIndex]);
+        let len = this.sceneDis;
+        // 遍历自身点数组
+        for (let i = 0; i < this.line.length; i++) {
+            let dis = SMathUtil.pointDistance(
+                p.x,
+                p.y,
+                this.line[i].x,
+                this.line[i].y
+            );
+            if (dis < len) {
+                // 鼠标的点到自身的点距离在吸附范围内
+                len = dis;
+                this.curIndex = i;
+                this.curPoint = new SPoint(this.line[this.curIndex]);
+            }
         }
-      }
     } // Function findNearestPoint()
 
     /**
@@ -285,29 +310,34 @@ export class SBaseArrowEdit extends SGraphEdit {
      *
      * @param event   鼠标事件
      * @return  是否处理事件
-    */
+     */
     onMouseMove(event: SMouseEvent): boolean {
-      if (event.shiftKey || this._verAndLeve) {
-        event = this.compare(event);
-      }
-
-      if (this.status == SItemStatus.Create) {
-        if (this.line[0] instanceof SPoint) {
-          this.line[1] = new SPoint(event.x, event.y);
-          this.calRect()
+        if (event.shiftKey || this._verAndLeve) {
+            // 按下了 shift 键 或者模拟 shift 键功能开启
+            event = this.compare(event);
         }
-      } else if (this.status == SItemStatus.Edit) {
-        if (-1 != this.curIndex) {
-          this.line[this.curIndex].x = event.x;
-          this.line[this.curIndex].y = event.y;
-          this.calRect()
+
+        if (this.status == SItemStatus.Create) {
+            // 处于创建态
+            if (this.line[0] instanceof SPoint) {
+                // 第一个数据是点类型
+                this.line[1] = new SPoint(event.x, event.y);
+                this.calRect();
+            }
+        } else if (this.status == SItemStatus.Edit) {
+            // 处于编辑态
+            if (-1 != this.curIndex) {
+                // 存在当前选中的点
+                this.line[this.curIndex].x = event.x;
+                this.line[this.curIndex].y = event.y;
+                this.calRect();
+            }
+        } else {
+            return super.onMouseMove(event);
         }
-      } else {
-        return super.onMouseMove(event);
-      }
 
-      this.update();
-      return true;
+        this.update();
+        return true;
     } // Function onMouseMove()
 
     /**
@@ -315,93 +345,102 @@ export class SBaseArrowEdit extends SGraphEdit {
      *
      * @param	event   事件参数
      * @return 是否处理该事件
-    */
+     */
     onMouseUp(event: SMouseEvent): boolean {
-      if (this.status == SItemStatus.Edit) {
-        if (this.curIndex > -1) {
-          const p = new SPoint(
-            this.line[this.curIndex].x,
-            this.line[this.curIndex].y
-          );
-          this.recordAction(SGraphPointListUpdate, [
-            this.line,
-            this.curPoint,
-            p,
-            this.curIndex
-          ]);
+        if (this.status == SItemStatus.Edit) {
+            // 处于编辑态
+            if (this.curIndex > -1) {
+                // 存在当前选中的点
+                const p = new SPoint(
+                    this.line[this.curIndex].x,
+                    this.line[this.curIndex].y
+                );
+                this.recordAction(SGraphPointListUpdate, [
+                    this.line,
+                    this.curPoint,
+                    p,
+                    this.curIndex
+                ]);
+            }
+        } else if (this.status == SItemStatus.Normal) {
+            // 处于正常态
+            super.onMouseUp(event);
+            return true;
         }
-      } else if (this.status == SItemStatus.Normal) {
-        super.onMouseUp(event)
-        return true;
-      }
 
-      this.curIndex = -1;
-      this.curPoint = null;
-      return true;
+        this.curIndex = -1;
+        this.curPoint = null;
+        return true;
     } // Function onMouseUp()
 
     /**
      * 计算矩形的左上角和右下角
-    */
+     */
     private calRect(): void {
-      if (this.line.length > 1) {
-        const fi = this.line[0];
-        const se = this.line[1];
-        let minx, maxx, miny, maxy;
-        if (fi.x < se.x) {
-          minx = fi.x;
-          maxx = se.x;
-        } else {
-          minx = se.x;
-          maxx = fi.x;
-        }
+        if (this.line.length > 1) {
+            // 当前对象有效
+            const fi = this.line[0];
+            const se = this.line[1];
+            let minx, maxx, miny, maxy;
+            if (fi.x < se.x) {
+                // 存储最大值和最小值
+                minx = fi.x;
+                maxx = se.x;
+            } else {
+                minx = se.x;
+                maxx = fi.x;
+            }
 
-        if (fi.y < se.y) {
-          miny = fi.y;
-          maxy = se.y;
-        } else {
-          miny = se.y;
-          maxy = fi.y;
-        }
+            if (fi.y < se.y) {
+                // 存储最大值和最小值
+                miny = fi.y;
+                maxy = se.y;
+            } else {
+                miny = se.y;
+                maxy = fi.y;
+            }
 
-        this._leftTop = new SPoint(minx, miny)
-        this._rightBottom = new SPoint(maxx, maxy)
-      }
+            this._leftTop = new SPoint(minx, miny);
+            this._rightBottom = new SPoint(maxx, maxy);
+        }
     } // Function calRect
 
     /**
      * 添加点至数组中
      *
      * @param p   添加的点
-    */
+     */
     private addPoint(p: SPoint): void {
-      if (this.line.length < 2) {
-        this.line.push(p);
-        this.recordAction(SGraphPointListInsert, [this.line, p]);
-      } else {
-        this.line[1] = p;
-        this.recordAction(SGraphPointListInsert, [this.line, p, 1]);
-        this.status = SItemStatus.Normal;
-        this.releaseItem();
-        this.$emit("finishCreated");
-      }
-
-      this.calRect()
-      this.update();
+        if (this.line.length < 2) {
+            // 当前对象点数据少于2条
+            this.line.push(p);
+            this.recordAction(SGraphPointListInsert, [this.line, p]);
+        } else {
+            // 否则
+            this.line[1] = p;
+            this.recordAction(SGraphPointListInsert, [this.line, p, 1]);
+            this.status = SItemStatus.Normal;
+            this.releaseItem();
+            this.$emit("finishCreated");
+        }
+
+        this.calRect();
+        this.update();
     } // Function addPoint()
 
     /**
      * 移动后处理所有坐标,并肩原点置为场景原点
-    */
+     */
     moveToOrigin(): void {
-      this.line = this.line.map(t => {
-        t.x = t.x + this.x;
-        t.y = t.y + this.y;
-        return t;
-      });
-
-      this.x = 0;
-      this.y = 0;
+        // 遍历当前对象点数据
+        this.line = this.line.map(t => {
+            t.x = t.x + this.x;
+            t.y = t.y + this.y;
+            return t;
+        });
+
+        this.x = 0;
+        this.y = 0;
     } // Function moveToOrigin()
 
     /**
@@ -409,11 +448,11 @@ export class SBaseArrowEdit extends SGraphEdit {
      *
      * @param	SGraphCommand   相关命令类
      * @param	any             对应传入参数
-    */
+     */
     protected recordAction(SGraphCommand: any, any: any[]): void {
-      // 记录相关命令并推入堆栈中
-      const command = new SGraphCommand(this.scene, this, ...any);
-      this.undoStack.push(command);
+        // 记录相关命令并推入堆栈中
+        const command = new SGraphCommand(this.scene, this, ...any);
+        this.undoStack.push(command);
     } // Function recordAction()
 
     /**
@@ -422,139 +461,159 @@ export class SBaseArrowEdit extends SGraphEdit {
      * @param x   x 横向坐标
      * @param y   y 纵向坐标
      * @return  在区域内返回 true, 否则 false
-    */
+     */
     contains(x: number, y: number): boolean {
-      if (this.line.length == 2) {
-        let p = new SPoint(x, y);
-        if (
-          SMathUtil.pointToLine(p, new SLine(this.line[0], this.line[1]))
-            .MinDis < this.dis
-        ) {
-          return true;
+        if (this.line.length == 2) {
+            // 当前对象有效
+            let p = new SPoint(x, y);
+            if (
+                SMathUtil.pointToLine(p, new SLine(this.line[0], this.line[1]))
+                    .MinDis < this.dis
+            ) {
+                // 鼠标点到本对象的距离在吸附距离之内
+                return true;
+            }
         }
-      }
 
-      return false;
+        return false;
     } // Function contains()
 
     /**
      * Item 对象边界区域
      *
      * @return 外接矩阵
-    */
+     */
     boundingRect(): SRect {
-      if (this.line.length > 1) {
-        this.calRect()
-        return new SRect(this._leftTop, this._rightBottom);
-      }
+        if (this.line.length > 1) {
+            // 当前对象有效
+            this.calRect();
+            return new SRect(this._leftTop, this._rightBottom);
+        }
 
-      return new SRect()
+        return new SRect();
     } // Function boundingRect()
 
     /**
      * 撤销操作
-    */
+     */
     undo(): void {
-      if (this._status != SItemStatus.Normal) {
-        this.undoStack.undo();
-      }
+        if (this._status != SItemStatus.Normal) {
+            // 处于非正常态,即编辑态和创建态
+            this.undoStack.undo();
+        }
     } // Function undo()
 
     /**
      * 重做操作
-    */
+     */
     redo(): void {
-      if (this._status != SItemStatus.Normal) {
-        this.undoStack.redo();
-      }
+        if (this._status != SItemStatus.Normal) {
+            // 处于非正常态,即编辑态和创建态
+            this.undoStack.redo();
+        }
     } // Function redo()
 
     /**
      * 取消操作执行
-    */
+     */
     cancelOperate(): void {
-      if (this.status == SItemStatus.Create) {
-        this.parent = null;
-        this.releaseItem();
-      } else if (this.status == SItemStatus.Edit) {
-        this.status = SItemStatus.Normal;
-        this.releaseItem();
-      }
+        if (this.status == SItemStatus.Create) {
+            // 处于创建态
+            this.parent = null;
+            this.releaseItem();
+        } else if (this.status == SItemStatus.Edit) {
+            // 处于编辑态
+            this.status = SItemStatus.Normal;
+            this.releaseItem();
+        }
     } // Function cancelOperate()
 
     /**
      * Item绘制操作
      *
      * @param painter   绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
-      painter.pen.color = this.strokeColor;
-      if (this.line.length == 2) {
-        painter.brush.color = this.fillColor;
-        painter.pen.lineWidth = this.lineWidth
-        if (this.lineStyle == SLineStyle.Dashed) {
-          painter.pen.lineDash = [
-            painter.toPx(this.lineWidth * 3),
-            painter.toPx(this.lineWidth * 7)
-          ];
-        } else if (this.lineStyle == SLineStyle.Dotted) {
-          painter.pen.lineDash = [
-            painter.toPx(this.lineWidth * 2),
-            painter.toPx(this.lineWidth * 2)
-          ];
-        }
-
-        if (this.selected && this.status == SItemStatus.Normal) {
-          painter.pen.lineWidth = painter.toPx(this.lineWidth * 2);
-          painter.shadow.shadowBlur = 10;
-          painter.shadow.shadowColor = new SColor(`#00000033`);
-          painter.shadow.shadowOffsetX = 5;
-          painter.shadow.shadowOffsetY = 5;
-        }
-
-        painter.drawArrowLine(this.line[0], this.line[1], { begin: SArrowStyleType.None, end: SArrowStyleType.Basic });
-        if (
-          this.status == SItemStatus.Edit ||
-          this.status == SItemStatus.Create
-        ) {
-          // 绘制端点
-          this.line.forEach((p, i): void => {
+        painter.pen.color = this.strokeColor;
+        if (this.line.length == 2) {
+            // 当前对象2个点都存在,即创建完成
             painter.brush.color = this.fillColor;
-            if (i == this.curIndex) {
-              painter.brush.color = this.activeFillColor;
+            painter.pen.lineWidth = this.lineWidth;
+            if (this.lineStyle == SLineStyle.Dashed) {
+                // 线类型是虚线
+                painter.pen.lineDash = [
+                    painter.toPx(this.lineWidth * 3),
+                    painter.toPx(this.lineWidth * 7)
+                ];
+            } else if (this.lineStyle == SLineStyle.Dotted) {
+                // 线类型是点线
+                painter.pen.lineDash = [
+                    painter.toPx(this.lineWidth * 2),
+                    painter.toPx(this.lineWidth * 2)
+                ];
             }
-            painter.drawCircle(p.x, p.y, painter.toPx(5));
-          });
-        }
 
-      } else if (this.line.length == 1) {
-        if (
-          this.status == SItemStatus.Edit ||
-          this.status == SItemStatus.Create
-        ) {
-          // 绘制端点
-          painter.brush.color = this.fillColor;
-          painter.drawCircle(
-            this.line[0].x,
-            this.line[0].y,
-            painter.toPx(5)
-          );
+            if (this.selected && this.status == SItemStatus.Normal) {
+                // 当前对象呗选中而且处于正常态
+                painter.pen.lineWidth = painter.toPx(this.lineWidth * 2);
+                painter.shadow.shadowBlur = 10;
+                painter.shadow.shadowColor = new SColor(`#00000033`);
+                painter.shadow.shadowOffsetX = 5;
+                painter.shadow.shadowOffsetY = 5;
+            }
+
+            painter.drawArrowLine(this.line[0], this.line[1], {
+                begin: SArrowStyleType.None,
+                end: SArrowStyleType.Basic
+            });
+            if (
+                this.status == SItemStatus.Edit ||
+                this.status == SItemStatus.Create
+            ) {
+                // 处于创建态或者编辑态
+                // 绘制端点
+                this.line.forEach((p, i): void => {
+                    painter.brush.color = this.fillColor;
+                    if (i == this.curIndex) {
+                        // 该点是当前选中的点
+                        painter.brush.color = this.activeFillColor;
+                    }
+                    painter.drawCircle(p.x, p.y, painter.toPx(5));
+                });
+            }
+        } else if (this.line.length == 1) {
+            // 当前对象中只存在一个点
+            if (
+                this.status == SItemStatus.Edit ||
+                this.status == SItemStatus.Create
+            ) {
+                // 处于创建态或者编辑态
+                // 绘制端点
+                painter.brush.color = this.fillColor;
+                painter.drawCircle(
+                    this.line[0].x,
+                    this.line[0].y,
+                    painter.toPx(5)
+                );
+            }
         }
-      }
     } // Function onDraw()
 
     /**
      * 返回对象储存的相关数据
      *
      * @return	实体类保存得数据
-    */
+     */
     toData(): any {
-      this.moveToOrigin()
-      const Line = [{ x: this.line[0].x, y: this.line[0].y }, { x: this.line[1].x, y: this.line[1].y }];
-      this.data.style.default.line = Line;
-      this.data.style.default.lineWidth = this.lineWidth;
-      this.data.style.default.lineStyle = this.lineStyle;
-      this.data.style.default.strokeColor = this.strokeColor;
-      return this.data
+        this.moveToOrigin();
+        const Line = [
+            { x: this.line[0].x, y: this.line[0].y },
+            { x: this.line[1].x, y: this.line[1].y }
+        ];
+        this.data.style.default.line = Line;
+        this.data.style.default.lineWidth = this.lineWidth;
+        this.data.style.default.lineStyle = this.lineStyle;
+        this.data.style.default.strokeColor = this.strokeColor;
+        return this.data;
     } // Function toData()
-  } // Class SArrowEdit
+} // Class SArrowEdit

+ 27 - 2
persagy-web-edit/src/items/SBaseCircleEdit.ts

@@ -43,6 +43,7 @@ import { Marker } from "../type/Marker";
 export class SBaseCircleEdit extends SGraphEdit {
     /** 编辑相关操作的数据 */
     data: Marker;
+    /** 本对象的状态 */
     _status: SItemStatus = SItemStatus.Normal;
     get status(): SItemStatus {
         return this._status;
@@ -133,10 +134,12 @@ export class SBaseCircleEdit extends SGraphEdit {
     constructor(parent: SGraphItem | null, data: Marker) {
         super(parent);
         this.data = data;
+        // 数据中存有样式属性
         if (data.style) {
             // 关于顶点
             if (data.style.line) {
                 let setPointList: SPoint[];
+                // 生成所需要的点数据
                 setPointList = data.style.line.map(i => {
                     return new SPoint(i.x, i.y);
                 });
@@ -144,7 +147,7 @@ export class SBaseCircleEdit extends SGraphEdit {
                 this.calRect();
             }
         }
-
+        // 数据中存在默认样式
         if (data.style && data.style.default) {
             // 颜色
             if (data.style.default.strokeColor) {
@@ -172,6 +175,7 @@ export class SBaseCircleEdit extends SGraphEdit {
     resize(oldSize: SRect, newSize: SRect): void {
         const xs = newSize.width / oldSize.width;
         const ys = newSize.height / oldSize.height;
+        // 遍历本身控制点,执行放缩
         this.line = this.line.map(t => {
             t.x = t.x * xs;
             t.y = t.y * ys;
@@ -190,10 +194,13 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     onMouseDown(event: SMouseEvent): boolean {
         if (event.buttons == SMouseButton.LeftButton) {
+            // 按下的是左键
             if (this.status == SItemStatus.Create) {
+                // 处于创建态
                 this.addPoint(new SPoint(event.x, event.y));
                 return true;
             } else {
+                // 否则
                 // return super.onMouseDown(event);
                 super.onMouseDown(event);
                 return true;
@@ -211,11 +218,14 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     onMouseMove(event: SMouseEvent): boolean {
         if (this.status == SItemStatus.Create) {
+            // 处于创建态
             if (this.line[0] instanceof SPoint) {
+                // 控制点钟第一个是 SPoint 类型
                 this.line[1] = new SPoint(event.x, event.y);
                 this.calRect();
             }
         } else {
+            // 否则
             return super.onMouseMove(event);
         }
 
@@ -231,6 +241,7 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     onMouseUp(event: SMouseEvent): boolean {
         if (this.status != SItemStatus.Create) {
+            // 处于非创建态
             super.onMouseUp(event);
         }
 
@@ -242,9 +253,11 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     private calRect(): void {
         if (this.line.length > 1) {
+            // 本对象的控制点有效
             const fi = this.line[0];
             const se = this.line[1];
             let minx, maxx, miny, maxy;
+            // 存储 x 最大值和最小值
             if (fi.x < se.x) {
                 minx = fi.x;
                 maxx = se.x;
@@ -253,6 +266,7 @@ export class SBaseCircleEdit extends SGraphEdit {
                 maxx = fi.x;
             }
 
+            // 存储 y 最大值和最小值
             if (fi.y < se.y) {
                 miny = fi.y;
                 maxy = se.y;
@@ -273,9 +287,11 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     private addPoint(p: SPoint): void {
         if (this.line.length < 2) {
+            // 本对象的控制点少于2个
             this.line.push(p);
             this.recordAction(SGraphPointListInsert, [this.line, p]);
         } else {
+            // 否则
             this.line[1] = p;
             this.recordAction(SGraphPointListInsert, [this.line, p, 1]);
             this.status = SItemStatus.Normal;
@@ -306,6 +322,7 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     boundingRect(): SRect {
         if (this.line.length > 1) {
+            // 本对象的控制点有效,为2个
             this.calRect();
             return new SRect(this._leftTop, this._rightBottom);
         }
@@ -318,6 +335,7 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     undo(): void {
         if (this._status != SItemStatus.Normal) {
+            // 处于非正常态
             this.undoStack.undo();
         }
     }
@@ -327,6 +345,7 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     redo(): void {
         if (this._status != SItemStatus.Normal) {
+            // 处于非正常态
             this.undoStack.redo();
         }
     }
@@ -336,9 +355,11 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     cancelOperate(): void {
         if (this.status == SItemStatus.Create) {
+            // 处于创建态
             this.parent = null;
             this.releaseItem();
         } else if (this.status == SItemStatus.Edit) {
+            // 处于编辑态
             this.status = SItemStatus.Normal;
             this.releaseItem();
         }
@@ -348,6 +369,7 @@ export class SBaseCircleEdit extends SGraphEdit {
      * 移动后处理所有坐标,并肩原点置为场景原点
      */
     moveToOrigin(): void {
+        // 遍历本身控制点
         this.line = this.line.map(t => {
             t.x = t.x + this.x;
             t.y = t.y + this.y;
@@ -386,22 +408,25 @@ export class SBaseCircleEdit extends SGraphEdit {
      */
     onDraw(painter: SPainter): void {
         if (this.line.length == 2) {
+            // 本对象控制点有 2 个
             painter.pen.color = this.strokeColor;
             painter.brush.color = this.fillColor;
 
-            // 使用像素值
             if (this.widthIsPx) {
+                // 使用像素值
                 painter.pen.lineWidth = painter.toPx(this.lineWidth);
             } else {
                 //否则
                 painter.pen.lineWidth = this.lineWidth;
             }
             if (this.lineStyle == SLineStyle.Dashed) {
+                // 线类型为虚线
                 painter.pen.lineDash = [
                     painter.toPx(this.lineWidth * 3),
                     painter.toPx(this.lineWidth * 7)
                 ];
             } else if (this.lineStyle == SLineStyle.Dotted) {
+                // 线类型为点线
                 painter.pen.lineDash = [
                     painter.toPx(this.lineWidth * 2),
                     painter.toPx(this.lineWidth * 2)

+ 44 - 5
persagy-web-edit/src/items/SBaseCirclePolylineEdit.ts

@@ -152,6 +152,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
     }
     set radius(v: number) {
         if (v === this._radius) {
+            // 与旧值相等
             return;
         }
         this._radius = v;
@@ -171,6 +172,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
     constructor(parent: null | SGraphItem, data: Marker | null = null) {
         super(parent);
         if (data) {
+            // 传入数据则存储
             this.data = data;
         }
     } // Constructor
@@ -178,14 +180,17 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
     /**
      * 初始化 data 数据
      */
-    initData() {
+    initData(): void {
         const data = this.data;
+        // 没有存储数据不处理
         if (!data) return;
         this.name = data.name;
         this.moveTo(data.pos.x, data.pos.y);
         this.showSelect = false;
         if (data && data.style) {
+            // 数据中存在样式属性
             if (data.style.outLine) {
+                // 存在轮廓线
                 let setPointList: SPoint[];
                 setPointList = data.style.outLine.map(i => {
                     return new SPoint(i.x, i.y);
@@ -195,6 +200,8 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
 
             this.moveable = data.style.isMove ? data.style.isMove : false;
             if (data.style && data.style.default) {
+                // 存在默认样式
+
                 // 颜色
                 if (data.style.default.strokeColor) {
                     this.strokeColor = new SColor(
@@ -223,6 +230,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      */
     private addPoint(p: SPoint, index?: number): void {
         if (index && this.canHandle(index)) {
+            // 传入索引且索引有效
             this.pointList.splice(index, 0, p);
             this.recordAction(SGraphPointListInsert, [
                 this.pointList,
@@ -230,6 +238,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
                 index
             ]);
         } else {
+            // 否则
             this.pointList.push(p);
             this.recordAction(SGraphPointListInsert, [this.pointList, p]);
         }
@@ -254,6 +263,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      */
     deletePoint(index: number): void {
         if (this.canHandle(index) && this.pointList.length > 2) {
+            // 索引值有效且本对象的点数据个数大于2个
             const p = new SPoint(
                 this.pointList[this.curIndex].x,
                 this.pointList[this.curIndex].y
@@ -280,14 +290,18 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
         this.curIndex = -1;
         this.curPoint = null;
         if (event.shiftKey || this.verAndLeve) {
+            // 按下了 shift 键 或者模拟 shift 键功能开启
             event = this.compare(event);
         }
 
         if (event.buttons == 1) {
+            // 按下的是左键
             if (this.status == SItemStatus.Create) {
+                // 处于创建态
                 this.addPoint(new SPoint(event.x, event.y));
                 return true;
             } else if (this.status == SItemStatus.Edit) {
+                // 处于编辑态
                 // 查询鼠标最近的索引
                 this.findNearestPoint(new SPoint(event.x, event.y));
                 // 增加点
@@ -318,22 +332,29 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      */
     onMouseMove(event: SMouseEvent): boolean {
         if (event.shiftKey || this.verAndLeve) {
+            // 按下了 shift 键 或者模拟 shift 键功能开启
             event = this.compare(event);
         }
 
         if (this.status == SItemStatus.Create) {
+            // 处于创建态
             if (this.lastPoint) {
+                // 最后一个点存在
                 this.lastPoint.x = event.x;
                 this.lastPoint.y = event.y;
             } else {
+                // 否则
                 this.lastPoint = new SPoint(event.x, event.y);
             }
 
             this.update();
             return true;
         } else if (this.status == SItemStatus.Edit) {
+            // 处于编辑态
             if (event.buttons == 1) {
+                // 按下的是左键
                 if (this.canHandle(this.curIndex)) {
+                    // 索引值有效
                     this.pointList[this.curIndex].x = event.x;
                     this.pointList[this.curIndex].y = event.y;
                 }
@@ -342,6 +363,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
             this.update();
             return true;
         } else {
+            // 否则
             return super.onMouseMove(event);
         }
     }
@@ -354,7 +376,9 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      */
     onMouseUp(event: SMouseEvent): boolean {
         if (this.status == SItemStatus.Edit) {
+            // 处于编辑态
             if (this.curIndex > -1) {
+                // 索引值有效
                 const p = new SPoint(
                     this.pointList[this.curIndex].x,
                     this.pointList[this.curIndex].y
@@ -367,6 +391,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
                 ]);
             }
         } else if (this.status == SItemStatus.Normal) {
+            // 处于正常态
             super.onMouseUp(event);
             return true;
         }
@@ -381,17 +406,19 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      * @return 是否处理事件
      */
     onDoubleClick(event: SMouseEvent): boolean {
-        // 如果为show状态 双击改对象则需改为编辑状态
         if (this.status == SItemStatus.Normal) {
+            // 处于正常态 双击改为编辑状态
             this.status = SItemStatus.Edit;
+            // @ts-ignore
             this.grabItem(this);
         } else if (this.status == SItemStatus.Edit) {
-            // 编辑状态
+            // 处于编辑状态 双击则改为正常态
             this.status = SItemStatus.Normal;
             this.releaseItem();
         } else if (this.status == SItemStatus.Create) {
-            // 创建状态
+            // 处于创建状态
             if (this.pointList.length > 1) {
+                // 本对象点数据中已经给存在的点个数大于1个
                 this.status = SItemStatus.Normal;
                 this.releaseItem();
                 this.$emit("finishCreated");
@@ -409,8 +436,11 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      */
     onKeyUp(event: KeyboardEvent): void {
         if (event.keyCode == SKeyCode.Enter) {
+            // 按键为 enter 键
             if (this.pointList.length > 1) {
+                // 点数据个数大于一个
                 if (this.status == SItemStatus.Create) {
+                    // 处于创建态
                     this.$emit("finishCreated");
                 }
 
@@ -418,11 +448,11 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
                 this.releaseItem();
             }
         }
-        // delete删除点
         if (
             event.keyCode == SKeyCode.Delete &&
             this.status == SItemStatus.Edit
         ) {
+            // 处于编辑态且按键为 delete 键, 则删除点
             this.deletePoint(this.curIndex);
         }
     }
@@ -431,6 +461,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      * 移动后处理所有坐标,并肩原点置为场景原点
      */
     moveToOrigin(): void {
+        // 遍历本身点数据坐标
         this.pointList = this.pointList.map(t => {
             t.x = t.x + this.x;
             t.y = t.y + this.y;
@@ -447,6 +478,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      */
     findNearestPoint(p: SPoint): void {
         let len = this.sceneDis;
+        // 遍历本身点数据列表
         for (let i = 0; i < this.pointList.length; i++) {
             let dis = SMathUtil.pointDistance(
                 p.x,
@@ -455,6 +487,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
                 this.pointList[i].y
             );
             if (dis < len) {
+                // 点击点到对象中的点距离在吸附距离之内
                 len = dis;
                 this.curIndex = i;
                 this.curPoint = new SPoint(
@@ -476,12 +509,15 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
                 new SLine(this.pointList[0], this.pointList[1])
             ),
             index = 0;
+        // 点数据个数大于2
         if (this.pointList.length > 2) {
+            // 遍历点数据列表
             for (let i = 1; i < this.pointList.length - 1; i++) {
                 let dis = SMathUtil.pointToLine(
                     p,
                     new SLine(this.pointList[i], this.pointList[i + 1])
                 );
+                // 点击点到对象中的点距离在吸附距离之内
                 if (dis.MinDis < len.MinDis) {
                     len = dis;
                     index = i;
@@ -490,7 +526,9 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
         }
 
         if (len.MinDis < this.sceneDis) {
+            // 如果点击点到第条线距离在吸附距离之内
             if (len.Point) {
+                // 存在吸附的点
                 this.addPoint(len.Point, index + 1);
             }
         }
@@ -504,6 +542,7 @@ export default class SBaseCirclePolylineEdit extends SGraphEdit {
      */
     compare(event: SMouseEvent): SMouseEvent {
         if (this.pointList.length) {
+            // 点数据列表有效
             let last = new SPoint(event.x, event.y);
             if (this.status == SItemStatus.Create) {
                 last = this.pointList[this.pointList.length - 1];

+ 20 - 19
persagy-web-edit/src/items/SBasePolygonEdit.ts

@@ -45,7 +45,7 @@ import {
 import { SItemStatus, ItemOrder } from "@persagy-web/big";
 import { Marker } from "../type/Marker";
 import { SMathUtil } from "@persagy-web/big/lib/utils/SMathUtil";
-import { SGraphEdit } from ".."
+import { SGraphEdit } from "..";
 
 /**
  * 编辑多边形
@@ -166,8 +166,8 @@ export class SBasePolygonEdit extends SGraphEdit {
                     this.setPointList = data.style.outLine;
                 } else {
                     setPointList = data.style.outLine.map(i => {
-                        return (new SPoint(i.x, i.y))
-                    })
+                        return new SPoint(i.x, i.y);
+                    });
                     this.setPointList = setPointList;
                 }
             }
@@ -176,22 +176,24 @@ export class SBasePolygonEdit extends SGraphEdit {
             if (data.style.default) {
                 // 颜色
                 if (data.style.default.strokeColor) {
-                    this.strokeColor = new SColor(data.style.default.strokeColor)
+                    this.strokeColor = new SColor(
+                        data.style.default.strokeColor
+                    );
                 }
 
                 // 线宽
                 if (data.style.default.lineWidth) {
-                    this.lineWidth = data.style.default.lineWidth
+                    this.lineWidth = data.style.default.lineWidth;
                 }
 
                 // 线样式
                 if (data.style.default.lineStyle) {
-                    this.lineStyle = data.style.default.lineStyle
+                    this.lineStyle = data.style.default.lineStyle;
                 }
 
                 // 填充色
                 if (data.style.default.fillColor) {
-                    this.fillColor = new SColor(data.style.default.fillColor)
+                    this.fillColor = new SColor(data.style.default.fillColor);
                 }
             }
         }
@@ -289,7 +291,7 @@ export class SBasePolygonEdit extends SGraphEdit {
      * @return    移动对应得点。如果索引无法找到移动顶点,则返回 null
      */
     movePoint(x: number, y: number, i: number): SPoint | null {
-        let point
+        let point;
         if (i >= this.pointList.length || i < 0) {
             return null;
         }
@@ -488,9 +490,9 @@ export class SBasePolygonEdit extends SGraphEdit {
             // 2判断是否点击在多边形得边上
             if (-1 == lenIndex) {
                 let len = SMathUtil.pointToLine(
-                    new SPoint(event.x, event.y),
-                    new SLine(this.pointList[0], this.pointList[1])
-                ),
+                        new SPoint(event.x, event.y),
+                        new SLine(this.pointList[0], this.pointList[1])
+                    ),
                     index = 0;
                 if (this.pointList.length > 2) {
                     for (let i = 1; i < this.pointList.length; i++) {
@@ -869,7 +871,6 @@ export class SBasePolygonEdit extends SGraphEdit {
                 if (y > this.maxY) {
                     this.maxY = y;
                 }
-
             });
         }
 
@@ -902,13 +903,13 @@ export class SBasePolygonEdit extends SGraphEdit {
      *
      * @return	对象参数
      */
-    toData() : any {
-        this.moveToOrigin();        
+    toData(): any {
+        this.moveToOrigin();
         const Line = this.pointList.map(pos => {
             return {
                 x: pos.x,
                 y: pos.y
-            }
+            };
         });
 
         this.data.style.outLine = Line;
@@ -916,22 +917,22 @@ export class SBasePolygonEdit extends SGraphEdit {
         this.data.style.default.lineStyle = this.lineStyle;
         this.data.style.default.strokeColor = this.strokeColor.value;
         this.data.style.default.fillColor = this.fillColor.value;
-        return this.data
+        return this.data;
     }
 
     /**
      * 选择器放缩控制大小变化'
-     * 
+     *
      * @param old    旧的大小
      * @param newS   新的大小
-    */
+     */
     resize(old: SSize, newS: SSize): void {
         const xs = newS.width / old.width;
         const ys = newS.height / old.height;
         this.pointList = this.pointList.map(item => {
             item.x = item.x * xs;
             item.y = item.y * ys;
-            return item
+            return item;
         });
     }
 

+ 26 - 24
persagy-web-edit/src/items/SBasePolylineEdit.ts

@@ -26,8 +26,8 @@
 
 import { SColor, SLine, SPainter, SPoint, SRect } from "@persagy-web/draw";
 import { SKeyCode, SMouseEvent, SUndoStack } from "@persagy-web/base";
-import { SItemStatus } from "@persagy-web/big";;
-import { SMathUtil } from "@persagy-web/big/lib/utils/SMathUtil";;
+import { SItemStatus } from "@persagy-web/big";
+import { SMathUtil } from "@persagy-web/big/lib/utils/SMathUtil";
 import {
     SGraphPointListDelete,
     SGraphPointListInsert,
@@ -35,10 +35,9 @@ import {
     SLineStyle,
     SGraphItem
 } from "@persagy-web/graph/";
-import { SGraphEdit } from ".."
+import { SGraphEdit } from "..";
 import { Marker } from "../type/Marker";
 
-
 /**
  * 折线编辑类
  *
@@ -46,13 +45,13 @@ import { Marker } from "../type/Marker";
  */
 export class SBasePolylineEdit extends SGraphEdit {
     /** 传入数据 */
-    _data: Marker | null = null;
+    private _data: Marker | null = null;
     get data(): Marker | null {
         return this._data;
     } // Get data
     set data(v: Marker | null) {
         this._data = v;
-        this.initData()
+        this.initData();
         this.update();
     } // Set data
 
@@ -120,11 +119,11 @@ export class SBasePolylineEdit extends SGraphEdit {
     }
 
     /** 是否垂直水平绘制 */
-    private _verAndLeve: Boolean = false;
-    get verAndLeve(): Boolean {
+    private _verAndLeve: boolean = false;
+    get verAndLeve(): boolean {
         return this._verAndLeve;
     }
-    set verAndLeve(bool: Boolean) {
+    set verAndLeve(bool: boolean) {
         this._verAndLeve = bool;
         this.update();
     }
@@ -151,7 +150,6 @@ export class SBasePolylineEdit extends SGraphEdit {
         if (data) {
             this.data = data;
         }
-
     } // Constructor
 
     /**
@@ -167,7 +165,7 @@ export class SBasePolylineEdit extends SGraphEdit {
             if (data.style.outLine) {
                 let setPointList: SPoint[];
                 setPointList = data.style.outLine.map(i => {
-                    return new SPoint(i.x, i.y)
+                    return new SPoint(i.x, i.y);
                 });
                 this.pointList = setPointList;
             }
@@ -176,22 +174,23 @@ export class SBasePolylineEdit extends SGraphEdit {
             if (data.style && data.style.default) {
                 // 颜色
                 if (data.style.default.strokeColor) {
-                    this.strokeColor = new SColor(data.style.default.strokeColor)
+                    this.strokeColor = new SColor(
+                        data.style.default.strokeColor
+                    );
                 }
 
                 // 线宽
                 if (data.style.default.lineWidth) {
-                    this.lineWidth = data.style.default.lineWidth
+                    this.lineWidth = data.style.default.lineWidth;
                 }
 
                 // 线样式
                 if (data.style.default.lineStyle) {
-                    this.lineStyle = data.style.default.lineStyle
+                    this.lineStyle = data.style.default.lineStyle;
                 }
             }
-
         }
-    }// Function initData()
+    } // Function initData()
     /**
      * 添加点至数组中
      *
@@ -344,7 +343,7 @@ export class SBasePolylineEdit extends SGraphEdit {
                 ]);
             }
         } else if (this.status == SItemStatus.Normal) {
-            super.onMouseUp(event)
+            super.onMouseUp(event);
             return true;
         }
 
@@ -361,11 +360,14 @@ export class SBasePolylineEdit extends SGraphEdit {
         // 如果为show状态 双击改对象则需改为编辑状态
         if (this.status == SItemStatus.Normal) {
             this.status = SItemStatus.Edit;
+            // @ts-ignore
             this.grabItem(this);
-        } else if (this.status == SItemStatus.Edit) { // 编辑状态
+        } else if (this.status == SItemStatus.Edit) {
+            // 编辑状态
             this.status = SItemStatus.Normal;
             this.releaseItem();
-        } else if (this.status == SItemStatus.Create) { // 创建状态
+        } else if (this.status == SItemStatus.Create) {
+            // 创建状态
             if (this.pointList.length > 1) {
                 this.status = SItemStatus.Normal;
                 this.releaseItem();
@@ -447,9 +449,9 @@ export class SBasePolylineEdit extends SGraphEdit {
      */
     findAddPos(p: SPoint): void {
         let len = SMathUtil.pointToLine(
-            p,
-            new SLine(this.pointList[0], this.pointList[1])
-        ),
+                p,
+                new SLine(this.pointList[0], this.pointList[1])
+            ),
             index = 0;
         if (this.pointList.length > 2) {
             for (let i = 1; i < this.pointList.length - 1; i++) {
@@ -645,13 +647,13 @@ export class SBasePolylineEdit extends SGraphEdit {
             return {
                 x: pos.x,
                 y: pos.y
-            }
+            };
         });
         this.data.style.outLine = Line;
         this.data.style.default.lineWidth = this.lineWidth;
         this.data.style.default.lineStyle = this.lineStyle;
         this.data.style.default.strokeColor = this.strokeColor.value;
-        return this.data
+        return this.data;
     }
 
     /**

+ 2 - 2
persagy-web-graph/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/graph",
-    "version": "2.2.44",
+    "version": "2.2.45",
     "description": "博锐尚格二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -40,7 +40,7 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@persagy-web/draw": "2.2.12",
+        "@persagy-web/draw": "2.2.13",
         "@types/uuid": "^8.0.0"
     }
 }

+ 1 - 0
persagy-web-graph/src/types/SGraphRect.ts

@@ -32,6 +32,7 @@ import { Style } from "./Style";
  */
 export interface SGraphRect {
     /** item 风格 */
+
     style?: Style;
     /** 矩形左上角 X 坐标 */
     x: number;