فهرست منبع

edit:feat>完善 edit 模块

YaolongHan 4 سال پیش
والد
کامیت
83e3efb122
32فایلهای تغییر یافته به همراه839 افزوده شده و 287 حذف شده
  1. 4 3
      persagy-web-edit/package.json
  2. 14 6
      persagy-web-edit/src/SGraphEdit.ts
  3. 107 38
      persagy-web-edit/src/SGraphEditScene.ts
  4. 10 10
      persagy-web-edit/src/commands/SGraphAddCommand.ts
  5. 81 0
      persagy-web-edit/src/commands/SGraphAddListCommand.ts
  6. 3 3
      persagy-web-edit/src/commands/SGraphCommand.ts
  7. 82 0
      persagy-web-edit/src/commands/SGraphDeleteListCommand.ts
  8. 11 11
      persagy-web-edit/src/commands/SGraphMoveCommand.ts
  9. 9 9
      persagy-web-edit/src/commands/SGraphPointListDelete.ts
  10. 11 9
      persagy-web-edit/src/commands/SGraphPointListInsert.ts
  11. 9 9
      persagy-web-edit/src/commands/SGraphPointListUpdate.ts
  12. 9 9
      persagy-web-edit/src/commands/SGraphPropertyCommand.ts
  13. 1 1
      persagy-web-edit/src/enums/SGraphLayoutType.ts
  14. 1 1
      persagy-web-edit/src/enums/SImageShowType.ts
  15. 1 1
      persagy-web-edit/src/enums/SLineStyle.ts
  16. 1 1
      persagy-web-edit/src/enums/SOrderSetType.ts
  17. 1 1
      persagy-web-edit/src/enums/STextOrigin.ts
  18. 2 1
      persagy-web-edit/src/index.ts
  19. 6 9
      persagy-web-edit/src/items/SBaseArrowEdit.ts
  20. 19 2
      persagy-web-edit/src/items/SBaseCircleEdit.ts
  21. 209 76
      persagy-web-edit/src/items/SBaseIconTextEdit.ts
  22. 55 6
      persagy-web-edit/src/items/SBaseImageEdit.ts
  23. 46 33
      persagy-web-edit/src/items/SBaseLineEdit.ts
  24. 25 10
      persagy-web-edit/src/items/SBasePolygonEdit.ts
  25. 32 15
      persagy-web-edit/src/items/SBasePolylineEdit.ts
  26. 23 6
      persagy-web-edit/src/items/SBaseRectEdit.ts
  27. 44 6
      persagy-web-edit/src/items/SBaseTextEdit.ts
  28. 1 1
      persagy-web-edit/src/type/Anchor.ts
  29. 3 3
      persagy-web-edit/src/type/ElementData.ts
  30. 7 3
      persagy-web-edit/src/type/Legend.ts
  31. 6 2
      persagy-web-edit/src/type/Marker.ts
  32. 6 2
      persagy-web-edit/src/type/Relation.ts

+ 4 - 3
persagy-web-edit/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/edit",
-    "version": "2.2.1",
+    "version": "2.2.2",
     "description": "博锐尚格二维图形编辑器。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -40,7 +40,8 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@persagy-web/graph": "2.2.22",
+        "@persagy-web/big": "2.2.19",
+        "@persagy-web/graph": "2.2.23",
         "@types/uuid": "^8.0.0"
     }
-}
+}

+ 14 - 6
persagy-web-edit/src/SGraphEdit.ts

@@ -50,6 +50,12 @@ export class SGraphEdit extends SGraphItem {
         this.update();
     } // Set status
 
+    /** 存储数据 Mark */
+    data: any;
+    /** 存储数据 legend */
+    legendData: any;
+    /** 存储数据 Relation */
+    relationData: any
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //函数
     /**
@@ -64,21 +70,21 @@ export class SGraphEdit extends SGraphItem {
         }
 
         this.selectable = true;
-    } // Constructor
+    }
 
     /**
      * 重做
      */
     redo(): void {
         // do nothing
-    } // Function redo()
+    }
 
     /**
      * 撤销
      */
     undo(): void {
         // do nothing
-    } // Function undo()
+    }
 
     /**
      * 将类中得数据转换为方便存储格式的方法
@@ -87,14 +93,16 @@ export class SGraphEdit extends SGraphItem {
      */
     toData(): any {
         // do nothing
-    } // Function toData()
+    }
+
     /**
      * 将类中得数据转换为方便存储格式的方法
      *
+     * @param event 鼠标事件
      * @return 针对 item 类型保持相应的格式
      */
     onContextMenu(event: SMouseEvent): boolean {
         this.$emit('onContextMenu', event);
         return true;
-    } // Function onContextMenu()
-} // Class SGraphEdit
+    }
+}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 107 - 38
persagy-web-edit/src/SGraphEditScene.ts


+ 10 - 10
persagy-web-edit/src/commands/SGraphAddCommand.ts

@@ -25,7 +25,7 @@
  */
 
 import { SGraphCommand } from "./SGraphCommand";
-import { SGraphItem,SGraphScene } from "@persagy-web/graph/";
+import { SGraphItem, SGraphScene } from "@persagy-web/graph/";
 import { SUndoCommand } from "@persagy-web/base";
 
 /**
@@ -46,40 +46,40 @@ export class SGraphAddCommand extends SGraphCommand {
      *
      * @param scene   item 所在场景
      * @param item    命令 item 对象
-    */
+     */
     constructor(scene: SGraphScene, item: SGraphItem) {
         super(scene);
         this.item = item;
         this.parent = item.parent;
         this.command = "SGraphAddCommand";
         this.desc = `添加对象=${item.id}`;
-    } // Constructor
+    }
 
     /**
      * 合并命令
      *
      * @param command   命令对象
      * @return 是否已执行合并
-    */
+     */
     mergeWith(command: SUndoCommand): boolean {
         return false;
-    } // Function mergeWith()
+    }
 
     /**
      * 重做
-    */
+     */
     redo(): void {
         this.item.parent = this.parent;
         // @ts-ignore
         this.parent.update();
-    } // Function redo()
+    }
 
     /**
      * 撤销
-    */
+     */
     undo(): void {
         this.item.parent = null;
         // @ts-ignore
         this.parent.update();
-    } // Function undo()
-} // Class SGraphAddCommand
+    }
+}

+ 81 - 0
persagy-web-edit/src/commands/SGraphAddListCommand.ts

