Browse Source

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

zhangyu 5 years ago
parent
commit
15776397da

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

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

+ 8 - 13
saga-web-big/src/items/SLineItem.ts

@@ -42,6 +42,7 @@ export class SLineItem extends SGraphItem {
     }
     set status(v: SItemStatus) {
         this._status = v;
+        this.undoStack.clear();
         this.update();
     }
 
@@ -108,7 +109,7 @@ export class SLineItem extends SGraphItem {
     private curPoint: SPoint | null = null;
 
     /** undo/redo堆栈 */
-    private undoStack: SUndoStack | null = new SUndoStack();
+    private undoStack: SUndoStack = new SUndoStack();
 
     /**
      * 构造函数
@@ -281,7 +282,7 @@ export class SLineItem extends SGraphItem {
             if (dis < len) {
                 len = dis;
                 this.curIndex = i;
-                this.curPoint = this.line[this.curIndex];
+                this.curPoint = new SPoint(this.line[this.curIndex]);
             }
         }
     } // Function findNearestPoint()
@@ -294,10 +295,8 @@ export class SLineItem extends SGraphItem {
      */
     protected recordAction(SGraphCommand: any, any: any[]): void {
         // 记录相关命令并推入堆栈中
-        const command = new SGraphCommand(this, ...any);
-        if (this.undoStack) {
-            this.undoStack.push(command);
-        }
+        const command = new SGraphCommand(this.scene, this, ...any);
+        this.undoStack.push(command);
     } // Function recordAction()
 
     /**
@@ -343,9 +342,7 @@ export class SLineItem extends SGraphItem {
      */
     undo(): void {
         if (this.status != SItemStatus.Normal) {
-            if (this.undoStack) {
-                this.undoStack.undo();
-            }
+            this.undoStack.undo();
         }
     } // Function undo()
 
@@ -355,9 +352,7 @@ export class SLineItem extends SGraphItem {
      */
     redo(): void {
         if (this.status != SItemStatus.Normal) {
-            if (this.undoStack) {
-                this.undoStack.redo();
-            }
+            this.undoStack.redo();
         }
     } // Function redo()
 
@@ -437,7 +432,7 @@ export class SLineItem extends SGraphItem {
             if (this.selected && this.status == SItemStatus.Normal) {
                 painter.pen.lineWidth = painter.toPx(this.lineWidth * 2);
                 painter.shadow.shadowBlur = 10;
-                painter.shadow.shadowColor = new SColor(`#00000060`);
+                painter.shadow.shadowColor = new SColor(`#00000033`);
                 painter.shadow.shadowOffsetX = 5;
                 painter.shadow.shadowOffsetY = 5;
             }

+ 36 - 53
saga-web-big/src/items/SPolygonItem.ts

@@ -54,12 +54,7 @@ export class SPolygonItem extends SGraphItem {
     // 编辑当前状态
     set status(value: SItemStatus) {
         this._status = value;
-        // 如果状态为show则需清栈
-        if (value == SItemStatus.Normal) {
-            if (this.undoStack) {
-                this.undoStack.clear();
-            }
-        }
+        this.undoStack.clear();
         this.update();
     }
 
@@ -117,7 +112,7 @@ export class SPolygonItem extends SGraphItem {
     /** 场景像素  */
     private isAlt: boolean = false;
     /** undoredo堆栈 */
-    protected undoStack: SUndoStack | null = new SUndoStack();
+    protected undoStack: SUndoStack = new SUndoStack();
 
     /**
      * 构造函数
@@ -237,7 +232,7 @@ export class SPolygonItem extends SGraphItem {
         }
         if (this.selected) {
             painter.shadow.shadowBlur = 10;
-            painter.shadow.shadowColor = new SColor(`#00000060`);
+            painter.shadow.shadowColor = new SColor(`#00000033`);
             painter.shadow.shadowOffsetX = 5;
             painter.shadow.shadowOffsetY = 5;
         } else {
@@ -275,26 +270,28 @@ export class SPolygonItem extends SGraphItem {
             // 绘制顶点块
             painter.pen.color = SColor.Black;
             painter.brush.color = SColor.White;
-            pointList.forEach((item, index) => {
+            pointList.forEach(item => {
                 painter.drawCircle(item.x, item.y, painter.toPx(this.len / 2));
             });
             // 如果最后一个点在第一个点的灵敏度范围内,第一个点填充变红
-            if (
-                SMathUtil.pointDistance(
-                    this.lastPoint.x,
-                    this.lastPoint.y,
-                    this.pointList[0].x,
-                    this.pointList[0].y
-                ) < this.scenceLen
-            ) {
-                // 绘制第一个点的顶点块
-                painter.pen.color = SColor.Black;
-                painter.brush.color = SColor.Red;
-                painter.drawCircle(
-                    this.pointList[0].x,
-                    this.pointList[0].y,
-                    painter.toPx(this.len / 2)
-                );
+            if (this.pointList.length) {
+                if (
+                    SMathUtil.pointDistance(
+                        this.lastPoint.x,
+                        this.lastPoint.y,
+                        this.pointList[0].x,
+                        this.pointList[0].y
+                    ) < this.scenceLen
+                ) {
+                    // 绘制第一个点的顶点块
+                    painter.pen.color = SColor.Black;
+                    painter.brush.color = SColor.Red;
+                    painter.drawCircle(
+                        this.pointList[0].x,
+                        this.pointList[0].y,
+                        painter.toPx(this.len / 2)
+                    );
+                }
             }
         } else {
             painter.drawPolygon(pointList);
@@ -451,10 +448,8 @@ export class SPolygonItem extends SGraphItem {
      */
     protected recordAction(SGraphCommand: any, any: any[]): void {
         // 记录相关命令并推入堆栈中
-        const sgraphcommand = new SGraphCommand(this, ...any);
-        if (this.undoStack) {
-            this.undoStack.push(sgraphcommand);
-        }
+        const sgraphcommand = new SGraphCommand(this.scene, this, ...any);
+        this.undoStack.push(sgraphcommand);
     }
 
     /**
@@ -464,9 +459,7 @@ export class SPolygonItem extends SGraphItem {
         if (this.status == SItemStatus.Normal) {
             return;
         }
-        if (this.undoStack) {
-            this.undoStack.undo();
-        }
+        this.undoStack.undo();
     }
 
     /**
@@ -476,9 +469,7 @@ export class SPolygonItem extends SGraphItem {
         if (this.status == SItemStatus.Normal) {
             return;
         }
-        if (this.undoStack) {
-            this.undoStack.redo();
-        }
+        this.undoStack.redo();
     }
 
     ///////////////////////////////
@@ -498,9 +489,6 @@ export class SPolygonItem extends SGraphItem {
         } else if (SItemStatus.Edit == this.status) {
             this.status = SItemStatus.Normal;
             this.releaseItem();
-            if (this.undoStack) {
-                this.undoStack.clear();
-            }
         }
         this.update();
         return true;
@@ -525,10 +513,6 @@ export class SPolygonItem extends SGraphItem {
                     this.$emit("finishCreated");
                     //1 grabItem 置为null
                     this.releaseItem();
-                    //2 清空undo
-                    if (this.undoStack) {
-                        this.undoStack.clear();
-                    }
                 }
             }
         } else if (this.status == SItemStatus.Edit) {
@@ -570,22 +554,21 @@ export class SPolygonItem extends SGraphItem {
         // 如果状态为编辑状态则添加点
         if (this.status == SItemStatus.Create) {
             // 新增顶点
-            let len = SMathUtil.pointDistance(
-                event.x,
-                event.y,
-                this.pointList[0].x,
-                this.pointList[0].y
-            );
-            if (this.pointList.length > 2 && len < this.scenceLen) {
+            let len = -1;
+            if (this.pointList.length) {
+                len = SMathUtil.pointDistance(
+                    event.x,
+                    event.y,
+                    this.pointList[0].x,
+                    this.pointList[0].y
+                );
+            }
+            if (this.pointList.length > 2 && len > 0 && len < this.scenceLen) {
                 this.status = SItemStatus.Normal;
                 //3 传递完成事件状态
                 this.$emit("finishCreated");
                 //1 grabItem 置为null
                 this.releaseItem();
-                //2 清空undo
-                if (this.undoStack) {
-                    this.undoStack.clear();
-                }
             } else {
                 this.insertPoint(event.x, event.y);
                 // 记录新增顶点操作记录压入堆栈

+ 7 - 12
saga-web-big/src/items/SPolylineItem.ts

@@ -32,6 +32,7 @@ export class SPolylineItem extends SGraphItem {
     }
     set status(v: SItemStatus) {
         this._status = v;
+        this.undoStack.clear();
         this.update();
     }
     /** 鼠标移动时的点 */
@@ -72,7 +73,7 @@ export class SPolylineItem extends SGraphItem {
     /** 当前点索引   */
     private curPoint: SPoint | null = null;
     /** undo/redo堆栈 */
-    private undoStack: SUndoStack | null = new SUndoStack();
+    private undoStack: SUndoStack = new SUndoStack();
 
     /**
      * 构造函数
@@ -371,10 +372,8 @@ export class SPolylineItem extends SGraphItem {
      */
     protected recordAction(SGraphCommand: any, any: any[]): void {
         // 记录相关命令并推入堆栈中
-        const command = new SGraphCommand(this, ...any);
-        if (this.undoStack) {
-            this.undoStack.push(command);
-        }
+        const command = new SGraphCommand(this.scene, this, ...any);
+        this.undoStack.push(command);
     } // Function recordAction()
 
     /**
@@ -445,9 +444,7 @@ export class SPolylineItem extends SGraphItem {
      */
     undo(): void {
         if (this._status != SItemStatus.Normal) {
-            if (this.undoStack) {
-                this.undoStack.undo();
-            }
+            this.undoStack.undo();
         }
     } // Function undo()
 
@@ -457,9 +454,7 @@ export class SPolylineItem extends SGraphItem {
      */
     redo(): void {
         if (this._status != SItemStatus.Normal) {
-            if (this.undoStack) {
-                this.undoStack.redo();
-            }
+            this.undoStack.redo();
         }
     } // Function redo()
 
@@ -527,7 +522,7 @@ export class SPolylineItem extends SGraphItem {
             if (this.selected) {
                 painter.pen.lineWidth = painter.toPx(this.lineWidth * 2);
                 painter.shadow.shadowBlur = 10;
-                painter.shadow.shadowColor = new SColor(`#00000060`);
+                painter.shadow.shadowColor = new SColor(`#00000033`);
                 painter.shadow.shadowOffsetX = 5;
                 painter.shadow.shadowOffsetY = 5;
             }

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

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

+ 1 - 1
saga-web-graph/src/SGraphSelectContainer.ts

@@ -75,7 +75,7 @@ export class SGraphSelectContainer extends SObject {
             if (this.itemList[i] == item) {
                 this.itemList[i].selected = false;
                 this.itemList.splice(i, 1);
-                this.$emit("listChange", this.itemList);
+                this.$emit("listChange", this.itemList, item);
                 return;
             }
         }

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

@@ -132,7 +132,7 @@ export class STextItem extends SObjectItem {
         //绘制矩形轮廓
         if (this.selected) {
             painter.shadow.shadowBlur = 10;
-            painter.shadow.shadowColor = new SColor(`#00000060`);
+            painter.shadow.shadowColor = new SColor(`#00000033`);
             painter.shadow.shadowOffsetX = 5;
             painter.shadow.shadowOffsetY = 5;
         } else {