2019-11-29 12:51:58 +08:00
|
|
|
import Polyline from 'zrender/src/graphic/shape/Polyline';
|
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
|
|
|
|
class ESigPost extends Group {
|
2019-12-03 13:36:02 +08:00
|
|
|
constructor(model) {
|
|
|
|
super();
|
|
|
|
this.model = model;
|
|
|
|
this.create();
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-03 13:36:02 +08:00
|
|
|
create() {
|
|
|
|
const model = this.model;
|
|
|
|
const style = this.model.style;
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-03 13:36:02 +08:00
|
|
|
this.ver = new Polyline({
|
|
|
|
_subType: 'SignalLamp',
|
|
|
|
_val: '3',
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
shape: {
|
|
|
|
points: [
|
2020-02-03 17:17:56 +08:00
|
|
|
[model.x, model.y + style.Signal.post.standardHeight * 1.2],
|
|
|
|
[model.x, model.y - style.Signal.post.standardHeight * 1.2]
|
2019-12-03 13:36:02 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
lineWidth: style.Signal.post.standardWidth,
|
|
|
|
stroke: style.Signal.post.standardColor
|
|
|
|
}
|
|
|
|
});
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-03 13:36:02 +08:00
|
|
|
this.hor = new Polyline({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
shape: {
|
|
|
|
points: [
|
|
|
|
[model.x, model.y],
|
2020-02-03 17:17:56 +08:00
|
|
|
[model.x + model.drict * style.Signal.post.standardLength * 1.2, model.y]
|
2019-12-03 13:36:02 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
lineWidth: style.Signal.post.standardWidth,
|
|
|
|
stroke: style.Signal.post.standardColor
|
|
|
|
}
|
|
|
|
});
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-03 13:36:02 +08:00
|
|
|
this.add(this.ver);
|
|
|
|
this.add(this.hor);
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-03 13:36:02 +08:00
|
|
|
model.type === '01' ? this.hor.hide() : this.hor.show();
|
2020-02-03 17:17:56 +08:00
|
|
|
if (style.Signal.post.standardShow) {
|
|
|
|
this.hor.show();
|
|
|
|
}
|
2019-12-03 13:36:02 +08:00
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-03 13:36:02 +08:00
|
|
|
getLampPosition(type) {
|
|
|
|
const model = this.model;
|
|
|
|
const style = this.model.style;
|
2020-02-03 17:17:56 +08:00
|
|
|
if (style.Signal.post.standardShow) {
|
2020-03-02 16:16:17 +08:00
|
|
|
type = '01';
|
2020-02-03 17:17:56 +08:00
|
|
|
}
|
|
|
|
const length = style.Signal.post.standardShow ? 4 : 0;
|
2019-12-03 13:36:02 +08:00
|
|
|
if (type === '01') {
|
|
|
|
return {
|
2020-02-03 17:17:56 +08:00
|
|
|
x: model.x + model.drict * style.Signal.lamp.radiusR * 3 / 2 + model.drict * length,
|
2019-12-03 13:36:02 +08:00
|
|
|
y: model.y
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return {
|
2020-02-03 17:17:56 +08:00
|
|
|
x: this.hor.shape.points[1][0] + model.drict * style.Signal.lamp.radiusR + model.drict * length,
|
2019-12-03 13:36:02 +08:00
|
|
|
y: this.hor.shape.points[1][1]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ESigPost;
|