@@ -0,0 +1,81 @@
+/*
+ * *********************************************************************************************************************
+ *
+ *          !!
+ *        .F88X
+ *        X8888Y
+ *      .}888888N;
+ *        i888888N;        .:!              .I$WI:
+ *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
+ *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
+ *            +888888N;  .8888888Y                                  "&&8Y.}8,
+ *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
+ *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
+ *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
+ *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
+ *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
+ *          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.  博锐尚格科技股份有限公司
+ *        ~8888'
+ *        .!88~                                                                     All rights reserved.
+ *
+ * *********************************************************************************************************************
+ */
+
+import { SUndoCommand } from '@persagy-web/base/lib';
+import { SGraphCommand, SGraphItem, SGraphScene } from '@persagy-web/graph/lib';
+
+/**
+ * 批量添加 item 命令
+ *
+ * @author 韩耀龙 <han_yao_long@163.com>
+ */
+export class SGraphAddListCommand extends SGraphCommand {
+    /** 命令item对象    */
+    itemList: SGraphItem[];
+    /** 命令名称    */
+    readonly command: string = "AddListCommand"
+    /** 命令item的父类   */
+    parent: SGraphItem | null;
+    constructor(scene: SGraphScene, itemList: SGraphItem[]) {
+        super(scene);
+        this.itemList = itemList;
+        this.parent = itemList[0].parent;
+    }
+
+    /**
+     * 合并命令
+     *
+     * @param command   命令对象
+     * @return 是否已执行合并
+     */
+    mergeWith(command: SUndoCommand): boolean {
+        return false;
+    }
+
+    /**
+     * 重做
+     *
+     */
+    redo(): void {
+        this.itemList.map((item) => {
+            item.parent = this.parent;
+        })
+        // @ts-ignore
+        this.parent.update();
+    }
+
+    /**
+     * 撤销
+     *
+     */
+    undo(): void {
+        this.itemList.map((item) => {
+            item.parent = null;
+        })
+        // @ts-ignore
+        this.parent.update();
+    }
+}

+ 3 - 3
persagy-web-edit/src/commands/SGraphCommand.ts

@@ -40,9 +40,9 @@ export abstract class SGraphCommand extends SUndoCommand {
      * 构造函数
      *
      * @param scene   命令所属的场景类
-    */
+     */
     protected constructor(scene: SGraphScene | null) {
         super();
         this.scene = scene;
-    } // Constructor
-} // Class SGraphCommand
+    }
+}

+ 82 - 0
persagy-web-edit/src/commands/SGraphDeleteListCommand.ts

@@ -0,0 +1,82 @@
+/*
+ * *********************************************************************************************************************
+ *
+ *          !!
+ *        .F88X
+ *        X8888Y
+ *      .}888888N;
+ *        i888888N;        .:!              .I$WI:
+ *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
+ *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
+ *            +888888N;  .8888888Y                                  "&&8Y.}8,
+ *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
+ *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
+ *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
+ *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
+ *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
+ *          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.  博锐尚格科技股份有限公司
+ *        ~8888'
+ *        .!88~                                                                     All rights reserved.
+ *
+ * *********************************************************************************************************************
+ */
+
+import { SGraphCommand } from "@persagy-web/graph/lib/commands/SGraphCommand";
+import { SGraphItem } from "@persagy-web/graph/lib/SGraphItem";
+import { SUndoCommand } from "@persagy-web/base";
+import { SGraphScene } from "@persagy-web/graph/";
+
+/**
+ * 删除多个 item 命令
+ *
+ * @author 韩耀龙 <han_yao_long@163.com>
+ */
+
+export class SGraphDeleteListCommand extends SGraphCommand {
+    /** 命令item对象    */
+    itemList: SGraphItem[];
+    desc: string = 'DeleteCommandList'
+    /** 命令名称    */
+    readonly command: string = "DeleteCommandList"
+    /** 命令item的父类   */
+    parent: SGraphItem | null;
+    constructor(scene: SGraphScene, itemList: SGraphItem[]) {
+        super(scene);
+        this.itemList = itemList;
+        this.parent = itemList[0].parent;
+    }
+
+    /**
+     * 合并命令
+     * @param command 合并对象
+     * @return 是否已执行合并
+     */
+    mergeWith(command: SUndoCommand): boolean {
+        return false;
+    }
+
+    /**
+     * 重做
+     */
+    undo(): void {
+        this.itemList.map((item) => {
+            item.parent = this.parent;
+        })
+        // @ts-ignore
+        this.parent.update();
+    }
+
+    /**
+     * 撤销
+     */
+    redo(): void {
+        this.itemList.map((item) => {
+            item.parent = null;
+        })
+        // @ts-ignore
+        this.parent.update();
+    }
+}

+ 11 - 11
persagy-web-edit/src/commands/SGraphMoveCommand.ts

@@ -52,7 +52,7 @@ export class SGraphMoveCommand extends SGraphCommand {
      * @param item     item 对象
      * @param old      移动前位置
      * @param pos      移动后位置
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -65,14 +65,14 @@ export class SGraphMoveCommand extends SGraphCommand {
         this.pos = pos;
         this.command = "SGraphMoveCommand";
         this.desc = `移动对象=${item.id}`;
-    } // Constructor
+    }
 
     /**
      * 合并命令
      *
      * @param command      命令
      * @return 是否已执行合并命令
-    */
+     */
     mergeWith(command: SUndoCommand): boolean {
         if (command instanceof SGraphMoveCommand && command.item == this.item) {
             command.pos = this.pos;
@@ -80,32 +80,32 @@ export class SGraphMoveCommand extends SGraphCommand {
         }
 
         return false;
-    } // Function mergeWith()
+    }
 
     /**
      * 重做
-    */
+     */
     redo(): void {
         this.item.pos = new SPoint(this.pos.x, this.pos.y);
         this.item.update();
-    } // Function redo()
+    }
 
     /**
      * 撤销
-    */
+     */
     undo(): void {
         this.item.pos = new SPoint(this.old.x, this.old.y);
         this.item.update();
-    } // Function undo()
+    }
 
     /**
      * 命令细节描述
      *
      * @return 字符串类型的数据
-    */
+     */
     toString(): string {
         return `oldPos=${JSON.stringify(this.old)};\nnewPos=${JSON.stringify(
             this.pos
         )}`;
-    } // Function toString()
-} // Class SGraphMoveCommand
+    }
+}

+ 9 - 9
persagy-web-edit/src/commands/SGraphPointListDelete.ts

@@ -52,7 +52,7 @@ export class SGraphPointListDelete extends SGraphCommand {
      * @param pointList   顶点数组
      * @param pos         删除的点
      * @param index       索引
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -67,11 +67,11 @@ export class SGraphPointListDelete extends SGraphCommand {
         this.pos = pos;
         this.command = "SGraphPointListDelete";
         this.desc = `删除折点=${item.id}`;
-    } // Constructor
+    }
 
     /**
      * 执行重做操作执行
-    */
+     */
     redo(): void {
         if (this.index == null) {
             this.pointList.pop();
@@ -80,11 +80,11 @@ export class SGraphPointListDelete extends SGraphCommand {
         }
 
         this.item.update();
-    } // Function redo()
+    }
 
     /**
      * 执行取消操作执行
-    */
+     */
     undo(): void {
         if (this.pos == null) return;
 
@@ -95,17 +95,17 @@ export class SGraphPointListDelete extends SGraphCommand {
         }
 
         this.item.update();
-    } // Function undo()
+    }
 
     /**
      * 命令细节描述
      *
      * @return 字符串类型数据
-    */
+     */
     toString(): string {
         const pointList = `pointList=${JSON.stringify(this.pointList)}`;
         const pos = `pos=${JSON.stringify(this.pos)}`;
         const index = `index=${this.index}`;
         return `${index};\n${pos};\n${pointList}`;
-    } // Function toString()
-} // Class SGraphPointListDelete
+    }
+}

