rt-sim-training-client/src/jmap/shape/Signal/ESigPost.js

71 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-07-16 16:29:31 +08:00
import Polyline from 'zrender/src/graphic/shape/Polyline';
import Group from 'zrender/src/container/Group';
class ESigPost extends Group {
2019-07-16 18:37:49 +08:00
constructor(model) {
2019-07-16 16:29:31 +08:00
super();
2019-07-16 18:37:49 +08:00
this.model = model;
2019-07-31 14:59:38 +08:00
this.create();
2019-07-16 18:37:49 +08:00
}
2019-07-16 16:29:31 +08:00
2019-07-31 14:59:38 +08:00
create() {
2019-07-16 18:37:49 +08:00
const model = this.model;
const style = this.model.style;
2019-07-16 16:29:31 +08:00
this.ver = new Polyline({
2019-07-30 09:35:00 +08:00
_subType: 'SignalLamp',
_val: '3',
2019-07-16 18:37:49 +08:00
zlevel: model.zlevel,
z: model.z,
2019-07-16 16:29:31 +08:00
shape: {
points: [
2019-07-23 18:21:49 +08:00
[model.x, model.y + style.Signal.lamp.signalR * 1.2],
[model.x, model.y - style.Signal.lamp.signalR * 1.2]
2019-07-16 16:29:31 +08:00
]
},
style: {
2019-07-23 18:21:49 +08:00
lineWidth: style.Signal.post.signalLampStandardWidth,
stroke: style.Signal.post.signalLampStandardColor
2019-07-16 16:29:31 +08:00
}
});
this.hor = new Polyline({
2019-07-16 18:37:49 +08:00
zlevel: model.zlevel,
z: model.z,
2019-07-16 16:29:31 +08:00
shape: {
points: [
2019-07-16 18:37:49 +08:00
[model.x, model.y],
2019-07-23 18:21:49 +08:00
[model.x + model.drict * style.Signal.lamp.signalR * 1.2, model.y]
2019-07-16 16:29:31 +08:00
]
},
style: {
2019-07-23 18:21:49 +08:00
lineWidth: style.Signal.post.signalLampStandardWidth,
stroke: style.Signal.post.signalLampStandardColor
2019-07-16 16:29:31 +08:00
}
});
this.add(this.ver);
this.add(this.hor);
2019-07-16 18:37:49 +08:00
model.type === '01' ? this.hor.hide() : this.hor.show();
2019-07-16 16:29:31 +08:00
}
getLampPosition(type) {
2019-07-16 18:37:49 +08:00
const model = this.model;
const style = this.model.style;
2019-07-16 16:29:31 +08:00
if (type === '01') {
return {
2019-07-23 18:21:49 +08:00
x: model.x + model.drict * style.Signal.lamp.signalR * 3 / 2,
2019-07-16 18:37:49 +08:00
y: model.y
2019-07-16 16:29:31 +08:00
};
} else {
return {
2019-07-23 18:21:49 +08:00
x: this.hor.shape.points[1][0] + model.drict * style.Signal.lamp.signalR,
2019-07-16 16:29:31 +08:00
y: this.hor.shape.points[1][1]
};
}
}
}
export default ESigPost;