调整:列车调整

This commit is contained in:
fan 2019-08-08 09:35:28 +08:00
parent db37f69619
commit 05e4fd73bb
13 changed files with 250 additions and 428 deletions

View File

@ -509,13 +509,13 @@ class SkinStyle extends defaultStyle {
},
{
status: '04',
trainLColor: '#A0522D',
trainRColor: '#A0522D'
trainLColor: '#C2C2C2',
trainRColor: '#C2C2C2'
},
{
status: '05',
trainLColor: '#A0522D',
trainRColor: '#A0522D'
trainLColor: '#C2C2C2',
trainRColor: '#C2C2C2'
}
], // 列车运行模式对应车头颜色 01未知 02 ATO自动驾驶模式AM 03 ATP监控下的人工驾驶模式CM 04 限制人工驾驶模式RM 05 非限制人工驾驶模式RM
runControlStatus: [

View File

@ -0,0 +1,243 @@
import Group from 'zrender/src/container/Group';
import TrainBodyBox from './TrainBodyBox';
import '../StationStand/EDetain';
import ETextName from '../element/ETextName'; // 名称文字 (共有)
import EMouse from './EMouse';
import store from '@/store';
/** 车身*/
export default class TrainBody extends Group {
constructor(model) {
super();
this.model = model;
this.deviceModel = model.model;
this.create();
this.createMouse(); // 鼠标事件
}
createMouse() {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
if (this.deviceModel.down) {
store.dispatch('map/setTrainDetails', this.deviceModel);
this.mouseEvent.mouseover();
}
this.on('mouseover', () => {
store.dispatch('map/setTrainDetails', this.deviceModel);
this.mouseEvent.mouseover();
});
this.on('mouseout', () => {
store.dispatch('map/setTrainDetails', null);
this.mouseEvent.mouseout();
});
}
create() {
const model = this.model;
const style = this.model.style;
this.trainBodyBox = new TrainBodyBox({
zlevel: model.zlevel,
z: model.z,
shape: {
x: model.point.x,
y: model.point.y,
width: style.Train.common.trainWidth,
height: style.Train.common.trainHeight
},
style: {
lineWidth: style.Train.trainBody.trainBodyLineWidth,
stroke: style.trainSidelineColor,
fill: style.Train.trainBody.trainBodyFillColor
},
cursor: 'pointer'
});
const beginX = (model.point.x + style.Train.trainBody.lrPadding);
const beginY = (model.point.y - style.Train.hsda.trainHSDATextFontSize - style.Train.hsda.upPaddingHSDA);
const margin = (style.Train.common.trainWidth - style.Train.hsda.lrPaddingHSDA * 2) / 4;
this.textH = style.Train.common.haveTextHSDA ? new ETextName({
zlevel: model.zlevel,
z: model.z,
x: parseInt(beginX + margin * 0),
y: parseInt(beginY),
text: style.Train.hsda.textHContent,
textFill: style.trainYellowColor,
fontSize: style.Train.hsda.trainHSDATextFontSize,
fontFamily: style.Train.common.fontFamily,
textAlign: 'middle',
textVerticalAlign: 'top'
}) : '';
this.textS = style.Train.common.haveTextHSDA ? new ETextName({
zlevel: model.zlevel,
z: model.z,
x: parseInt(beginX + margin * 1),
y: parseInt(beginY),
text: style.Train.hsda.textSContent,
textFill: style.trainBlueColor,
fontSize: style.Train.hsda.trainHSDATextFontSize,
fontFamily: style.Train.common.fontFamily,
textAlign: 'middle',
textVerticalAlign: 'top'
}) : '';
this.textD = style.Train.common.haveTextHSDA ? new ETextName({
zlevel: model.zlevel,
z: model.z,
x: parseInt(beginX + margin * 2),
y: parseInt(beginY),
text: style.Train.hsda.textDContent,
textFill: style.trainGreenColor,
fontSize: style.Train.hsda.trainHSDATextFontSize,
fontFamily: style.Train.common.fontFamily,
textAlign: 'middle',
textVerticalAlign: 'top'
}) : '';
this.textA = style.Train.common.haveTextHSDA ? new ETextName({
zlevel: model.zlevel,
z: model.z,
x: parseInt(beginX + margin * 3),
y: parseInt(beginY),
text: style.Train.hsda.textAContent,
textFill: style.trainRedColor,
fontSize: style.Train.hsda.trainHSDATextFontSize,
fontFamily: style.Train.common.fontFamily,
textAlign: 'middle',
textVerticalAlign: 'top'
}) : '';
let serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || style.Train.trainServer.defaultServiceNumber) + '';// 服务号(表号)
const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode
?(model.directionCode||style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber)
:model.tripNumber || style.Train.trainTarget.defaultTripNumber) + ''; // 车次号
const targetCode = style.Train.trainNumber.targetCodePrefix + (model.targetCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号
this.textTrainServer = new ETextName({
zlevel: model.zlevel,
z: model.z+1,
x: parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x),
y: parseInt(model.point.y + style.Train.trainServer.trainServerOffset.y),
text: serviceNumber.substring(serviceNumber.length - style.Train.trainServer.serviceNumberPrefix.length),
textFill: style.trainTextColor,
fontSize: model.fontSize,
fontFamily: style.Train.common.fontFamily,
textAlign: 'left',
textVerticalAlign: 'top'
});
this.textTrainTarget = new ETextName({
zlevel: this.model.zlevel,
z: this.model.z+1,
x: parseInt(model.point.x + model.style.Train.trainTarget.trainTargetOffset.x),
y: parseInt(model.point.y + model.style.Train.trainTarget.trainTargetOffset.y),
text: tripNumber.substring(tripNumber.length - 3),
textFill: style.trainTextColor,
fontSize: model.fontSize,
fontFamily: style.Train.common.fontFamily,
textAlign: style.Train.trainTarget.trainTargetTextAlign,
textVerticalAlign: 'top'
});
this.textTrainNumber = new ETextName({
zlevel: model.zlevel,
z: model.z+1,
x: parseInt(model.point.x + style.Train.trainBody.lrPadding),
y: parseInt(model.point.y + style.Train.trainBody.upPadding),
text: targetCode.substring(targetCode.length - 3),
textFill: style.trainTextColor,
textStroke: style.trainTextColor,
fontWeight: 400,
textStrokeWidth: 0,
fontSize: model.fontSize,
fontFamily: style.Train.common.fontFamily,
textAlign: 'left',
textVerticalAlign: 'top'
});
this.textTrainTargetNumber = new ETextName({
zlevel: model.zlevel,
z: model.z+1,
x: parseInt(model.point.x - style.Train.trainBody.lrPadding),
y: parseInt(model.point.y + style.Train.trainBody.upPadding),
text: groupNumber.substring(groupNumber.length - 3),
textFill: style.trainTextColor,
textStroke: style.trainTextColor,
textStrokeWidth: 0,
fontSize: model.fontSize,
textAlign: 'left',
textVerticalAlign: 'top'
});
// 根据列车类型设置显示格式
if ( style.Train.trainBody.specialTrainType.length > 0) {
style.Train.trainBody.specialTrainType.some((item) =>{
if (model.type === item.type) {
serviceNumber = item.serviceNumber;
style.Train.trainBody.nameFormat = item.nameFormat;
return true;
}
});
}
this.formatChangePosition(model, style);
this.add(this.trainBodyBox);
if (style.Train.common.haveTextHSDA) {
this.add(this.textH);
this.add(this.textS);
this.add(this.textD);
this.add(this.textA);
}
}
removeTrainDetail() {
this.mouseEvent.mouseout();
store.dispatch('map/setTrainDetails', null);
this.deviceModel.down = false;
}
setTrainColor(color) {
this.trainBodyBox && this.trainBodyBox.setStyle('fill', color);
}
setTextTrainServerColor(color) {
this.textTrainServer.setStyle('textFill', color);
this.textTrainServer.setStyle('textStroke', color);
}
setTextTrainTargetColor(color) {
this.textTrainTarget.setStyle('textFill', color);
this.textTrainTarget.setStyle('textStroke', color);
}
setHShow(isShow) {
if (this.textH) {
isShow ? this.textH.show() : this.textH.hide();
}
}
setSShow(isShow) {
if (this.textS) {
isShow ? this.textS.show() : this.textS.hide();
}
}
setDShow(isShow) {
if (this.textD) {
isShow ? this.textD.show() : this.textD.hide();
}
}
setAShow(isShow) {
if (this.textA) {
isShow ? this.textA.show() : this.textA.hide();
}
}
formatChangePosition(model, style) {
if (style.Train.trainBody.trainNameFormat) {
const arr = style.Train.trainBody.trainNameFormat.split(':');
arr.forEach(ele => {
if (ele == 'targetCode') {
this.textTrainNumber.setStyle('x', parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x));
this.add(this.textTrainNumber);
} else if (ele == 'serviceNumber') {
this.textTrainServer.setStyle('x', parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x));
this.add(this.textTrainServer);
} else if (ele == 'tripNumber') {
this.textTrainTarget.setStyle('x', parseInt(model.point.x + style.Train.trainTarget.trainTargetOffset.x));
this.add(this.textTrainTarget);
} else if (ele == 'groupNumber') {
this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + style.Train.textTrainTargetNumber.trainTargetNumberOffset.x));
this.add(this.textTrainTargetNumber);
}
});
}
}
}

