|
@@ -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
|