修改代码

This commit is contained in:
ival 2019-07-23 18:21:49 +08:00
parent af6e9fe3c9
commit 1bab212c05
8 changed files with 150 additions and 192 deletions

View File

@ -15,7 +15,7 @@ class ESigButton extends Group {
const model = this.model;
const style = this.model.style;
const padding = 1;
const r = style.Signal.signalR * 0.8;
const r = style.Signal.lamp.signalR * 0.8;
this.style = style;
this._subType = 'SignalButton';
@ -26,15 +26,15 @@ class ESigButton extends Group {
_subType: this._subType,
_val: '1',
shape: {
x: model.x - style.Signal.signalR,
x: model.x - style.Signal.lamp.signalR,
y: model.y - r + r * model.posit,
width: style.Signal.signalR * 2,
height: style.Signal.signalR * 2
width: style.Signal.lamp.signalR * 2,
height: style.Signal.lamp.signalR * 2
},
style: {
lineWidth: 0.2,
stroke: style.Signal.signalButtonDashColor,
fill: style.Signal.signalButtonColor
stroke: style.Signal.button.signalButtonDashColor,
fill: style.Signal.button.signalButtonColor
}
});
@ -46,12 +46,12 @@ class ESigButton extends Group {
shape: {
cx: model.x,
cy: model.y - 5 / 2 * r * model.posit,
r: style.Signal.signalR
r: style.Signal.lamp.signalR
},
style: {
lineWidth: 0.2,
stroke: style.Signal.signalButtonDashColor,
fill: style.Signal.signalButtonColor
stroke: style.Signal.button.signalButtonDashColor,
fill: style.Signal.button.signalButtonColor
}
});

View File

@ -20,12 +20,12 @@ class ESigLmap extends Group {
shape: {
cx: model.x,
cy: model.y,
r: style.Signal.signalR
r: style.Signal.lamp.signalR
},
style: {
lineWidth: 0.4,
lineWidth: style.Signal.lamp.signalBorderWidth,
fill: style.backgroundColor,
stroke: style.Signal.signalLampStandardColor
stroke: style.Signal.post.signalLampStandardColor
}
});
@ -37,13 +37,13 @@ class ESigLmap extends Group {
y: model.originY
},
shape: {
x1: model.x + (style.Signal.signalR + 1) * Math.cos(Math.PI / 4),
y1: model.y + (style.Signal.signalR + 1) * Math.sin(Math.PI / 4),
x2: model.x - (style.Signal.signalR + 1) * Math.cos(Math.PI / 4),
y2: model.y - (style.Signal.signalR + 1) * Math.sin(Math.PI / 4)
x1: model.x + (style.Signal.lamp.signalR + 1) * Math.cos(Math.PI / 4),
y1: model.y + (style.Signal.lamp.signalR + 1) * Math.sin(Math.PI / 4),
x2: model.x - (style.Signal.lamp.signalR + 1) * Math.cos(Math.PI / 4),
y2: model.y - (style.Signal.lamp.signalR + 1) * Math.sin(Math.PI / 4)
},
style: {
lineWidth: 1.5,
lineWidth: style.Signal.lamp.signalStopWidth,
stroke: style.backgroundColor
}
});
@ -56,13 +56,13 @@ class ESigLmap extends Group {
y: model.originY
},
shape: {
x1: model.x + (style.Signal.signalR + 1) * Math.cos(Math.PI / 4),
y1: model.y + (style.Signal.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2)),
x2: model.x - (style.Signal.signalR + 1) * Math.cos(Math.PI / 4),
y2: model.y - (style.Signal.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2))
x1: model.x + (style.Signal.lamp.signalR + 1) * Math.cos(Math.PI / 4),
y1: model.y + (style.Signal.lamp.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2)),
x2: model.x - (style.Signal.lamp.signalR + 1) * Math.cos(Math.PI / 4),
y2: model.y - (style.Signal.lamp.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2))
},
style: {
lineWidth: 1.5,
lineWidth: style.Signal.lamp.signalStopWidth,
stroke: style.backgroundColor
}
});

View File

