|
|
@@ -13,11 +13,12 @@ import { tagService } from '../Service/TagService.js'
|
|
|
import Constant from '../Constant'
|
|
|
import { addWall } from '../Controls/AddWall'
|
|
|
import { floorplanData } from '../FloorplanData.js'
|
|
|
-import { furnitureService } from '../Service/FurnitureService.js'
|
|
|
+import { signService } from '../Service/SignService.js'
|
|
|
|
|
|
export default class UIControl {
|
|
|
constructor(layer) {
|
|
|
this.layer = layer
|
|
|
+ this.selectUI = null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -31,20 +32,7 @@ export default class UIControl {
|
|
|
* 设置选中要添加的UI
|
|
|
*/
|
|
|
set selectUI(value) {
|
|
|
- this.layer.updateEventNameForSelectUI()
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取选中要操作的UI
|
|
|
- */
|
|
|
- get currentUI() {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置选中要操作的UI
|
|
|
- */
|
|
|
- set currentUI(value) {
|
|
|
-
|
|
|
+ this.updateEventNameForSelectUI()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -59,6 +47,61 @@ export default class UIControl {
|
|
|
set currentFloor(value) {
|
|
|
}
|
|
|
|
|
|
+ //点击左侧栏后,更新事件
|
|
|
+ updateEventNameForSelectUI() {
|
|
|
+ elementService.hideAll()
|
|
|
+ //正在添加tag的时候,需要先删除
|
|
|
+ const eventName = stateService.getEventName()
|
|
|
+ if (eventName == LayerEvents.AddTag) {
|
|
|
+ let item = stateService.getDraggingItem()
|
|
|
+ if (item && item.type == VectorType.Tag) {
|
|
|
+ floorplanService.deleteTag(item.vectorId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stateService.clearItems()
|
|
|
+ if (this.selectUI == UIEvents.Wall || this.selectUI == UIEvents.OutWall) {
|
|
|
+ stateService.setEventName(LayerEvents.AddWall)
|
|
|
+ } else if (
|
|
|
+ this.selectUI == UIEvents.SingleDoor ||
|
|
|
+ this.selectUI == UIEvents.DoubleDoor ||
|
|
|
+ this.selectUI == UIEvents.SlideDoor ||
|
|
|
+ this.selectUI == UIEvents.SingleWindow ||
|
|
|
+ this.selectUI == UIEvents.BayWindow ||
|
|
|
+ this.selectUI == UIEvents.FrenchWindow ||
|
|
|
+ this.selectUI == UIEvents.Pass
|
|
|
+ ) {
|
|
|
+ stateService.setEventName(LayerEvents.AddSymbol)
|
|
|
+ } else if (this.selectUI == UIEvents.Beam || this.selectUI == UIEvents.Flue || this.selectUI == UIEvents.Corridor) {
|
|
|
+ stateService.setEventName(LayerEvents.AddComponent)
|
|
|
+ } else if (this.selectUI == UIEvents.Tag) {
|
|
|
+ stateService.setEventName(LayerEvents.AddTag)
|
|
|
+ } else if (
|
|
|
+ this.selectUI == UIEvents.TV ||
|
|
|
+ this.selectUI == UIEvents.CombinationSofa ||
|
|
|
+ this.selectUI == UIEvents.SingleSofa ||
|
|
|
+ this.selectUI == UIEvents.TeaTable ||
|
|
|
+ this.selectUI == UIEvents.Carpet ||
|
|
|
+ this.selectUI == UIEvents.Plant ||
|
|
|
+ this.selectUI == UIEvents.DiningTable ||
|
|
|
+ this.selectUI == UIEvents.DoubleBed ||
|
|
|
+ this.selectUI == UIEvents.SingleBed ||
|
|
|
+ this.selectUI == UIEvents.Wardrobe ||
|
|
|
+ this.selectUI == UIEvents.Dresser ||
|
|
|
+ this.selectUI == UIEvents.BedsideCupboard ||
|
|
|
+ this.selectUI == UIEvents.Pillow ||
|
|
|
+ this.selectUI == UIEvents.GasStove ||
|
|
|
+ this.selectUI == UIEvents.Cupboard ||
|
|
|
+ this.selectUI == UIEvents.Bathtub ||
|
|
|
+ this.selectUI == UIEvents.Closestool ||
|
|
|
+ this.selectUI == UIEvents.Washstand ||
|
|
|
+ this.selectUI == UIEvents.Desk ||
|
|
|
+ this.selectUI == UIEvents.BalconyChair ||
|
|
|
+ this.selectUI == UIEvents.Elevator
|
|
|
+ ) {
|
|
|
+ stateService.setEventName(LayerEvents.AddSign)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设置部件属性
|
|
|
* @param {*} type 部件类型
|
|
|
@@ -68,7 +111,6 @@ export default class UIControl {
|
|
|
setAttributes(type, name, value) {
|
|
|
console.log(name)
|
|
|
let item = stateService.getFocusItem()
|
|
|
- // 回写 this.layer.$xui.currentAttributes = {...}
|
|
|
switch (name) {
|
|
|
case 'remove':
|
|
|
if (type == VectorType.Wall || type == 'OutWall') {
|
|
|
@@ -83,12 +125,11 @@ export default class UIControl {
|
|
|
}
|
|
|
} else if (type == VectorType.WallCorner) {
|
|
|
wallService.deleteWallCorner(item.vectorId)
|
|
|
- } else if (furnitureService.isFurniture(type)) {
|
|
|
- floorplanService.deleteFurniture(item.vectorId)
|
|
|
+ } else if (signService.isSign(type)) {
|
|
|
+ floorplanService.deleteSign(item.vectorId)
|
|
|
}
|
|
|
stateService.clearItems()
|
|
|
stateService.clearEventName()
|
|
|
- //this.layer.history.save()
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
break
|
|
|
case 'angle':
|
|
|
@@ -96,14 +137,10 @@ export default class UIControl {
|
|
|
let component = floorplanService.getComponent(item.vectorId)
|
|
|
component.angle = value
|
|
|
component.setPoints2d()
|
|
|
-
|
|
|
- //this.layer.history.save()
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
- } else if (furnitureService.isFurniture(type)) {
|
|
|
- let furniture = floorplanService.getFurniture(item.vectorId)
|
|
|
- furniture.angle = value
|
|
|
-
|
|
|
- //this.layer.history.save()
|
|
|
+ } else if (signService.isSign(type)) {
|
|
|
+ let sign = floorplanService.getSign(item.vectorId)
|
|
|
+ sign.angle = value
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
}
|
|
|
break
|
|
|
@@ -113,15 +150,13 @@ export default class UIControl {
|
|
|
component.sideWidth = value
|
|
|
component.setPoints2d()
|
|
|
}
|
|
|
- //this.layer.history.save()
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
break
|
|
|
|
|
|
case 'scale':
|
|
|
- if (furnitureService.isFurniture(type)) {
|
|
|
- let furniture = floorplanService.getFurniture(item.vectorId)
|
|
|
- furniture.scale = value
|
|
|
- //this.layer.history.save()
|
|
|
+ if (signService.isSign(type)) {
|
|
|
+ let sign = floorplanService.getSign(item.vectorId)
|
|
|
+ sign.scale = value
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
}
|
|
|
break
|
|
|
@@ -130,7 +165,6 @@ export default class UIControl {
|
|
|
let component = floorplanService.getComponent(item.vectorId)
|
|
|
component.sideThickness = value
|
|
|
component.setPoints2d()
|
|
|
- //this.layer.history.save()
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
}
|
|
|
break
|
|
|
@@ -163,8 +197,6 @@ export default class UIControl {
|
|
|
} else if (mid.x == _mid.x && mid.y > _mid.y) {
|
|
|
stateService.setFocusItem(focusItem)
|
|
|
}
|
|
|
- //stateService.clearFocusItem()
|
|
|
- //this.layer.history.save()
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
}
|
|
|
break
|
|
|
@@ -181,14 +213,6 @@ export default class UIControl {
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
}
|
|
|
break
|
|
|
- case 'area':
|
|
|
- if (type == VectorType.Tag) {
|
|
|
- let tag = floorplanService.getTag(item.vectorId)
|
|
|
- tag.setDes(value)
|
|
|
- //this.layer.history.save()
|
|
|
- this.layer.renderer.autoRedraw()
|
|
|
- }
|
|
|
- break
|
|
|
case 'default':
|
|
|
if (type == 'compass') {
|
|
|
floorplanService.setCompass(0)
|
|
|
@@ -206,55 +230,8 @@ export default class UIControl {
|
|
|
angle: 0,
|
|
|
}
|
|
|
}
|
|
|
- //this.layer.history.save()
|
|
|
- this.layer.renderer.autoRedraw()
|
|
|
- break
|
|
|
- case 'enter': //入户门
|
|
|
- if (type == VectorType.SingleDoor || type == VectorType.DoubleDoor || type == VectorType.SlideDoor) {
|
|
|
- let symbol = floorplanService.getSymbol(item.vectorId)
|
|
|
- if (value) {
|
|
|
- symbol.enter = 'default'
|
|
|
- } else {
|
|
|
- symbol.enter = null
|
|
|
- }
|
|
|
- //this.layer.history.save()
|
|
|
- this.layer.renderer.autoRedraw()
|
|
|
- }
|
|
|
- break
|
|
|
- case 'enterRotate': //入户门方向
|
|
|
- if (type == VectorType.SingleDoor || type == VectorType.DoubleDoor || type == VectorType.SlideDoor) {
|
|
|
- let symbol = floorplanService.getSymbol(item.vectorId)
|
|
|
- if (symbol.enter == null) {
|
|
|
- symbol.enter = 'default'
|
|
|
- } else if (symbol.enter == 'default') {
|
|
|
- symbol.enter = 'reverse'
|
|
|
- } else if (symbol.enter == 'reverse') {
|
|
|
- symbol.enter = 'default'
|
|
|
- }
|
|
|
- }
|
|
|
- //this.layer.history.save()
|
|
|
this.layer.renderer.autoRedraw()
|
|
|
break
|
|
|
- case 'important':
|
|
|
- if (type == VectorType.Wall) {
|
|
|
- let wall = floorplanService.getWall(item.vectorId)
|
|
|
- wall.setImportant(value)
|
|
|
- //this.layer.history.save()
|
|
|
- this.layer.renderer.autoRedraw()
|
|
|
- }
|
|
|
- break
|
|
|
- case 'wallType':
|
|
|
- if (type == VectorType.Wall) {
|
|
|
- let wall = floorplanService.getWall(item.vectorId)
|
|
|
- if (value == 'OutWall') {
|
|
|
- wall.setOut(true)
|
|
|
- } else {
|
|
|
- wall.setOut(false)
|
|
|
- }
|
|
|
- //this.layer.history.save()
|
|
|
- this.layer.renderer.autoRedraw()
|
|
|
- }
|
|
|
- break
|
|
|
case 'compass':
|
|
|
floorplanService.setCompass(parseFloat(value))
|
|
|
break
|
|
|
@@ -269,13 +246,6 @@ export default class UIControl {
|
|
|
}
|
|
|
|
|
|
showAttributes(type) {
|
|
|
- if (type == 'compass') {
|
|
|
- this.layer.$xui.currentAttributes = {
|
|
|
- name: 'compass',
|
|
|
- compass: floorplanService.getCompass(),
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
let item = stateService.getFocusItem()
|
|
|
if (item == null) {
|
|
|
item = stateService.getDraggingItem()
|
|
|
@@ -304,13 +274,13 @@ export default class UIControl {
|
|
|
important: wall.important || wall.out,
|
|
|
wallType: wall.out ? 'OutWall' : item.type,
|
|
|
}
|
|
|
- } else if (furnitureService.isFurniture(item.type)) {
|
|
|
- let furniture = floorplanService.getFurniture(item.vectorId)
|
|
|
- let scale = furniture.scale
|
|
|
+ } else if (signService.isSign(item.type)) {
|
|
|
+ let sign = floorplanService.getSign(item.vectorId)
|
|
|
+ let scale = sign.scale
|
|
|
this.layer.$xui.currentAttributes = {
|
|
|
name: item.type,
|
|
|
scale: scale,
|
|
|
- angle: furniture.angle,
|
|
|
+ angle: sign.angle,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -329,49 +299,21 @@ export default class UIControl {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- getFurnitureTypeForUI() {
|
|
|
- if (this.selectUI == UIEvents.TV) {
|
|
|
- return VectorType.TV
|
|
|
- } else if (this.selectUI == UIEvents.CombinationSofa) {
|
|
|
- return VectorType.CombinationSofa
|
|
|
- } else if (this.selectUI == UIEvents.SingleSofa) {
|
|
|
- return VectorType.SingleSofa
|
|
|
- } else if (this.selectUI == UIEvents.TeaTable) {
|
|
|
- return VectorType.TeaTable
|
|
|
- } else if (this.selectUI == UIEvents.Carpet) {
|
|
|
- return VectorType.Carpet
|
|
|
- } else if (this.selectUI == UIEvents.Plant) {
|
|
|
- return VectorType.Plant
|
|
|
- } else if (this.selectUI == UIEvents.DiningTable) {
|
|
|
- return VectorType.DiningTable
|
|
|
- } else if (this.selectUI == UIEvents.DoubleBed) {
|
|
|
- return VectorType.DoubleBed
|
|
|
- } else if (this.selectUI == UIEvents.SingleBed) {
|
|
|
- return VectorType.SingleBed
|
|
|
- } else if (this.selectUI == UIEvents.Wardrobe) {
|
|
|
- return VectorType.Wardrobe
|
|
|
- } else if (this.selectUI == UIEvents.Dresser) {
|
|
|
- return VectorType.Dresser
|
|
|
- } else if (this.selectUI == UIEvents.BedsideCupboard) {
|
|
|
- return VectorType.BedsideCupboard
|
|
|
- } else if (this.selectUI == UIEvents.Pillow) {
|
|
|
- return VectorType.Pillow
|
|
|
- } else if (this.selectUI == UIEvents.GasStove) {
|
|
|
- return VectorType.GasStove
|
|
|
- } else if (this.selectUI == UIEvents.Cupboard) {
|
|
|
- return VectorType.Cupboard
|
|
|
- } else if (this.selectUI == UIEvents.Bathtub) {
|
|
|
- return VectorType.Bathtub
|
|
|
- } else if (this.selectUI == UIEvents.Closestool) {
|
|
|
- return VectorType.Closestool
|
|
|
- } else if (this.selectUI == UIEvents.Washstand) {
|
|
|
- return VectorType.Washstand
|
|
|
- } else if (this.selectUI == UIEvents.Desk) {
|
|
|
- return VectorType.Desk
|
|
|
- } else if (this.selectUI == UIEvents.BalconyChair) {
|
|
|
- return VectorType.BalconyChair
|
|
|
- } else if (this.selectUI == UIEvents.Elevator) {
|
|
|
- return VectorType.Elevator
|
|
|
+ getSignTypeForUI() {
|
|
|
+ if (this.selectUI == UIEvents.Cigaret) {
|
|
|
+ return VectorType.Cigaret
|
|
|
+ } else if (this.selectUI == UIEvents.FirePoint) {
|
|
|
+ return VectorType.FirePoint
|
|
|
+ } else if (this.selectUI == UIEvents.FootPrint) {
|
|
|
+ return VectorType.FootPrint
|
|
|
+ } else if (this.selectUI == UIEvents.ShoePrint) {
|
|
|
+ return VectorType.ShoePrint
|
|
|
+ } else if (this.selectUI == UIEvents.FingerPrint) {
|
|
|
+ return VectorType.FingerPrint
|
|
|
+ } else if (this.selectUI == UIEvents.DeadBody) {
|
|
|
+ return VectorType.DeadBody
|
|
|
+ } else if (this.selectUI == UIEvents.BloodStain) {
|
|
|
+ return VectorType.BloodStain
|
|
|
}
|
|
|
}
|
|
|
|