120 lines
4.4 KiB
JavaScript
120 lines
4.4 KiB
JavaScript
import Group from 'zrender/src/container/Group';
|
|
import Isogon from 'zrender/src/graphic/shape/Isogon';
|
|
import Polygon from 'zrender/src/graphic/shape/Polygon';
|
|
import Line from 'zrender/src/graphic/shape/Line';
|
|
import {arrow} from '../utils/ShapePoints';
|
|
|
|
class ESafeEmergent extends Group {
|
|
constructor(model) {
|
|
super();
|
|
this.model = model;
|
|
this.isNew = false;
|
|
if (this.model.style.StationStand.standEmergent.special) {
|
|
this.create();
|
|
}
|
|
}
|
|
|
|
create() {
|
|
if (!this.isNew) {
|
|
const model = this.model;
|
|
const style = this.model.style;
|
|
|
|
this.isNew = true;
|
|
if (style.StationStand.standEmergent.radiusR) {
|
|
const rotation = model.right == 1 ? Math.PI / 2 : Math.PI * 3 / 2;
|
|
this.emergent = new Polygon({
|
|
zlevel: model.zlevel,
|
|
z: model.z,
|
|
origin: [model.x, model.y],
|
|
rotation: rotation,
|
|
shape: {
|
|
points: arrow(model.x, model.y, style.StationStand.standEmergent.width, style.StationStand.standEmergent.radiusR * 0.8)
|
|
},
|
|
style: {
|
|
stroke: style.StationStand.standEmergent.closeColor,
|
|
fill: style.StationStand.standEmergent.closeColor
|
|
}
|
|
});
|
|
this.add(this.emergent);
|
|
} else {
|
|
this.emergent = new Isogon({
|
|
zlevel: model.zlevel,
|
|
z: model.z,
|
|
shape: {
|
|
x: model.x,
|
|
y: model.y,
|
|
r: model.r,
|
|
n: model.n
|
|
},
|
|
style: {
|
|
lineWidth: 0
|
|
}
|
|
});
|
|
if (style.StationStand.standEmergent.special) {
|
|
this.emergent.setStyle('lineWidth', 2);
|
|
this.emergent.setStyle('stroke', style.StationStand.standEmergent.defaultColor);
|
|
} else {
|
|
this.emergent.setStyle('stroke', style.StationStand.standEmergent.closeColor);
|
|
this.emergent.setStyle('fill', style.StationStand.standEmergent.closeColor);
|
|
}
|
|
this.add(this.emergent);
|
|
if (style.StationStand.standEmergent.special) {
|
|
// r*Math.r*cos(Math.PI/180*22.5)
|
|
// Math.sin(Math.PI/180*50)
|
|
// Math.cos(Math.PI/180*50)
|
|
this.emergent.rotation = Math.PI / 8;
|
|
this.emergent.origin = [model.x, model.y];
|
|
this.emergent.dirty();
|
|
this.emergentLine1 = new Line({
|
|
zlevel: model.zlevel,
|
|
z: model.z,
|
|
shape:{
|
|
x1:model.x - model.r * 0.5939,
|
|
y1:model.y - model.r * 0.7077,
|
|
x2:model.x + model.r * 0.5939,
|
|
y2:model.y + model.r * 0.7077
|
|
},
|
|
style:{
|
|
lineWidth:2,
|
|
stroke:style.StationStand.standEmergent.defaultColor
|
|
}
|
|
});
|
|
this.emergentLine2 = new Line({
|
|
zlevel: model.zlevel,
|
|
z: model.z,
|
|
shape:{
|
|
x1:model.x + model.r * 0.5939,
|
|
y1:model.y - model.r * 0.7077,
|
|
x2:model.x - model.r * 0.5939,
|
|
y2:model.y + model.r * 0.7077
|
|
},
|
|
style:{
|
|
lineWidth:2,
|
|
stroke:style.StationStand.standEmergent.defaultColor
|
|
}
|
|
});
|
|
this.add(this.emergentLine1);
|
|
this.add(this.emergentLine2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
hideMode() {
|
|
if (!this.model.style.StationStand.standEmergent.special) {
|
|
this.emergent && this.emergent.hide();
|
|
}
|
|
}
|
|
|
|
showMode() {
|
|
this.create();
|
|
this.emergent.show();
|
|
}
|
|
|
|
getElement() {
|
|
return this.emergent;
|
|
}
|
|
}
|
|
|
|
export default ESafeEmergent;
|