View File

@ -1,83 +0,0 @@
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
export default class TextHSDA extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
create() {
const model = this.model;
this.textH = new Text({
zlevel: model.zlevel,
z: model.z,
style: {
x: parseInt(model.beginX + model.margin * 0),
y: parseInt(model.beginY),
text: 'H',
textFill: model.trainYellowColor,
textFont: model.TextFontHSDA,
textAlign: model.textAlign,
textVerticalAlign: model.textVerticalAlign
}
});
this.textS = new Text({
zlevel: model.zlevel,
z: model.z,
style: {
x: parseInt(model.beginX + model.margin * 1),
y: parseInt(model.beginY),
text: 'S',
textFill: model.trainBlueColor,
textFont: model.TextFontHSDA,
textAlign: model.textAlign,
textVerticalAlign: model.textVerticalAlign
}
});
this.textD = new Text({
zlevel: model.zlevel,
z: model.z,
style: {
x: parseInt(model.beginX + model.margin * 2),
y: parseInt(model.beginY),
text: 'D',
textFill: model.trainGreenColor,
textFont: model.TextFontHSDA,
textAlign: model.textAlign,
textVerticalAlign: model.textVerticalAlign
}
});
this.textA = new Text({
zlevel: model.zlevel,
z: model.z,
style: {
x: parseInt(model.beginX + model.margin * 3),
y: parseInt(model.beginY),
text: 'A',
textFill: model.trainRedColor,
textFont: model.TextFontHSDA,
textAlign: model.textAlign,
textVerticalAlign: model.textVerticalAlign
}
});
this.add(this.textH);
this.add(this.textS);
this.add(this.textD);
this.add(this.textA);
}
setHShow(isShow) {
isShow ? this.textH.show() : this.textH.hide();
}
setSShow(isShow) {
isShow ? this.textS.show() : this.textS.hide();
}
setDShow(isShow) {
isShow ? this.textD.show() : this.textD.hide();
}
setAShow(isShow) {
isShow ? this.textA.show() : this.textA.hide();
}
}

