修改代码

This commit is contained in:
ival 2019-07-23 18:30:08 +08:00
parent b2da416325
commit a5528542cc
7 changed files with 4 additions and 347 deletions

View File

@ -15,11 +15,7 @@ class ESigButton extends Group {
const model = this.model;
const style = this.model.style;
const padding = 1;
<<<<<<< HEAD
const r = style.Signal.lamp.signalR * 0.8;
=======
const r = style.Signal.Lamp.signalR * 0.8;
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
this.style = style;
this._subType = 'SignalButton';
@ -30,17 +26,6 @@ class ESigButton extends Group {
_subType: this._subType,
_val: '1',
shape: {
<<<<<<< HEAD
x: model.x - style.Signal.lamp.signalR,
y: model.y - r + r * model.posit,
width: style.Signal.lamp.signalR * 2,
height: style.Signal.lamp.signalR * 2
},
style: {
lineWidth: 0.2,
stroke: style.Signal.button.signalButtonDashColor,
fill: style.Signal.button.signalButtonColor
=======
x: model.x - style.Signal.Lamp.signalR,
y: model.y - r + r * model.posit,
width: style.Signal.Lamp.signalR * 2,
@ -50,7 +35,6 @@ class ESigButton extends Group {
lineWidth: 0.2,
stroke: style.Signal.Button.signalButtonDashColor,
fill: style.Signal.Button.signalButtonColor
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
});
@ -62,21 +46,12 @@ class ESigButton extends Group {
shape: {
cx: model.x,
cy: model.y - 5 / 2 * r * model.posit,
<<<<<<< HEAD
r: style.Signal.lamp.signalR
},
style: {
lineWidth: 0.2,
stroke: style.Signal.button.signalButtonDashColor,
fill: style.Signal.button.signalButtonColor
=======
r: style.Signal.Lamp.signalR
},
style: {
lineWidth: 0.2,
stroke: style.Signal.Button.signalButtonDashColor,
fill: style.Signal.Button.signalButtonColor
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
});

View File

@ -1,27 +0,0 @@
import Path from 'zrender/src/graphic/Path';
export default Path.extend({
type: 'SigAuto',
shape: {
x: 0, // 三角中心x
y: 0, // 三角中心y
r: 0, // 三角形半径
forward: false // 三角箭头朝向: 左/右
},
style: {
stroke: '#c0c0c0',
lineWidth: 0.5,
fill: null
},
buildPath: function (ctx, shape) {
const r = shape.forward ? shape.r : -shape.r;
ctx.moveTo(shape.x, shape.y);
ctx.lineTo(shape.x + r, shape.y - shape.r);
ctx.lineTo(shape.x + r, shape.y + shape.r);
ctx.closePath();
ctx.fill();
}
});

View File

@ -1,36 +0,0 @@
import Path from 'zrender/src/graphic/Path';
export default Path.extend({
type: 'SigLmap',
shape: {
x: 0, // 圆心x
y: 0, // 圆心y
r: 5, // 圆半径
signalStopWidth: 2, // 圆心禁止线宽度
isStop: true // 圆心叉是否存在
},
style: {
stroke: '#c0c0c0',
lineWidth: 0.5,
fill: null
},
buildPath: function (ctx, shape) {
// ctx.strokeStyle = this.style.stroke;
// ctx.lineWidth = this.style.lineWidth;
// ctx.fillStyle = this.style.fill;
ctx.arc(shape.x, shape.y, shape.r, 0, Math.PI * 2, true);
if (!shape.isStop) {
// ctx.beginPath();
// ctx.strokeStyle = '#000';
// ctx.lineWidth = shape.signalStopWidth;
ctx.moveTo(shape.x - shape.r * Math.cos(Math.PI / 4), shape.y - shape.r * Math.sin(Math.PI / 4));
ctx.lineTo(shape.x + shape.r * Math.cos(Math.PI / 4), shape.y + shape.r * Math.sin(Math.PI / 4));
ctx.moveTo(shape.x + shape.r * Math.cos(Math.PI / 4), shape.y - shape.r * Math.sin(Math.PI / 4));
ctx.lineTo(shape.x - shape.r * Math.cos(Math.PI / 4), shape.y + shape.r * Math.sin(Math.PI / 4));
}
}
});

View File

@ -1,30 +0,0 @@
import Path from 'zrender/src/graphic/Path';
export default Path.extend({
type: 'SigPost',
shape: {
x: 0, // 灯柱高柱中心x
y: 0, // 灯柱高柱中心y
h: 10, // 灯柱高柱长度
w: 5, // 灯珠矮柱宽度
isDwarf: false, // 是否是矮柱
forward: true // 灯柱朝向
},
style: {
stroke: '#000',
lineWidth: 1
},
buildPath: function (ctx, shape) {
const w = shape.forward ? -shape.w : shape.w;
const r = shape.h / 2;
ctx.moveTo(shape.x, shape.y - r);
ctx.lineTo(shape.x, shape.y + r);
if (shape.isDwarf) {
ctx.moveTo(shape.x, shape.y);
ctx.lineTo(shape.x + w, shape.y);
}
}
});

View File

@ -1,37 +0,0 @@
import Path from 'zrender/src/graphic/Path';
export default Path.extend({
type: 'SigRoute',
shape: {
x: 0,
y: 0,
h: 4,
w: 4,
l: 10,
d: 2,
forward: false
},
style: {
stroke: '#c0c0c0',
lineWidth: 0.5,
fill: null
},
buildPath: function (ctx, shape) {
const l = shape.forward ? shape.l : -shape.l;
const w = shape.forward ? shape.w : -shape.w;
ctx.moveTo(shape.x, shape.y);
ctx.lineTo(shape.x + w, shape.y - shape.h);
ctx.lineTo(shape.x + w, shape.y - shape.h + shape.d);
ctx.lineTo(shape.x + w + l, shape.y - shape.h + shape.d);
ctx.lineTo(shape.x + w + l, shape.y + shape.h - shape.d);
ctx.lineTo(shape.x + w, shape.y + shape.h - shape.d);
ctx.lineTo(shape.x + w, shape.y + shape.h);
ctx.closePath();
ctx.fill();
}
});

View File

@ -2,19 +2,12 @@
* 信号机
*/
<<<<<<< HEAD
import ESigPost from './ESigPost';
import ESigLmap from './ESigLmap';
import ESigLamp from './ESigLamp';
import ESigAuto from './ESigAuto';
import ESigRoute from './ESigRoute';
=======
import SigPost from './SigPost';
import SigLamp from './SigLamp';
import SigAuto from './SigAuto';
import SigRoute from './SigRoute';
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
import ESigButton from './ESigButton';
import Text from 'zrender/src/graphic/Text';
import ESigName from './ESigName';
import Group from 'zrender/src/container/Group';
class Signal extends Group {
@ -41,30 +34,14 @@ class Signal extends Group {
const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下
// 信号机高柱矮柱
this.sigPost = new SigPost({
this.sigPost = new ESigPost({
zlevel: this.zlevel,
<<<<<<< HEAD
z: this.z,
style: style,
drict: drict,
type: model.lampPostType,
x: model.position.x,
y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.lamp.signalR)
=======
z: this.z + 1,
shape: {
x: model.position.x,
y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR),
h: style.Signal.Lamp.signalR * 2,
w: style.Signal.Lamp.signalR,
isDwarf: model.lampPositionType == '02',
forward: model.directionType == '01'
},
style: {
stroke: style.Signal.Post.signalLampStandardColor,
lineWidth: style.Signal.Post.signalLampStandardWidth
}
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
});
const endPoint = {
@ -75,10 +52,9 @@ class Signal extends Group {
// 信号灯
this.lamps = [];
for (let i = 0; i < this.count; i++) {
const lamp = new SigLamp({
const lamp = new ESigLamp({
zlevel: this.zlevel,
z: this.z,
<<<<<<< HEAD
style: style,
index: i + 1,
drict: drict,
@ -86,20 +62,6 @@ class Signal extends Group {
y: endPoint.y,
originX: model.position.x,
originY: model.position.y
=======
shape: {
x: endPoint.x + i * drict * (style.Signal.Lamp.signalR * 2 + style.Signal.Lamp.signalBorderWidth),
y: endPoint.y,
r: style.Signal.Lamp.signalR,
signalStopWidth: style.Signal.Lamp.signalStopWidth,
isStop: false
},
style: {
stroke: style.Signal.Lamp.signalBorderColor,
lineWidth: style.Signal.Lamp.signalBorderWidth,
fill: style.Signal.Lamp.signalLampGrayColor
}
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
});
this.lamps.push(lamp);
@ -107,7 +69,6 @@ class Signal extends Group {
// 信号机名称
const sigNameX = model.position.x + model.namePosition.x;
<<<<<<< HEAD
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,
@ -128,30 +89,6 @@ class Signal extends Group {
const sigRouteX = endPoint.x + (style.Signal.route.signalRouteOffset.x + sigRouteH) * drict;
const sigRouteY = endPoint.y + (style.Signal.route.signalRouteOffset.y);
this.sigRoute = new ESigRoute({
=======
const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR * 2 + model.namePosition.y);
this.sigName = new Text({
zlevel: this.zlevel,
z: this.z,
silent: false,
style: {
x: sigNameX,
y: sigNameY,
text: model.name,
textFont: `bold ${style.Signal.Text.signalTextFontSize} px ${style.textFontFormat}`,
textFill: style.Signal.Text.signalTextGreen,
textAlign: 'middle',
textPosition: model.textPosition || 'inside',
textVerticalAlign: posit == 1 ? 'top' : 'bottom'
}
});
// 自动进路
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 SigRoute({
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
zlevel: this.zlevel,
z: this.z,
shape: {
@ -165,7 +102,6 @@ class Signal extends Group {
});
// 自动通过
<<<<<<< HEAD
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);
@ -198,43 +134,6 @@ class Signal extends Group {
textFill: style.Signal.delay.signalDelayTextColor,
textAlign: drict > 0 ? 'right' : 'left',
textVerticalAlign: 'middle'
=======
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 SigAuto({
zlevel: this.zlevel,
z: this.z,
shape: {
x: sigAutoX,
y: sigAutoY,
r: style.Signal.Lamp.signalR,
forward: model.directionType == '01'
},
style: {
fill: style.Signal.Auto.signalAutoColor
}
});
// 延迟解锁
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 Text({
zlevel: this.zlevel,
z: this.z,
silent: false,
style: {
x: sigDelayX,
y: sigDelayY,
text: this.state.delayCount || '0',
textFont: `bold ${style.Signal.Delay.signalDelayTextFontSize} px ${style.textFontFormat}`,
textFill: style.Signal.Delay.signalDelayTextColor,
textAlign: drict > 0 ? 'right' : 'left',
textPosition: model.textPosition || 'inside',
textVerticalAlign: 'middle'
}
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
});
// 信号灯按钮
@ -245,20 +144,13 @@ class Signal extends Group {
posit: posit,
show: model.buttonShow,
x: model.buttonPosition.x,
<<<<<<< HEAD
y: model.buttonPosition.y - posit * (style.Signal.button.signalButtonDistance + style.Signal.lamp.signalR * 2)
=======
y: model.buttonPosition.y - posit * (style.Signal.Button.signalButtonDistance + style.Signal.Lamp.signalR * 2)
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
});
this.add(this.sigPost);
this.lamps.forEach(lamp => { this.add(lamp); });
this.add(this.sigName);
<<<<<<< HEAD
this.add(this.sigAuto);
=======
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
this.add(this.sigRoute);
this.add(this.sigAuto);
this.add(this.sigDelay);
@ -285,21 +177,13 @@ class Signal extends Group {
if (this.count === 1) {
if (this.model.useType === '05') {
/** 单灯 调车信号机*/
<<<<<<< HEAD
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampBlueColor);
=======
this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampBlueColor);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
} else {
/** 单灯 出站信号机 */
/** 单灯 阻挡信号机*/
/** 单灯 阻挡兼调车信号 */
/** 单灯 列兼调信号机 */
<<<<<<< HEAD
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor);
=======
this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampRedColor);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
}
}
@ -309,11 +193,7 @@ class Signal extends Group {
if (this.count === 1) {
/** 单灯 出站信号机*/
/** 单灯 阻隔信号机*/
<<<<<<< HEAD
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampGreenColor);
=======
this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampGreenColor);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
}
@ -321,11 +201,7 @@ class Signal extends Group {
trainRoute() {
if (this.count === 1) {
/** 单灯 列兼调信号*/
<<<<<<< HEAD
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampYellowColor);
=======
this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampYellowColor);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
}
@ -334,11 +210,7 @@ class Signal extends Group {
if (this.count === 1) {
/** 单灯 列兼调信号*/
/** 单灯 阻挡兼调车信号*/
<<<<<<< HEAD
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampWhiteColor);
=======
this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampWhiteColor);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
}
@ -349,13 +221,8 @@ class Signal extends Group {
// 封锁
block() {
<<<<<<< HEAD
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor);
this.sigName.setColor(this.style.Signal.sectionBlockTextColor);
=======
this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampRedColor);
this.sigName.setStyle('textFill', this.style.Signal.Text.signalTextRed);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
// 功能封锁
@ -390,11 +257,7 @@ class Signal extends Group {
}
this.recover();
<<<<<<< HEAD
this.sigAuto.setColor(this.style.Signal.auto.signalAutoRoute);
=======
this.sigAuto.setStyle('fill', this.style.Signal.signalAutoRoute);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
// 信号机进路自动触发模式状态类型
@ -406,11 +269,7 @@ class Signal extends Group {
}
this.recover();
<<<<<<< HEAD
this.sigAuto.setColor(this.style.Signal.auto.signalAutoTrigger);
=======
this.sigAuto.setStyle('fill', this.style.Signal.signalAutoTrigger);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
// 设置自动信号模式状态类型
@ -420,29 +279,15 @@ class Signal extends Group {
// 隐藏自动信号和自动进路
setAutoClose() {
<<<<<<< HEAD
this.sigAuto.hide();
this.sigAuto.setColor(this.style.backgroundColor);
=======
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
this.sigRoute.hide();
this.sigAuto.hide();
}
// 自动信号和自动进路开始动画
setAutoFlicker() {
<<<<<<< HEAD
this.sigAuto.arrowsAnimation();
=======
const style = this.model.style;
const fill = this.sigAuto.style.Signal.fill;
this.sigAuto.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();
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
// 设置延时解锁
@ -453,13 +298,8 @@ class Signal extends Group {
// 恢复状态
recover() {
this.sigDelay.hide();
<<<<<<< HEAD
this.sigAuto.animationRecover();
this.sigName.setColor(this.style.Signal.text.signalTextGreen);
=======
this.sigAuto.stopAnimation(false);
this.sigName.setStyle('textFill', this.style.Signal.Text.signalTextGreen);
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
}
setState(state) {

View File

@ -66,19 +66,11 @@ class Fuzhou extends defaultSkin {
this[deviceType.Signal] = {
/** 设备距离区段的距离*/
signalDistance: 10,
<<<<<<< HEAD
post: {
signalLampStandardColor: '#3149C3',
signalLampStandardWidth: 2
},
text: {
=======
Post: {
signalLampStandardColor: '#3149C3',
signalLampStandardWidth: 2
},
Text: {
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
/** 信号机名称字体大小*/
signalTextFontSize: 8,
/** 信号灯字体颜色*/
@ -86,11 +78,7 @@ class Fuzhou extends defaultSkin {
/** 信号机字体绿色*/
signalTextGreen: '#4DD43F'
},
<<<<<<< HEAD
lamp: {
=======
Lamp: {
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
/** 禁止线宽度*/
signalStopWidth: 2,
/** 信号灯边框线宽度*/
@ -114,11 +102,7 @@ class Fuzhou extends defaultSkin {
/** 信号灯蓝色*/
signalLampBlueColor: '#0070C0'
},
<<<<<<< HEAD
route: {
=======
Route: {
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
/** 自动进路方向*/
signalRouteDirection: false,
/** 自动进路偏移量*/
@ -126,11 +110,7 @@ class Fuzhou extends defaultSkin {
/** 自动进路*/
signalRouteColor: '#00FF00'
},
<<<<<<< HEAD
auto: {
=======
Auto: {
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
/** 自动通过方向*/
signalAutoDirection: false,
/** 自动通过偏移量*/
@ -140,11 +120,7 @@ class Fuzhou extends defaultSkin {
/** 自动触发*/
signalAutoTrigger: '#FFFF00'
},
<<<<<<< HEAD
delay: {
=======
Delay: {
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
/** 延迟解锁字体大小*/
signalDelayTextFontSize: 9,
/** 延时解锁方向*/
@ -154,11 +130,7 @@ class Fuzhou extends defaultSkin {
/** 延迟解锁颜色*/
signalDelayTextColor: '#FF0000'
},
<<<<<<< HEAD
button: {
=======
Button: {
>>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77
/** 信号灯按钮距离区段的距离*/
signalButtonDistance: 5,
/** 信号灯按钮边线*/