+ 11 - 9
persagy-web-edit/src/commands/SGraphPointListInsert.ts

@@ -52,7 +52,7 @@ export class SGraphPointListInsert extends SGraphCommand {
      * @param pointList   顶点数组
      * @param pos         当前位置
      * @param index       索引
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -67,11 +67,11 @@ export class SGraphPointListInsert extends SGraphCommand {
         this.pointList = pointList;
         this.command = "SGraphPointListInsert";
         this.desc = `添加折点=${item.id}`;
-    } // Constructor
+    }
 
     /**
      * 执行重做操作执行
-    */
+     */
     redo(): void {
         const point = new SPoint(this.pos.x, this.pos.y);
         if (this.index == null) {
@@ -79,30 +79,32 @@ export class SGraphPointListInsert extends SGraphCommand {
         } else {
             this.pointList.splice(this.index, 0, point);
         }
+
         this.item.update();
-    } // Function redo()
+    }
 
     /**
      * 执行取消操作执行
-    */
+     */
     undo(): void {
         if (this.index == null) {
             this.pointList.pop();
         } else {
             this.pointList.splice(this.index, 1);
         }
+
         this.item.update();
-    } // Function undo()
+    }
 
     /**
      * 命令细节描述
      *
      * @return 字符串类型数据
-    */
+     */
     toString(): string {
         const pointList = `pointList=${JSON.stringify(this.pointList)}`;
         const pos = `pos=${JSON.stringify(this.pos)}`;
         const index = `index=${this.index}`;
         return `${index};\n${pos};\n${pointList}`;
-    } // Function toString()
-} // Class SGraphPointListInsert()
+    }
+}

+ 9 - 9
persagy-web-edit/src/commands/SGraphPointListUpdate.ts

@@ -55,7 +55,7 @@ export class SGraphPointListUpdate extends SGraphCommand {
      * @param old         原位置
      * @param pos         当前位置
      * @param index       索引
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -72,36 +72,36 @@ export class SGraphPointListUpdate extends SGraphCommand {
         this.pointList = pointList;
         this.command = "SGraphPointListUpdate";
         this.desc = `更新折点=${item.id}`;
-    } // Constructor
+    }
 
     /**
      * 执行重做操作执行
-    */
+     */
     redo(): void {
         this.pointList[this.index].x = this.pos.x;
         this.pointList[this.index].y = this.pos.y;
         this.item.update();
-    } // Function redo()
+    }
 
     /**
      * 执行取消操作执行
-    */
+     */
     undo(): void {
         this.pointList[this.index].x = this.old.x;
         this.pointList[this.index].y = this.old.y;
         this.item.update();
-    } // Function undo()
+    }
 
     /**
      * 命令细节描述
      *
      * @return 字符串型数据
-    */
+     */
     toString(): string {
         const pointList = `pointList=${JSON.stringify(this.pointList)}`;
         const old = `old=${JSON.stringify(this.old)}`;
         const pos = `pos=${JSON.stringify(this.pos)}`;
         const index = `index=${this.index}`;
         return `${index};\n${old};\n${pos};\n${pointList}`;
-    } // Function toString()
-} // Class SGraphPointListUpdate
+    }
+}

+ 9 - 9
persagy-web-edit/src/commands/SGraphPropertyCommand.ts

@@ -53,7 +53,7 @@ export class SGraphPropertyCommand<T> extends SGraphCommand {
      * @param propName    修改的属性名称
      * @param oldProp     修改前的属性值
      * @param newProp     修改后的属性值
-    */
+     */
     constructor(
         scene: SGraphScene,
         item: SGraphItem,
@@ -68,35 +68,35 @@ export class SGraphPropertyCommand<T> extends SGraphCommand {
         this.newProp = newProp;
         this.command = "SGraphPropertyCommand";
         this.command = `更新属性=${item.id}`;
-    } // Constructor
+    }
 
     /**
      * redo 操作
-    */
+     */
     redo(): void {
         // @ts-ignore
         this.item[this.propName] = this.newProp;
         this.item.update();
-    } // Function redo()
+    }
 
     /**
      * undo 操作
-    */
+     */
     undo(): void {
         // @ts-ignore
         this.item[this.propName] = this.oldProp;
         this.item.update();
-    } // Function undo()
+    }
 
     /**
      * 命令细节描述
      *
      * @return 字符串型数据
-    */
+     */
     toString(): string {
         const propName = `propName=${this.propName}`;
         const oldProp = `oldProp=${JSON.stringify(this.oldProp)}`;
         const newProp = `newProp=${JSON.stringify(this.newProp)}`;
         return `${propName};\n${oldProp};\n${newProp}`;
-    } // Function toString()
-} // Class SGraphPropertyCommand
+    }
+}

+ 1 - 1
persagy-web-edit/src/enums/SGraphLayoutType.ts

@@ -46,4 +46,4 @@ export enum SGraphLayoutType {
     Center,
     /** 垂直居中 */
     Middle
-} // Enum SGraphLayoutType
+}

+ 1 - 1
persagy-web-edit/src/enums/SImageShowType.ts

@@ -36,4 +36,4 @@ export enum SImageShowType {
     AutoFit,
     /** 等比缩放 */
     Equivalency
-} // Enum SImageShowType
+}

+ 1 - 1
persagy-web-edit/src/enums/SLineStyle.ts

@@ -38,4 +38,4 @@ export enum SLineStyle {
     Dotted,
     /** 无 */
     None
-} // Enum SLineStyle
+}

+ 1 - 1
persagy-web-edit/src/enums/SOrderSetType.ts

@@ -38,4 +38,4 @@ export enum SOrderSetType {
     After,
     /** 下移一层 */
     Before
-} // Enum SOrderSetType
+}

+ 1 - 1
persagy-web-edit/src/enums/STextOrigin.ts

@@ -34,4 +34,4 @@ export enum STextOrigin {
   LeftTop,
   /** 中心点 */
   Center,
-} // Enum STextOrigin
+}

+ 2 - 1
persagy-web-edit/src/index.ts

@@ -39,9 +39,10 @@ import { SBaseTextEdit } from "./items/SBaseTextEdit" ;
 import { SGraphCommand } from "./commands/SGraphCommand";
 import { SGraphAddCommand } from "./commands/SGraphAddCommand";
 import { SGraphMoveCommand } from "./commands/SGraphMoveCommand";
+import { SGraphDeleteListCommand } from "./commands/SGraphDeleteListCommand";
 import { SGraphPointListDelete } from "./commands/SGraphPointListDelete";
 import { SGraphPointListInsert } from "./commands/SGraphPointListInsert";
 import { SGraphPointListUpdate } from "./commands/SGraphPointListUpdate";
 import { SGraphPropertyCommand } from "./commands/SGraphPropertyCommand";
 