View File

@ -1,37 +0,0 @@
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
/** 目的码 */
export default class TextTrainNumber extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
create() {
const model = this.model;
this.textTrainNumber = new Text({
zlevel: model.zlevel,
z: model.z+1,
style: {
x: parseInt(model.point.x + model.lrPadding),
y: parseInt(model.point.y + model.upPadding),
text: model.targetCode.substring(model.targetCode.length - 3),
textFill: model.trainTextColor,
textStroke: model.trainTextColor,
fontWeight: 400,
textStrokeWidth: 0,
textFont: model.textFont,
textAlign: 'left',
textVerticalAlign: 'top',
onmouseover: model.onmouseover,
onmouseout: model.onmouseout
},
cursor: 'pointer'
});
this.add(this.textTrainNumber);
}
setShapeStyle(key, style) {
this.textTrainNumber.setStyle(key, style);
}
}

View File

@ -1,35 +0,0 @@
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
/** 服务号、表号 */
export default class TextTrainServer extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
create() {
this.textTrainServer = new Text({
zlevel: this.model.zlevel,
z: this.model.z+1,
style: {
x: parseInt(this.model.point.x + this.model.style.Train.trainServer.trainServerOffset.x),
y: parseInt(this.model.point.y + this.model.style.Train.trainServer.trainServerOffset.y),
text: this.model.serviceNumber.substring(this.model.serviceNumber.length - this.model.style.Train.trainServer.serviceNumberPrefix.length),
textFill: this.model.trainBrownColor,
textFont: this.model.textFont,
textAlign: 'left',
textVerticalAlign: 'top',
onmouseover: this.model.onmouseover,
onmouseout: this.model.onmouseout
},
cursor: 'pointer'
});
this.add(this.textTrainServer);
}
setColor(key, color) {
this.textTrainServer.setStyle(key, color);
}
setShapeStyle(key, style) {
this.textTrainServer.setStyle(key, style);
}
}

View File

