Selaa lähdekoodia

更新item更新方法update;2.0.530

haojianlong 5 vuotta sitten
vanhempi
commit
361b0cddbd

+ 1 - 1
.eslintrc.js

@@ -40,7 +40,7 @@ module.exports = {
     },
     rules: {
         // 缩进
-        'indent': ['error', 4],                         // 缩进控制4空格
+        'indent': ['error', 4, { SwitchCase: 1 }],      // 缩进控制4空格
         'max-len': ['error', 120],                      // 每行字符不超过120
         'no-mixed-spaces-and-tabs': 'error',            // 禁止使用空格和tab混合缩进
         // 语句

+ 8 - 8
package-lock.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/cad-engine",
-    "version": "2.0.487",
+    "version": "2.0.528",
     "lockfileVersion": 1,
     "requires": true,
     "dependencies": {
@@ -30,19 +30,19 @@
             "integrity": "sha512-V5Xgh02IFmRgM0/7Hkm34RFS/VHepK7786LefuJLyuRh0B48DNJSPrkBAgad5Rl5VM76c8hSQikiS/fyuy7nDQ=="
         },
         "@saga-web/draw": {
-            "version": "2.1.71",
-            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@saga-web/draw/-/draw-2.1.71.tgz",
-            "integrity": "sha512-Dtn/TVaj/PiA95Yr0cyR9+KKqTa1nOsYYJxekm0XN9ETMForfZgib4y4exRwLhOEq7HwjKR/q+SCtCLRnDTvVQ==",
+            "version": "2.1.74",
+            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@saga-web/draw/-/draw-2.1.74.tgz",
+            "integrity": "sha512-ruPBhBdjUpjQw8gMmvCYXlqueS/W3TX8Lr2oBIH0Bg2lhezMhuHf6j46TAA6/oCuKwg99REV2jU2i50WWkogdQ==",
             "requires": {
                 "@saga-web/base": "^2.1.9"
             }
         },
         "@saga-web/graphy": {
-            "version": "2.1.34",
-            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@saga-web/graphy/-/graphy-2.1.34.tgz",
-            "integrity": "sha512-X4azMAFxHH02tNUX8JeCtvs6bQlyZRwrgXC5o1TAf1+ffN9BCE9cDQQhw+lrPqdmIBcJmRjE6sfZMUnEtT3MXw==",
+            "version": "2.1.39",
+            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@saga-web/graphy/-/graphy-2.1.39.tgz",
+            "integrity": "sha512-WyD+DCmcrNETqiEkeenD4V7zSE1kejFXAhQC9f+vAnFnxtEJBzCMF3fLnM2jtquynstz7aSRQ7kCRzEdls8XDA==",
             "requires": {
-                "@saga-web/draw": "^2.1.61"
+                "@saga-web/draw": "^2.1.74"
             }
         },
         "@types/eslint-visitor-keys": {

+ 3 - 3
package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/cad-engine",
-    "version": "2.0.522",
+    "version": "2.0.530",
     "description": "上格云 CAD图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -32,8 +32,8 @@
     },
     "dependencies": {
         "@saga-web/base": "2.1.9",
-        "@saga-web/draw": "2.1.71",
-        "@saga-web/graphy": "2.1.34",
+        "@saga-web/draw": "2.1.74",
+        "@saga-web/graphy": "2.1.39",
         "axios": "^0.18.0",
         "pako": "^1.0.10",
         "poly-decomp": "^0.3.0",

+ 74 - 0
src/DrawingScene.ts

@@ -0,0 +1,74 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { SGraphyScene } from "@saga-web/graphy/lib";
+import { SMouseEvent } from "@saga-web/base/lib";
+
+/**
+ * 在线绘图
+ *
+ * @author 郝建龙
+ */
+export class DrawingScene extends SGraphyScene {
+    /** 画布状态    */
+    sceneStatus: DrawStatus = DrawStatus.None;
+
+    /**
+     * 鼠标按下事件
+     *
+     * @param   event   保存事件参数
+     * @return  boolean
+     */
+    onMouseDown(event: SMouseEvent): boolean {
+        switch (this.sceneStatus) {
+            case DrawStatus.None:
+                console.log(0);
+                break;
+            case DrawStatus.LINE:
+                break;
+            case DrawStatus.CIRCLE:
+                break;
+            case DrawStatus.RECT:
+                break;
+            default:
+                break;
+        }
+        return true;
+    } // Function onMouseDown()
+
+    /**
+     * 鼠标抬起事件
+     *
+     * @param   event   保存事件参数
+     * @return  boolean
+     */
+    onMouseUp(event: SMouseEvent): boolean {
+        return false;
+    } // Function onMouseUp()
+
+    /**
+     *  鼠标移动事件
+     *
+     *  @param  event   鼠标事件对象
+     */
+    onMouseMove(event: SMouseEvent): boolean {
+        return false;
+    } // Function onMouseMove()
+} // Class DrawingScene

+ 20 - 23
src/FloorView.ts

@@ -19,12 +19,7 @@
  */
 
 import { SGraphyView } from "@saga-web/graphy/lib";
-import {
-    SMouseButton,
-    SMouseEvent,
-    SNetUtil,
-    STouchState
-} from "@saga-web/base/lib";
+import { SMouseButton, SMouseEvent, SNetUtil } from "@saga-web/base/lib";
 import { SPoint } from "@saga-web/draw/lib";
 
 /**
@@ -59,23 +54,25 @@ export class FloorView extends SGraphyView {
     protected onKeyDown(event: KeyboardEvent): void {
         let keyCode = event.keyCode;
         this.spaceKey = false;
-        if (keyCode == 32) {
-            // 空格按键
-            this.spaceKey = true;
-        } else if (keyCode == 87) {
-            // w按键
-            this.origin.y -= 10;
-        } else if (keyCode == 83) {
-            // s按键
-            this.origin.y += 10;
-        } else if (keyCode == 68) {
-            // d按键
-            this.origin.x += 10;
-        } else if (keyCode == 65) {
-            // a按键
-            this.origin.x -= 10;
-        } else {
-            super.onKeyDown(event);
+        switch (keyCode) {
+            case 32:
+                this.spaceKey = true;
+                break;
+            case 87:
+                this.origin.y -= 10;
+                break;
+            case 83:
+                this.origin.y += 10;
+                break;
+            case 68:
+                this.origin.x += 10;
+                break;
+            case 65:
+                this.origin.x -= 10;
+                break;
+            default:
+                super.onKeyDown(event);
+                break;
         }
     } // Function onKeyDown()
 

+ 2 - 0
src/items/HighlightItem.ts

@@ -42,6 +42,7 @@ export class HighlightItem extends SGraphyItem {
     set point(v: SPoint) {
         this._point = v;
         this.type = 1;
+        this.update();
     } // Set point
 
     /** 点对象数据   */
@@ -52,6 +53,7 @@ export class HighlightItem extends SGraphyItem {
     set line(v: SLine) {
         this._line = v;
         this.type = 2;
+        this.update();
     } // Set line
 
     /**

+ 1 - 0
src/items/LikeSpaceItem.ts

@@ -59,6 +59,7 @@ export class LikeSpaceItem extends SGraphyItem {
     } // Get highLightFlag
     set highLightFlag(value: boolean) {
         this._highLightFlag = value;
+        this.update();
     } // Set highLightFlag
 
     /**

+ 2 - 0
src/items/RectSelectItem.ts

@@ -45,6 +45,7 @@ export class RectSelectItem extends SGraphyItem {
         super(parent);
         this.startPoint = point;
         this.endPoint = new SPoint(point.x, point.y);
+        this.update();
         this.zOrder = ItemOrder.rectSelectOrder;
     } // Constructor
 
@@ -57,6 +58,7 @@ export class RectSelectItem extends SGraphyItem {
     onMouseMove(event: SMouseEvent): boolean {
         this.endPoint.x = event.x;
         this.endPoint.y = event.y;
+        this.update();
         return true;
     } // Function onMouseMove()
 

+ 0 - 1
src/items/RelationItem.ts

@@ -23,7 +23,6 @@ import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SColor, SPainter, SPoint } from "@saga-web/draw/lib";
 import { SMouseEvent } from "@saga-web/base/lib";
 import { ItemOrder } from "../types/ItemOrder";
-import { ZoneItem } from "./ZoneItem";
 import { RelationPoint } from "../types/RelationPoint";
 
 /**

+ 1 - 0
src/items/SpaceItem.ts

@@ -60,6 +60,7 @@ export class SpaceItem extends SGraphyItem {
     } // Get highLightFlag
     set highLightFlag(value: boolean) {
         this._highLightFlag = value;
+        this.update();
     } // Set highLightFlag
 
     /**

+ 22 - 1
src/items/ZoneItem.ts

@@ -66,9 +66,27 @@ export class ZoneItem extends SGraphyItem {
     } // Get highLightFlag
     set highLightFlag(value: boolean) {
         this._highLightFlag = value;
+        this.update();
     } // Set highLightFlag
     /** 透明度 */
-    transparency: number = 20;
+    _transparency: number = 20;
+    get transparency(): number {
+        return this._transparency;
+    } // Get transparency
+    set transparency(value: number) {
+        this._transparency = value;
+        this.update();
+    } // Set transparency
+    /** 受影响状态   */
+    _isInfected: boolean = false;
+    get isInfected(): boolean {
+        return this._isInfected;
+    } // Get isInfected
+    set isInfected(value: boolean) {
+        this._isInfected = value;
+        this.update();
+    } // Set isInfected
+    private infectedColor = Opt.zoneInfectedColor;
 
     /**
      * 构造函数
@@ -82,6 +100,7 @@ export class ZoneItem extends SGraphyItem {
         this.zOrder = ItemOrder.zoneOrder;
         this.highLightFlag = data.HighLightFlag || false;
         this.transparency = data.Transparency || 20;
+        this.isInfected = data.Infected || false;
         if (
             this.data.OutLine.length &&
             this.data.OutLine[0] &&
@@ -199,6 +218,8 @@ export class ZoneItem extends SGraphyItem {
                 painter.brush.color = this.selectColor;
             } else if (this.highLightFlag) {
                 painter.brush.color = new SColor(this.data.Color);
+            } else if (this.isInfected) {
+                painter.brush.color = this.infectedColor;
             } else {
                 painter.brush.color = new SColor(
                     `${this.data.Color}${Transparency[this.transparency]}`

+ 31 - 0
src/types/DrawStatus.ts

@@ -0,0 +1,31 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+/**
+ * 绘图工具状态
+ *
+ * @author 郝建龙
+ */
+enum DrawStatus {
+    None = 0,
+    LINE = 1,
+    CIRCLE = 2,
+    RECT = 3
+} // Enum DrawStatus

+ 2 - 0
src/types/Opt.ts

@@ -56,4 +56,6 @@ export class Opt {
     static spaceHighColor = new SColor("#fbb029");
     /** 业务空间不可选中颜色 */
     static zoneUnselectColor = new SColor("#cecece");
+    /** 受影响业务空间颜色 */
+    static zoneInfectedColor = new SColor("#e2675c");
 } // Interface Opt

+ 2 - 0
src/types/Zone.ts

@@ -40,4 +40,6 @@ export interface Zone {
     HighLightFlag?: boolean;
     /** 透明度  */
     Transparency?: number;
+    /** 是否受影响   */
+    Infected?: boolean;
 } // Interface Zone