rt-sim-training-client/src/jmapNew/shape/Psd/index.js
2020-02-17 17:50:15 +08:00

97 lines
2.8 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.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,
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) {
/** 设置屏蔽门开关*/
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(); });
}
}
}