@ -1,35 +0,0 @@
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
export default class TextTrainTarget extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
create() {
this.textTrainTarget = new Text({
zlevel: this.model.zlevel,
z: this.model.z+1,
style: {
x: parseInt(this.model.point.x + this.model.style.Train.trainTarget.trainTargetOffset.x),
y: parseInt(this.model.point.y + this.model.style.Train.trainTarget.trainTargetOffset.y),
text: this.model.tripNumber.substring(this.model.tripNumber.length - 3),
textFill: this.model.trainYellowColor,
textFont: this.model.textFont,
textAlign: this.model.style.Train.trainTarget.trainTargetTextAlign,
textVerticalAlign: 'top',
onmouseover: this.model.onmouseover,
onmouseout: this.model.onmouseout
},
cursor: 'pointer'
});
this.add(this.textTrainTarget);
}
setColor(key, color) {
this.textTrainTarget.setStyle(key, color);
}
setShapeStyle(key, style) {
this.textTrainTarget.setStyle(key, style);
}
}

View File

@ -1,35 +0,0 @@
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
/** 车组号 */
export default class TextTrainTargetNumber extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
create() {
const model = this.model;
this.textTrainTargetNumber = new Text({
zlevel: model.zlevel,
z: model.z+1,
style: {
x: parseInt(model.point.x - model.lrPadding),
y: parseInt(model.point.y + model.upPadding),
text: model.groupNumber.substring(model.groupNumber.length - 3),
textFill: model.trainTextColor,
textStroke: model.trainTextColor,
textStrokeWidth: 0,
textFont: model.textFont,
textAlign: 'left',
textVerticalAlign: 'top',
onmouseover: model.onmouseover,
onmouseout: model.onmouseout
},
cursor: 'pointer'
});
this.add(this.textTrainTargetNumber);
}
setShapeStyle(key, style) {
this.textTrainTargetNumber.setStyle(key, style);
}
}

View File

