2019-07-15 10:06:07 +08:00
|
|
|
/*
|
|
|
|
* 信号机
|
|
|
|
*/
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
import ESigPost from './element/ESigPost';
|
|
|
|
import ESigLmap from './element/ESigLmap';
|
|
|
|
import ESigButton from './element/ESigButton';
|
|
|
|
import Group from 'zrender/src/container/Group';
|
2019-07-15 10:06:07 +08:00
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
class Signal extends Group {
|
|
|
|
constructor({ _code, _type, zlevel, model, state }, style) {
|
2019-07-16 12:01:43 +08:00
|
|
|
super();
|
2019-07-16 16:29:31 +08:00
|
|
|
this._code = _code;
|
|
|
|
this._type = _type;
|
|
|
|
this.zlevel = zlevel;
|
2019-07-15 10:06:07 +08:00
|
|
|
this.model = model;
|
2019-07-16 16:29:31 +08:00
|
|
|
this.state = state;
|
|
|
|
this.style = style;
|
|
|
|
this.count = parseInt(model.lampPositionType);
|
|
|
|
this.lamps = new Array(this.count);
|
|
|
|
this.create();
|
|
|
|
this.setState(state);
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
create() {
|
|
|
|
const drict = this.model.directionType == '01' ? -1 : 1; // 朝向 左:右
|
|
|
|
const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下
|
2019-07-15 10:06:07 +08:00
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
// 信号机高柱矮柱
|
|
|
|
this.siglpost = new ESigPost({
|
2019-07-15 10:06:07 +08:00
|
|
|
zlevel: this.zlevel,
|
2019-07-16 16:29:31 +08:00
|
|
|
z: 1,
|
|
|
|
style: this.style,
|
|
|
|
drict: drict,
|
|
|
|
type: this.model.lampPostType,
|
|
|
|
position: {
|
|
|
|
x: this.model.position.x,
|
|
|
|
y: this.model.position.y + posit * (this.style.Signal.signalDistance + this.style.Section.sectionWidth)
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
// 信号灯
|
|
|
|
const nextPosition = this.siglpost.getLampPosition(this.model.highType);
|
|
|
|
this.lamps = [];
|
|
|
|
for (let i = 0; i < this.count; i++) {
|
|
|
|
const lamp = new ESigLmap({
|
2019-07-15 10:06:07 +08:00
|
|
|
zlevel: this.zlevel,
|
2019-07-16 16:29:31 +08:00
|
|
|
z: 1,
|
|
|
|
style: this.style,
|
|
|
|
index: i + 1,
|
|
|
|
drict: drict,
|
2019-07-15 10:06:07 +08:00
|
|
|
position: {
|
2019-07-16 16:29:31 +08:00
|
|
|
x: nextPosition.x + i * drict * this.style.Signal.signalR * 2,
|
|
|
|
y: nextPosition.y
|
2019-07-15 10:06:07 +08:00
|
|
|
},
|
|
|
|
origin: {
|
2019-07-16 16:29:31 +08:00
|
|
|
x: this.model.position.x,
|
|
|
|
y: this.model.position.y
|
|
|
|
}
|
2019-07-15 10:06:07 +08:00
|
|
|
});
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
this.lamps.push(lamp);
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 信号灯按钮
|
2019-07-16 16:29:31 +08:00
|
|
|
this.sigButton = new ESigButton({
|
2019-07-15 10:06:07 +08:00
|
|
|
zlevel: this.zlevel,
|
2019-07-16 16:29:31 +08:00
|
|
|
z: 1,
|
|
|
|
style: this.style,
|
|
|
|
posit: posit,
|
|
|
|
show: this.model.buttonShow,
|
2019-07-15 10:06:07 +08:00
|
|
|
position: {
|
2019-07-16 16:29:31 +08:00
|
|
|
x: this.model.buttonPosition.x,
|
|
|
|
y: this.model.buttonPosition.y
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
2019-07-16 16:29:31 +08:00
|
|
|
});
|
2019-07-15 10:06:07 +08:00
|
|
|
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
this.add(this.siglpost);
|
|
|
|
this.lamps.forEach(lamp => { this.add(lamp); });
|
|
|
|
// this.add(this.sigButton);
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
|
2019-07-15 15:25:49 +08:00
|
|
|
setState(state) {
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
export default Signal;
|