2019-11-29 12:51:58 +08:00
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
import TrainBodyBox from './TrainBodyBox';
|
2020-09-15 17:48:08 +08:00
|
|
|
// import '../StationStand/EDetain';
|
2019-11-29 12:51:58 +08:00
|
|
|
import ETextName from '../element/ETextName'; // 名称文字 (共有)
|
|
|
|
import EMouse from './EMouse';
|
2020-12-15 11:18:15 +08:00
|
|
|
import store from '@/store/index';
|
2020-03-02 14:46:59 +08:00
|
|
|
import Circle from 'zrender/src/graphic/shape/Circle';
|
2020-03-09 09:58:49 +08:00
|
|
|
import BoundingRect from 'zrender/src/core/BoundingRect';
|
2020-08-28 17:22:12 +08:00
|
|
|
import Vue from 'vue';
|
2019-11-29 12:51:58 +08:00
|
|
|
|
|
|
|
/** 车身*/
|
|
|
|
export default class TrainBody extends Group {
|
2020-03-09 09:58:49 +08:00
|
|
|
constructor(model) {
|
|
|
|
super();
|
|
|
|
this.model = model;
|
|
|
|
this.deviceModel = model.model;
|
2020-03-25 17:15:16 +08:00
|
|
|
this.style = model.style;
|
2020-03-09 09:58:49 +08:00
|
|
|
this.nameFormat = model.nameFormat;
|
|
|
|
this.create();
|
|
|
|
this.createMouse(); // 鼠标事件
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
create() {
|
|
|
|
const model = this.model;
|
|
|
|
const style = this.model.style;
|
2020-10-28 16:54:57 +08:00
|
|
|
this.nameFormat = model.nameFormat;
|
2020-03-09 09:58:49 +08:00
|
|
|
const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode
|
|
|
|
? (model.directionCode || style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber)
|
2020-10-28 16:54:57 +08:00
|
|
|
: model.tripNumber || style.Train.trainTarget.defaultTripNumber); // 车次号
|
2020-06-17 13:35:21 +08:00
|
|
|
const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (style.Train.trainTargetNumber.lineNumber || '') + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber); // 车组号
|
2020-10-28 16:54:57 +08:00
|
|
|
let serviceNumber = ''; // 服务号(表号)
|
|
|
|
if (this.model.type == 'PLAN') { // 计划车
|
|
|
|
serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || model.model.specialServiceNumber || style.Train.trainServer.defaultServiceNumber);
|
|
|
|
} else if (this.model.type == 'HEAD') { // 头码车
|
|
|
|
serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.destinationCode || style.Train.trainNumber.defaultTargetCode);
|
|
|
|
this.nameFormat = 'serviceNumber:groupNumber';
|
|
|
|
} else if (this.model.type == 'MANUAL') { // 人工车
|
|
|
|
serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || model.model.specialServiceNumber || style.Train.trainServer.defaultServiceHeadNum);
|
|
|
|
this.nameFormat = 'serviceNumber:groupNumber';
|
|
|
|
}
|
|
|
|
let targetCode = style.Train.trainNumber.targetCodePrefix + (model.destinationCode || style.Train.trainNumber.defaultTargetCode); // 目的地码
|
2020-08-28 17:22:12 +08:00
|
|
|
if (Vue.prototype.$jlmap.lineCode == '09') { // 暂时先写死 后面有了删掉就好
|
|
|
|
targetCode = '01';
|
|
|
|
}
|
2020-06-17 13:35:21 +08:00
|
|
|
// 服务号
|
2020-03-09 09:58:49 +08:00
|
|
|
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: model.style.Train.trainServer.fontColor || style.trainTextColor,
|
2020-08-20 16:02:21 +08:00
|
|
|
fontSize: model.style.Train.trainServer.fontSize || model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
2020-06-17 13:35:21 +08:00
|
|
|
// 车次号
|
|
|
|
this.textTrainTrip = new ETextName({
|
2020-03-09 09:58:49 +08:00
|
|
|
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 - style.Train.trainTarget.tripNumberPrefix.length),
|
|
|
|
textFill: model.style.Train.trainTarget.fontColor || style.trainTextColor,
|
2020-08-20 16:02:21 +08:00
|
|
|
fontSize: model.style.Train.trainTarget.fontSize || model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-25 15:22:52 +08:00
|
|
|
textAlign: 'left',
|
2020-03-09 09:58:49 +08:00
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
2020-06-17 13:35:21 +08:00
|
|
|
this.textTrainTarget = new ETextName({
|
2020-03-09 09:58:49 +08:00
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.trainNumber.trainNumberOffset.y),
|
2020-03-25 15:22:52 +08:00
|
|
|
text: targetCode.substring(targetCode.length - style.Train.trainNumber.targetCodePrefix.length),
|
2020-05-14 10:22:13 +08:00
|
|
|
textFill: model.style.Train.trainNumber.fontColor || style.trainTextColor,
|
2020-03-09 09:58:49 +08:00
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
2020-08-20 16:02:21 +08:00
|
|
|
fontSize: model.style.Train.trainNumber.fontSize || model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
2020-06-17 13:35:21 +08:00
|
|
|
this.textTrainGroup = new ETextName({
|
2020-03-09 09:58:49 +08:00
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.trainTargetNumber.trainTargetNumberOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.trainTargetNumber.trainTargetNumberOffset.y),
|
2020-04-15 09:33:21 +08:00
|
|
|
text: groupNumber.substring(groupNumber.length - style.Train.trainTargetNumber.groupNumberPrefix.length),
|
2020-03-09 09:58:49 +08:00
|
|
|
textFill: style.trainTextColor,
|
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
2020-06-16 13:56:33 +08:00
|
|
|
if (style.Train.trainTargetNumber.maskText) {
|
2020-06-17 13:35:21 +08:00
|
|
|
this.textTrainGroupMask = new ETextName({
|
2020-06-16 13:56:33 +08:00
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 2,
|
|
|
|
x: parseInt(model.point.x + style.Train.trainTargetNumber.trainTargetNumberOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.trainTargetNumber.trainTargetNumberOffset.y),
|
|
|
|
text: style.Train.trainTargetNumber.maskText,
|
|
|
|
textFill: style.trainTextColor,
|
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
|
|
|
fontFamily: style.Train.common.fontFamily,
|
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
|
|
|
}
|
2020-03-09 09:58:49 +08:00
|
|
|
this.formatChangePosition(model, style);
|
2020-06-17 13:35:21 +08:00
|
|
|
this.trainBodyBox = new TrainBodyBox({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
point: model.point,
|
2020-08-28 17:22:12 +08:00
|
|
|
speed: model.speed,
|
2020-06-17 13:35:21 +08:00
|
|
|
style: style
|
|
|
|
});
|
|
|
|
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),
|
|
|
|
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),
|
|
|
|
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'
|
|
|
|
}) : '';
|
2020-03-09 09:58:49 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
if (style.Train.common.hasAtrStatus) {
|
2020-03-02 14:46:59 +08:00
|
|
|
this.atrStatus = new Circle({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
shape: {
|
|
|
|
cx: parseInt(model.point.x + style.Train.trainAtrStatus.trainAtrStatusOffset.x),
|
|
|
|
cy: parseInt(model.point.y + style.Train.trainAtrStatus.trainAtrStatusOffset.y),
|
|
|
|
r: style.Train.trainAtrStatus.r
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
fill: '#ff0000'
|
|
|
|
}
|
|
|
|
});
|
2020-03-07 18:57:01 +08:00
|
|
|
// this.add(this.atrStatus);
|
2020-03-02 14:46:59 +08:00
|
|
|
}
|
|
|
|
if (style.Train.common.hasTravelSigns) {
|
2020-05-20 17:08:21 +08:00
|
|
|
const travelSignsOffsetX = this.deviceModel.right ? style.Train.travelSigns.trainTravelRightSignsOffset.x + 4 : style.Train.travelSigns.trainTravelLeftSignsOffset.x;
|
2020-03-09 18:25:25 +08:00
|
|
|
const travelSignsOffsetY = this.deviceModel.right ? style.Train.travelSigns.trainTravelRightSignsOffset.y : style.Train.travelSigns.trainTravelLeftSignsOffset.y;
|
2020-03-02 14:46:59 +08:00
|
|
|
this.travelSigns = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
2020-03-09 09:58:49 +08:00
|
|
|
x: parseInt(model.point.x + travelSignsOffsetX),
|
|
|
|
y: parseInt(model.point.y + travelSignsOffsetY),
|
2020-03-07 18:57:01 +08:00
|
|
|
text: this.deviceModel.right ? '>' : '<',
|
|
|
|
textFill: '#00C300',
|
2020-03-02 14:46:59 +08:00
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-06-02 17:50:56 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
2020-03-02 14:46:59 +08:00
|
|
|
});
|
|
|
|
this.add(this.travelSigns);
|
|
|
|
}
|
|
|
|
if (style.Train.common.hasCrewNum) {
|
|
|
|
this.crewNum = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.crewNum.trainCrewNumOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.crewNum.trainCrewNumOffset.y),
|
|
|
|
text: 'BBB',
|
|
|
|
textFill: style.trainTextColor,
|
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-06-02 17:50:56 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
2020-03-02 14:46:59 +08:00
|
|
|
});
|
|
|
|
this.add(this.crewNum);
|
|
|
|
}
|
|
|
|
if (style.Train.common.hasTravelNum) {
|
|
|
|
this.travelNum = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.travelNum.trainTravelNumOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.travelNum.trainTravelNumOffset.y),
|
2020-05-20 17:08:21 +08:00
|
|
|
text: model.destinationCode,
|
2020-03-07 18:57:01 +08:00
|
|
|
textFill: '#00C300',
|
2020-03-02 14:46:59 +08:00
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-06-02 17:50:56 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
2020-03-02 14:46:59 +08:00
|
|
|
});
|
|
|
|
this.add(this.travelNum);
|
|
|
|
}
|
|
|
|
if (style.Train.common.hasDelayTime) {
|
|
|
|
this.delayTime = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.delayTime.trainDelayTimeOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.delayTime.trainDelayTimeOffset.y),
|
2020-05-20 17:08:21 +08:00
|
|
|
text: model.dt > 0 ? '+' + model.dt : model.dt,
|
2020-03-07 18:57:01 +08:00
|
|
|
textFill: '#DADA00',
|
2020-03-02 14:46:59 +08:00
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-06-02 17:50:56 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
2020-03-02 14:46:59 +08:00
|
|
|
});
|
|
|
|
this.add(this.delayTime);
|
|
|
|
}
|
2021-01-19 16:07:32 +08:00
|
|
|
if (style.Train.common.hasDriveMode) {
|
|
|
|
this.driveModeText = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.driveModeText.driveModeTextOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.driveModeText.driveModeTextOffset.y),
|
|
|
|
text: model.driveMode,
|
|
|
|
textFill: '#DADA00',
|
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
|
|
|
fontFamily: style.Train.common.fontFamily,
|
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
|
|
|
this.add(this.driveModeText);
|
|
|
|
}
|
2020-03-09 09:58:49 +08:00
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
removeTrainDetail() {
|
|
|
|
this.mouseEvent.mouseout();
|
|
|
|
store.dispatch('map/setTrainDetails', null);
|
|
|
|
this.deviceModel.down = false;
|
|
|
|
}
|
|
|
|
setTrainColor(color) {
|
2020-11-20 14:21:57 +08:00
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor('fill', color);
|
|
|
|
// Style('fill', color);
|
2020-03-09 09:58:49 +08:00
|
|
|
}
|
|
|
|
setHShow(isShow) {
|
|
|
|
if (this.textH) {
|
|
|
|
isShow ? this.textH.show() : this.textH.hide();
|
|
|
|
}
|
2020-08-28 17:22:12 +08:00
|
|
|
if (this.style.Train.common.HSDASpliceShow) {
|
|
|
|
isShow ? this.trainBodyBox.buckleTrain() : this.trainBodyBox.release();
|
|
|
|
}
|
2020-03-09 09:58:49 +08:00
|
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setBodyBoxShape(key, color) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor(key, color);
|
|
|
|
}
|
2020-03-03 09:46:50 +08:00
|
|
|
getBoundingRect() {
|
2020-05-14 11:03:24 +08:00
|
|
|
if (this.trainBodyBox) {
|
|
|
|
const tempRect = this.trainBodyBox.getBoundingRect().clone();
|
2020-05-20 14:46:26 +08:00
|
|
|
return tempRect;
|
|
|
|
} else {
|
|
|
|
return new BoundingRect(0, 0, 0, 0);
|
2020-05-14 11:03:24 +08:00
|
|
|
}
|
2020-03-03 09:46:50 +08:00
|
|
|
}
|
2021-01-19 16:07:32 +08:00
|
|
|
setTravelNumColor(color) { // 设置目的地码颜色
|
|
|
|
this.travelNum && this.travelNum.setStyle({ textFill: color });
|
|
|
|
}
|
|
|
|
setServiceColor(color) { // 设置服务号颜色
|
|
|
|
this.textTrainServer && this.textTrainServer.setStyle({ textFill: color });
|
|
|
|
}
|
|
|
|
setTripColor(color) { // 设置车次号颜色
|
|
|
|
this.textTrainTrip && this.textTrainTrip.setStyle({ textFill: color });
|
|
|
|
}
|
2020-06-23 16:21:54 +08:00
|
|
|
getBoundingRectOfFont() { // 获取文字高度
|
2020-05-29 16:55:25 +08:00
|
|
|
if (this.textTrainServer) {
|
|
|
|
const tempRect = this.textTrainServer.getBoundingRect().clone();
|
|
|
|
return tempRect;
|
2020-06-17 13:35:21 +08:00
|
|
|
} else if (this.textTrainTrip) {
|
|
|
|
const tempRect = this.textTrainTrip.getBoundingRect().clone();
|
|
|
|
return tempRect;
|
2020-05-29 16:55:25 +08:00
|
|
|
} else if (this.textTrainTarget) {
|
|
|
|
const tempRect = this.textTrainTarget.getBoundingRect().clone();
|
|
|
|
return tempRect;
|
2020-06-17 13:35:21 +08:00
|
|
|
} else if (this.textTrainGroup) {
|
|
|
|
const tempRect = this.textTrainGroup.getBoundingRect().clone();
|
2020-05-29 16:55:25 +08:00
|
|
|
return tempRect;
|
|
|
|
} else {
|
|
|
|
return new BoundingRect(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2020-05-22 13:05:08 +08:00
|
|
|
setPlanRoutingTypeColor(planRoutingTypes) {
|
|
|
|
if (planRoutingTypes === 'BIG') {
|
2020-06-17 13:35:21 +08:00
|
|
|
this.style.Train.trainTarget.bigColor && this.textTrainTrip && this.textTrainTrip.setStyle({textFill: this.style.Train.trainTarget.bigColor});
|
2020-05-22 13:05:08 +08:00
|
|
|
} else if (planRoutingTypes === 'SMALL') {
|
2020-06-17 13:35:21 +08:00
|
|
|
this.style.Train.trainTarget.smallColor && this.textTrainTrip && this.textTrainTrip.setStyle({textFill: this.style.Train.trainTarget.smallColor});
|
2020-05-22 13:05:08 +08:00
|
|
|
} else if (planRoutingTypes === 'INBOUND') {
|
2020-06-17 13:35:21 +08:00
|
|
|
this.style.Train.trainTarget.inboundColor && this.textTrainTrip && this.textTrainTrip.setStyle({textFill: this.style.Train.trainTarget.inboundColor});
|
2020-05-22 13:05:08 +08:00
|
|
|
}
|
|
|
|
}
|
2020-05-22 14:47:19 +08:00
|
|
|
setTrainTypeColor(type) {
|
|
|
|
if (type === 'PLAN') {
|
2020-06-17 13:35:21 +08:00
|
|
|
this.style.Train.trainTarget.planTypeColor && this.textTrainTrip && this.textTrainTrip.setStyle({textFill: this.style.Train.trainTarget.planTypeColor});
|
2020-05-22 14:47:19 +08:00
|
|
|
} else if (type === 'MANUAL') {
|
2020-06-17 13:35:21 +08:00
|
|
|
this.style.Train.trainTargetNumber.manualTypeColor && this.textTrainGroup && this.textTrainGroup.setStyle({textFill: this.style.Train.trainTargetNumber.manualTypeColor});
|
2020-09-04 17:21:34 +08:00
|
|
|
this.style.Train.trainNumber.manualTypeColor && this.textTrainTarget && this.textTrainTarget.setStyle({textFill: this.style.Train.trainNumber.manualTypeColor});
|
|
|
|
this.style.Train.trainServer.manualTypeColor && this.textTrainServer && this.textTrainServer.setStyle({textFill: this.style.Train.trainServer.manualTypeColor});
|
2020-05-22 14:47:19 +08:00
|
|
|
} else if (type === 'HEAD') {
|
2020-06-17 13:35:21 +08:00
|
|
|
this.style.Train.trainTargetNumber.headTypeColor && this.textTrainGroup && this.textTrainGroup.setStyle({textFill: this.style.Train.trainTargetNumber.headTypeColor});
|
|
|
|
this.style.Train.trainNumber.headTypeColor && this.textTrainTarget && this.textTrainTarget.setStyle({textFill: this.style.Train.trainNumber.headTypeColor});
|
2020-05-22 14:47:19 +08:00
|
|
|
}
|
|
|
|
}
|
2020-05-20 17:08:21 +08:00
|
|
|
setSoonerOrLater(dt) {
|
2020-05-20 17:44:47 +08:00
|
|
|
if (this.style.Train.soonerOrLater && this.style.Train.soonerOrLater.level === 5) {
|
2020-05-20 17:08:21 +08:00
|
|
|
if (dt > 120) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.severeEarlyColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.severeEarlyColor});
|
|
|
|
} else if (dt >= 15 && dt <= 120) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.earlyColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.earlyColor});
|
|
|
|
} else if (dt <= -15 && dt >= -120) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.lateColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.lateColor});
|
|
|
|
} else if (dt < -120) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.severeLateColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.severeLateColor});
|
|
|
|
}
|
2020-05-20 17:44:47 +08:00
|
|
|
} else if (this.style.Train.soonerOrLater && this.style.Train.soonerOrLater.level === 3) {
|
2020-05-22 18:41:23 +08:00
|
|
|
if (dt > 120) {
|
2020-05-21 09:31:16 +08:00
|
|
|
this.style.Train.soonerOrLater.serviceNumber && this.textTrainServer && this.textTrainServer.setStyle({textFill: this.style.Train.soonerOrLater.earlyColor});
|
2020-06-17 13:35:21 +08:00
|
|
|
this.style.Train.soonerOrLater.destinationCode && this.textTrainTarget && this.textTrainTarget.setStyle({textFill: this.style.Train.soonerOrLater.earlyColor});
|
2020-05-21 09:31:16 +08:00
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.earlyColor});
|
2020-05-22 18:41:23 +08:00
|
|
|
} else if (dt < -120) {
|
2020-05-21 09:31:16 +08:00
|
|
|
this.style.Train.soonerOrLater.serviceNumber && this.textTrainServer && this.textTrainServer.setStyle({textFill: this.style.Train.soonerOrLater.lateColor});
|
2020-06-17 13:35:21 +08:00
|
|
|
this.style.Train.soonerOrLater.destinationCode && this.textTrainTarget && this.textTrainTarget.setStyle({textFill: this.style.Train.soonerOrLater.lateColor});
|
2020-05-21 09:31:16 +08:00
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.lateColor});
|
2020-05-20 17:44:47 +08:00
|
|
|
}
|
2020-10-22 16:39:34 +08:00
|
|
|
} else if (this.style.Train.soonerOrLater && this.style.Train.soonerOrLater.level === 6) {
|
|
|
|
if (dt <= 59 && dt >= -59) {
|
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.normalColor});
|
|
|
|
} else if (dt < -59 && dt >= -300) {
|
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.smallLateColor});
|
|
|
|
} else if (dt > 300) {
|
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.bigEarlyColor});
|
|
|
|
} else if (dt < -300) {
|
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.bigLateColor});
|
|
|
|
}
|
2020-05-20 17:08:21 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-09 09:58:49 +08:00
|
|
|
formatChangePosition(model, style) {
|
|
|
|
if (this.nameFormat) {
|
|
|
|
const arr = this.nameFormat.split(':');
|
|
|
|
let widthText = 0;
|
|
|
|
arr.forEach(ele => {
|
|
|
|
if (ele == 'targetCode') {
|
2020-06-17 13:35:21 +08:00
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainTarget.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset) );
|
|
|
|
widthText += this.textTrainTarget.getBoundingRect().width;
|
|
|
|
this.add(this.textTrainTarget);
|
2020-03-09 09:58:49 +08:00
|
|
|
} else if (ele == 'serviceNumber') {
|
2020-03-02 14:46:59 +08:00
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainServer.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
2020-03-09 09:58:49 +08:00
|
|
|
widthText += this.textTrainServer.getBoundingRect().width;
|
|
|
|
this.add(this.textTrainServer);
|
|
|
|
} else if (ele == 'tripNumber') {
|
2020-06-17 13:35:21 +08:00
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainTrip.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
|
|
|
widthText += this.textTrainTrip.getBoundingRect().width;
|
|
|
|
this.add(this.textTrainTrip);
|
2020-03-09 09:58:49 +08:00
|
|
|
} else if (ele == 'groupNumber') {
|
2020-06-17 13:35:21 +08:00
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainGroup.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainGroupMask && this.textTrainGroupMask.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
|
|
|
widthText += this.textTrainGroup.getBoundingRect().width;
|
|
|
|
this.add(this.textTrainGroup);
|
|
|
|
this.textTrainGroupMask && this.add(this.textTrainGroupMask);
|
2020-03-09 09:58:49 +08:00
|
|
|
}
|
|
|
|
});
|
2020-06-17 13:35:21 +08:00
|
|
|
if (style.Train.trainBody.changeTrainWidth) {
|
|
|
|
style.Train.common.trainWidth = widthText + style.Train.common.trainWidthMoreText;
|
|
|
|
}
|
2020-03-09 09:58:49 +08:00
|
|
|
}
|
|
|
|
}
|
2021-01-19 16:07:32 +08:00
|
|
|
setSpeedColor(speed) {
|
|
|
|
const style = this.style;
|
|
|
|
if (speed == 0) {
|
|
|
|
this.crewNum && this.crewNum.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel1});
|
|
|
|
this.textTrainGroup && this.textTrainGroup.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel1});
|
|
|
|
this.driveModeText && this.driveModeText.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel1});
|
|
|
|
} else if (speed < 25) {
|
|
|
|
this.crewNum && this.crewNum.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel2});
|
|
|
|
this.textTrainGroup && this.textTrainGroup.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel2});
|
|
|
|
this.driveModeText && this.driveModeText.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel2});
|
|
|
|
} else if (speed < 60) {
|
|
|
|
this.crewNum && this.crewNum.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel3});
|
|
|
|
this.textTrainGroup && this.textTrainGroup.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel3});
|
|
|
|
this.driveModeText && this.driveModeText.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel3});
|
|
|
|
} else {
|
|
|
|
this.crewNum && this.crewNum.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel4});
|
|
|
|
this.textTrainGroup && this.textTrainGroup.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel4});
|
|
|
|
this.driveModeText && this.driveModeText.setStyle({textFill: style.Train.common.cbtcSpeedColorLevel4});
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 16:02:21 +08:00
|
|
|
setPositionText(model, right) {
|
|
|
|
let widthText = 0;
|
|
|
|
let point = {
|
|
|
|
x: model.x - 10,
|
|
|
|
y: model.y
|
|
|
|
};
|
|
|
|
if (right == 1) {
|
|
|
|
point = {
|
|
|
|
x: model.x - 20,
|
|
|
|
y: model.y
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (this.textTrainTarget) {
|
|
|
|
this.textTrainTarget.attr({
|
|
|
|
style: {
|
|
|
|
x: parseInt(point.x + widthText),
|
|
|
|
y: parseInt(point.y - this.style.Section.line.width),
|
|
|
|
textVerticalAlign: 'middle'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
widthText += this.textTrainTarget.getBoundingRect().width;
|
|
|
|
this.textTrainTarget.dirty();
|
|
|
|
}
|
|
|
|
if (this.textTrainServer) {
|
|
|
|
this.textTrainServer.attr({
|
|
|
|
style: {
|
|
|
|
x: parseInt(point.x + widthText),
|
|
|
|
y: parseInt(point.y - this.style.Section.line.width),
|
|
|
|
textVerticalAlign: 'middle'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
widthText += this.textTrainServer.getBoundingRect().width;
|
|
|
|
this.textTrainServer.dirty();
|
|
|
|
}
|
|
|
|
if (this.textTrainTrip) {
|
|
|
|
this.textTrainTrip.attr({
|
|
|
|
style: {
|
|
|
|
x: parseInt(point.x + widthText),
|
|
|
|
y: parseInt(point.y - this.style.Section.line.width),
|
|
|
|
textVerticalAlign: 'middle'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
widthText += this.textTrainTrip.getBoundingRect().width;
|
|
|
|
this.textTrainTrip.dirty();
|
|
|
|
}
|
|
|
|
if (this.textTrainGroup) {
|
|
|
|
this.textTrainGroup.attr({
|
|
|
|
style: {
|
|
|
|
x: parseInt(point.x + widthText),
|
|
|
|
y: parseInt(point.y - this.style.Section.line.width),
|
|
|
|
textVerticalAlign: 'middle'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
widthText += this.textTrainGroup.getBoundingRect().width;
|
|
|
|
this.textTrainGroup.dirty();
|
|
|
|
}
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|