@ -1,197 +0,0 @@
import Group from 'zrender/src/container/Group';
import Train from './Train';
import '../../StationStand/EDetain';
import TextHSDA from './TextHSDA';
import TextTrainServer from './TextTrainServer';
import TextTrainTarget from './TextTrainTarget';
import TextTrainNumber from './TextTrainNumber';
import TextTrainTargetNumber from './TextTrainTargetNumber';
import EMouse from './EMouse';
import store from '@/store';
/** 车身*/
export default class TrainBody extends Group {
constructor(model) {
super();
this.model = model;
this.deviceModel = model.model;
this.create();
this.createMouse(); // 鼠标事件
}
createMouse() {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
if (this.deviceModel.down) {
store.dispatch('map/setTrainDetails', this.deviceModel);
this.mouseEvent.mouseover();
}
this.on('mouseover', () => {
store.dispatch('map/setTrainDetails', this.deviceModel);
this.mouseEvent.mouseover();
});
this.on('mouseout', () => {
store.dispatch('map/setTrainDetails', null);
this.mouseEvent.mouseout();
});
}
create() {
const model = this.model;
const style = this.model.style;
const textFont = model.fontSize + 'px ' + style.Train.common.fontFamily;
const TextFontHSDA = style.Train.hsda.trainHSDATextFontSize + 'px ' + style.Train.common.fontFamily;
this.train = new Train({
zlevel: model.zlevel,
z: model.z,
shape: {
x: model.point.x,
y: model.point.y,
width: style.Train.common.trainWidth,
height: style.Train.common.trainHeight
},
style: {
lineWidth: style.Train.trainBody.trainBodyLineWidth,
stroke: style.trainSidelineColor,
fill: style.Train.trainBody.trainBodyFillColor
},
cursor: 'pointer'
});
const beginX = (model.point.x + style.Train.trainBody.lrPadding);
const beginY = (model.point.y - style.Train.hsda.trainHSDATextFontSize - style.Train.hsda.upPaddingHSDA);
const margin = (style.Train.common.trainWidth - style.Train.hsda.lrPaddingHSDA * 2) / 4;
this.textHSDA = style.Train.common.haveTextHSDA ? new TextHSDA({
zlevel: model.zlevel,
z: model.z,
beginX: beginX,
beginY: beginY,
margin: margin,
trainYellowColor: style.trainYellowColor,
trainBlueColor: style.trainBlueColor,
textFontHSDA: TextFontHSDA,
textAlign: 'middle',
textVerticalAlign: 'top'
}) : '';
let serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || style.Train.trainServer.defaultServiceNumber) + '';// 服务号(表号)
const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode
?(model.directionCode||style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber)
:model.tripNumber || style.Train.trainTarget.defaultTripNumber) + ''; // 车次号
const targetCode = style.Train.trainNumber.targetCodePrefix + (model.targetCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号
this.textTrainServer = new TextTrainServer({
zlevel: model.zlevel,
z: model.z,
point: model.point,
style: style,
serviceNumber: serviceNumber,
trainBrownColor: style.trainTextColor,
textFont: textFont
});
this.textTrainTarget = new TextTrainTarget({
zlevel: model.zlevel,
z: model.z,
point: model.point,
trainWidth: model.style.Train.common.trainWidth,
style: style,
tripNumber: tripNumber,
trainYellowColor: style.trainTextColor,
textFont: textFont
});
this.textTrainNumber = new TextTrainNumber({
zlevel: model.zlevel,
z: model.z,
point: model.point,
lrPadding: style.Train.trainBody.lrPadding,
upPadding: style.Train.trainBody.upPadding,
targetCode: targetCode,
trainTextColor: style.trainTextColor,
textFont: textFont
});
this.textTrainTargetNumber = new TextTrainTargetNumber({
zlevel: model.zlevel,
z: model.z,
point: model.point,
lrPadding: style.Train.lrPadding,
upPadding: style.Train.upPadding,
groupNumber: groupNumber,
trainTextColor: style.trainTextColor,
textFont: textFont
});
// 根据列车类型设置显示格式
if ( style.Train.trainBody.specialTrainType.length > 0) {
style.Train.trainBody.specialTrainType.some((item) =>{
if (model.type === item.type) {
serviceNumber = item.serviceNumber;
style.Train.trainBody.nameFormat = item.nameFormat;
return true;
}
});
}
this.formatChangePosition(model, style);
this.add(this.train);
this.add(this.arrowText);
this.add(this.textHSDA);
}
removeTrainDetail() {
this.mouseEvent.mouseout();
store.dispatch('map/setTrainDetails', null);
this.deviceModel.down = false;
}
setTrainColor(color) {
this.train && this.train.setColor('fill', color);
}
setTextTrainServerColor(color) {
this.textTrainServer.setColor('textFill', color);
this.textTrainServer.setColor('textStroke', color);
}
setTextTrainTargetColor(color) {
this.textTrainTarget.setColor('textFill', color);
this.textTrainTarget.setColor('textStroke', color);
}
setHShow(isShow) {
this.textHSDA && this.textHSDA.setHShow(isShow);
}
setSShow(isShow) {
this.textHSDA && this.textHSDA.setSShow(isShow);
}
setDShow(isShow) {
this.textHSDA && this.textHSDA.setDShow(isShow);
}
setAShow(isShow) {
this.textHSDA && this.textHSDA.setAShow(isShow);
}
onMouseOver() {
this.arrowText.setShapeStyle('x', this.model.point.x+50);
this.arrowText.setShapeStyle('y', this.model.point.y+25);
this.arrowText.getArrowText().show();
}
formatChangePosition(model, style) {
if (style.Train.trainBody.trainNameFormat) {
const arr = style.Train.trainBody.trainNameFormat.split(':');
arr.forEach(ele => {
if (ele == 'targetCode') {
this.textTrainNumber.setShapeStyle('x', parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x));
this.add(this.textTrainNumber);
} else if (ele == 'serviceNumber') {
this.textTrainServer.setShapeStyle('x', parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x));
this.add(this.textTrainServer);
} else if (ele == 'tripNumber') {
this.textTrainTarget.setShapeStyle('x', parseInt(model.point.x + style.Train.trainTarget.trainTargetOffset.x));
this.add(this.textTrainTarget);
} else if (ele == 'groupNumber') {
this.textTrainTargetNumber.setShapeStyle('x', parseInt(model.point.x + style.Train.textTrainTargetNumber.trainTargetNumberOffset.x));
this.add(this.textTrainTargetNumber);
}
});
}
}
}

View File

@ -1,6 +1,6 @@
import Group from 'zrender/src/container/Group';
import TrainHead from './TrainHead/index';
import TrainBody from './TrainBody/index';
import TrainHead from './TrainHead';
import TrainBody from './TrainBody';
import BoundingRect from 'zrender/src/core/BoundingRect';
import Rect from 'zrender/src/graphic/shape/Rect';

View File

@ -15,6 +15,7 @@ export default function ETextName(model) {
fontSize: model.fontSize,
fontFamily: model.fontFamily,
text: model.text,
textStrokeWidth: model.textStrokeWidth,
textFill: model.textFill,
textAlign: model.textAlign,
textPosition: model.textPosition || 'inside',