Browse Source

命令日志添加;版本更新

haojianlong 5 years ago
parent
commit
b8fd7d4cbf

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/base",
-    "version": "2.1.18",
+    "version": "2.1.19",
     "description": "上格云Web基础库。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 2 - 0
saga-web-base/src/SObject.ts

@@ -10,6 +10,8 @@ export class SObject {
     name: string = "";
     /** 监听数组 */
     private listeners = {};
+    /** 对象id    */
+    id: string = "";
 
     /**
      * 连接信号

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

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

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/draw",
-    "version": "2.1.93",
+    "version": "2.1.94",
     "description": "上格云绘制引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -33,7 +33,7 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/base": "^2.1.18"
+        "@saga-web/base": "^2.1.19"
     },
     "jest": {
         "setupFiles": [

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.79",
+    "version": "2.1.80",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -41,6 +41,6 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/draw": "2.1.90"
+        "@saga-web/draw": "2.1.94"
     }
 }

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

@@ -9,6 +9,8 @@ import { SGraphScene } from "../SGraphScene";
  * @author  panglixiang
  * */
 export class SGraphAddCommand extends SGraphCommand {
+    /** 命令名称    */
+    readonly command: string;
     /** 命令item对象    */
     item: SGraphItem;
     /** 命令item的父类   */
@@ -24,6 +26,8 @@ export class SGraphAddCommand extends SGraphCommand {
         super(scene);
         this.item = item;
         this.parent = item.parent;
+        this.command = "SGraphAddCommand";
+        this.desc = `添加对象=${item.id}`;
     } // Constructor
 
     /**

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

@@ -11,6 +11,8 @@ import { SGraphScene } from "../SGraphScene";
  *
  * */
 export class SGraphMoveCommand extends SGraphCommand {
+    /** 命令名称    */
+    readonly command: string;
     /** 执行命令的item   */
     item: SGraphItem;
     /** 移动前位置    */
@@ -36,6 +38,8 @@ export class SGraphMoveCommand extends SGraphCommand {
         this.item = item;
         this.old = old;
         this.pos = pos;
+        this.command = "SGraphMoveCommand";
+        this.desc = `移动对象=${item.id}`;
     } // Constructor
 
     /**
@@ -69,4 +73,14 @@ export class SGraphMoveCommand extends SGraphCommand {
         this.item.pos = new SPoint(this.old.x, this.old.y);
         this.item.update();
     } // Function undo()
+
+    /**
+     * 命令细节描述
+     *
+     * */
+    toString(): string {
+        return `oldPos=${JSON.stringify(this.old)};\nnewPos=${JSON.stringify(
+            this.pos
+        )}`;
+    } // Function toString()
 } // Class SGraphMoveCommand

+ 20 - 2
saga-web-graph/src/commands/SGraphPointListDelete.ts

@@ -19,7 +19,7 @@
  */
 
 import { SPoint } from "@saga-web/draw/lib";
-import { SGraphCommand, SGraphItem } from "../index";
+import { SGraphCommand, SGraphItem, SGraphScene } from "../index";
 
 /**
  * 多边形、折线等相关顶点的位置删除命令
@@ -28,6 +28,8 @@ import { SGraphCommand, SGraphItem } from "../index";
  */
 
 export class SGraphPointListDelete extends SGraphCommand {
+    /** 命令名称    */
+    readonly command: string;
     /**  指向item对象 */
     item: SGraphItem;
     /** 索引 */
@@ -39,21 +41,26 @@ export class SGraphPointListDelete extends SGraphCommand {
 
     /**
      * 构造函数
+     * @param   scene       item所在场景
      * @param   item        指向item对象
      * @param   pointList   顶点数组
+     * @param   pos         删除的点
      * @param   index       索引
      */
     constructor(
+        scene: SGraphScene,
         item: SGraphItem,
         pointList: SPoint[],
         pos: SPoint,
         index: number | null = null
     ) {
-        super(null);
+        super(scene);
         this.item = item;
         this.index = index;
         this.pointList = pointList;
         this.pos = pos;
+        this.command = "SGraphPointListDelete";
+        this.desc = `删除折点=${item.id}`;
     } // Constructor
 
     /**
@@ -80,4 +87,15 @@ export class SGraphPointListDelete extends SGraphCommand {
         }
         this.item.update();
     } // Function undo()
+
+    /**
+     * 命令细节描述
+     *
+     * */
+    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

+ 19 - 2
saga-web-graph/src/commands/SGraphPointListInsert.ts

@@ -19,7 +19,7 @@
  */
 
 import { SPoint } from "@saga-web/draw/lib";
-import { SGraphCommand, SGraphItem } from "../index";
+import { SGraphCommand, SGraphItem, SGraphScene } from "../index";
 
 /**
  * 多边形、折线等相关顶点的位置插入命令
@@ -28,6 +28,8 @@ import { SGraphCommand, SGraphItem } from "../index";
  */
 
 export class SGraphPointListInsert extends SGraphCommand {
+    /** 命令名称    */
+    readonly command: string;
     /**  指向item对象 */
     item: SGraphItem;
     /**  当前位置 */
@@ -39,22 +41,26 @@ export class SGraphPointListInsert extends SGraphCommand {
 
     /**
      * 构造函数
+     * @param   scene       item所在场景
      * @param   item        指向item对象
      * @param   pointList   顶点数组
      * @param   pos         当前位置
      * @param   index       索引
      */
     constructor(
+        scene: SGraphScene,
         item: SGraphItem,
         pointList: SPoint[],
         pos: SPoint,
         index: number | null = null
     ) {
-        super(null);
+        super(scene);
         this.item = item;
         this.pos = pos;
         this.index = index;
         this.pointList = pointList;
+        this.command = "SGraphPointListInsert";
+        this.desc = `添加折点=${item.id}`;
     } // Constructor
 
     /**
@@ -81,4 +87,15 @@ export class SGraphPointListInsert extends SGraphCommand {
         }
         this.item.update();
     } // Function undo()
+
+    /**
+     * 命令细节描述
+     *
+     * */
+    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()

+ 20 - 2
saga-web-graph/src/commands/SGraphPointListUpdate.ts

@@ -19,7 +19,7 @@
  */
 
 import { SPoint } from "@saga-web/draw/lib";
-import { SGraphCommand, SGraphItem } from "../index";
+import { SGraphCommand, SGraphItem, SGraphScene } from "../index";
 
 /**
  * 多边形、折线等相关顶点的位置更新命令
@@ -28,6 +28,8 @@ import { SGraphCommand, SGraphItem } from "../index";
  */
 
 export class SGraphPointListUpdate extends SGraphCommand {
+    /** 命令名称    */
+    readonly command: string;
     /**  指向item对象 */
     item: SGraphItem;
     /**  原位置 */
@@ -41,6 +43,7 @@ export class SGraphPointListUpdate extends SGraphCommand {
 
     /**
      * 构造函数
+     * @param   scene       item所在场景
      * @param   item        指向item对象
      * @param   pointList   顶点数组
      * @param   old         原位置
@@ -48,18 +51,21 @@ export class SGraphPointListUpdate extends SGraphCommand {
      * @param   index       索引
      */
     constructor(
+        scene: SGraphScene,
         item: SGraphItem,
         pointList: SPoint[],
         old: SPoint,
         pos: SPoint,
         index: number
     ) {
-        super(null);
+        super(scene);
         this.item = item;
         this.old = old;
         this.pos = pos;
         this.index = index;
         this.pointList = pointList;
+        this.command = "SGraphPointListUpdate";
+        this.desc = `更新折点=${item.id}`;
     } // Constructor
 
     /**
@@ -79,4 +85,16 @@ export class SGraphPointListUpdate extends SGraphCommand {
         this.pointList[this.index].y = this.old.y;
         this.item.update();
     } // Function undo()
+
+    /**
+     * 命令细节描述
+     *
+     * */
+    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

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

@@ -9,6 +9,8 @@ import { SGraphScene } from "../SGraphScene";
  */
 
 export class SGraphPropertyCommand<T> extends SGraphCommand {
+    /** 命令名称    */
+    readonly command: string;
     /**	指向item对象	*/
     item: SGraphItem;
     /** 属性名称 */
@@ -39,6 +41,8 @@ export class SGraphPropertyCommand<T> extends SGraphCommand {
         this.propName = propName;
         this.oldProp = oldProp;
         this.newProp = newProp;
+        this.command = "SGraphPropertyCommand";
+        this.command = `更新属性=${item.id}`;
     } // Constructor
 
     /**
@@ -58,4 +62,15 @@ export class SGraphPropertyCommand<T> extends SGraphCommand {
         this.item[this.propName] = this.oldProp;
         this.item.update();
     } // Function undo()
+
+    /**
+     * 命令细节描述
+     *
+     * */
+    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

+ 17 - 36
saga-web-graph/src/items/STextItem.ts

@@ -1,7 +1,6 @@
 import { SObjectItem } from "./SObjectItem";
 import { SPainter, SRect, SColor, SFont } from "@saga-web/draw/lib";
 import { SGraphItem } from "../SGraphItem";
-import { SLineStyle } from "../enums/SLineStyle";
 
 /**
  * 文本item
@@ -49,33 +48,25 @@ export class STextItem extends SObjectItem {
         this.update();
     }
 
-    /** 边框宽度 */
-    private _borderWidth: number = 1;
-    get borderWidth(): number {
-        return this._borderWidth;
-    }
-    set borderWidth(v: number) {
-        this._borderWidth = v;
-        this.update();
-    }
-
     /** 边框色 */
-    private _borderColor: string = "#00000000";
-    get borderColor(): string {
-        return this._borderColor;
+    private _strokeColor: string = "#00000000";
+    get strokeColor(): string {
+        return this._strokeColor;
     }
-    set borderColor(v: string) {
-        this._borderColor = v;
+    set strokeColor(v: string) {
+        this._strokeColor = v;
         this.update();
     }
 
-    /** 边框样式    */
-    private _borderStyle: SLineStyle = SLineStyle.Soild;
-    get borderStyle(): SLineStyle {
-        return this._borderStyle;
+    private _showBorder: boolean = false;
+    get showBorder(): boolean {
+        return this._showBorder;
     }
-    set borderStyle(v: SLineStyle) {
-        this._borderStyle = v;
+    set showBorder(v: boolean) {
+        if (this._showBorder === v) {
+            return;
+        }
+        this._showBorder = v;
         this.update();
     }
 
@@ -111,21 +102,11 @@ export class STextItem extends SObjectItem {
      */
     protected drawShowText(painter: SPainter): void {
         //绘制矩形轮廓
-        painter.brush.color = new SColor(this.backgroundColor);
-        painter.pen.color = new SColor(this.borderColor);
-        painter.pen.lineWidth = painter.toPx(this.borderWidth);
-        if (this.borderStyle == SLineStyle.Dashed) {
-            painter.pen.lineDash = [
-                painter.toPx(this.borderWidth * 3),
-                painter.toPx(this.borderWidth * 7)
-            ];
-        } else if (this.borderStyle == SLineStyle.Dotted) {
-            painter.pen.lineDash = [
-                painter.toPx(this.borderWidth),
-                painter.toPx(this.borderWidth)
-            ];
+        if (this.showBorder) {
+            painter.brush.color = new SColor(this.backgroundColor);
+            painter.pen.color = new SColor(this.strokeColor);
+            painter.drawRect(this.boundingRect());
         }
-        painter.drawRect(this.boundingRect());
 
         //绘制文本
         painter.brush.color = new SColor(this.color);