@ -1,66 +0,0 @@
import Polygon from 'zrender/src/graphic/shape/Polygon';
import Group from 'zrender/src/container/Group';
import { arrows } from '../utils/ShapePoints';
class ESigPass extends Group {
constructor(model) {
super();
this.model = model;
this._create();
}
_create() {
const model = this.model;
const style = this.model.style;
const rotation = model.drict != 1? 0 : Math.PI;
const point = arrows(model.x, model.y, style.Signal.signalSigPassWidth, style.Signal.signalR * 0.8);
this.arrows = new Polygon({
zlevel: model.zlevel,
z: model.z,
rotation: rotation,
shape: {
points: point
},
style: {
stroke: model.stroke,
lineWidth: model.lineWidth,
fill: model.fill
}
});
this.add(this.arrows);
}
// 停止动画
animationRecover() {
this.arrows.stopAnimation(false);
}
// 箭头颜色
setColor(color) {
this.arrows.setStyle('fill', color);
}
// 箭头闪烁
arrowsAnimation() {
const style = this.model.style;
const fill = this.arrows.style.Signal.fill;
this.arrows.animate(true)
.when(1000, { fill: style.backgroundColor, stroke: style.style.backgroundColor })
.when(2000, { fill: fill, stroke: style.style.Signal.sidelineColor })
.when(3000, { fill: style.style.backgroundColor, stroke: style.style.backgroundColor })
.when(4000, { fill: fill, stroke: style.style.Signal.sidelineColor })
.start();
}
// 隐藏
hide() {
this.arrows.hide();
}
// 显示
show() {
this.arrows.show();
}
}
export default ESigPass;

View File

@ -17,13 +17,13 @@ class ESigPost extends Group {
z: model.z,
shape: {
points: [
[model.x, model.y + style.Signal.signalR * 1.2],
[model.x, model.y - style.Signal.signalR * 1.2]
[model.x, model.y + style.Signal.lamp.signalR * 1.2],
[model.x, model.y - style.Signal.lamp.signalR * 1.2]
]
},
style: {
lineWidth: style.Signal.signalLampStandardWidth,
stroke: style.Signal.signalLampStandardColor
lineWidth: style.Signal.post.signalLampStandardWidth,
stroke: style.Signal.post.signalLampStandardColor
}
});
@ -33,12 +33,12 @@ class ESigPost extends Group {
shape: {
points: [
[model.x, model.y],
[model.x + model.drict * style.Signal.signalR * 1.2, model.y]
[model.x + model.drict * style.Signal.lamp.signalR * 1.2, model.y]
]
},
style: {
lineWidth: style.Signal.signalLampStandardWidth,
stroke: style.Signal.signalLampStandardColor
lineWidth: style.Signal.post.signalLampStandardWidth,
stroke: style.Signal.post.signalLampStandardColor
}
});
@ -53,12 +53,12 @@ class ESigPost extends Group {
const style = this.model.style;
if (type === '01') {
return {
x: model.x + model.drict * style.Signal.signalR * 3 / 2,
x: model.x + model.drict * style.Signal.lamp.signalR * 3 / 2,
y: model.y
};
} else {
return {
x: this.hor.shape.points[1][0] + model.drict * style.Signal.signalR,
x: this.hor.shape.points[1][0] + model.drict * style.Signal.lamp.signalR,
y: this.hor.shape.points[1][1]
};
}

View File

@ -16,12 +16,12 @@ class ESigDrict extends Group {
zlevel: model.zlevel,
z: model.z,
shape: {
points: triangular(model.x, model.y, model.drict, style.Signal.signalR)
points: triangular(model.x, model.y, model.drict, style.Signal.lamp.signalR)
},
style: {
stroke: style.backgroundColor,
lineWidth: 0.5,
fill: style.Signal.signalLampYellowColor
fill: style.Signal.route.signalRouteColor
}
});
this.add(this.sigDrict);

View File

