信号机故障 绘图代码调整

This commit is contained in:
joylink_cuiweidong 2020-07-03 11:27:01 +08:00
parent 92c10db690
commit ec1c5a9bbb
4 changed files with 61 additions and 4 deletions

View File

@ -160,7 +160,8 @@ class SkinCode extends defaultStyle {
greenColor: '#00FF00', // 信号灯绿色
yellowColor: '#FFFF00', // 信号灯黄色
whiteColor: '#FFFFFF', // 信号灯白色
blueColor: '#0070C0' // 信号灯蓝色
blueColor: '#0070C0', // 信号灯蓝色
faultType: 'flash' // 信号机故障类型 flash为西安三号线特殊类型
},
route: {
direction: false, // 自动进路方向

View File

@ -0,0 +1,17 @@
import Path from 'zrender/src/graphic/Path';
// 信号机故障 (主灯丝断裂)
export const ESigFault = Path.extend({
type: 'ESigFault',
shape: {
points: null
},
buildPath: function (ctx, shape) {
const points = shape.points;
const oldradius = shape.radius + 1;
const newradius = shape.radius + 5;
for (let i = 0; i < 8; i++) {
ctx.moveTo(points.x + oldradius * Math.sin(Math.PI / 4 * i), points.y - oldradius * Math.cos(Math.PI / 4 * i));
ctx.lineTo(points.x + newradius * Math.sin(Math.PI / 4 * i), points.y - newradius * Math.cos(Math.PI / 4 * i));
}
}
});

View File

@ -1,6 +1,8 @@
import Line from 'zrender/src/graphic/shape/Line';
import Arc from 'zrender/src/graphic/shape/Arc';
import Group from 'zrender/src/container/Group';
import Path from 'zrender/src/graphic/Path';
import {ESigFault} from './ESigFault';
class ESigLamp extends Group {
constructor(model) {
@ -30,6 +32,27 @@ class ESigLamp extends Group {
stroke: style.Signal.lamp.borderColor
}
});
if (style.Signal.lamp.faultType && style.Signal.lamp.faultType == 'flash') {
this.lampFault = new ESigFault({
zlevel: model.zlevel,
z: model.z + 1,
style:{
lineWidth: 1,
stroke: '#F00'
},
shape: {
points: {
x: model.x,
y: model.y
},
radius:style.Signal.lamp.radiusR
}
});
this.add(this.lampFault);
this.lampFault.hide();
}
if ( !style.Signal.lamp.logicDisplayNone ) {
this.lstop = new Line({
_subType: 'SignalLamp',
@ -79,6 +102,14 @@ class ESigLamp extends Group {
}
}
faultShow() {
this.lampFault.show();
}
faultHide() {
this.lampFault.hide();
}
setColor(color) {
if (this.model.style.Signal.lamp.borderVariable) {
this.lamp.setStyle({ fill: color, stroke: color });

View File

@ -456,10 +456,16 @@ class Signal extends Group {
this.sigName.setColor(this.style.Signal.text.checkColor);
}
// 故障
// // 故障
// fault() {
// this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.blueColor);
// this.lamps[1] && this.lamps[1].setColor(this.style.Signal.lamp.blueColor);
// }
fault() {
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.blueColor);
this.lamps[1] && this.lamps[1].setColor(this.style.Signal.lamp.blueColor);
if (this.style.Signal.lamp.faultType && this.style.Signal.lamp.faultType == 'flash') {
this.lamps[0].faultShow();
}
}
// 逻辑点灯
@ -542,6 +548,7 @@ class Signal extends Group {
// 恢复状态
recover() {
this.lamps.forEach(item=> { item.show(); });
this.lamps[0].faultHide();
this.sigName.setStyle({ textBorderWidth: 0 });
this.sigName.setColor(this.style.Signal.text.defaultColor);
this.setAutoClose();
@ -588,6 +595,7 @@ class Signal extends Group {
model.redOpen && !model.yellowOpen && !model.greenOpen && this.close(model.logicLight); // 信号关闭
model.greenOpen && !model.redOpen && !model.yellowOpen && this.openPositive(model.logicLight); // 信号正向开放
model.yellowOpen && !model.redOpen && !model.greenOpen && this.openLateral(model.logicLight); // 信号侧向开放
model.fault && this.fault();// 信号机故障
// 联锁自动进路通过
model.fleetMode && this.setAutoRouteOpen();