/* * ******************************************************************************************************************** * * :*$@@%$*: ;: ;; ;; * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@ * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$ * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$= * =@* %! @ $= % %@= =%@! %= * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =% * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%* * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$ * $@* ;@@@%=!: *@* * =@$ ;;;!=%@@@@=! =@! * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司 * ;%@@$=$@@%* *@@@$=%@@%; * ::;:: ::;:: All rights reserved. * * ******************************************************************************************************************** */ import { FloorScene } from "./FloorScene"; import { MarkerItem } from "./items/MarkItem"; import { Marker } from "./types/Marker"; import { IconTextItem } from "./items/IconTextItem"; /** * 位置标签绘制标志 * * @author 郝建龙 */ export class LocationPointScene extends FloorScene { /** 标志list */ markerList: MarkerItem[] = []; /** 标志是否可选 */ _isMarkSelectable: boolean = true; get isMarkSelectable(): boolean { return this._isMarkSelectable; } // Get isMarkSelectable set isMarkSelectable(v: boolean) { if (this._isMarkSelectable === v) { return; } this._isMarkSelectable = v; this.markerList.map((t: MarkerItem) => { t.selectable = this._isMarkSelectable; return t; }); } // Set isMarkSelectable /** 标志list */ iconList: IconTextItem[] = []; /** 标志是否可选 */ _isIconSelectable: boolean = true; get isIconSelectable(): boolean { return this._isIconSelectable; } // Get isMarkSelectable set isIconSelectable(v: boolean) { if (this._isIconSelectable === v) { return; } this._isIconSelectable = v; this.iconList.map((t: IconTextItem) => { t.selectable = this._isIconSelectable; return t; }); } // Set isMarkSelectable /** * 构造函数 */ constructor() { super(); } // Constructor /** * 添加标志list至scene中 * * @param markerList 标志对象list */ addMarkerList(markerList: Marker[]): void { markerList.map(t => { this.addMarker(t); }); } // Function addMarkerList() /** * 添加标志到scene中 * * @param marker 标志对象 */ addMarker(marker: Marker): void { let mark = new MarkerItem(null, marker); mark.moveTo(marker.X, marker.Y); mark.selectable = this.isMarkSelectable; this.markerList.push(mark); this.addItem(mark); } // Function addMarker() /** * 添加设备带文字item * * @param iconTextList item列表 */ addIconTextList(iconTextList: IconTextItem[]): void { iconTextList.map(t => { this.addIconText(t); }); } /** * 添加单个设备 * * @param iconText item 数据 */ addIconText(iconText: any): void { const icon = new IconTextItem(null, iconText); if (iconText.X && iconText.Y) { icon.moveTo(iconText.X, iconText.Y); } this.iconList.push(icon); this.addItem(icon); } /** * 标志的点击事件 * * @param _this 接收者 * @param fn 处理函数 */ markerClick(_this: any, fn: Function): void { this.markerList.map(m => { m.connect("click", _this, fn); }); } // Function markerClick() /** * 空间的点击事件 * * @param _this 接收者 * @param fn 处理函数 */ spaceClick(_this: any, fn: Function): void { this.spaceList.map(m => { m.connect("click", _this, fn); }); this.imgList.map(m => { m.connect("click", _this, fn); }); } // Function spaceClick() /** * 清空所有设备 icon */ clearIcon(): void { this.iconList.forEach(t => { this.removeItem(t); }); this.iconList = []; } /** * 设备 icon 绑定点击事件和文本修改事件 */ iconChangeText(_this: any, fn: Function): void { this.iconList.forEach(t => { t.connect("changeText", _this, fn); }); } /** * 设备 icon 绑定移动事件 */ iconMove(_this: any, fn: Function): void { this.iconList.forEach(t => { t.connect("onMove", _this, fn); }); } } // Class LocationPointScene