@ -4,7 +4,7 @@
import ESigPost from './ESigPost';
import ESigLmap from './ESigLmap';
import ESigPass from './ESigPass';
import ESigAuto from './ESigAuto';
import ESigRoute from './ESigRoute';
import ESigButton from './ESigButton';
import ESigDelay from './ESigDelay';
@ -42,7 +42,7 @@ class Signal extends Group {
drict: drict,
type: model.lampPostType,
x: model.position.x,
y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR)
y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.lamp.signalR)
});
// 信号灯
@ -55,7 +55,7 @@ class Signal extends Group {
style: style,
index: i + 1,
drict: drict,
x: endPoint.x + i * drict * style.Signal.signalR * 2,
x: endPoint.x + i * drict * style.Signal.lamp.signalR * 2,
y: endPoint.y,
originX: model.position.x,
originY: model.position.y
@ -66,7 +66,7 @@ class Signal extends Group {
// 信号机名称
const sigNameX = model.position.x + model.namePosition.x;
const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR * 2 + model.namePosition.y);
const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.lamp.signalR * 2 + model.namePosition.y);
this.sigName = new ESigName({
zlevel: this.zlevel,
z: this.z,
@ -75,16 +75,16 @@ class Signal extends Group {
x: sigNameX,
y: sigNameY,
text: model.name,
textFont: `bold ${style.Signal.signalTextFontSize} px ${style.textFontFormat}`,
textFill: style.Signal.signalTextGreen,
textFont: `bold ${style.Signal.text.signalTextFontSize} px ${style.textFontFormat}`,
textFill: style.Signal.text.signalTextGreen,
textAlign: 'middle',
textVerticalAlign: posit == 1 ? 'top' : 'bottom'
});
// 自动进路
const sigRouteH = style.Signal.signalSigRouteDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2;
const sigRouteX = endPoint.x + (style.Signal.signalSigRouteOffset.x + sigRouteH) * drict;
const sigRouteY = endPoint.y + (style.Signal.signalSigRouteOffset.y);
const sigRouteH = style.Signal.route.signalRouteDirection ? this.count * style.Signal.lamp.signalR * 2 : -style.Signal.lamp.signalR * 2;
const sigRouteX = endPoint.x + (style.Signal.route.signalRouteOffset.x + sigRouteH) * drict;
const sigRouteY = endPoint.y + (style.Signal.route.signalRouteOffset.y);
this.sigRoute = new ESigRoute({
zlevel: this.zlevel,
z: this.z,
@ -95,27 +95,27 @@ class Signal extends Group {
});
// 自动通过
const sigPassH = style.Signal.signalSigPassDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2;
const sigPassX = endPoint.x + (style.Signal.signalSigPassOffset.x + sigPassH) * drict;
const sigPassY = endPoint.y + (style.Signal.signalSigPassOffset.y);
this.sigPass = new ESigPass({
const sigAutoH = style.Signal.auto.signalAutoDirection ? this.count * style.Signal.lamp.signalR * 2 : -style.Signal.lamp.signalR * 2;
const sigAutoX = endPoint.x + (style.Signal.auto.signalAutoOffset.x + sigAutoH) * drict;
const sigAutoY = endPoint.y + (style.Signal.auto.signalAutoOffset.y);
this.sigAuto = new ESigAuto({
zlevel: this.zlevel,
z: this.z,
style: style,
count: this.count,
drict: drict,
x: sigPassX,
y: sigPassY,
x: sigAutoX,
y: sigAutoY,
width: style.Signal.signalSigPassWidth,
fill: style.Signal.signalLampGreenColor,
fill: style.Signal.lamp.signalLampGreenColor,
lineWidth: 0.6,
stroke: style.sidelineColor
});
// 延迟解锁
const sigDelayH = style.Signal.signalSigDelayDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2;
const sigDelayX = endPoint.x + (style.Signal.signalSigDelayOffset.x + sigDelayH) * drict;
const sigDelayY = endPoint.y - (style.Signal.signalSigDelayOffset.y) * posit;
const sigDelayH = style.Signal.delay.signalDelayDirection ? this.count * style.Signal.lamp.signalR * 2 : -style.Signal.lamp.signalR * 2;
const sigDelayX = endPoint.x + (style.Signal.delay.signalDelayOffset.x + sigDelayH) * drict;
const sigDelayY = endPoint.y - (style.Signal.delay.signalDelayOffset.y) * posit;
this.sigDelay = new ESigDelay({
zlevel: this.zlevel,
z: this.z,
@ -123,8 +123,8 @@ class Signal extends Group {
x: sigDelayX,
y: sigDelayY,
text: this.state.delayCount || '0',
textFont: `bold ${style.Signal.signalDelayTextFontSize} px ${style.textFontFormat}`,
textFill: style.Signal.signalTextRed,
textFont: `bold ${style.Signal.delay.signalDelayTextFontSize} px ${style.textFontFormat}`,
textFill: style.Signal.delay.signalDelayTextColor,
textAlign: drict > 0 ? 'right' : 'left',
textVerticalAlign: 'middle'
});
@ -137,13 +137,13 @@ class Signal extends Group {
posit: posit,
show: model.buttonShow,
x: model.buttonPosition.x,
y: model.buttonPosition.y - posit * (style.Signal.signalButtonDistance + style.Signal.signalR * 2)
y: model.buttonPosition.y - posit * (style.Signal.button.signalButtonDistance + style.Signal.lamp.signalR * 2)
});
this.add(this.sigPost);
this.lamps.forEach(lamp => { this.add(lamp); });
this.add(this.sigName);
this.add(this.sigPass);
this.add(this.sigAuto);
this.add(this.sigRoute);
this.add(this.sigDelay);
// this.add(this.sigButton);
@ -169,13 +169,13 @@ class Signal extends Group {
if (this.count === 1) {
if (this.model.useType === '05') {
/** 单灯 调车信号机*/
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampBlueColor);
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampBlueColor);
} else {
/** 单灯 出站信号机 */
/** 单灯 阻挡信号机*/
/** 单灯 阻挡兼调车信号 */
/** 单灯 列兼调信号机 */
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampRedColor);
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor);
}
}
}
@ -185,7 +185,7 @@ class Signal extends Group {
if (this.count === 1) {
/** 单灯 出站信号机*/
/** 单灯 阻隔信号机*/
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampGreenColor);
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampGreenColor);
}
}
@ -193,7 +193,7 @@ class Signal extends Group {
trainRoute() {
if (this.count === 1) {
/** 单灯 列兼调信号*/
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampYellowColor);
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampYellowColor);
}
}
@ -202,7 +202,7 @@ class Signal extends Group {
if (this.count === 1) {
/** 单灯 列兼调信号*/
/** 单灯 阻挡兼调车信号*/
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampWhiteColor);
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampWhiteColor);
}
}
@ -213,7 +213,7 @@ class Signal extends Group {
// 封锁
block() {
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampRedColor);
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor);
this.sigName.setColor(this.style.Signal.sectionBlockTextColor);
}
@ -243,25 +243,25 @@ class Signal extends Group {
// 设置自动进路模式状态类型
setAutoRouteOpen() {
if (this.model.linkageAutoRouteShow) {
this.sigPass.show();
this.sigAuto.show();
} else {
this.sigPass.hide();
this.sigAuto.hide();
}
this.recover();
this.sigPass.setColor(this.style.Signal.signalLampGreenColor);
this.sigAuto.setColor(this.style.Signal.auto.signalAutoRoute);
}
// 信号机进路自动触发模式状态类型
setAutoAccessOpen() {
if (this.model.atsAutoTriggerShow) {
this.sigPass.show();
this.sigAuto.show();
} else {
this.sigPass.hide();
this.sigAuto.hide();
}
this.recover();
this.sigPass.setColor(this.style.Signal.signalLampYellowColor);
this.sigAuto.setColor(this.style.Signal.auto.signalAutoTrigger);
}
// 设置自动信号模式状态类型
@ -271,14 +271,14 @@ class Signal extends Group {
// 隐藏自动信号和自动进路
setAutoClose() {
this.sigPass.hide();
this.sigPass.setColor(this.style.backgroundColor);
this.sigAuto.hide();
this.sigAuto.setColor(this.style.backgroundColor);
this.sigRoute.hide();
}
// 自动信号和自动进路开始动画
setAutoFlicker() {
this.sigPass.arrowsAnimation();
this.sigAuto.arrowsAnimation();
}
// 设置延时解锁
@ -289,8 +289,8 @@ class Signal extends Group {
// 恢复状态
recover() {
this.sigDelay.hide();
this.sigPass.animationRecover();
this.sigName.setColor(this.style.Signal.signalTextGreen);
this.sigAuto.animationRecover();
this.sigName.setColor(this.style.Signal.text.signalTextGreen);
}
setState(state) {

View File

@ -13,8 +13,8 @@ class ESigAuto extends Group {
const model = this.model;
const style = this.model.style;
const rotation = model.drict != 1? 0 : Math.PI;
const x = model.x + model.drict * (model.count * style.Signal.signalR + style.Signal.signalLampStandardWidth) * 2;
const y = model.y - style.Signal.signalLampStandardWidth;
const x = model.x + model.drict * (model.count * style.Signal.lamp.signalR + style.Signal.post.signalLampStandardWidth) * 2;
const y = model.y - style.Signal.post.signalLampStandardWidth;
this.arrows = new Polygon({
zlevel: model.zlevel,

View File

@ -76,58 +76,82 @@ class Fuzhou extends defaultSkin {
sectionAxleFailure: '#E6A23C' // #FFFF00 计轴失效
};
this[deviceType.Signal] = {
/** 信号机宽度 */
signalR: 5,
/** 自动信号宽度*/
signalSigPassWidth: 6,
/** 延迟解锁字体大小*/
signalDelayTextFontSize: 9,
/** 信号机名称字体大小*/
signalTextFontSize: 12,
/** 灯柱宽度*/
signalLampStandardWidth: 1.2,
/** 设备距离区段的距离*/
signalDistance: 3,
/** 信号灯按钮距离区段的距离*/
signalButtonDistance: 5,
/** 自动进路方向*/
signalSigRouteDirection: false,
/** 自动进路偏移量*/
signalSigRouteOffset: { x: -4, y: -2 },
/** 自动通过方向*/
signalSigPassDirection: false,
/** 自动通过偏移量*/
signalSigPassOffset: { x: -12, y: 0},
/** 延时解锁方向*/
signalSigDelayDirection: true,
/** 延时解锁偏移量*/
signalSigDelayOffset: { x: 15, y: -10},
/** 信号灯按钮边线*/
signalButtonDashColor: '#FFFFFF',
/** 信号灯按钮颜色*/
signalButtonColor: 'darkgreen',
/** 信号灯按钮闪烁颜色*/
signalButtonLightenColor: '#E4EF50',
/** 信号灯字体颜色*/
signalTextRed: '#EF0C08',
/** 信号机字体绿色*/
signalTextGreen: '#4DD43F',
/** 信号灯灯柱颜色*/
signalLampStandardColor: '#3149C3',
/** 信号灯锁闭*/
signalBlockColor: '#EF0C08',
/** 信号灯灰色*/
signalLampGrayColor: '#7F7F7F',
/** 信号灯红色*/
signalLampRedColor: '#FF0000',
/** 信号灯绿色*/
signalLampGreenColor: '#00FF00',
/** 信号灯黄色*/
signalLampYellowColor: '#FFFF00',
/** 信号灯白色*/
signalLampWhiteColor: '#FFFFFF',
/** 信号灯蓝色*/
signalLampBlueColor: '#0070C0'
signalDistance: 10,
post: {
signalLampStandardColor: '#3149C3',
signalLampStandardWidth: 2
},
text: {
/** 信号机名称字体大小*/
signalTextFontSize: 8,
/** 信号灯字体颜色*/
signalTextRed: '#EF0C08',
/** 信号机字体绿色*/
signalTextGreen: '#4DD43F'
},
lamp: {
/** 禁止线宽度*/
signalStopWidth: 2,
/** 信号灯边框线宽度*/
signalBorderWidth: 0.5,
/** 信号灯边框线颜色*/
signalBorderColor: '#3149C3',
/** 信号灯半径*/
signalR: 6,
/** 信号灯锁闭*/
signalBlockColor: '#EF0C08',
/** 信号灯灰色*/
signalLampGrayColor: '#7F7F7F',
/** 信号灯红色*/
signalLampRedColor: '#FF0000',
/** 信号灯绿色*/
signalLampGreenColor: '#00FF00',
/** 信号灯黄色*/
signalLampYellowColor: '#FFFF00',
/** 信号灯白色*/
signalLampWhiteColor: '#FFFFFF',
/** 信号灯蓝色*/
signalLampBlueColor: '#0070C0'
},
route: {
/** 自动进路方向*/
signalRouteDirection: false,
/** 自动进路偏移量*/
signalRouteOffset: { x: -4, y: 0 },
/** 自动进路*/
signalRouteColor: '#00FF00'
},
auto: {
/** 自动通过方向*/
signalAutoDirection: false,
/** 自动通过偏移量*/
signalAutoOffset: { x: -4, y: 0},
/** 自动进路*/
signalAutoRoute: '#00FF00',
/** 自动触发*/
signalAutoTrigger: '#FFFF00'
},
delay: {
/** 延迟解锁字体大小*/
signalDelayTextFontSize: 9,
/** 延时解锁方向*/
signalDelayDirection: true,
/** 延时解锁偏移量*/
signalDelayOffset: { x: 15, y: -10},
/** 延迟解锁颜色*/
signalDelayTextColor: '#FF0000'
},
button: {
/** 信号灯按钮距离区段的距离*/
signalButtonDistance: 5,
/** 信号灯按钮边线*/
signalButtonDashColor: '#FFFFFF',
/** 信号灯按钮颜色*/
signalButtonColor: 'darkgreen',
/** 信号灯按钮闪烁颜色*/
signalButtonLightenColor: '#E4EF50'
}
};
this[deviceType.StationStand] = {
/** 站台和屏蔽门之间的距离*/