浏览代码

比例尺item修改;抛出事件;蒙版item沉入floorscene

haojianlong 4 年之前
父节点
当前提交
d71794ba41
共有 4 个文件被更改,包括 67 次插入52 次删除
  1. 2 2
      package.json
  2. 0 46
      src/DivideFloorScene.ts
  3. 62 3
      src/FloorScene.ts
  4. 3 1
      src/items/EditLineItem.ts

+ 2 - 2
package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/cad-engine",
-    "version": "2.0.572",
+    "version": "2.0.574",
     "description": "上格云 CAD图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -31,7 +31,7 @@
         "typescript": "^3.9.7"
     },
     "dependencies": {
-        "@saga-web/graph": "2.1.129",
+        "@saga-web/graph": "2.1.131",
         "axios": "^0.18.0",
         "pako": "^1.0.10",
         "poly-decomp": "^0.3.0",

+ 0 - 46
src/DivideFloorScene.ts

@@ -43,19 +43,6 @@ import { ZoneScene } from "./ZoneScene";
  * @author 郝建龙
  */
 export class DivideFloorScene extends ZoneScene {
-    /** 是否开启用户标记     */
-    _isMarking: boolean = false;
-    get isMarking(): boolean {
-        return this._isMarking;
-    } // Get isMarking
-    set isMarking(v: boolean) {
-        if (this._isMarking === v) {
-            return;
-        }
-        this._isMarking = v;
-    } // Set isMarking
-    /** 蒙版item  */
-    sceneMark: SceneMarkItem | null = null;
     /** 遮罩List  */
     shadeList: ShadeItem[] = [];
     /** 划分item  */
@@ -88,39 +75,6 @@ export class DivideFloorScene extends ZoneScene {
     } // Set isRectSelection
 
     /**
-     * 添加轮廓线
-     *
-     * @param   data
-     */
-    addSceneMark(data: SPoint[]): void {
-        if (data.length) {
-            let outline = data.map(
-                (t: SPoint): SPoint => {
-                    t.y = -t.y;
-                    return t;
-                }
-            );
-            let sceneMark = new SceneMarkItem(null, outline);
-            this.addItem(sceneMark);
-            this.sceneMark = sceneMark;
-        }
-    } // Function addSceneMark()
-
-    /**
-     * 清除蒙版
-     *
-     */
-    clearSceneMark(): void {
-        if (this.sceneMark) {
-            this.grabItem = null;
-            this.removeItem(this.sceneMark);
-            this.sceneMark = null;
-            this.isMarking = false;
-            this.view && this.view.update();
-        }
-    } // Function clearSceneMark()
-
-    /**
      * 清除划分区域
      *
      */

+ 62 - 3
src/FloorScene.ts

@@ -19,6 +19,7 @@
  */
 
 import { SGraphScene, SImageItem } from "@saga-web/graph/lib";
+import { SPoint } from "@saga-web/draw";
 // @ts-ignore
 import pako from "pako";
 import { FloorData } from "./types/FloorData";
@@ -36,6 +37,7 @@ import { VirtualWallItem } from "./items/VirtualWallItem";
 import { DoorItem } from "./items/DoorItem";
 import { WindowItem } from "./items/WindowItem";
 import { SImageShowType } from "./enums/SImageShowType";
+import { SceneMarkItem } from "./items/SceneMarkItem";
 
 /**
  * 楼层场景
@@ -47,6 +49,17 @@ export class FloorScene extends SGraphScene {
     data: FloorData | null = null;
     /** json数据  */
     json: string | null = null;
+    /** 是否开启用户标记     */
+    _isMarking: boolean = false;
+    get isMarking(): boolean {
+        return this._isMarking;
+    } // Get isMarking
+    set isMarking(v: boolean) {
+        if (this._isMarking === v) {
+            return;
+        }
+        this._isMarking = v;
+    } // Set isMarking
     /** 是否显示空间  */
     private _isShowSpace: boolean = true;
     get isShowSpace(): boolean {
@@ -187,6 +200,8 @@ export class FloorScene extends SGraphScene {
     spaceList: SpaceItem[] = [];
     /** 底图为图片   */
     imgList: SImageItem[] = [];
+    /** 蒙版item  */
+    sceneMark: SceneMarkItem | null = null;
 
     /**
      *  构造函数
@@ -230,15 +245,26 @@ export class FloorScene extends SGraphScene {
     /**
      *  获取底图压缩文件
      *
-     * @param   url 请求数据文件路径
-     * @param   _fn 回调
+     * @param url   请求数据文件路径
+     * @param _fn   回调
+     * @param x     底图坐标原点x坐标
+     * @param y     底图坐标原点y坐标
+     * @param scale 宽高缩放比
      */
-    loadImg(url: string, _fn: Function): void {
+    loadImg(
+        url: string,
+        _fn: Function,
+        x: number = 0,
+        y: number = 0,
+        scale: number = 1
+    ): void {
         const imgItem = new SImageItem(null, url);
         imgItem.showType = SImageShowType.AutoFit;
         imgItem.connect("imgLoadOver", this, () => {
             _fn(imgItem);
         });
+        imgItem.moveTo(x, y);
+        imgItem.widthHeightScale = scale;
         this.addItem(imgItem);
         this.imgList.push(imgItem);
     } // Function loadImg()
@@ -465,4 +491,37 @@ export class FloorScene extends SGraphScene {
             }
         );
     } // Function clearSelectedSpaces()
+
+    /**
+     * 添加蒙版轮廓线
+     *
+     * @param   data
+     */
+    addSceneMark(data: SPoint[]): void {
+        if (data.length) {
+            let outline = data.map(
+                (t: SPoint): SPoint => {
+                    t.y = -t.y;
+                    return t;
+                }
+            );
+            let sceneMark = new SceneMarkItem(null, outline);
+            this.addItem(sceneMark);
+            this.sceneMark = sceneMark;
+        }
+    } // Function addSceneMark()
+
+    /**
+     * 清除蒙版
+     *
+     */
+    clearSceneMark(): void {
+        if (this.sceneMark) {
+            this.grabItem = null;
+            this.removeItem(this.sceneMark);
+            this.sceneMark = null;
+            this.isMarking = false;
+            this.view && this.view.update();
+        }
+    } // Function clearSceneMark()
 } // Class FloorScene

+ 3 - 1
src/items/EditLineItem.ts

@@ -232,7 +232,7 @@ export class EditLineItem extends SGraphItem {
             // this.recordAction(SGraphPointListInsert, [this.line, p, 1]);
             this.status = SItemStatus.Edit;
             this.releaseItem();
-            // this.$emit("finishCreated");
+            this.$emit("finishCreated");
             this.pointChange();
         }
         this.update();
@@ -289,6 +289,7 @@ export class EditLineItem extends SGraphItem {
                 this.releaseItem();
             } else {
                 if (this.isChangeText) {
+                    this.releaseItem();
                     this.$emit("changText", event);
                 } else {
                     return super.onMouseUp(event);
@@ -552,6 +553,7 @@ export class EditLineItem extends SGraphItem {
             if (this.text && this.textPos) {
                 painter.font.textAlign = STextAlign.Center;
                 painter.brush.color = SColor.Black;
+                painter.font.size = 10;
                 painter.pen.color = SColor.White;
                 painter.pen.lineWidth = 8 * lw;
                 painter.drawText(this.text, this.textPos.x, this.textPos.y);