71 lines
1.4 KiB
JavaScript
71 lines
1.4 KiB
JavaScript
import Polyline from 'zrender/src/graphic/shape/Polyline';
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
class ESigPost extends Group {
|
|
constructor(model) {
|
|
super();
|
|
this.model = model;
|
|
this.create();
|
|
}
|
|
|
|
create() {
|
|
const model = this.model;
|
|
const style = this.model.style;
|
|
|
|
this.ver = new Polyline({
|
|
_subType: 'SignalLamp',
|
|
_val: '3',
|
|
zlevel: model.zlevel,
|
|
z: model.z,
|
|
shape: {
|
|
points: [
|
|
[model.x, model.y + style.Signal.lamp.radiusR * 1.2],
|
|
[model.x, model.y - style.Signal.lamp.radiusR * 1.2]
|
|
]
|
|
},
|
|
style: {
|
|
lineWidth: style.Signal.post.standardWidth,
|
|
stroke: style.Signal.post.standardColor
|
|
}
|
|
});
|
|
|
|
this.hor = new Polyline({
|
|
zlevel: model.zlevel,
|
|
z: model.z,
|
|
shape: {
|
|
points: [
|
|
[model.x, model.y],
|
|
[model.x + model.drict * style.Signal.lamp.radiusR * 1.2, model.y]
|
|
]
|
|
},
|
|
style: {
|
|
lineWidth: style.Signal.post.standardWidth,
|
|
stroke: style.Signal.post.standardColor
|
|
}
|
|
});
|
|
|
|
this.add(this.ver);
|
|
this.add(this.hor);
|
|
|
|
model.type === '01' ? this.hor.hide() : this.hor.show();
|
|
}
|
|
|
|
getLampPosition(type) {
|
|
const model = this.model;
|
|
const style = this.model.style;
|
|
if (type === '01') {
|
|
return {
|
|
x: model.x + model.drict * style.Signal.lamp.radiusR * 3 / 2,
|
|
y: model.y
|
|
};
|
|
} else {
|
|
return {
|
|
x: this.hor.shape.points[1][0] + model.drict * style.Signal.lamp.radiusR,
|
|
y: this.hor.shape.points[1][1]
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
export default ESigPost;
|