卡斯柯显示调整

This commit is contained in:
fan 2022-08-11 11:18:38 +08:00
parent 319cd60d6c
commit 1a80ae7558
3 changed files with 353 additions and 326 deletions

View File

@ -261,7 +261,9 @@ class SkinCode extends defaultStyle {
this[deviceType.SignalButton] = { this[deviceType.SignalButton] = {
shape: 'roundWithDock', shape: 'roundWithDock',
fillColor: '#808080', fillColor: '#808080',
showName: true showName: true,
selectColor: '#0000ff',
flashingColor: '#ffff00'
}; };
this[deviceType.SwitchFault] = { this[deviceType.SwitchFault] = {
displayCondition: '01', // 显示条件 01所有模式下显示 02 行调显示 03现地显示 displayCondition: '01', // 显示条件 01所有模式下显示 02 行调显示 03现地显示

View File

@ -647,7 +647,6 @@ class Signal extends Group {
} }
this.sigPost.setHorColor(this.style.Signal.post.openHorColor); this.sigPost.setHorColor(this.style.Signal.post.openHorColor);
} }
} }
/* 侧向开放 */ /* 侧向开放 */
openLateral(logicLight) { openLateral(logicLight) {
@ -726,6 +725,14 @@ class Signal extends Group {
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.yellowColor); this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.yellowColor);
this.lamps[1] && this.lamps[1].setColor(this.style.Signal.lamp.greenColor); this.lamps[1] && this.lamps[1].setColor(this.style.Signal.lamp.greenColor);
} }
redFlash() {
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.redColor);
this.lamps[0].setAnimationStart(this.style.Signal.lamp.redColor);
}
blueFlash() {
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.blueColor);
this.lamps[0].setAnimationStart(this.style.Signal.lamp.blueColor);
}
lampWhite() { lampWhite() {
if (this.lamps.length === 1) { if (this.lamps.length === 1) {
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.whiteColor); this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.whiteColor);
@ -1086,6 +1093,14 @@ class Signal extends Group {
this.greenYellow(); this.greenYellow();
break; break;
} }
case 'RF': {
this.redFlash();
break;
}
case 'BF': {
this.blueFlash();
break;
}
default: { default: {
this.close(model.logicLight); // 信号关闭 this.close(model.logicLight); // 信号关闭
break; break;

View File

@ -1,333 +1,343 @@
import Group from 'zrender/src/container/Group' import Group from 'zrender/src/container/Group';
import Rect from 'zrender/src/graphic/shape/Rect' import Rect from 'zrender/src/graphic/shape/Rect';
import Line from 'zrender/src/graphic/shape/Line' import Line from 'zrender/src/graphic/shape/Line';
import Text from 'zrender/src/graphic/Text' import Text from 'zrender/src/graphic/Text';
import Arc from 'zrender/src/graphic/shape/Arc' import Arc from 'zrender/src/graphic/shape/Arc';
import Circle from 'zrender/src/graphic/shape/Circle' import Circle from 'zrender/src/graphic/shape/Circle';
import store from '@/store/index' import store from '@/store/index';
const typeList = [ const typeList = [
'PICK_ASSIST', 'PICK_ASSIST',
'DEPART_ASSIST', 'DEPART_ASSIST',
'ASSIST', 'ASSIST',
'GUIDELOCK', 'GUIDELOCK',
'SECTION_FAULT_UNLOCK', 'SECTION_FAULT_UNLOCK',
'LOCATE', 'LOCATE',
'REVERSE', 'REVERSE',
'CANCEL', 'CANCEL',
'HUMAN_RELEASE_ROUTE', 'HUMAN_RELEASE_ROUTE',
'MONOLOCK', 'MONOLOCK',
'UNLOCK', 'UNLOCK',
'BLOCK', 'BLOCK',
'UNBLOCK', 'UNBLOCK',
'CHANGE_DIRECTION' 'CHANGE_DIRECTION'
] ];
export default class SignalButton extends Group { export default class SignalButton extends Group {
constructor(model, { style }) { constructor(model, { style }) {
super() super();
this._code = model.code this._code = model.code;
this._type = model._type this._type = model._type;
this.zlevel = model.zlevel this.zlevel = model.zlevel;
const pictureDevice = store.getters['map/getPictureDeviceByCode'](model.code) const pictureDevice = store.getters['map/getPictureDeviceByCode'](model.code);
if (pictureDevice) { if (pictureDevice) {
this.computedPosition = pictureDevice.position this.computedPosition = pictureDevice.position;
} else {
this.computedPosition = model.position
}
this.z = 0
this.model = model
this.style = style
this.pressed = false
// Line
this.create()
this.setState(model)
}
create() {
const model = this.model
const computedPosition = this.computedPosition
const fillColor = this.getTypeColor()
if (this.style.SignalButton && this.style.SignalButton.shape === 'roundWithDock' && typeList.includes(model.type)) {
const circle1 = new Circle({
zlevel: this.zlevel,
z: this.z + 2,
shape: {
cx: computedPosition.x + 7,
cy: computedPosition.y + 7,
r: 7
},
style: {
stroke: '#69666E',
lineWidth: 1,
fill: fillColor
}
})
const circle2 = new Circle({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
cx: computedPosition.x + 7,
cy: computedPosition.y + 9,
r: 8
},
style: {
fill: '#000'
}
})
const circle3 = new Circle({
zlevel: this.zlevel,
z: this.z,
shape: {
cx: computedPosition.x + 7,
cy: computedPosition.y + 9,
r: 9
},
style: {
fill: '#eee'
}
})
this.arcShape = circle1
this.arcShapeDock1 = circle2
this.arcShapeDock2 = circle3
this.add(circle1)
.add(circle2)
.add(circle3)
} else {
this.rectButton = new Rect({
zlevel: this.zlevel,
z: this.z,
shape: {
x: computedPosition.x,
y: computedPosition.y,
width: 14,
height: 14
},
style: {
lineDash: null,
stroke: '#69666E',
lineWidth: 1,
fill: fillColor
}
})
this.add(this.rectButton)
}
this.leftLine = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x + 1,
y1: computedPosition.y + 1,
x2: computedPosition.x + 13,
y2: computedPosition.y + 13
},
style: {
lineWidth: 2,
stroke: '#ff0000'
}
})
this.add(this.leftLine)
this.leftLine.hide()
this.rightLine = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x + 13,
y1: computedPosition.y + 1,
x2: computedPosition.x + 1,
y2: computedPosition.y + 13
},
style: {
lineWidth: 2,
stroke: '#ff0000'
}
})
this.add(this.rightLine)
this.rightLine.hide()
this.leftBoard = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x - 1,
y1: computedPosition.y - 1,
x2: computedPosition.x - 1,
y2: computedPosition.y + 15
},
style: {
lineWidth: 2,
stroke: '#FFFFFF'
}
})
this.add(this.leftBoard)
this.leftBoard.hide()
this.topBoard = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x - 1,
y1: computedPosition.y - 1,
x2: computedPosition.x + 15,
y2: computedPosition.y - 1
},
style: {
lineWidth: 2,
stroke: '#FFFFFF'
}
})
this.add(this.topBoard)
this.topBoard.hide()
this.rightBoard = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x + 15,
y1: computedPosition.y - 1,
x2: computedPosition.x + 15,
y2: computedPosition.y + 15
},
style: {
lineWidth: 2,
stroke: '#A0A0A0'
}
})
this.add(this.rightBoard)
this.rightBoard.hide()
this.bottomBoard = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x - 1,
y1: computedPosition.y + 15,
x2: computedPosition.x + 15,
y2: computedPosition.y + 15
},
style: {
lineWidth: 2,
stroke: '#A0A0A0'
}
})
this.add(this.bottomBoard)
this.bottomBoard.hide()
const hasTextList = ['PASS', 'ASSIST', 'PICK_ASSIST', 'DEPART_ASSIST', 'ACCIDENT', 'CHANGE_DIRECTION', 'RECOVERY', 'OCCLUSION']
if (hasTextList.includes(model.type) || (this.style.SignalButton && this.style.SignalButton.showName)) {
this.buttonText = new Text({
zlevel: this.zlevel,
z: this.z,
style: {
x: computedPosition.x + model.nameOffset.x,
y: computedPosition.y + model.nameOffset.y,
fontWeight: '400',
fontSize: 10,
fontFamily: '',
text: model.name,
textFill: '#C0C0C0',
textAlign: 'middle',
textVerticalAlign: 'top'
}
})
this.add(this.buttonText)
}
}
startAnimate() {
this.rectButton &&
this.rectButton
.animateStyle(true)
.when(0, { fill: '#000' })
.when(1000, { fill: this.getTypeColor() })
.when(2000, { fill: '#000' })
.start()
}
stopAnimation() {
this.rectButton && this.rectButton.stopAnimation(true)
// this.arcFlash && this.arcFlash.stopAnimation(false);
}
getTypeColor() {
if (this.style.SignalButton && this.style.SignalButton.fillColor && typeList.includes(this.model.type)) {
return this.style.SignalButton.fillColor
}
let color = ''
const list = ['ASSIST', 'ACCIDENT', 'PICK_ASSIST', 'DEPART_ASSIST', 'CHANGE_DIRECTION', 'RECOVERY', 'OCCLUSION']
if (this.model.type === 'FLEXIBLE' || this.model.type === 'SHUNT_TERMINAL') {
color = '#808080'
} else if (this.model.type === 'GUIDE') {
color = '#5050E1'
} else if (list.includes(this.model.type)) {
color = '#ccc'
} else {
color = '#008000'
}
return color
} //
recover() {
this.stopAnimation()
this.rectButton && this.rectButton.setStyle({ fill: this.getTypeColor() })
this.arcShape && this.arcShape.setStyle({ fill: this.getTypeColor() })
this.rightLine && this.rightLine.hide()
this.leftLine && this.leftLine.hide()
this.rectButton && this.rectButton.show()
this.arcShape && this.arcShape.show()
this.arcShapeDock1 && this.arcShapeDock1.show()
this.arcShapeDock2 && this.arcShapeDock2.show()
this.buttonText && this.buttonText.show()
this.leftBoard && this.leftBoard.hide()
this.rightBoard && this.rightBoard.hide()
this.topBoard && this.topBoard.hide()
this.bottomBoard && this.bottomBoard.hide()
}
blockShow() {
this.rightLine && this.rightLine.show()
this.leftLine && this.leftLine.show()
}
setState(model) {
this.recover()
// { value: 'ASSIST', label: '总辅助按钮' },
// { value: 'PICK_ASSIST', label: '接辅助按钮' },
// { value: 'DEPART_ASSIST', label: '发辅助按钮' },
const list = ['ASSIST', 'PICK_ASSIST', 'DEPART_ASSIST', 'CHANGE_DIRECTION', 'ACCIDENT', 'RECOVERY', 'OCCLUSION']
if (list.includes(model.type)) {
if (this.rectButton) {
if (model.pressDown) {
this.rectButton.setStyle({ fill: '#FFFF00' })
} else { } else {
this.rectButton.setStyle({ fill: this.getTypeColor() }) this.computedPosition = model.position;
} }
} this.z = 0;
this.model = model;
this.style = style;
this.pressed = false;
// Line
this.create();
this.setState(model);
} }
// { value: 'PICK', label: '接车按钮' },
// { value: 'SHUNT_TERMINAL', label: '调车终端按钮' }, create() {
if (!store.getters['map/checkDeviceShow'](this._code)) { const model = this.model;
this.buttonText && this.buttonText.hide() const computedPosition = this.computedPosition;
this.rectButton && this.rectButton.hide() const fillColor = this.getTypeColor();
this.leftLine && this.leftLine.hide() if (this.style.SignalButton && this.style.SignalButton.shape === 'roundWithDock' && typeList.includes(model.type)) {
this.rightLine && this.rightLine.hide() const circle1 = new Circle({
this.arcShape && this.arcShape.hide() zlevel: this.zlevel,
this.arcShapeDock1 && this.arcShapeDock1.hide() z: this.z + 2,
this.arcShapeDock2 && this.arcShapeDock2.hide() shape: {
} else { cx: computedPosition.x + 7,
if (model.hasSelected) { cy: computedPosition.y + 7,
this.startAnimate() r: 7
} },
} style: {
} stroke: '#69666E',
pressDown(flg, color) { lineWidth: 1,
if (this.pressed === flg) return fill: fillColor
if (this.arcShapeDock1) { }
if (flg) { });
this.arcShape.attr({ shape: { cy: this.arcShape.shape.cy + 2 }, z: this.z + 2, zlevel: this.zlevel }) const circle2 = new Circle({
if (color) { zlevel: this.zlevel,
this.arcShape z: this.z + 1,
.animateStyle(true) shape: {
.when(0, { fill: '#69666E' }) cx: computedPosition.x + 7,
.when(1000, { fill: color }) cy: computedPosition.y + 9,
.when(2000, { fill: '#69666E' }) r: 8
.start() },
style: {
fill: '#000'
}
});
const circle3 = new Circle({
zlevel: this.zlevel,
z: this.z,
shape: {
cx: computedPosition.x + 7,
cy: computedPosition.y + 9,
r: 9
},
style: {
fill: '#eee'
}
});
this.arcShape = circle1;
this.arcShapeDock1 = circle2;
this.arcShapeDock2 = circle3;
this.add(circle1)
.add(circle2)
.add(circle3);
} else {
this.rectButton = new Rect({
zlevel: this.zlevel,
z: this.z,
shape: {
x: computedPosition.x,
y: computedPosition.y,
width: 14,
height: 14
},
style: {
lineDash: null,
stroke: '#69666E',
lineWidth: 1,
fill: fillColor
}
});
this.add(this.rectButton);
}
this.leftLine = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x + 1,
y1: computedPosition.y + 1,
x2: computedPosition.x + 13,
y2: computedPosition.y + 13
},
style: {
lineWidth: 2,
stroke: '#ff0000'
}
});
this.add(this.leftLine);
this.leftLine.hide();
this.rightLine = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x + 13,
y1: computedPosition.y + 1,
x2: computedPosition.x + 1,
y2: computedPosition.y + 13
},
style: {
lineWidth: 2,
stroke: '#ff0000'
}
});
this.add(this.rightLine);
this.rightLine.hide();
this.leftBoard = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x - 1,
y1: computedPosition.y - 1,
x2: computedPosition.x - 1,
y2: computedPosition.y + 15
},
style: {
lineWidth: 2,
stroke: '#FFFFFF'
}
});
this.add(this.leftBoard);
this.leftBoard.hide();
this.topBoard = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x - 1,
y1: computedPosition.y - 1,
x2: computedPosition.x + 15,
y2: computedPosition.y - 1
},
style: {
lineWidth: 2,
stroke: '#FFFFFF'
}
});
this.add(this.topBoard);
this.topBoard.hide();
this.rightBoard = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x + 15,
y1: computedPosition.y - 1,
x2: computedPosition.x + 15,
y2: computedPosition.y + 15
},
style: {
lineWidth: 2,
stroke: '#A0A0A0'
}
});
this.add(this.rightBoard);
this.rightBoard.hide();
this.bottomBoard = new Line({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x1: computedPosition.x - 1,
y1: computedPosition.y + 15,
x2: computedPosition.x + 15,
y2: computedPosition.y + 15
},
style: {
lineWidth: 2,
stroke: '#A0A0A0'
}
});
this.add(this.bottomBoard);
this.bottomBoard.hide();
const hasTextList = ['PASS', 'ASSIST', 'PICK_ASSIST', 'DEPART_ASSIST', 'ACCIDENT', 'CHANGE_DIRECTION', 'RECOVERY', 'OCCLUSION'];
if (hasTextList.includes(model.type) || (this.style.SignalButton && this.style.SignalButton.showName)) {
this.buttonText = new Text({
zlevel: this.zlevel,
z: this.z,
style: {
x: computedPosition.x + model.nameOffset.x,
y: computedPosition.y + model.nameOffset.y,
fontWeight: '400',
fontSize: 10,
fontFamily: '',
text: model.name,
textFill: '#C0C0C0',
textAlign: 'middle',
textVerticalAlign: 'top'
}
});
this.add(this.buttonText);
} }
} else {
this.arcShape.attr({ shape: { cy: this.arcShape.shape.cy - 2 }, z: this.z + 2, zlevel: this.zlevel })
this.arcShape.stopAnimation(true)
this.recover()
}
this.pressed = flg
} }
} startAnimate(color) {
getAnchorPoint() {} // let color = this.getTypeColor();
// if (this.style.SignalButton && this.style.SignalButton.flashingColor) {
// color = this.style.SignalButton.flashingColor;
// }
this.rectButton &&
this.rectButton
.animateStyle(true)
.when(0, { fill: '#000' })
.when(1000, { fill: color })
.when(2000, { fill: '#000' })
.start();
}
stopAnimation() {
this.rectButton && this.rectButton.stopAnimation(true);
// this.arcFlash && this.arcFlash.stopAnimation(false);
}
getTypeColor() {
if (this.style.SignalButton && this.style.SignalButton.fillColor && typeList.includes(this.model.type)) {
return this.style.SignalButton.fillColor;
}
let color = '';
const list = ['ASSIST', 'ACCIDENT', 'PICK_ASSIST', 'DEPART_ASSIST', 'CHANGE_DIRECTION', 'RECOVERY', 'OCCLUSION'];
if (this.model.type === 'FLEXIBLE' || this.model.type === 'SHUNT_TERMINAL') {
color = '#808080';
} else if (this.model.type === 'GUIDE') {
color = '#5050E1';
} else if (list.includes(this.model.type)) {
color = '#ccc';
} else {
color = '#008000';
}
return color;
} //
recover() {
this.stopAnimation();
this.rectButton && this.rectButton.setStyle({ fill: this.getTypeColor() });
this.arcShape && this.arcShape.setStyle({ fill: this.getTypeColor() });
this.rightLine && this.rightLine.hide();
this.leftLine && this.leftLine.hide();
this.rectButton && this.rectButton.show();
this.arcShape && this.arcShape.show();
this.arcShapeDock1 && this.arcShapeDock1.show();
this.arcShapeDock2 && this.arcShapeDock2.show();
this.buttonText && this.buttonText.show();
this.leftBoard && this.leftBoard.hide();
this.rightBoard && this.rightBoard.hide();
this.topBoard && this.topBoard.hide();
this.bottomBoard && this.bottomBoard.hide();
}
blockShow() {
this.rightLine && this.rightLine.show();
this.leftLine && this.leftLine.show();
}
setState(model) {
this.recover();
// { value: 'ASSIST', label: '总辅助按钮' },
// { value: 'PICK_ASSIST', label: '接辅助按钮' },
// { value: 'DEPART_ASSIST', label: '发辅助按钮' },
const list = ['ASSIST', 'PICK_ASSIST', 'DEPART_ASSIST', 'CHANGE_DIRECTION', 'ACCIDENT', 'RECOVERY', 'OCCLUSION'];
if (list.includes(model.type)) {
if (this.rectButton) {
if (model.pressDown) {
this.rectButton.setStyle({ fill: '#FFFF00' });
} else {
this.rectButton.setStyle({ fill: this.getTypeColor() });
}
}
}
// { value: 'PICK', label: '接车按钮' },
// { value: 'SHUNT_TERMINAL', label: '调车终端按钮' },
if (!store.getters['map/checkDeviceShow'](this._code)) {
this.buttonText && this.buttonText.hide();
this.rectButton && this.rectButton.hide();
this.leftLine && this.leftLine.hide();
this.rightLine && this.rightLine.hide();
this.arcShape && this.arcShape.hide();
this.arcShapeDock1 && this.arcShapeDock1.hide();
this.arcShapeDock2 && this.arcShapeDock2.hide();
} else {
if (model.hasSelected) {
if (this.style.SignalButton && this.style.SignalButton.selectColor) {
this.rectButton && this.rectButton.setStyle({fill:this.style.SignalButton.selectColor});
} else {
this.startAnimate(this.getTypeColor());
}
} else if (model.toSelected) {
this.startAnimate(this.style.SignalButton.flashingColor);
}
}
}
pressDown(flg, color) {
if (this.pressed === flg) return;
if (this.arcShapeDock1) {
if (flg) {
this.arcShape.attr({ shape: { cy: this.arcShape.shape.cy + 2 }, z: this.z + 2, zlevel: this.zlevel });
if (color) {
this.arcShape
.animateStyle(true)
.when(0, { fill: '#69666E' })
.when(1000, { fill: color })
.when(2000, { fill: '#69666E' })
.start();
}
} else {
this.arcShape.attr({ shape: { cy: this.arcShape.shape.cy - 2 }, z: this.z + 2, zlevel: this.zlevel });
this.arcShape.stopAnimation(true);
this.recover();
}
this.pressed = flg;
}
}
getAnchorPoint() {}
} }