Browse Source

'解决冲突'

zhangyu 5 năm trước cách đây
mục cha
commit
81064e43cd

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

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

+ 11 - 0
saga-web-big/src/enums/SImageShowType.ts

@@ -0,0 +1,11 @@
+/**
+ * 图片item展示方式
+ *
+ * @author  haojianlong
+ */
+export enum SImageShowType {
+    /** 铺满  */
+    Full,
+    /** 自适应 */
+    AutoFit
+} // Enum SImageShowType

+ 26 - 12
saga-web-big/src/items/SImageItem.ts

@@ -1,6 +1,7 @@
 import { SObjectItem } from "./SObjectItem";
-import { SPainter, SRect } from "@saga-web/draw/lib";
+import { SPainter, SRect, SSize } from "@saga-web/draw/lib";
 import { SGraphItem } from "@saga-web/graph/lib";
+import { SImageShowType } from "../enums/SImageShowType";
 
 /**
  *  图片绘制
@@ -15,18 +16,22 @@ export class SImageItem extends SObjectItem {
     }
     set url(v: string) {
         this._url = v;
-        this.Img = new Image();
-        this.Img.src = v;
-        this.Img.onload = (): void => {
-            // @ts-ignore
-            this.width = this.Img.width;
-            // @ts-ignore
-            this.height = this.Img.height;
+        this.img = new Image();
+        this.img.src = v;
+        this.img.onload = (): void => {
+            if (this.showType == SImageShowType.AutoFit) {
+                // @ts-ignore
+                this.width = this.Img.width;
+                // @ts-ignore
+                this.height = this.Img.height;
+            }
             this.update();
         };
     }
     /** 图片dom */