-export {SBasePolylineEdit, SBaseIconTextEdit, SBasePolygonEdit, SBaseTextEdit, SBaseImageEdit, SBaseLineEdit, SBaseCircleEdit, SBaseTriangleEdit, SBaseRectEdit, SBaseArrowEdit, SGraphEditScene, SGraphEdit, SGraphCommand, SGraphAddCommand, SGraphMoveCommand, SGraphPointListDelete, SGraphPointListInsert, SGraphPointListUpdate, SGraphPropertyCommand }
+export {SGraphDeleteListCommand,SBasePolylineEdit, SBaseIconTextEdit, SBasePolygonEdit, SBaseTextEdit, SBaseImageEdit, SBaseLineEdit, SBaseCircleEdit, SBaseTriangleEdit, SBaseRectEdit, SBaseArrowEdit, SGraphEditScene, SGraphEdit, SGraphCommand, SGraphAddCommand, SGraphMoveCommand, SGraphPointListDelete, SGraphPointListInsert, SGraphPointListUpdate, SGraphPropertyCommand }

+ 6 - 9
persagy-web-edit/src/items/SBaseArrowEdit.ts

@@ -329,8 +329,8 @@ export class SBaseArrowEdit extends SGraphEdit {
         ]);
       }
     } else if (this.status == SItemStatus.Normal) {
-      this.moveToOrigin(this.x, this.y);
-      return super.onMouseUp(event);
+      super.onMouseUp(event)
+      return true;
     }
 
     this.curIndex = -1;
@@ -390,15 +390,11 @@ export class SBaseArrowEdit extends SGraphEdit {
 
   /**
    * 移动后处理所有坐标,并肩原点置为场景原点
-   *
-   * @param x   x 坐标
-   * @param y   y 坐标
   */
-  moveToOrigin(x: number, y: number): void {
-    super.moveToOrigin(x, y);
+  moveToOrigin(): void {
     this.line = this.line.map(t => {
-      t.x = t.x + x;
-      t.y = t.y + y;
+      t.x = t.x + this.x;
+      t.y = t.y + this.y;
       return t;
     });
 
@@ -551,6 +547,7 @@ export class SBaseArrowEdit extends SGraphEdit {
    * @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;

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

@@ -141,7 +141,6 @@ export class SBaseCircleEdit extends SGraphEdit {
         });
         this.line = setPointList;
         this.calRect()
-        console.log('this.line', this.line)
       }
     }
 
@@ -195,7 +194,9 @@ export class SBaseCircleEdit extends SGraphEdit {
         this.addPoint(new SPoint(event.x, event.y));
         return true;
       } else {
-        return super.onMouseDown(event);
+        // return super.onMouseDown(event);
+        super.onMouseDown(event);
+        return true;
       }
     }
 
@@ -343,12 +344,28 @@ export class SBaseCircleEdit extends SGraphEdit {
     }
   } // Function cancelOperate()
 
+   /**
+     * 移动后处理所有坐标,并肩原点置为场景原点
+     */
+    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;
+    } // Function moveToOrigin()
+  
   /**
    * 返回对象储存的相关数据
    *
    * @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.line = Line;
     this.data.style.default.lineWidth = this.lineWidth;

+ 209 - 76
persagy-web-edit/src/items/SBaseIconTextEdit.ts

@@ -25,13 +25,10 @@
  */
 
 import {
-    SImageItem,
-    STextItem,
     SAnchorItem,
     SGraphItem,
-
 } from "@persagy-web/graph";
