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

73 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-03-05 15:48:51 +08:00
import Group from 'zrender/src/container/Group';
import Rect from 'zrender/src/graphic/shape/Rect';
export default class OutFrame extends Group {
constructor(model, style) {
super();
this.model = model;
this._type = model._type;
this._code = model.code;
this.style = style;
this.zlevel = model.zlevel;
2020-03-13 13:01:58 +08:00
this.isShowShape = true;
2020-03-05 15:48:51 +08:00
this.z = 0;
2021-01-20 16:07:10 +08:00
this.create();
this.setState(model);
2021-01-20 15:53:13 +08:00
this.setShowMode();
2020-03-05 15:48:51 +08:00
}
create() {
const model = this.model;
this.box = new Rect({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x - model.width / 2,
y: model.position.y - model.height / 2,
width: model.width,
height: model.height
},
style: {
lineDash: null,
stroke: '#fff',
lineWidth: 1,
fill: 'rgb(135,206,250,0)'
}
});
this.add(this.box);
}
// 设置状态
setState(model) {
2020-03-13 13:01:58 +08:00
if (!this.isShowShape) return;
2020-03-05 15:48:51 +08:00
}
2020-03-11 15:10:08 +08:00
// 设置显示模式
setShowMode() {
const showMode = this.model.showMode;
const showConditions = this.model.showConditions;
2020-05-12 16:45:45 +08:00
if (showMode == '04') {
this.box && this.box.hide();
return;
}
2020-03-11 15:10:08 +08:00
if (!showConditions || showConditions === '01' || showMode === showConditions) {
this.box && this.box.show();
2020-03-13 13:01:58 +08:00
this.setState(this.model);
2020-03-11 15:10:08 +08:00
} else {
this.box && this.box.hide();
}
}
2020-03-13 13:01:58 +08:00
setShowStation(stationCode) {
if (!stationCode || this.model.stationCode === stationCode) {
this.box && this.box.show();
this.isShowShape = true;
this.setState(this.model);
} else {
this.box && this.box.hide();
this.isShowShape = false;
}
}
screenShow() {
this.box && this.box.hide();
}
2020-03-05 15:48:51 +08:00
}