-    Img: CanvasImageSource | undefined;
+    img: CanvasImageSource | undefined;
+    /** 展示模式    */
+    showType: SImageShowType = SImageShowType.Full;
 
     /**
      * 构造函数
@@ -35,7 +40,6 @@ export class SImageItem extends SObjectItem {
      * */
     constructor(parent: SGraphItem | null) {
         super(parent);
-        this.isTransform = false;
     }
 
     /**
@@ -53,14 +57,24 @@ export class SImageItem extends SObjectItem {
     }
 
     /**
+     * 宽高发发生变化
+     *
+     * @param   oldSize 改之前的大小
+     * @param   newSize 改之后大小
+     * */
+    protected onResize(oldSize: SSize, newSize: SSize) {
+        this.update();
+    } // Function onResize()
+
+    /**
      * Item绘制操作
      *
      * @param   painter       painter对象
      */
     onDraw(painter: SPainter): void {
-        if (this.Img) {
+        if (this.img) {
             painter.drawImage(
-                this.Img,
+                this.img,
                 -this.width / 2,
                 -this.height / 2,
                 this.width,

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

@@ -7,7 +7,7 @@ import { SGraphItem } from "@saga-web/graph/lib";
  *
  * @author  张宇(taohuzy@163.com)
  */
-export class TextItem extends SObjectItem {
+export class STextItem extends SObjectItem {
     /** 文本内容 */
     private _text: string = "";
     get text(): string {

+ 20 - 1
saga-web-big/src/items/topology/SAnchorItem.ts

@@ -1,8 +1,27 @@
 import { SGraphItem } from "@saga-web/graph/lib";
+import { SPainter } from "@saga-web/draw/lib";
 
 /**
  * 锚点item
  *
  * @author  郝建龙(1061851420@qq.com)
  */
-export class SAnchorItem extends SGraphItem {} // Class SAnchorItem
+export class SAnchorItem extends SGraphItem {
+    // private width: number;
+    // private height: number;
+    //
+    // /**
+    //  * Item绘制操作
+    //  *
+    //  * @param   painter       painter对象
+    //  */
+    // onDraw(painter: SPainter): void {
+    //     painter.pen.lineWidth = painter.toPx(1);
+    //     painter.drawRect(
+    //         -this.width / 2,
+    //         -this.height / 2,
+    //         this.width,
+    //         this.height
+    //     );
+    // } // Function onDraw()
+} // Class SAnchorItem

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/feng-map",
-    "version": "1.0.6",
+    "version": "1.0.7",
     "description": "上格云Web平面图。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -32,6 +32,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/big": "1.0.9"
+        "@saga-web/big": "^1.0.17"
     }
 }

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

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

+ 57 - 0
saga-web-graph/src/commands/SGraphAddCommand.ts

@@ -0,0 +1,57 @@
+import { SGraphCommand } from "./SGraphCommand";
+import { SGraphItem } from "../SGraphItem";
+import { SUndoCommand } from "@saga-web/base/lib";
+import { SGraphScene } from "../SGraphScene";
+
+/**
+ * 添加item命令
+ *
+ * @author  panglixiang
+ * */
+export class SGraphAddCommand extends SGraphCommand {
+    /** 命令item对象    */
+    item: SGraphItem;
+    /** 命令item的父类   */
+    parent: SGraphItem | null;
+
+    /**
+     * 构造函数
+     *
+     * @param   scene   item所在场景
+     * @param   item    命令item对象
+     * */
+    constructor(scene: SGraphScene, item: SGraphItem) {
+        super(scene);
+        this.item = item;
+        this.parent = item.parent;
+    } // Constructor
+
+    /**
+     * 合并命令
+     *
+     * @return  boolean 是否已执行合并
+     * */
+    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

+ 13 - 16
saga-web-graph/src/commands/SGraphCommand.ts

@@ -1,22 +1,19 @@
 /*
  * ********************************************************************************************************************
  *
- *               iFHS7.
- *              ;BBMBMBMc                  rZMBMBR              BMB
- *              MBEr:;PBM,               7MBMMEOBB:             BBB                       RBW
- *     XK:      BO     SB.     :SZ       MBM.       c;;     ir  BBM :FFr       :SSF:    ;xBMB:r   iuGXv.    i:. iF2;
- *     DBBM0r.  :D     S7   ;XMBMB       GMBMu.     MBM:   BMB  MBMBBBMBMS   WMBMBMBBK  MBMBMBM  BMBRBMBW  .MBMBMBMBB
- *      :JMRMMD  ..    ,  1MMRM1;         ;MBMBBR:   MBM  ;MB:  BMB:   MBM. RMBr   sBMH   BM0         UMB,  BMB.  KMBv
- *     ;.   XOW  B1; :uM: 1RE,   i           .2BMBs  rMB. MBO   MBO    JMB; MBB     MBM   BBS    7MBMBOBM:  MBW   :BMc
- *     OBRJ.SEE  MRDOWOR, 3DE:7OBM       .     ;BMB   RMR7BM    BMB    MBB. BMB    ,BMR  .BBZ   MMB   rMB,  BMM   rMB7
- *     :FBRO0D0  RKXSXPR. JOKOOMPi       BMBSSWBMB;    BMBB:    MBMB0ZMBMS  .BMBOXRBMB    MBMDE RBM2;SMBM;  MBB   xBM2
- *         iZGE  O0SHSPO. uGZ7.          sBMBMBDL      :BMO     OZu:BMBK,     rRBMB0;     ,EBMB  xBMBr:ER.  RDU   :OO;
- *     ,BZ, 1D0  RPSFHXR. xWZ .SMr                  . .BBB
- *      :0BMRDG  RESSSKR. 2WOMBW;                   BMBMR
- *         i0BM: SWKHKGO  MBDv
- *           .UB  OOGDM. MK,                                          Copyright (c) 2015-2019.  斯伯坦机器人
- *              ,  XMW  ..
- *                  r                                                                     All rights reserved.
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
  *
  * ********************************************************************************************************************
  */

+ 72 - 0
saga-web-graph/src/commands/SGraphMoveCommand.ts

@@ -0,0 +1,72 @@
+import { SGraphCommand } from "./SGraphCommand";
+import { SGraphItem } from "../SGraphItem";
+import { SPoint } from "@saga-web/draw/lib";
+import { SUndoCommand } from "@saga-web/base/lib";
+import { SGraphScene } from "../SGraphScene";
+
+/**
+ * item移动命令
+ *
+ * @author  panglixiang
+ *
+ * */
+export class SGraphMoveCommand extends SGraphCommand {
+    /** 执行命令的item   */
+    item: SGraphItem;
+    /** 移动前位置    */
+    old: SPoint;
+    /** 移动后位置   */
+    pos: SPoint;
+
+    /**
+     * 构造函数
+     *
+     * @param   scene   当前场景
+     * @param   item    item对象
+     * @param   old     移动前位置
+     * @param   pos     移动后位置
+     * */
+    constructor(
+        scene: SGraphScene,
+        item: SGraphItem,
+        old: SPoint,
+        pos: SPoint
+    ) {
+        super(scene);
+        this.item = item;
+        this.old = old;
+        this.pos = pos;
+    } // Constructor
+
+    /**
+     * 合并命令
+     *
+     * @param   command 命令
+     * @return  boolean 是否已执行合并命令
+     * */
+    mergeWith(command: SUndoCommand): boolean {
+        if (command instanceof SGraphMoveCommand && command.item == this.item) {
+            command.pos = this.pos;
+            return true;
+        }
+        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()
+} // Class SGraphMoveCommand

+ 83 - 0
saga-web-graph/src/commands/SGraphPointListDelete.ts

@@ -0,0 +1,83 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { SPoint } from "@saga-web/draw/lib";
+import { SGraphCommand, SGraphItem } from "../index";
+
+/**
+ * 多边形、折线等相关顶点的位置删除命令
+ *
+ * @author  韩耀龙
+ */
+
+export class SGraphPointListDelete extends SGraphCommand {
+    /**  指向item对象 */
+    item: SGraphItem;
+    /** 索引 */
+    index: number | null;
+    /**  删除位置 */
+    pos: SPoint | null;
+    /** 顶点数组 */
+    pointList: SPoint[];
+
+    /**
+     * 构造函数
+     * @param   item        指向item对象
+     * @param   pointList   顶点数组
+     * @param   index       索引
+     */
+    constructor(
+        item: SGraphItem,
+        pointList: SPoint[],
+        pos: SPoint,
+        index: number | null = null
+    ) {
+        super(null);
+        this.item = item;
+        this.index = index;
+        this.pointList = pointList;
+        this.pos = pos;
+    } // Constructor
+
+    /**
+     * 执行重做操作执行
+     */
+    redo(): void {
+        if (this.index == null) {
+            this.pointList.pop();
+        } else {
+            this.pointList.splice(this.index, 1);
+        }
+        this.item.update();
+    } // Function redo()
+
+    /**
+     * 执行取消操作执行
+     */
+    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);
+        }
+        this.item.update();
+    } // Function undo()
+} // Class SGraphPointListDelete

+ 84 - 0
saga-web-graph/src/commands/SGraphPointListInsert.ts

@@ -0,0 +1,84 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { SPoint } from "@saga-web/draw/lib";
+import { SGraphCommand, SGraphItem } from "../index";
+
+/**
+ * 多边形、折线等相关顶点的位置插入命令
+ *
+ * @author  韩耀龙
+ */
+
+export class SGraphPointListInsert extends SGraphCommand {
+    /**  指向item对象 */
+    item: SGraphItem;
+    /**  当前位置 */
+    pos: SPoint;
+    /** 索引 */
+    index: number | null;
+    /** 顶点数组 */
+    pointList: SPoint[];
+
+    /**
+     * 构造函数
+     * @param   item        指向item对象
+     * @param   pointList   顶点数组
+     * @param   pos         当前位置
+     * @param   index       索引
+     */
+    constructor(
+        item: SGraphItem,
+        pointList: SPoint[],
+        pos: SPoint,
+        index: number | null = null
+    ) {
+        super(null);
+        this.item = item;
+        this.pos = pos;
+        this.index = index;
+        this.pointList = pointList;
+    } // Constructor
+
+    /**
+     * 执行重做操作执行
+     */
+    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);
+        }
+        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()
+} // Class SGraphPointListInsert()

+ 82 - 0
saga-web-graph/src/commands/SGraphPointListUpdate.ts

@@ -0,0 +1,82 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { SPoint } from "@saga-web/draw/lib";
+import { SGraphCommand, SGraphItem } from "../index";
+
+/**
+ * 多边形、折线等相关顶点的位置更新命令
+ *
+ * @author  韩耀龙
+ */
+
+export class SGraphPointListUpdate extends SGraphCommand {
+    /**  指向item对象 */
+    item: SGraphItem;
+    /**  原位置 */
+    old: SPoint;
+    /**  当前位置 */
+    pos: SPoint;
+    /** 索引 */
+    index: number;
+    /** 顶点数组 */
+    pointList: SPoint[];
+
+    /**
+     * 构造函数
+     * @param   item        指向item对象
+     * @param   pointList   顶点数组
+     * @param   old         原位置
+     * @param   pos         当前位置
+     * @param   index       索引
+     */
+    constructor(
+        item: SGraphItem,
+        pointList: SPoint[],
+        old: SPoint,
+        pos: SPoint,
+        index: number
+    ) {
+        super(null);
+        this.item = item;
+        this.old = old;
+        this.pos = pos;
+        this.index = index;
+        this.pointList = pointList;
+    } // 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()
+} // Class SGraphPointListUpdate

+ 61 - 0
saga-web-graph/src/commands/SGraphPropertyCommand.ts

@@ -0,0 +1,61 @@
+import { SGraphCommand } from "./SGraphCommand";
+import { SGraphItem } from "../SGraphItem";
+import { SGraphScene } from "../SGraphScene";
+
+/**
+ * 属性修改命令类
+ *
+ * @author  张宇(taohuzy@163.com)
+ */
+
+export class SGraphPropertyCommand<T> extends SGraphCommand {
+    /**	指向item对象	*/
+    item: SGraphItem;
+    /** 属性名称 */
+    propName: string;
+    /** 属性旧值 */
+    oldProp: T;
+    /** 属性新值 */
+    newProp: T;
+
+    /**
+     * 构造函数
+     *
+     * @param   scene       命令所属的场景类
+     * @param   item        命令所属的item类
+     * @param   propName    修改的属性名称
+     * @param   oldProp     修改前的属性值
+     * @param   newProp     修改后的属性值
+     */
+    constructor(
+        scene: SGraphScene,
+        item: SGraphItem,
+        propName: string,
+        oldProp: T,
+        newProp: T
+    ) {
+        super(scene);
+        this.item = item;
+        this.propName = propName;
+        this.oldProp = oldProp;
+        this.newProp = newProp;
+    } // 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()
+} // Class SGraphPropertyCommand

+ 13 - 1
saga-web-graph/src/index.ts

@@ -32,11 +32,23 @@ import { SGraphScene } from "./SGraphScene";
 import { SGraphView } from "./SGraphView";
 import { SGraphSelectContainer } from "./SGraphSelectContainer";
 import { SGraphLayoutType } from "./enums/SGraphLayoutType";
+import { SGraphAddCommand } from "./commands/SGraphAddCommand";
+import { SGraphMoveCommand } from "./commands/SGraphMoveCommand";
+import { SGraphPointListDelete } from "./commands/SGraphPointListDelete";
+import { SGraphPointListInsert } from "./commands/SGraphPointListInsert";
+import { SGraphPointListUpdate } from "./commands/SGraphPointListUpdate";
+import { SGraphPropertyCommand } from "./commands/SGraphPropertyCommand";
 
 export {
     SGraphItem,
     SGraphScene,
     SGraphView,
     SGraphSelectContainer,
-    SGraphLayoutType
+    SGraphLayoutType,
+    SGraphAddCommand,
+    SGraphMoveCommand,
+    SGraphPointListDelete,
+    SGraphPointListInsert,
+    SGraphPointListUpdate,
+    SGraphPropertyCommand
 };