rt-sim-training-client/src/jmapNew/shape/Psd/index.js

113 lines
3.3 KiB
JavaScript
Raw Normal View History

import Group from 'zrender/src/container/Group';
import ESafeDoor from './ESafeDoor';
2019-12-13 14:19:38 +08:00
import EHighlight from '../element/EHighlight';
export default class Line2 extends Group {
constructor(model, style) {
super();
this._code = model.code;
this._type = model._type;
this.zlevel = model.zlevel;
this.z = 1;
this.model = model;
this.style = style;
2020-03-13 13:01:58 +08:00
this.isShowShape = true;
this.create();
this.setState(model);
2019-12-13 14:19:38 +08:00
this.checkIsDrawMap();
}
create() {
/** 屏蔽门*/
const model = this.model;
const style = this.style;
this.safeDoor = new ESafeDoor({
zlevel: this.zlevel,
z: this.z + 1,
style: style,
x: model.position.x,
2019-12-12 10:05:28 +08:00
y: model.position.y - (model.height / 2),
width: model.width || style.StationStand.safetyDoor.width,
2020-02-19 16:19:37 +08:00
height: model.height || style.StationStand.safetyDoor.height
// show: model.hasDoor
});
this.add(this.safeDoor);
}
/** 恢复初始状态*/
recover() {
this.safeDoor && this.safeDoor.setColor(this.style.StationStand.safetyDoor.defaultColor);
}
/** 开门*/
openDoor() {
this.safeDoor && this.safeDoor.hasDoor(true);
}
/** 关门*/
closeDoor() {
this.safeDoor && this.safeDoor.hasDoor(false);
}
/** 屏蔽门正常*/
doorNormal() {
this.safeDoor && this.safeDoor.setColor(this.style.StationStand.safetyDoor.defaultColor);
}
/** 屏蔽门故障*/
doorFault() {
this.safeDoor && this.safeDoor.setColor(this.style.StationStand.safetyDoor.splitDoorColor);
}
/** 屏蔽门切除*/
doorSplit() {
this.safeDoor && this.safeDoor.setColor(this.style.StationStand.safetyDoor.splitDoorColor);
}
setState(model) {
2020-03-13 13:01:58 +08:00
if (!this.isShowShape) return;
/** 设置屏蔽门开关*/
// if (model.name == 'Psd44') {
// console.log(model, model.screenDoorOpenStatus, '1 为关门 0 为开门');
// }
2020-02-19 16:46:34 +08:00
model.screenDoorOpenStatus == 0 && this.openDoor(); /** 开门*/
model.screenDoorOpenStatus != 0 && this.closeDoor(); /** 关门*/
// /** 设置屏蔽门状态*/
// switch (model.screenDoorStatus) {
// case '01':
// this.doorNormal(); /** 正常*/
// break;
// case '02':
// this.doorFault(); /** 故障*/
// break;
// case '03':
// this.doorSplit(); /** 切除*/
// }
}
2019-12-13 14:19:38 +08:00
drawSelected(selected) {
this.highlight && this.highlight.drawSelected(selected);
}
checkIsDrawMap() {
const path = window.location.href;
if (path.includes('/map/draw')) {
this.highlight = new EHighlight(this);
this.add(this.highlight);
this.on('mouseout', () => { this.highlight.mouseout(); });
this.on('mouseover', () => { this.highlight.mouseover(); });
}
}
2020-03-11 15:10:08 +08:00
setShowMode() {}
2020-03-13 13:01:58 +08:00
setShowStation(flag) {
if (flag) {
this.safeDoor && this.safeDoor.show();
this.isShowShape = true;
this.setState(this.model);
} else {
this.safeDoor && this.safeDoor.hide();
this.isShowShape = false;
}
}
}