调整南京二号线岔区设限显示

This commit is contained in:
fan 2021-01-26 18:19:04 +08:00
parent de1d8bb0db
commit f92e017f1b
4 changed files with 76 additions and 9 deletions

View File

@ -128,7 +128,7 @@ class SkinCode extends defaultStyle {
nameBackgroundBorderColor: '#C00808', // 限速值背景边框颜色
limitValueDistance: 18,
kilometerFontSize: 0, // 公里标大小
nameAlone: true, // 只显示一个限速名称
switchSectionNoShow: true, // 道岔区段不展示限速
nameNumberFontSize: 11, // 限速值大小
nameNumberColor: '#C00808', // 限速值颜色
nameBackground: 'rgba(0,0,0,0)', // 限速名称背景颜色
@ -603,6 +603,10 @@ class SkinCode extends defaultStyle {
show: true, // 显示
coverBlockColor: '#0010FF', // 遮挡物颜色
preResetColor: '#FFBEC9' // 区段计轴预复位
},
limitNameText: { // 道岔限速值
fillColor: '#C00808', // 填充颜色
fontSize: 11 // 字体大小
}
};

View File

@ -270,14 +270,11 @@ export default class Section extends Group {
/** 设置限速*/
setSpeedUpperLimit(speedUpLimit) {
if (this.style.Section.line.speedLimitColor) { // 宁波三号线 独有
if (this.style.Section.speedLimitName && this.style.Section.speedLimitName.switchSectionNoShow && this.model.type == '03') {
// 南京二号线 岔区设限 在道岔下显示
return;
} else if (this.style.Section.line.speedLimitColor) { // 宁波三号线 独有
this.line.setStyle({stroke: this.style.Section.line.speedLimitColor});
} else if (this.style.Section.speedLimitName && this.style.Section.speedLimitName.nameAlone && this.model.type == '03') { // 南京2道岔区段只显示一个名称
const switchModel = Vue.prototype.$jlmap.mapDevice[this.model.relSwitchCode];
if (switchModel && switchModel.sectionACode == this._code) {
this.speedLimit && this.speedLimit.show();
this.speedLimitName && this.speedLimitName.show(speedUpLimit);
}
} else if (this.style.Section.cross && this.model.type == '05') {
this.line.setCrossSpeedUpperLimit(speedUpLimit);
} else {
@ -391,6 +388,7 @@ export default class Section extends Group {
const sectionSwitch = store.getters['map/getDeviceByCode'](model.switch.code);
if (sectionSwitch && sectionSwitch.sectionACode === model.code) {
sectionSwitch.instance && sectionSwitch.instance.setState(sectionSwitch);
sectionSwitch.instance && sectionSwitch.instance.setLimitState(model.speedUpLimit > 0, model.speedUpLimit);
}
}
}

View File

@ -0,0 +1,44 @@
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
class ESwName extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
create() {
const model = this.model;
const style = this.model.style;
this.limitNameText = new Text({
zlevel: model.zlevel,
z: model.z + 6,
style: {
x: model.nameTextX,
y: model.nameTextY,
fontWeight: style.Switch.text.fontWeight,
fontSize: model.fontSize,
fontFamily: style.fontFamily,
text: '0',
textAlign: 'center',
textVerticalAlign: 'middle',
textFill: model.fillColor
}
});
this.add(this.limitNameText);
this.limitNameText.hide();
}
limitNameShow(text) {
this.limitNameText.show();
this.limitNameText.setStyle({ text: text });
}
limitNameHide() {
this.limitNameText.hide();
}
}
export default ESwName;

View File

@ -3,6 +3,7 @@ import Text from 'zrender/src/graphic/Text';
import Rect from 'zrender/src/graphic/shape/Rect';
import JTriangle from '../../utils/JTriangle';
import ESwName from './ESwName.js';
import ELimitName from './ELimitName.js';
import ESwLocal from './ESwLocal.js';
import ESwLnversion from './ESwLnversion';
import ELockRect from './ELockRect';
@ -167,6 +168,20 @@ export default class Switch extends Group {
nameShow: style.Switch.text.show,
triangle: this.triangle
});
if (this.style.Switch.limitNameText) { // 道岔限速
const limitTextX = model.intersection.x + directx * (style.Section.line.width * 3 + style.Switch.text.offset.x) * this.triangle.getCotRate();
const limitTextY = model.intersection.y - style.Switch.text.offset.y * directy;
this.limitName = new ELimitName({
zlevel: this.zlevel,
z: this.z,
style: style,
fillColor: style.Switch.limitNameText.fillColor,
fontSize: style.Switch.limitNameText.fontSize,
nameTextX: limitTextX,
nameTextY: limitTextY
});
this.add(this.limitName);
}
this.enabledName = new Text({ // 道岔使能 E 西安二号线独有
zlevel: this.zlevel,
@ -636,7 +651,13 @@ export default class Switch extends Group {
}
model.noStatus && this.setAshShow();
}
setLimitState(flag, limitValue) {
if (flag) {
this.limitName && this.limitName.limitNameShow(limitValue);
} else {
this.limitName && this.limitName.limitNameHide();
}
}
getBoundingRect() {
return this.name.getBoundingRect();
}