rt-sim-training-client/src/jmapNew/shape/Psd/index.js
2020-03-13 13:01:58 +08:00

113 lines
3.3 KiB
JavaScript

import Group from 'zrender/src/container/Group';
import ESafeDoor from './ESafeDoor';
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;
this.isShowShape = true;
this.create();
this.setState(model);
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,
y: model.position.y - (model.height / 2),
width: model.width || style.StationStand.safetyDoor.width,
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) {
if (!this.isShowShape) return;
/** 设置屏蔽门开关*/
// if (model.name == 'Psd44') {
// console.log(model, model.screenDoorOpenStatus, '1 为关门 0 为开门');
// }
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(); /** 切除*/
// }
}
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(); });
}
}
setShowMode() {}
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;
}
}
}