|
@@ -9,6 +9,8 @@ import UIControl from './Controls/UIControl'
|
|
|
import { moveTag } from './Controls/MoveTag'
|
|
|
import { addWall } from './Controls/AddWall'
|
|
|
import { moveWall } from './Controls/MoveWall'
|
|
|
+import { addRectangle } from './Controls/AddRectangle'
|
|
|
+import { moveRectangle } from './Controls/MoveRectangle'
|
|
|
import { coordinate } from './Coordinate'
|
|
|
import Render from './Renderer/Render'
|
|
|
import { draw } from './Renderer/Draw'
|
|
@@ -77,17 +79,14 @@ export default class Layer {
|
|
|
const eventName = stateService.getEventName()
|
|
|
//点击第一次
|
|
|
if (eventName == LayerEvents.AddWall) {
|
|
|
- let flag = this.setNewWallPoint('start', {
|
|
|
+ let flag = addWall.execute({
|
|
|
x: this.startX,
|
|
|
y: this.startY,
|
|
|
})
|
|
|
- if (!flag) {
|
|
|
- return
|
|
|
- }
|
|
|
}
|
|
|
//点击第二次
|
|
|
else if (eventName == LayerEvents.AddingWall) {
|
|
|
- let flag = this.setNewWallPoint('end', {
|
|
|
+ let flag = addWall.setNewWallPoint('end', {
|
|
|
x: this.startX,
|
|
|
y: this.startY,
|
|
|
})
|
|
@@ -100,12 +99,19 @@ export default class Layer {
|
|
|
} else {
|
|
|
return
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else if (eventName == LayerEvents.AddRectangle) {
|
|
|
+ addRectangle.execute({
|
|
|
+ x: this.startX,
|
|
|
+ y: this.startY,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
const selectItem = stateService.getSelectItem()
|
|
|
if (eventName == null && selectItem) {
|
|
|
stateService.setDraggingItem(selectItem)
|
|
|
//stateService.setFocusItem(selectItem)
|
|
|
- this.uiControl.showAttributes()
|
|
|
+ //this.uiControl.showAttributes()
|
|
|
this.uiControl.currentUI = selectItem.type
|
|
|
} else if (eventName == null) {
|
|
|
this.uiControl.currentUI = null
|
|
@@ -257,6 +263,43 @@ export default class Layer {
|
|
|
}
|
|
|
needAutoRedraw = true
|
|
|
break
|
|
|
+ case LayerEvents.AddRectangle:
|
|
|
+ stateService.clearDraggingItem()
|
|
|
+ stateService.clearFocusItem()
|
|
|
+ needAutoRedraw = true
|
|
|
+ elementService.setStartAddWall(position)
|
|
|
+ elementService.showStartAddWall()
|
|
|
+ break
|
|
|
+ case LayerEvents.AddingRectangle:
|
|
|
+ stateService.clearDraggingItem()
|
|
|
+ stateService.clearFocusItem()
|
|
|
+ needAutoRedraw = true
|
|
|
+ elementService.setStartAddWall(position)
|
|
|
+ elementService.showStartAddWall()
|
|
|
+ addRectangle.execute(position)
|
|
|
+ break
|
|
|
+ case LayerEvents.MoveRectangle:
|
|
|
+ needAutoRedraw = true
|
|
|
+ if (draggingItem != null) {
|
|
|
+ moveRectangle.moveFullRectangle(dx,dy, draggingItem.vectorId)
|
|
|
+ }
|
|
|
+ this.lastX = X
|
|
|
+ this.lastY = Y
|
|
|
+ break
|
|
|
+ case LayerEvents.MoveRectangleVertex:
|
|
|
+ needAutoRedraw = true
|
|
|
+ // if (draggingItem != null) {
|
|
|
+ // moveTag.moveFullTag(position, draggingItem.vectorId)
|
|
|
+ // }
|
|
|
+ this.lastX = X
|
|
|
+ this.lastY = Y
|
|
|
+ break
|
|
|
+ case LayerEvents.MoveRectangleSide:
|
|
|
+ needAutoRedraw = true
|
|
|
+ if (draggingItem != null) {
|
|
|
+ moveRectangle.moveRectangleSide(position,draggingItem.vectorId,parseInt(draggingItem.selectIndex.substring(5)))
|
|
|
+ }
|
|
|
+ break
|
|
|
case LayerEvents.AddTag:
|
|
|
needAutoRedraw = true
|
|
|
if (draggingItem == null) {
|
|
@@ -385,6 +428,43 @@ export default class Layer {
|
|
|
this.history.save()
|
|
|
}
|
|
|
break
|
|
|
+ case LayerEvents.AddingRectangle:
|
|
|
+ const rectangle = floorplanService.getRectangle(addRectangle.currentVectorId)
|
|
|
+ if(mathUtil.getDistance(addRectangle.start,addRectangle.end)<Constant.minAdsorb){
|
|
|
+ floorplanService.deleteRectangle(addRectangle.currentVectorId)
|
|
|
+ }
|
|
|
+ stateService.clearEventName()
|
|
|
+ elementService.hideAll()
|
|
|
+ addRectangle.clear();
|
|
|
+ //this.history.save()
|
|
|
+ break
|
|
|
+ case LayerEvents.MoveRectangle:
|
|
|
+ needAutoRedraw = true
|
|
|
+ // if (focusItem != null && focusItem.type == VectorType.Tag) {
|
|
|
+ // this.uiControl.currentUI = focusItem.type
|
|
|
+ // this.history.save()
|
|
|
+ // } else {
|
|
|
+ // this.history.save()
|
|
|
+ // }
|
|
|
+ break
|
|
|
+ case LayerEvents.MoveRectangleVertex:
|
|
|
+ needAutoRedraw = true
|
|
|
+ // if (focusItem != null && focusItem.type == VectorType.Tag) {
|
|
|
+ // this.uiControl.currentUI = focusItem.type
|
|
|
+ // this.history.save()
|
|
|
+ // } else {
|
|
|
+ // this.history.save()
|
|
|
+ // }
|
|
|
+ break
|
|
|
+ case LayerEvents.MoveRectangleSide:
|
|
|
+ needAutoRedraw = true
|
|
|
+ // if (focusItem != null && focusItem.type == VectorType.Tag) {
|
|
|
+ // this.uiControl.currentUI = focusItem.type
|
|
|
+ // this.history.save()
|
|
|
+ // } else {
|
|
|
+ // this.history.save()
|
|
|
+ // }
|
|
|
+ break
|
|
|
case LayerEvents.MoveTag:
|
|
|
needAutoRedraw = true
|
|
|
if (focusItem != null && focusItem.type == VectorType.Tag) {
|
|
@@ -495,16 +575,49 @@ export default class Layer {
|
|
|
stateService.setEventName(LayerEvents.MoveTag)
|
|
|
} else if (signService.isSign(selectItem.type)) {
|
|
|
stateService.setEventName(LayerEvents.MoveSign)
|
|
|
+ } else if (selectItem.type == VectorType.Rectangle) {
|
|
|
+ if(selectItem.selectIndex == SelectState.All){
|
|
|
+ stateService.setEventName(LayerEvents.MoveRectangle)
|
|
|
+ }
|
|
|
+ else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
|
|
|
+ stateService.setEventName(LayerEvents.MoveRectangleVertex)
|
|
|
+ }
|
|
|
+ else if(selectItem.selectIndex.indexOf(SelectState.Side)>-1){
|
|
|
+ stateService.setEventName(LayerEvents.MoveRectangleSide)
|
|
|
+ }
|
|
|
}
|
|
|
- } else if (eventName == LayerEvents.AddWall) {
|
|
|
+ }
|
|
|
+ else if (eventName == LayerEvents.AddWall) {
|
|
|
stateService.setEventName(LayerEvents.AddingWall)
|
|
|
}
|
|
|
+ // else if (eventName == LayerEvents.AddRectangle) {
|
|
|
+ // stateService.setEventName(LayerEvents.AddingRectangle)
|
|
|
+ // }
|
|
|
+ else if (eventName == LayerEvents.AddCircle) {
|
|
|
+ stateService.setEventName(LayerEvents.AddingCircle)
|
|
|
+ }
|
|
|
+ else if (eventName == LayerEvents.AddArrow) {
|
|
|
+ stateService.setEventName(LayerEvents.AddingArrow)
|
|
|
+ }
|
|
|
+ else if (eventName == LayerEvents.AddIcon) {
|
|
|
+ stateService.setEventName(LayerEvents.AddingIcon)
|
|
|
+ }
|
|
|
} else if (eventType == 'mouseUp') {
|
|
|
- if (eventName == LayerEvents.AddTag) {
|
|
|
+ if (eventName == LayerEvents.AddTag)
|
|
|
+ {
|
|
|
//可连续添加
|
|
|
- } else if (eventName != LayerEvents.AddWall && eventName != LayerEvents.AddingWall) {
|
|
|
+ }
|
|
|
+ else if (eventName == LayerEvents.AddRectangle)
|
|
|
+ {
|
|
|
+ stateService.setEventName(LayerEvents.AddingRectangle)
|
|
|
+ }
|
|
|
+ // else if (eventName == LayerEvents.AddingRectangle)
|
|
|
+ // {
|
|
|
+ // stateService.clearEventName()
|
|
|
+ // }
|
|
|
+ else if (eventName != LayerEvents.AddWall && eventName != LayerEvents.AddingWall ) { //&& eventName != LayerEvents.AddRectangle && eventName != LayerEvents.AddingRectangle && eventName != LayerEvents.AddCircle && eventName != LayerEvents.AddingCircle && eventName != LayerEvents.AddArrow && eventName != LayerEvents.AddingArrow && eventName != LayerEvents.AddIcon && eventName != LayerEvents.AddingIcon
|
|
|
stateService.clearEventName()
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -537,25 +650,6 @@ export default class Layer {
|
|
|
elementService.hideAll()
|
|
|
}
|
|
|
|
|
|
- setNewWallPoint(dir, position) {
|
|
|
- if (dir == 'start') {
|
|
|
- if (listenLayer.modifyPoint) {
|
|
|
- addWall.setPointInfo(dir, listenLayer.modifyPoint)
|
|
|
- } else {
|
|
|
- addWall.setPointInfo(dir, coordinate.getXYFromScreen(position))
|
|
|
- }
|
|
|
- return true
|
|
|
- } else if (dir == 'end') {
|
|
|
- if (listenLayer.modifyPoint) {
|
|
|
- addWall.setPointInfo(dir, listenLayer.modifyPoint)
|
|
|
- } else {
|
|
|
- addWall.setPointInfo(dir, coordinate.getXYFromScreen(position))
|
|
|
- }
|
|
|
- return true
|
|
|
- }
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
deleteItem() {
|
|
|
let item = stateService.getFocusItem()
|
|
|
if (item) {
|