123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import { SRect, SSize, SPoint } from "@sybotan-web/base";
- import { SGraphyPolygonItem } from './newItems/SGraphyPolygonItem.js'
- import { SGraphyScene, SMouseEvent } from "@sybotan-web/graphy";
- import { SPen, SPainter, SColor } from "@sybotan-web/draw";
- import { dataItemPath, dataItem, dataSpaceItem, dataInterface, PolygonItemInterface } from './dataType.js' //传入参数的参数接口类型
- /**
- * @name mainScene
- * @time 2019-07.07;
- * 添加所有item的场景到scene中
- */
- export default class mainScene extends SGraphyScene {
- data: dataInterface;
- private _isShowSpace: boolean = true; // 是否显示空间;
- private _isShowWallList: boolean = true; //是否展示墙体;
- private _isShowEquipmentList: boolean = true; //是否展示设备;
- private _isShowVrtualWallList: boolean = true; //是否展示虚拟墙
- // 设置是否显示空间
- get isShowSpace(): boolean {
- return this._isShowSpace
- }
- set isShowSpace(b: boolean) {
- this._isShowSpace = b
- }
- // 设置是否显示墙
- get isShowWallList(): boolean {
- return this._isShowWallList
- }
- set isShowWallList(b: boolean) {
- this._isShowWallList = b
- }
- // 设置是否显示设备
- get isShowEquipmentList(): boolean {
- return this._isShowEquipmentList
- }
- set isShowEquipmentList(b: boolean) {
- this._isShowEquipmentList = b
- }
- // 设置是否显示虚拟墙
- get isShowVrtualWallList(): boolean {
- return this._isShowVrtualWallList
- }
- set isShowVrtualWallList(b: boolean) {
- this._isShowVrtualWallList = b
- }
- /**
- * @param data 绘制空间地图得所有参数
- */
- constructor(data: dataInterface) {
- super()
- this.data = data;
- this.addAllItemList(data);
- }
- // 以下是绘制方法
- /**
- * 增添所有绘制item(地图);
- */
- addAllItemList(data: dataInterface) {
- let space: dataSpaceItem[] = data.SpaceList;
- this.addSpaceList(space) //绘制空间
- }
- /**
- * 添加所有空间到scene 中
- * @param space 空间list
- */
- addSpaceList(space: dataSpaceItem[]): void {
- if (space && space.length) {
- for (let i = 0; i < space.length; i++) {
- if (space[i].Paths[1] && space[i].Paths[1].length >= 2) {
- this.addItem(this.constructeItem(
- {
- parent: null,
- space: space[i]
- }));
- }
- }
- for (let i = 0; i < space.length; i++) {
- if (space[i].Paths[0] && space[i].Paths[0].length >= 2 && !space[i].Paths[1]) {
- this.addItem(this.constructeItem(
- {
- parent: null,
- space: space[i]
- }));
- }
- }
- }
- }
- // 绘制墙体
- addWallList(): void {
- }
- // 绘制设备
- addEquipmentList() {
- }
- // 绘制柱体
- addColumnListList(): void {
- }
- // 绘制虚拟墙
- addVrtualWallList(): void {
- }
- /**
- * 产生item实例
- */
- constructeItem(PolygonItemInterfaceData: PolygonItemInterface): SGraphyPolygonItem {
- return new SGraphyPolygonItem(PolygonItemInterfaceData)
- }
- // 鼠标交互类事件
- // 点击
- click(_this: any, fn: any): void {
- this.root.children.forEach(item => {
- item.connect("click", _this, fn);
- });
- }
- // 双击
- dbclick(_this: any, fn: any): void {
- this.root.children.forEach(item => {
- item.connect("doubleClick", _this, fn);
- });
- }
- // 按下
- mouseDown(_this: any, fn: any) {
- this.root.children.forEach(item => {
- item.connect("mouseDown", _this, fn);
- });
- }
- //移动
- mouseMove(_this: any, fn: any) {
- this.root.children.forEach(item => {
- item.connect("mouseMove", _this, fn);
- });
- }
- // 点解结束
- mouseUp(_this: any, fn: any) {
- this.root.children.forEach(item => {
- item.connect("mouseUp", _this, fn);
- });
- }
- }
|