-import { SItemStatus, ItemOrder, } from "@persagy-web/big";
+import { SItemStatus, ItemOrder } from "@persagy-web/big";
 import { SMouseEvent } from "@persagy-web/base";
 import {
     SSize,
@@ -40,9 +37,8 @@ import {
     SColor,
     SFont,
     SPoint
-
 } from "@persagy-web/draw";
-import { SGraphEdit } from "..";
+import { SGraphEdit, SBaseTextEdit, SBaseImageEdit } from "..";
 import { Marker } from "../type/Marker";
 
 /**
@@ -52,6 +48,17 @@ import { Marker } from "../type/Marker";
  */
 
 export class SBaseIconTextEdit extends SGraphEdit {
+    /** item 数据*/
+    _data: Marker | null = null;
+    get data(): Marker | null {
+        return this._data;
+    } // Get data
+    set data(v: Marker | null) {
+        this._data = v;
+        this.initData()
+        this.update();
+    } // Set data
+
     /** item 状态 */
     _status: SItemStatus = SItemStatus.Normal;
     get status(): SItemStatus {
@@ -61,15 +68,21 @@ export class SBaseIconTextEdit extends SGraphEdit {
         this._status = v;
         if (v == SItemStatus.Normal) {
             this.moveable = true;
-            this.textItem.moveable = false;
+            this.textItemList.map(item => {
+                item.moveable = false
+            });
             this.img.moveable = false;
         } else if (v == SItemStatus.Edit) {
             this.moveable = false;
-            this.textItem.moveable = true;
+            this.textItemList.map(item => {
+                item.moveable = true
+            });
             this.img.moveable = true;
         } else if (v == SItemStatus.Create) {
             this.moveable = true;
-            this.textItem.moveable = false;
+            this.textItemList.map(item => {
+                item.moveable = false
+            });
             this.img.moveable = false;
         }
 
@@ -90,9 +103,13 @@ export class SBaseIconTextEdit extends SGraphEdit {
 
         this._showText = v;
         if (v) {
-            this.textItem.show();
+            this.textItemList.map(item => {
+                item.show()
+            });
         } else {
-            this.textItem.hide();
+            this.textItemList.map(item => {
+                item.hide()
+            });
         }
     } // Set showText
 
@@ -127,11 +144,15 @@ export class SBaseIconTextEdit extends SGraphEdit {
         this._isActive = v;
         if (v) {
             this.cursor = "pointer";
-            this.textItem.cursor = "pointer";
+            this.textItemList.map(item => {
+                item.cursor = "pointer"
+            });
             this.img.cursor = "pointer";
         } else {
             this.cursor = "auto";
-            this.textItem.cursor = "auto";
+            this.textItemList.map(item => {
+                item.cursor = "auto"
+            });
             this.img.cursor = "auto";
         }
 
@@ -197,7 +218,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
     } // Set sHeight
 
     /** 是否显示锚点 */
-    private _showAnchor: boolean = false;
+    private _showAnchor: boolean = true;
     get showAnchor(): boolean {
         return this._showAnchor;
     } // Get showAnchor
@@ -208,36 +229,45 @@ export class SBaseIconTextEdit extends SGraphEdit {
         });
     } // Set showAnchor
 
-    /** 文本内容 */
-    get text(): string {
-        return this.textItem.text;
-    } // Get text
-    set text(v: string) {
-        this.textItem.text = v;
-        this.update();
-    } // Set text
-
     /** 文本颜色 */
     get color(): SColor {
-        return this.textItem.color;
+        if (this.textItemList.length) {
+            return this.textItemList[0].color;
+        } else {
+            return new SColor();
+        }
     } // Get color
     set color(v: SColor) {
-        this.textItem.color = v;
+        this.textItemList.forEach(item => {
+            item.color = v;
+        })
         this.update();
     } // Set color
 
     /** 文本字体 */
     get font(): SFont {
-        return this.textItem.font;
+        if (this.textItemList.length) {
+            return this.textItemList[0].font
+        } else {
+            return new SFont
+        }
     } // Get font
+
     set font(v: SFont) {
-        this.textItem.font = v;
+        this.textItemList.forEach(item => {
+            item.font = v
+        })
         this.update();
     } // Set font
+
     /** 图像 */
-    img: SImageItem = new SImageItem(this);
-    /** 文本 */
-    textItem: STextItem = new STextItem(this);
+    img: SBaseImageEdit = new SBaseImageEdit(this);
+
+    /** 文本数组 */
+    textItemList: SBaseTextEdit[] = [];
+
+    /** 当前选中的文本item */
+    curTextItem: SBaseTextEdit | null = null;
 
     /**
      * 构造体
@@ -245,54 +275,97 @@ export class SBaseIconTextEdit extends SGraphEdit {
      * @param parent  父节点
      * @param data    锚点数据
     */
-    constructor(parent: SGraphItem | null, data: Marker) {
+    constructor(parent: SGraphItem | null, data: Marker | null = null) {
         super(parent);
-        this.img.width = 32;
-        this.img.height = 32;
-        this.img.origin = new SPoint(
-            this.img.width * 0.5,
-            this.img.height * 0.5
-        );
-        this.img.connect("onMove", this, this.changeAnchorPoint.bind(this));
-        let anchorPoint: any = [];
-        if (data) {
-            anchorPoint = [
-                {
-                    x: data.pos.x,
-                    y: data.pos.y,
-                    id: '123'
-                }
-            ];
-            this.img.url = data.style.default.url
-        }
+        this.showSelect = false;
+        this.img.showSelect = false;
+        this.data = data;
+    } // Constructor
 
+    /**
+     * 如果 data 设置;初始化data
+     */
+    initData() {
+        if (!this.data) return;
+        if (this.data.size) {
+            this.sWidth = this.data.size.width;
+            this.sHeight = this.data.size.height;
+        }
+        this.img.connect("onMove", this, this.changeAnchorPoint.bind(this));
+        const anchorPoint = [
+            { x: this.img.x, y: this.img.y, id: "" },
+        ];
         this.anchorList = anchorPoint.map(t => {
             let item = new SAnchorItem(this);
             if (t.id) {
                 item.id = t.id;
             }
-
             item.moveTo(t.x, t.y);
             return item;
         });
 
         this.showAnchor = false;
-        this.textItem.text = "";
-        this.textItem.font.size = 12;
-        // 偏移二分之一文本高度
-        this.textItem.moveTo(
-            this.img.width * 0.5,
-            -(this.font.size * 1.25 * 0.5)
-        );
+        // 对文本数据进行处理
+        if (this.data.style && this.data.style.default && this.data.style.default.textList) {
+            const textList = this.data.style.default.textList;
+            if (textList.length) {
+                const textItemList: any[] = [];
+                textList.forEach((item: any, index: number) => {
+                    let obj = new SBaseTextEdit(this, null);
+                    obj.propertyData = item;
+                    obj.text = item.text;
+                    if (item.pos) {
+                        obj.moveTo(item.pos.x, item.pos.x)
+                    } else {
+                        obj.moveTo(
+                            this.img.width * 0.5,
+                            -(this.font.size * 1.25 * 0.5) + (index) * 10
+                        );
+                    }
+                    obj.font.size = item.font;
+                    obj.isTransform = false;
+                    obj.showSelect = false;
+                    obj.color = new SColor(item.color);
+                    obj.connect('textSelect', this, this.textSelectChange)
+                    textItemList.push(obj)
+                })
+                this.textItemList = textItemList;
+            }
+        }
+        this.img.url = this.data.style.default.url;
+
+        this.x = this.data.pos.x;
+        this.y = this.data.pos.y
 
         this.moveable = true;
         this.selectable = true;
-    } // Constructor
+    }// Function initData()
+
+    /**
+     * 添加文本
+     *
+     * @param item 文本图例
+     */
+    addTextItem(item: SBaseTextEdit) {
+        this.textItemList.push(item)
+    }// Function addTextItem
+
+    /**
+     * 删除文本
+     *
+     * @param index 索引
+     */
+    removeTextItem(index: number) {
+        let [delteItem] = this.textItemList.splice(index, 1);
+        if (this.scene) {
+            this.scene.removeItem(delteItem)
+        }
+    }// Function removeTextItem
 
     /**
      * 计算并移动锚点的位置
-    */
-    private changeAnchorPoint(): void {
+     */
+    changeAnchorPoint(): void {
         // 判断是否有锚点
         if (this.anchorList.length) {
             let anchorPoint = [
@@ -308,18 +381,26 @@ export class SBaseIconTextEdit extends SGraphEdit {
     } // Function changeAnchorPoint()
 
     /**
+     * 选中的文本item变化
+    */
+    textSelectChange(item: SBaseTextEdit): void {
+        this.curTextItem = item;
+    } // Function textSelectChange()
+
+    /**
      * 鼠标按下事件
      *
      * @param event   事件对象
      * @return  是否处理事件
     */
     onMouseDown(event: SMouseEvent): boolean {
+        this.curTextItem = null;
         if (this.status == SItemStatus.Normal) {
-            return super.onMouseDown(event);
+            super.onMouseDown(event)
+            return true;
         } else if (this.status == SItemStatus.Edit) {
             return super.onMouseDown(event);
         }
-
         return true;
     } // Function onMouseDown()
 
@@ -330,7 +411,7 @@ export class SBaseIconTextEdit extends SGraphEdit {
      * @param newSize   改之后大小
     */
     onResize(oldSize: SSize, newSize: SSize) {
-        console.log(arguments);
+        // console.log(arguments);
     } // Function onResize()
 
     /**
@@ -363,13 +444,14 @@ export class SBaseIconTextEdit extends SGraphEdit {
             .boundingRect()
             .adjusted(this.img.pos.x, this.img.pos.y, 0, 0);
         if (this.showText) {
-            rect = rect.unioned(
-                this.textItem
-                    .boundingRect()
-                    .adjusted(this.textItem.pos.x, this.textItem.pos.y, 0, 0)
-            );
+            this.textItemList.forEach(item => {
+                rect = rect.unioned(
+                    item
+                        .boundingRect()
+                        .adjusted(item.pos.x, item.pos.y, 0, 0)
+                );
+            })
         }
-
         return rect.adjusted(-5, -5, 10, 10);
     } // Function boundingRect()
 
@@ -377,16 +459,28 @@ export class SBaseIconTextEdit extends SGraphEdit {
      * Item 绘制操作
      *
      * @param painter    绘制对象
-    */
+     */
     onDraw(painter: SPainter): void {
-        if (this.status == SItemStatus.Edit) {
-            painter.pen.lineWidth = painter.toPx(1);
-            painter.pen.lineDash = [painter.toPx(3), painter.toPx(7)];
+        const rect = this.boundingRect();
+        const lw = painter.toPx(1);
+        // 编辑态和选中态出现绘制区域
+        if (this.status == SItemStatus.Edit || this.selected) {
+            // doto 如果子元素被选中
+            painter.pen.lineWidth = lw;
+            painter.pen.lineDash = [3 * lw, 7 * lw];
             painter.pen.color = SColor.Black;
             painter.brush.color = SColor.Transparent;
-            painter.drawRect(this.boundingRect());
+            painter.drawRect(rect);
+        }
+        // 编辑态出现四个角的圆点
+        if (this.status == SItemStatus.Edit) {
+            painter.pen.lineDash = [];
+            painter.brush.color = SColor.White;
+            painter.drawCircle(rect.x, rect.y, 5 * lw)
+            painter.drawCircle(rect.right, rect.bottom, 5 * lw)
+            painter.drawCircle(rect.x, rect.bottom, 5 * lw)
+            painter.drawCircle(rect.right, rect.y, 5 * lw)
         }
-
         if (this.isActive) {
             painter.pen.color = SColor.Transparent;
             painter.brush.color = this.activeColor;
@@ -419,4 +513,43 @@ export class SBaseIconTextEdit extends SGraphEdit {
             }
         }
     } // Function onDraw()
-} // Class SIconTextItem
+
+    /**
+    * 返回对象储存的相关数据
+    *
+    * @return 相关数据
+    */
+    toData(): any {
+        if (this.data) {
+            if (this.data.size) {
+                this.data.size.width = this.sWidth;
+                this.data.size.height = this.sHeight;
+            }
+            this.data.style.default.text = JSON.stringify(this.textItemList);
+            this.data.pos.x = this.pos.x;
+            this.data.pos.y = this.pos.y;
+            this.data.style.default.zorder = this.zOrder;
+            this.data.style.default.url = this.img.url;
+        }
+
+        const anchorPoint = [
+            { x: this.img.x, y: this.img.y, id: "" },
+        ];
+        this.anchorList = anchorPoint.map(t => {
+            let item = new SAnchorItem(this);
+            if (t.id) {
+                item.id = t.id;
+            }
+            item.moveTo(t.x, t.y);
+            return item;
+        });
+
+        // this.textItemList.font.size = this.data.style.default.font || 12;
+        // this.img.url = this.data.style.default.url;
+        if (this.data) {
+            this.x = this.data.pos.x;
+            this.y = this.data.pos.y
+
+        }
+    } // Function toData()
+} // Class SBaseIconTextEdit

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 55 - 6
persagy-web-edit/src/items/SBaseImageEdit.ts


+ 46 - 33
persagy-web-edit/src/items/SBaseLineEdit.ts

@@ -69,7 +69,7 @@ export class SBaseLineEdit extends SGraphEdit {
         this._line = arr;
         this.update();
     } // Set line
-
+    
     /** 是否垂直水平绘制 */
     private _verAndLeve: Boolean = false;
     get verAndLeve(): Boolean {
@@ -144,7 +144,7 @@ export class SBaseLineEdit extends SGraphEdit {
     /** 拖动灵敏度 */
     dis: number = 5;
     /** 拖动灵敏度 */
-    private sceneDis: number = 5;
+    protected sceneDis: number = 5;
     /** 当前点索引 */
     curIndex: number = -1;
     /** 当前点坐标 */
@@ -166,27 +166,29 @@ export class SBaseLineEdit extends SGraphEdit {
             // 关于顶点
             if (data.style.line) {
                 let setPointList: SPoint[];
-                setPointList = data.style.line.map(i => {
+                setPointList = data.style.line.map((i: { x: number; y: number; }) => {
                     return new SPoint(i.x, i.y)
                 });
                 this.line = setPointList;
             }
-        }
-
-        if (data.style && data.style.default) {
-            // 颜色
-            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.lineStyle) {
-                this.lineStyle = data.style.default.lineStyle
+            if (data.style.default) {
+                // 颜色
+                if (data.style.default.strokeColor) {
+                    this.strokeColor = new SColor(data.style.default.strokeColor)
+                }
+                // 颜色
+                if (data.style.default.fillColor) {
+                    this.fillColor = new SColor(data.style.default.fillColor)
+                }
+                // 线宽
+                if (data.style.default.lineWidth) {
+                    this.lineWidth = data.style.default.lineWidth
+                }
+    
+                // 线样式
+                if (data.style.default.lineStyle) {
+                    this.lineStyle = data.style.default.lineStyle
+                }
             }
         }
     }
@@ -206,6 +208,7 @@ export class SBaseLineEdit extends SGraphEdit {
             this.status = SItemStatus.Normal;
             this.releaseItem();
             this.$emit("finishCreated");
+            this.pointChange();
         }
 
         this.update();
@@ -242,10 +245,11 @@ export class SBaseLineEdit extends SGraphEdit {
         if (event.shiftKey || this._verAndLeve) {
             event = this.compare(event);
         }
-
         if (event.buttons == SMouseButton.LeftButton) {
             if (this.status == SItemStatus.Normal) {
-                return super.onMouseDown(event);
+                // return super.onMouseDown(event);
+                super.onMouseDown(event);
+                return true;
             } else if (this.status == SItemStatus.Edit) {
                 // 判断是否点击到端点上(获取端点索引值)
                 this.findNearestPoint(new SPoint(event.x, event.y));
@@ -279,8 +283,8 @@ export class SBaseLineEdit extends SGraphEdit {
                 ]);
             }
         } else if (this.status == SItemStatus.Normal) {
-            this.moveToOrigin(this.x, this.y);
-            return super.onMouseUp(event);
+            super.onMouseUp(event);
+            return true
         }
 
         this.curIndex = -1;
@@ -322,11 +326,13 @@ export class SBaseLineEdit extends SGraphEdit {
         if (this.status == SItemStatus.Create) {
             if (this.line[0] instanceof SPoint) {
                 this.line[1] = new SPoint(event.x, event.y);
+                this.pointChange();
             }
         } 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.pointChange();
             }
         } else {
             return super.onMouseMove(event);
@@ -336,6 +342,13 @@ export class SBaseLineEdit extends SGraphEdit {
         return true;
     } // Function onMouseMove()
 
+     /**
+     * 点发生变化
+     */
+    protected pointChange(): void {
+        // do nothing
+    } // Function pointChange()
+
     /**
      * 获取点击点与 Point[] 中的点距离最近点
      *
@@ -347,8 +360,8 @@ export class SBaseLineEdit extends SGraphEdit {
             let dis = SMathUtil.pointDistance(
                 p.x,
                 p.y,
-                this.line[i].x,
-                this.line[i].y
+                this.line[i].x + this.x,
+                this.line[i].y + this.y
             );
             if (dis < len) {
                 len = dis;
@@ -376,14 +389,12 @@ export class SBaseLineEdit extends SGraphEdit {
      * @param x   x 坐标
      * @param y   y 坐标
      */
-    moveToOrigin(x: number, y: number): void {
-        super.moveToOrigin(x, y);
+    moveToOrigin(): void {
         this.line = this.line.map(t => {
-            t.x = t.x + x;
-            t.y = t.y + y;
+            t.x = t.x + this.x;
+            t.y = t.y + this.y;
             return t;
         });
-
         this.x = 0;
         this.y = 0;
     } // Function moveToOrigin()
@@ -428,10 +439,10 @@ export class SBaseLineEdit extends SGraphEdit {
      */
     contains(x: number, y: number): boolean {
         if (this.line.length == 2) {
-            let p = new SPoint(x, y);
+            let p = new SPoint(x, y);            
             if (
                 SMathUtil.pointToLine(p, new SLine(this.line[0], this.line[1]))
-                    .MinDis < this.dis
+                    .MinDis < this.sceneDis
             ) {
                 return true;
             }
@@ -517,11 +528,13 @@ export class SBaseLineEdit extends SGraphEdit {
      * @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.line = Line;
         this.data.style.default.lineWidth = this.lineWidth;
         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
     } // Function toData()
 

+ 25 - 10
persagy-web-edit/src/items/SBasePolygonEdit.ts

@@ -39,7 +39,8 @@ import {
     SPainter,
     SPoint,
     SPolygonUtil,
-    SRect
+    SRect,
+    SSize
 } from "@persagy-web/draw";
 import { SItemStatus, ItemOrder } from "@persagy-web/big";
 import { Marker } from "../type/Marker";
@@ -154,6 +155,7 @@ export class SBasePolygonEdit extends SGraphEdit {
         this.zOrder = ItemOrder.polygonOrder;
         this.data = data;
         this.name = data.name;
+        this.showSelect = false;
         // this.text = data.Name;
         if (data.style) {
             this.setPointList = [];
@@ -685,7 +687,8 @@ export class SBasePolygonEdit extends SGraphEdit {
             // 对多边形数组做编辑操作
             this.editPolygonPoint(event);
         } else {
-            return super.onMouseDown(event);
+            // return super.onMouseDown(event);
+            super.onMouseDown(event);
         }
 
         return true;
@@ -791,7 +794,6 @@ export class SBasePolygonEdit extends SGraphEdit {
                 ]);
             }
         } else if (this.status == SItemStatus.Normal) {
-            this.moveToOrigin(this.x, this.y);
             return super.onMouseUp(event);
         }
         return true;
@@ -799,15 +801,11 @@ export class SBasePolygonEdit extends SGraphEdit {
 
     /**
      * 移动后处理所有坐标,并肩原点置为场景原点
-     *
-     * @param x   x 坐标
-     * @param y   y 坐标
      */
-    moveToOrigin(x: number, y: number): void {
-        super.moveToOrigin(x, y);
+    moveToOrigin(): void {
         this.pointList = this.pointList.map(t => {
-            t.x = t.x + x;
-            t.y = t.y + y;
+            t.x = t.x + this.x;
+            t.y = t.y + this.y;
             return t;
         });
 
@@ -904,6 +902,7 @@ export class SBasePolygonEdit extends SGraphEdit {
      * @return	对象参数
      */
     toData() : any {
+        this.moveToOrigin();        
         const Line = this.pointList.map(pos => {
             return {
                 x: pos.x,
@@ -920,6 +919,22 @@ export class SBasePolygonEdit extends SGraphEdit {
     } // Function toData()
 
     /**
+     * 选择器放缩控制大小变化'
+     * 
+     * @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
+        });
+    }
+
+    /**
      * Item 绘制操作
      *
      * @param painter    绘制对象

+ 32 - 15
persagy-web-edit/src/items/SBasePolylineEdit.ts

@@ -38,6 +38,7 @@ import {
 import { SGraphEdit } from ".."
 import { Marker } from "../type/Marker";
 
+
 /**
  * 折线编辑类
  *
@@ -45,7 +46,16 @@ import { Marker } from "../type/Marker";
  */
 export class SBasePolylineEdit extends SGraphEdit {
     /** 传入数据 */
-    data: Marker;
+    _data: Marker | null = null;
+    get data(): Marker | null {
+        return this._data;
+    } // Get data
+    set data(v: Marker | null) {
+        this._data = v;
+        this.initData()
+        this.update();
+    } // Set data
+
     /** X 坐标最小值 */
     private minX = Number.MAX_SAFE_INTEGER;
     /** X 坐标最大值 */
@@ -136,9 +146,20 @@ export class SBasePolylineEdit extends SGraphEdit {
      * @param parent    父级
      * @param data      折线数据
      */
-    constructor(parent: null | SGraphItem, data: Marker) {
+    constructor(parent: null | SGraphItem, data: Marker | null = null) {
         super(parent);
-        this.data = data;
+        if (data) {
+            this.data = data;
+        }
+
+    } // Constructor
+
+    /**
+     * 初始化 data 数据
+     */
+    initData() {
+        const data = this.data;
+        if (!data) return;
         this.name = data.name;
         this.moveTo(data.pos.x, data.pos.y);
         this.showSelect = false;
@@ -167,12 +188,10 @@ export class SBasePolylineEdit extends SGraphEdit {
                 if (data.style.default.lineStyle) {
                     this.lineStyle = data.style.default.lineStyle
                 }
-
             }
 
         }
-    } // Constructor
-
+    }// Function initData()
     /**
      * 添加点至数组中
      *
@@ -325,8 +344,8 @@ export class SBasePolylineEdit extends SGraphEdit {
                 ]);
             }
         } else if (this.status == SItemStatus.Normal) {
-            this.moveToOrigin(this.x, this.y);
-            return super.onMouseUp(event);
+            super.onMouseUp(event)
+            return true;
         }
 
         return true;
@@ -384,15 +403,11 @@ export class SBasePolylineEdit extends SGraphEdit {
 
     /**
      * 移动后处理所有坐标,并肩原点置为场景原点
-     *
-     * @param x   x 坐标
-     * @param y   y 坐标
      */
-    moveToOrigin(x: number, y: number): void {
-        super.moveToOrigin(x, y);
+    moveToOrigin(): void {
         this.pointList = this.pointList.map(t => {
-            t.x = t.x + x;
-            t.y = t.y + y;
+            t.x = t.x + this.x;
+            t.y = t.y + this.y;
             return t;
         });
         this.x = 0;
@@ -623,6 +638,8 @@ export class SBasePolylineEdit extends SGraphEdit {
      * @return 对象储存的相关数据
      */
     toData(): any {
+        this.moveToOrigin();
+        if (!this.data) return;
         const Line = this.pointList.map(pos => {
             return {
                 x: pos.x,

+ 23 - 6
persagy-web-edit/src/items/SBaseRectEdit.ts

@@ -51,9 +51,13 @@ export class SBaseRectEdit extends SGraphEdit {
     } // Set status
 
     /** 宽度 */
-    width: number = 0;
+    get width(): number {
+        return this._rightBottom.x - this._leftTop.x;
+    }
     /** 高度 */
-    height: number = 0;
+    get height(): number {
+        return this._rightBottom.y - this._leftTop.y;
+    }
     /** 矩形两个对角 */
     private _line: SPoint[] = [];
     get line(): SPoint[] {
@@ -143,6 +147,7 @@ export class SBaseRectEdit extends SGraphEdit {
                     return new SPoint(i.x, i.y)
                 });
                 this.line = setPointList;
+                this.calRect()
             }
             // 颜色
             if (data.style.default.strokeColor) {
@@ -277,8 +282,6 @@ export class SBaseRectEdit extends SGraphEdit {
             this.status = SItemStatus.Normal;
             this.releaseItem();
             this.$emit("finishCreated");
-            this.width = this.boundingRect().width;
-            this.height = this.boundingRect().height;
         }
 
         this.calRect();
@@ -304,7 +307,7 @@ export class SBaseRectEdit extends SGraphEdit {
      */
     boundingRect(): SRect {
         if (this.line.length > 1) {
-            this.calRect();
+            // this.calRect();
             return new SRect(this._leftTop, this._rightBottom);
         }
 
@@ -343,11 +346,25 @@ export class SBaseRectEdit extends SGraphEdit {
     } // Function cancelOperate()
 
     /**
+     * 移动后处理所有坐标,并肩原点置为场景原点
+     */
+    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;
+    } // Function moveToOrigin()
+
+    /**
      * 返回对象储存的相关数据
      *
      * @return 对象储存的相关数据
      */
     toData(): any {
+        this.moveToOrigin();
         const Line: any = [];
         this.line.forEach(item => {
             Line.push({ x: item.x, y: item.y })
@@ -367,7 +384,7 @@ export class SBaseRectEdit extends SGraphEdit {
      */
     onDraw(painter: SPainter): void {
         if (this.line.length == 2) {
-            this.calRect();
+            // this.calRect();
             painter.pen.color = this.strokeColor;
             painter.brush.color = this.fillColor;
             painter.pen.lineWidth = this.lineWidth;

+ 44 - 6
persagy-web-edit/src/items/SBaseTextEdit.ts

@@ -29,6 +29,7 @@ import { SItemStatus } from "@persagy-web/big";
 import { SGraphEdit } from ".."
 import { Marker } from "../type/Marker";
 import { ItemOrder } from '@persagy-web/big/lib';
+import { SMouseEvent } from '@persagy-web/base/lib';
 
 /**
  * 文本编辑类
@@ -39,7 +40,9 @@ export class SBaseTextEdit extends SGraphEdit {
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //属性
     /**编辑相关操作的数据 */
-    data: Marker;
+    data: Marker | null = null;
+    /** 存储相关的信息数据 */
+    propertyData: any
     /** 起始锚点 */
     startItem: SGraphItem | null = null;
     /** 结束锚点 */
@@ -196,8 +199,19 @@ export class SBaseTextEdit extends SGraphEdit {
      * @param parent    指向父 Item
      * @param data      文本数据
      */
-    constructor(parent: SGraphItem | null, data: Marker) {
+    constructor(parent: SGraphItem | null, data: Marker | null) {
         super(parent);
+        if (data) {
+            this.initData(data)
+        }
+    } // Constructor
+
+    /**
+     * 初始化 当data传入时设置相关状态
+     *
+     * @param data      Mark 数据
+     */
+    initData(data: Marker) {
         this.showSelect = false;
         this.zOrder = ItemOrder.textOrder;
         this.isTransform = false;
@@ -230,7 +244,7 @@ export class SBaseTextEdit extends SGraphEdit {
                 this.backgroundColor = new SColor(data.style.default.backgroundColor);
             }
         }
-    } // Constructor
+    }
 
     /**
      * 宽高发发生变化
@@ -260,9 +274,32 @@ export class SBaseTextEdit extends SGraphEdit {
      * @param x   x 坐标
      * @param y   y 坐标
      */
-    moveToOrigin(x: number, y: number): void {
-        this.moveTo(this.x + x, this.y + y);
-    } // Function moveToOrigin()
+    // moveToOrigin(x: number, y: number): void {
+    //     this.moveTo(this.x + x, this.y + y);
+    // } // Function moveToOrigin()
+
+    /**
+     * 鼠标按下事件
+     *
+     * @param event   保存事件参数
+     * @return 是否处理事件
+     */
+    onMouseDown(event: SMouseEvent): boolean {
+        this.$emit('textSelect')
+        super.onMouseDown(event);
+        return this.moveable;
+    } // Function onMouseDown()
+
+    /**
+     * 释放鼠标事件
+     *
+     * @param event   保存事件参数
+     * @return 是否处理事件
+     */
+    onMouseUp(event: SMouseEvent): boolean {
+        super.onMouseUp(event);
+        return this.moveable;
+    } // Function onMouseUp()
 
     /**
      * 绘制显示状态文本 Item
@@ -335,6 +372,7 @@ export class SBaseTextEdit extends SGraphEdit {
      * @return 对象储存的相关数据
      */
     toData(): any {
+        if(!this.data) return;
         if (this.data.size) {
             this.data.size.width = this.width;
             this.data.size.height = this.height;

+ 1 - 1
persagy-web-edit/src/type/Anchor.ts

@@ -33,7 +33,7 @@ import { Point } from "./Point";
  */
 export interface Anchor {
     /** 锚点 ID */
-    ID: string;
+    anchorId: string;
     /** 锚点的坐标 */
     Pos: Point;
 } // Interface Anchor

+ 3 - 3
persagy-web-edit/src/type/ElementData.ts

@@ -35,9 +35,9 @@ import { Relation } from "./Relation";
  */
 export interface ElementData {
     /** 在数据中台有数据的节点 */
-    Nodes: Legend[];
+    nodes: Legend[];
     /** 说明型节点 */
-    Markers: Marker[];
+    markers: Marker[];
     /** 关系类节点 */
-    Relations: Relation[];
+    relations: Relation[];
 } // Interface ElementData

+ 7 - 3
persagy-web-edit/src/type/Legend.ts

@@ -36,7 +36,11 @@ import { SPoint } from '@persagy-web/draw/lib';
  */
 export interface Legend {
     /** ID */
-    iD: string;
+    id?: string;
+    /** 图 id */
+    graphId?: string;
+    /** 图例实例 id */
+    nodeId?: string;
     /** 名称 */
     name: string;
     /** 返回工程信息化对象 ID 列表 */
@@ -63,6 +67,6 @@ export interface Legend {
     outLine?: Point[] | SPoint[];
     /** 由应用自己定义 */
     properties?: any;
-     /** zone 区分防火分区和石材铺装 */
-    subType?:string
+    /** zone 区分防火分区和石材铺装 */
+    subType?: string
 } // Interface Legend

+ 6 - 2
persagy-web-edit/src/type/Marker.ts

@@ -34,7 +34,11 @@ import { Size } from "@persagy-web/big/lib/types/Size";
  */
 export interface Marker {
     /** ID */
-    iD?: string;
+    id?: string;
+    /** 图 id */
+    graphId?: string;
+    /** 图例实例 id */
+    markerId?: string;
     /** 名称 */
     name: string;
     /** 图标(Image),线类型 (Line) */
@@ -48,7 +52,7 @@ export interface Marker {
     /** 大小 */
     size?: Size;
     /** 绘制时得数据以及样式 */
-    style:any;
+    style: any;
     /** 由应用自己定义 */
     properties?: any;
 } // Interface Marker

+ 6 - 2
persagy-web-edit/src/type/Relation.ts

@@ -33,8 +33,12 @@ import { Point } from "./Point";
  * @author 韩耀龙 <han_yao_long@163.com>
  */
 export interface Relation {
-    /** ID */
-    iD: string;
+    /** 图 id */
+    id?: string;
+    /** 图 id */
+    graphId?: string;
+    /** 图例实例 id */
+    relationId?: string;
     /** 名称 */
     name: string;
     /** 对应的图例 ID */