列车精确定位代码调整

列车的状态信息调整
去掉仿真里的拖动鼠标生成包围框
This commit is contained in:
joylink_cuiweidong 2020-03-12 14:41:53 +08:00
parent b7ee3e5f6e
commit 56126bdbf3
9 changed files with 328 additions and 260 deletions

View File

@ -7,234 +7,234 @@ import store from '@/store';
/** 车身*/ /** 车身*/
export default class TrainBody extends Group { export default class TrainBody extends Group {
constructor(model) { constructor(model) {
super(); super();
this.model = model; this.model = model;
this.deviceModel = model.model; this.deviceModel = model.model;
this.nameFormat = model.nameFormat; this.nameFormat = model.nameFormat;
this.create(); this.create();
this.createMouse(); // 鼠标事件 this.createMouse(); // 鼠标事件
} }
createMouse() { createMouse() {
this.mouseEvent = new EMouse(this); this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent); this.add(this.mouseEvent);
if (this.deviceModel.down) { if (this.deviceModel.down) {
store.dispatch('map/setTrainDetails', this.deviceModel); store.dispatch('map/setTrainDetails', this.deviceModel);
this.mouseEvent.mouseover(); this.mouseEvent.mouseover();
} }
this.on('mouseover', () => { this.on('mouseover', () => {
store.dispatch('map/setTrainDetails', this.deviceModel); store.dispatch('map/setTrainDetails', this.deviceModel);
this.mouseEvent.mouseover(); this.mouseEvent.mouseover();
}); });
this.on('mouseout', () => { this.on('mouseout', () => {
store.dispatch('map/setTrainDetails', null); store.dispatch('map/setTrainDetails', null);
this.mouseEvent.mouseout(); this.mouseEvent.mouseout();
}); });
} }
create() { create() {
const model = this.model; const model = this.model;
const style = this.model.style; const style = this.model.style;
this.trainBodyBox = new TrainBodyBox({ this.trainBodyBox = new TrainBodyBox({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z, z: model.z,
point: model.point, point: model.point,
style: style style: style
}); });
const beginX = (model.point.x + style.Train.trainBody.lrPadding); const beginX = (model.point.x + style.Train.trainBody.lrPadding);
const beginY = (model.point.y - style.Train.hsda.trainHSDATextFontSize - style.Train.hsda.upPaddingHSDA); 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; const margin = (style.Train.common.trainWidth - style.Train.hsda.lrPaddingHSDA * 2) / 4;
this.textH = style.Train.common.haveTextHSDA ? new ETextName({ this.textH = style.Train.common.haveTextHSDA ? new ETextName({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z, z: model.z,
x: parseInt(beginX + margin * 0), x: parseInt(beginX + margin * 0),
y: parseInt(beginY), y: parseInt(beginY),
text: style.Train.hsda.textHContent, text: style.Train.hsda.textHContent,
textFill: style.trainYellowColor, textFill: style.trainYellowColor,
fontSize: style.Train.hsda.trainHSDATextFontSize, fontSize: style.Train.hsda.trainHSDATextFontSize,
fontFamily: style.Train.common.fontFamily, fontFamily: style.Train.common.fontFamily,
textAlign: 'middle', textAlign: 'middle',
textVerticalAlign: 'top' textVerticalAlign: 'top'
}) : ''; }) : '';
this.textS = style.Train.common.haveTextHSDA ? new ETextName({ this.textS = style.Train.common.haveTextHSDA ? new ETextName({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z, z: model.z,
x: parseInt(beginX + margin * 1), x: parseInt(beginX + margin * 1),
y: parseInt(beginY), y: parseInt(beginY),
text: style.Train.hsda.textSContent, text: style.Train.hsda.textSContent,
textFill: style.trainBlueColor, textFill: style.trainBlueColor,
fontSize: style.Train.hsda.trainHSDATextFontSize, fontSize: style.Train.hsda.trainHSDATextFontSize,
fontFamily: style.Train.common.fontFamily, fontFamily: style.Train.common.fontFamily,
textAlign: 'middle', textAlign: 'middle',
textVerticalAlign: 'top' textVerticalAlign: 'top'
}) : ''; }) : '';
this.textD = style.Train.common.haveTextHSDA ? new ETextName({ this.textD = style.Train.common.haveTextHSDA ? new ETextName({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z, z: model.z,
x: parseInt(beginX + margin * 2), x: parseInt(beginX + margin * 2),
y: parseInt(beginY), y: parseInt(beginY),
text: style.Train.hsda.textDContent, text: style.Train.hsda.textDContent,
textFill: style.trainGreenColor, textFill: style.trainGreenColor,
fontSize: style.Train.hsda.trainHSDATextFontSize, fontSize: style.Train.hsda.trainHSDATextFontSize,
fontFamily: style.Train.common.fontFamily, fontFamily: style.Train.common.fontFamily,
textAlign: 'middle', textAlign: 'middle',
textVerticalAlign: 'top' textVerticalAlign: 'top'
}) : ''; }) : '';
this.textA = style.Train.common.haveTextHSDA ? new ETextName({ this.textA = style.Train.common.haveTextHSDA ? new ETextName({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z, z: model.z,
x: parseInt(beginX + margin * 3), x: parseInt(beginX + margin * 3),
y: parseInt(beginY), y: parseInt(beginY),
text: style.Train.hsda.textAContent, text: style.Train.hsda.textAContent,
textFill: style.trainRedColor, textFill: style.trainRedColor,
fontSize: style.Train.hsda.trainHSDATextFontSize, fontSize: style.Train.hsda.trainHSDATextFontSize,
fontFamily: style.Train.common.fontFamily, fontFamily: style.Train.common.fontFamily,
textAlign: 'middle', textAlign: 'middle',
textVerticalAlign: 'top' textVerticalAlign: 'top'
}) : ''; }) : '';
const serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || style.Train.trainServer.defaultServiceNumber) + '';// 服务号(表号) const serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || style.Train.trainServer.defaultServiceNumber) + '';// 服务号(表号)
const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode
?(model.directionCode||style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber) ? (model.directionCode || style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber)
: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 targetCode = style.Train.trainNumber.targetCodePrefix + (model.destinationCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号 const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号
this.textTrainServer = new ETextName({ this.textTrainServer = new ETextName({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z+1, z: model.z + 1,
x: parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x), x: parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x),
y: parseInt(model.point.y + style.Train.trainServer.trainServerOffset.y), y: parseInt(model.point.y + style.Train.trainServer.trainServerOffset.y),
text: serviceNumber.substring(serviceNumber.length - style.Train.trainServer.serviceNumberPrefix.length), text: serviceNumber.substring(serviceNumber.length - style.Train.trainServer.serviceNumberPrefix.length),
textFill: style.trainTextColor, textFill: style.trainTextColor,
fontSize: model.fontSize, fontSize: model.fontSize,
fontFamily: style.Train.common.fontFamily, fontFamily: style.Train.common.fontFamily,
textAlign: 'left', textAlign: 'left',
textVerticalAlign: 'top' textVerticalAlign: 'top'
}); });
this.textTrainTarget = new ETextName({ this.textTrainTarget = new ETextName({
zlevel: this.model.zlevel, zlevel: this.model.zlevel,
z: this.model.z+1, z: this.model.z + 1,
x: parseInt(model.point.x + model.style.Train.trainTarget.trainTargetOffset.x), x: parseInt(model.point.x + model.style.Train.trainTarget.trainTargetOffset.x),
y: parseInt(model.point.y + model.style.Train.trainTarget.trainTargetOffset.y), y: parseInt(model.point.y + model.style.Train.trainTarget.trainTargetOffset.y),
text: tripNumber.substring(tripNumber.length - style.Train.trainTarget.tripNumberPrefix.length), text: tripNumber.substring(tripNumber.length - style.Train.trainTarget.tripNumberPrefix.length),
textFill: style.trainTextColor, textFill: style.trainTextColor,
fontSize: model.fontSize, fontSize: model.fontSize,
fontFamily: style.Train.common.fontFamily, fontFamily: style.Train.common.fontFamily,
textAlign: style.Train.trainTarget.trainTargetTextAlign, textAlign: style.Train.trainTarget.trainTargetTextAlign,
textVerticalAlign: 'top' textVerticalAlign: 'top'
}); });
this.textTrainNumber = new ETextName({ this.textTrainNumber = new ETextName({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z+1, z: model.z + 1,
x: parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x), x: parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x),
y: parseInt(model.point.y + style.Train.trainNumber.trainNumberOffset.y), y: parseInt(model.point.y + style.Train.trainNumber.trainNumberOffset.y),
text: targetCode.substring(targetCode.length - 3), text: targetCode.substring(targetCode.length - 3),
textFill: style.trainTextColor, textFill: style.trainTextColor,
textStroke: style.trainTextColor, textStroke: style.trainTextColor,
fontWeight: 400, fontWeight: 400,
textStrokeWidth: 0, textStrokeWidth: 0,
fontSize: model.fontSize, fontSize: model.fontSize,
fontFamily: style.Train.common.fontFamily, fontFamily: style.Train.common.fontFamily,
textAlign: 'left', textAlign: 'left',
textVerticalAlign: 'top' textVerticalAlign: 'top'
}); });
this.textTrainTargetNumber = new ETextName({ this.textTrainTargetNumber = new ETextName({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z+1, z: model.z + 1,
x: parseInt(model.point.x - style.Train.trainBody.lrPadding), x: parseInt(model.point.x - style.Train.trainBody.lrPadding),
y: parseInt(model.point.y + style.Train.trainBody.upPadding), y: parseInt(model.point.y + style.Train.trainBody.upPadding),
text: groupNumber.substring(groupNumber.length - 3), text: groupNumber.substring(groupNumber.length - 3),
textFill: style.trainTextColor, textFill: style.trainTextColor,
textStroke: style.trainTextColor, textStroke: style.trainTextColor,
textStrokeWidth: 0, textStrokeWidth: 0,
fontSize: model.fontSize, fontSize: model.fontSize,
fontFamily: style.Train.common.fontFamily, fontFamily: style.Train.common.fontFamily,
textAlign: 'left', textAlign: 'left',
textVerticalAlign: 'top' textVerticalAlign: 'top'
}); });
this.formatChangePosition(model, style); this.formatChangePosition(model, style);
this.add(this.trainBodyBox); this.add(this.trainBodyBox);
if (style.Train.common.haveTextHSDA) { if (style.Train.common.haveTextHSDA) {
this.add(this.textH); this.add(this.textH);
this.add(this.textS); this.add(this.textS);
this.add(this.textD); this.add(this.textD);
this.add(this.textA); this.add(this.textA);
} }
} }
removeTrainDetail() { removeTrainDetail() {
this.mouseEvent.mouseout(); this.mouseEvent.mouseout();
store.dispatch('map/setTrainDetails', null); store.dispatch('map/setTrainDetails', null);
this.deviceModel.down = false; this.deviceModel.down = false;
} }
setTrainColor(color) { setTrainColor(color) {
this.trainBodyBox && this.trainBodyBox.setStyle('fill', color); this.trainBodyBox && this.trainBodyBox.setStyle('fill', color);
} }
setTextTrainServerColor(color) { setTextTrainServerColor(color) {
this.textTrainServer&&this.textTrainServer.setStyle('textFill', color); this.textTrainServer && this.textTrainServer.setStyle('textFill', color);
this.textTrainServer&&this.textTrainServer.setStyle('textStroke', color); this.textTrainServer && this.textTrainServer.setStyle('textStroke', color);
} }
setTextTrainTargetColor(color) { setTextTrainTargetColor(color) {
this.textTrainTarget&&this.textTrainTarget.setStyle('textFill', color); this.textTrainTarget && this.textTrainTarget.setStyle('textFill', color);
this.textTrainTarget&&this.textTrainTarget.setStyle('textStroke', color); this.textTrainTarget && this.textTrainTarget.setStyle('textStroke', color);
} }
setTextTrainNumberColor(color) { setTextTrainNumberColor(color) {
this.textTrainNumber&&this.textTrainNumber.setStyle('textFill', color); this.textTrainNumber && this.textTrainNumber.setStyle('textFill', color);
this.textTrainNumber&&this.textTrainNumber.setStyle('textStroke', color); this.textTrainNumber && this.textTrainNumber.setStyle('textStroke', color);
} }
setTextTrainTargetNumberColor(color) { setTextTrainTargetNumberColor(color) {
this.textTrainTargetNumber&&this.textTrainTargetNumber.setStyle('textFill', color); this.textTrainTargetNumber && this.textTrainTargetNumber.setStyle('textFill', color);
this.textTrainTargetNumber&&this.textTrainTargetNumber.setStyle('textStroke', color); this.textTrainTargetNumber && this.textTrainTargetNumber.setStyle('textStroke', color);
} }
setHShow(isShow) { setHShow(isShow) {
if (this.textH) { if (this.textH) {
isShow ? this.textH.show() : this.textH.hide(); isShow ? this.textH.show() : this.textH.hide();
} }
} }
setSShow(isShow) { setSShow(isShow) {
if (this.textS) { if (this.textS) {
isShow ? this.textS.show() : this.textS.hide(); isShow ? this.textS.show() : this.textS.hide();
} }
} }
setDShow(isShow) { setDShow(isShow) {
if (this.textD) { if (this.textD) {
isShow ? this.textD.show() : this.textD.hide(); isShow ? this.textD.show() : this.textD.hide();
} }
} }
setAShow(isShow) { setAShow(isShow) {
if (this.textA) { if (this.textA) {
isShow ? this.textA.show() : this.textA.hide(); isShow ? this.textA.show() : this.textA.hide();
} }
} }
setBodyBoxShape(key, color) { setBodyBoxShape(key, color) {
this.trainBodyBox && this.trainBodyBox.setColor(key, color); this.trainBodyBox && this.trainBodyBox.setColor(key, color);
} }
formatChangePosition(model, style) { formatChangePosition(model, style) {
if (this.nameFormat) { if (this.nameFormat) {
const arr = this.nameFormat.split(':'); const arr = this.nameFormat.split(':');
let widthText = 0; let widthText = 0;
arr.forEach(ele => { arr.forEach(ele => {
if (ele == 'targetCode') { if (ele == 'targetCode') {
this.textTrainNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset) ); this.textTrainNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset) );
widthText += this.textTrainNumber.getBoundingRect().width; widthText += this.textTrainNumber.getBoundingRect().width;
this.add(this.textTrainNumber); this.add(this.textTrainNumber);
} else if (ele == 'serviceNumber') { } else if (ele == 'serviceNumber') {
this.textTrainServer.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset)); this.textTrainServer.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
widthText += this.textTrainServer.getBoundingRect().width; widthText += this.textTrainServer.getBoundingRect().width;
this.add(this.textTrainServer); this.add(this.textTrainServer);
} else if (ele == 'tripNumber') { } else if (ele == 'tripNumber') {
this.textTrainTarget.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset)); this.textTrainTarget.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
widthText += this.textTrainTarget.getBoundingRect().width; widthText += this.textTrainTarget.getBoundingRect().width;
this.add(this.textTrainTarget); this.add(this.textTrainTarget);
} else if (ele == 'groupNumber') { } else if (ele == 'groupNumber') {
this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset)); this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
widthText += this.textTrainTargetNumber.getBoundingRect().width; widthText += this.textTrainTargetNumber.getBoundingRect().width;
this.add(this.textTrainTargetNumber); this.add(this.textTrainTargetNumber);
} }
}); });
} }
} }
} }

View File

@ -43,6 +43,7 @@ class Jlmap {
const width = opts.dom.clientWidth; const width = opts.dom.clientWidth;
const height = opts.dom.clientHeight; const height = opts.dom.clientHeight;
this.zoomOnMouseWheel = opts.options.zoomOnMouseWheel; this.zoomOnMouseWheel = opts.options.zoomOnMouseWheel;
this.previewOrMapDraw = opts.showConfig.previewOrMapDraw;
this.$zr = zrender.init(opts.dom, deepAssign({ renderer, devicePixelRatio, width, height }, opts.config)); this.$zr = zrender.init(opts.dom, deepAssign({ renderer, devicePixelRatio, width, height }, opts.config));
@ -137,6 +138,7 @@ class Jlmap {
this.$mouseController.disable(); this.$mouseController.disable();
} else { } else {
opts['zoomOnMouseWheel'] = this.zoomOnMouseWheel; opts['zoomOnMouseWheel'] = this.zoomOnMouseWheel;
opts['previewOrMapDraw'] = this.previewOrMapDraw;
this.$mouseController.enable(opts); this.$mouseController.enable(opts);
} }

View File

@ -54,6 +54,7 @@ class MouseController extends Eventful {
this._moveOnMouseMove = opts.moveOnMouseMove || true; this._moveOnMouseMove = opts.moveOnMouseMove || true;
this._zoomOnMouseWheel = opts.zoomOnMouseWheel || false; this._zoomOnMouseWheel = opts.zoomOnMouseWheel || false;
this._preventDefaultMouseMove = opts.preventDefaultMouseMove || true; this._preventDefaultMouseMove = opts.preventDefaultMouseMove || true;
this._previewOrMapDraw = opts.previewOrMapDraw || false;
this.disable(); this.disable();
@ -121,7 +122,7 @@ class MouseController extends Eventful {
this._preventDefaultMouseMove && eventTool.stop(e.event); this._preventDefaultMouseMove && eventTool.stop(e.event);
this.trigger(this.events.__Pan, { dx, dy, oldX, oldY, newX: this._x, newY: this._y }); this.trigger(this.events.__Pan, { dx, dy, oldX, oldY, newX: this._x, newY: this._y });
} else if (e.which === 3 && this._zoomOnMouseWheel) { } else if (e.which === 3 && this._zoomOnMouseWheel && this._previewOrMapDraw) {
this.handleMouseMoveRight({x: e.offsetX, y: e.offsetY}); this.handleMouseMoveRight({x: e.offsetX, y: e.offsetY});
} }
} }

View File

@ -27,9 +27,9 @@ class EMouse extends Group {
} }
let text = ''; let text = '';
if (LangStorage.getLang() == 'en') { if (LangStorage.getLang() == 'en') {
text = ` The planned train: ${trainType} \n Table No.: ${this.device.model.serviceNumber} \n Train Trip No.: ${this.device.model.tripNumber}\n Destination: ${this.device.model.targetCode ? this.device.model.targetCode : ''}\n Train No.: ${this.device.model.groupNumber}\n Early or late: ${destinationText}\n Direction: ${this.device.model.directionType == '02' ? 'up' : 'down'}\n Crew No.: \n Start Station: \n Terminal Station: \n Occupied Track: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n Current Station: \n Train-ground communication: normal \n Operation Speed level: 4 \n Detained: ${!this.device.model.hold ? 'Normal' : 'Detained'}\n \n 跳停状态: ${!this.device.model.jump ? 'Normal' : 'Skip to continue moving'}Stationary: ${!this.device.model.stop ? 'No' : 'Yes'}\n Blocked: No \n Speed: ${this.device.model.speed || 0} km/h \n Authorized Distance: ${this.device.model.maLen || 0} m`; text = ` The planned train: ${trainType} \n Table No.: ${this.device.model.serviceNumber} \n Train Trip No.: ${this.device.model.tripNumber}\n Destination: ${this.device.model.destinationCode ? this.device.model.destinationCode : ''}\n Train No.: ${this.device.model.groupNumber}\n Early or late: ${destinationText}\n Direction: ${this.device.model.directionType == '02' ? 'up' : 'down'}\n Crew No.: \n Start Station: \n Terminal Station: \n Occupied Track: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n Current Station: \n Train-ground communication: normal \n Operation Speed level: 4 \n Detained: ${!this.device.model.hold ? 'Normal' : 'Detained'}\n \n 跳停状态: ${!this.device.model.jump ? 'Normal' : 'Skip to continue moving'}Stationary: ${!this.device.model.stop ? 'No' : 'Yes'}\n Blocked: No \n Speed: ${this.device.model.speed || 0} km/h \n Authorized Distance: ${this.device.model.maLen || 0} m`;
} else { } else {
text = `列车类型: ${trainType} \n\0\0\0\0号: ${this.device.model.serviceNumber}\n\0\0号: ${this.device.model.tripNumber}\n目的地号: ${this.device.model.targetCode ? this.device.model.targetCode : ''}\n\0\0号: ${this.device.model.groupNumber}\n\0\0点: ${destinationText}\n运行方向: ${this.device.model.directionType == '02' ? '上行' : '下行'}\n乘务组号: \n起点站名: \n终点站名: \n占用轨道: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n所在车站: \n车地通信: 正常\n运行等级: 4\n扣车状态: ${ !this.device.model.hold ? '正常' : '扣车'}\n 跳停状态: ${!this.device.model.jump ? '正常' : '跳停'} \n停稳状态: ${!this.device.model.stop ? '未停稳' : '停稳'}\n阻塞状态: 无\n列车速度: ${this.device.model.speed || 0} km/h\n列车移动授权距离: ${this.device.model.maLen || 0} m`; text = `列车类型: ${trainType} \n\0\0\0\0号: ${this.device.model.serviceNumber}\n\0\0号: ${this.device.model.tripNumber}\n目的地号: ${this.device.model.destinationCode ? this.device.model.destinationCode : ''}\n\0\0号: ${this.device.model.groupNumber}\n\0\0点: ${destinationText}\n运行方向: ${this.device.model.directionType == '02' ? '上行' : '下行'}\n乘务组号: \n起点站名: \n终点站名: \n占用轨道: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n所在车站: \n车地通信: 正常\n运行等级: 4\n扣车状态: ${ !this.device.model.hold ? '正常' : '扣车'}\n 跳停状态: ${!this.device.model.jump ? '正常' : '跳停'} \n停稳状态: ${!this.device.model.stop ? '未停稳' : '停稳'}\n阻塞状态: 无\n列车速度: ${this.device.model.speed || 0} km/h\n列车移动授权距离: ${this.device.model.maLen || 0} m`;
} }
// 文字描述 // 文字描述
this.arrowText = new Text({ this.arrowText = new Text({

View File

@ -21,9 +21,9 @@ export default class ETriangle extends Group {
points:[[model.point.x + 10 * right, model.point.y], [model.point.x, model.point.y - 6], [model.point.x, model.point.y + 6]] points:[[model.point.x + 10 * right, model.point.y], [model.point.x, model.point.y - 6], [model.point.x, model.point.y + 6]]
}, },
style: { style: {
stroke:'#FFFF00', stroke:'#00FF00',
lineWidth: 0.5, lineWidth: 0.5,
fill: '#FFFF00' fill: '#00FF00'
} }
}); });
this.add(this.angle); this.add(this.angle);

View File

@ -102,7 +102,7 @@ export default class TrainBody extends Group {
const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode
? (model.directionCode || style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber) ? (model.directionCode || style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber)
: 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 targetCode = style.Train.trainNumber.targetCodePrefix + (model.destinationCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号 const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号
this.textTrainServer = new ETextName({ this.textTrainServer = new ETextName({
zlevel: model.zlevel, zlevel: model.zlevel,

View File

@ -18,6 +18,7 @@ export default class Train extends Group {
this.z = 40; this.z = 40;
this.size = 0; this.size = 0;
this.section = null; this.section = null;
this.nextPointIndex = 1;
this.fontSize = style.Train.common.useSelfText ? style.Train.common.nameFontSize || style.Train.common.trainTextFontSize : model.nameFontSize || style.Train.common.nameFontSize || style.Train.common.trainTextFontSize; this.fontSize = style.Train.common.useSelfText ? style.Train.common.nameFontSize || style.Train.common.trainTextFontSize : model.nameFontSize || style.Train.common.nameFontSize || style.Train.common.trainTextFontSize;
this.newScale = this.fontSize / style.Train.common.trainTextFontSize; this.newScale = this.fontSize / style.Train.common.trainTextFontSize;
this.nameFormat = style.Train.common.useSelfFormat ? style.Train.trainBody.trainNameFormat : model.nameFormat || style.Train.trainBody.trainNameFormat; this.nameFormat = style.Train.common.useSelfFormat ? style.Train.trainBody.trainNameFormat : model.nameFormat || style.Train.trainBody.trainNameFormat;
@ -68,7 +69,7 @@ export default class Train extends Group {
destinationStatus: model.destinationStatus, destinationStatus: model.destinationStatus,
serviceNumber: model.serviceNumber, serviceNumber: model.serviceNumber,
tripNumber: model.tripNumber, tripNumber: model.tripNumber,
targetCode: model.targetCode, destinationCode: model.destinationCode,
groupNumber: model.groupNumber, groupNumber: model.groupNumber,
directionType: model.directionType, directionType: model.directionType,
directionCode: model.directionCode, directionCode: model.directionCode,
@ -105,21 +106,38 @@ export default class Train extends Group {
scale: this.newScale scale: this.newScale
}); });
const data = this.model.physicalCode; if (style.Section.trainPosition.display) {
const oldmodel = store.getters['map/getDeviceByCode'](data); const data = this.model.physicalCode;
const leftPoint = oldmodel.points[0]; const oldmodel = store.getters['map/getDeviceByCode'](data);
const rightPoint = oldmodel.points[oldmodel.points.length - 1]; const leftPoint = oldmodel.points[0];
const right = this.model.right == 1 ? 1 : 0; const rightPoint = oldmodel.points[oldmodel.points.length - 1];
this.startX = leftPoint.x + (1 - right) * (rightPoint.x - leftPoint.x); const right = this.model.right == 1 ? 1 : 0;
this.startY = leftPoint.y + (1 - right) * (rightPoint.y - leftPoint.y); this.startX = leftPoint.x + (1 - right) * (rightPoint.x - leftPoint.x);
this.triangle = new ETriangle({ this.startY = leftPoint.y + (1 - right) * (rightPoint.y - leftPoint.y);
style: this.style, // 算出折线的长度
zlevel: this.zlevel, this.lineLength = 0;
z:10, this.currentAdd = 0;
right: this.model.right, let oldPoint = null;
point:{x:this.startX, y:this.startY} oldmodel.points.forEach((point)=>{
}); if (oldPoint) {
this.add(this.triangle); const temp = Math.sqrt(
Math.pow(point.x - oldPoint.x, 2) +
Math.pow(point.y - oldPoint.y, 2),
);
this.lineLength += temp;
}
oldPoint = point;
});
// this.animatePoint = {x:this.startX, y:this.startY};
this.triangle = new ETriangle({
style: this.style,
zlevel: this.zlevel,
z:10,
right: this.model.right,
point:{x:this.startX, y:this.startY}
});
this.add(this.triangle);
}
this.add(this.trainB); this.add(this.trainB);
this.add(this.trainL); this.add(this.trainL);
@ -136,20 +154,67 @@ export default class Train extends Group {
updateSection() { updateSection() {
const train = this.model; const train = this.model;
if (train.physicalCode && train.offsetp) { if (train.physicalCode && train.offsetp && this.triangle) {
const data = train.physicalCode; const data = train.physicalCode;
const oldmodel = store.getters['map/getDeviceByCode'](data); const oldmodel = store.getters['map/getDeviceByCode'](data);
const leftPoint = oldmodel.points[0]; // 待处理(多个点的问题)
const rightPoint = oldmodel.points[oldmodel.points.length - 1]; // const points = train.right == 1 ? oldmodel.points : oldmodel.points.reverse();
if (this.triangle) { const points = oldmodel.points;
// 目标距离
let targetDistance = Math.sqrt(
Math.pow(points[this.nextPointIndex - 1].x - points[this.nextPointIndex].x, 2) +
Math.pow(points[this.nextPointIndex - 1].y - points[this.nextPointIndex].y, 2),
);
// // 当前距离
// const currentDistance = Math.sqrt(
// Math.pow(points[this.nextPointIndex - 1].x - this.animatePoint.x, 2) +
// Math.pow(points[this.nextPointIndex - 1].y - this.animatePoint.y, 2),
// );
const currentDistance = this.lineLength * train.offsetp - this.currentAdd;
// let cureent this.lineLength * train.offsetp
// 利用运动距离与目标距离, 判断运动的点是否超过下一个目标点, 超过了就重置下一个点
if (currentDistance >= targetDistance) {
// this.animatePoint = {
// x: points[this.nextPointIndex].x,
// y: points[this.nextPointIndex].y
// };
this.nextPointIndex++;
this.currentAdd += targetDistance;
targetDistance = Math.sqrt(
Math.pow(points[this.nextPointIndex - 1].x - points[this.nextPointIndex].x, 2) +
Math.pow(points[this.nextPointIndex - 1].y - points[this.nextPointIndex].y, 2),
);
}
if (this.nextPointIndex > points.length - 1) {
const leftPoint = oldmodel.points[0];
const rightPoint = oldmodel.points[oldmodel.points.length - 1];
this.startX = leftPoint.x + (rightPoint.x - leftPoint.x) * train.offsetp; this.startX = leftPoint.x + (rightPoint.x - leftPoint.x) * train.offsetp;
this.startY = leftPoint.y + (rightPoint.y - leftPoint.y) * train.offsetp; this.startY = leftPoint.y + (rightPoint.y - leftPoint.y) * train.offsetp;
const point = {x:this.startX, y:this.startY}; } else {
this.triangle.point = point; // debugger;
this.triangle.updateTriangle(point, train.right); // this.lineLength * train.offsetp
this.triangle.dirty(); // if (this.currentLength > targetDistance) {
this.dirty(); // this.currentLength = this.currentLength - targetDistance;
// this.nextPointIndex++;
// targetDistance = Math.sqrt(
// Math.pow(points[this.nextPointIndex - 1].x - points[this.nextPointIndex].x, 2) +
// Math.pow(points[this.nextPointIndex - 1].y - points[this.nextPointIndex].y, 2),
// );
// }
debugger;
const rate = (this.lineLength * train.offsetp - this.currentAdd) / targetDistance;
this.startX = points[this.nextPointIndex - 1].x + (points[this.nextPointIndex].x - points[this.nextPointIndex - 1].x) * rate;
this.startY = points[this.nextPointIndex - 1].y + (points[this.nextPointIndex].y - points[this.nextPointIndex - 1].y) * rate;
// this.animatePoint.x = this.startX;
// this.animatePoint.y = this.startY;
} }
const point = {x:this.startX, y:this.startY};
this.triangle.point = point;
this.triangle.updateTriangle(point, train.right);
this.triangle.dirty();
this.dirty();
} }
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<pop-menu ref="popMenu" :menu="menu" /> <pop-menu ref="popMenu" :menu="menu" />
<train-init-plan ref="trainInitPlan"/> <train-init-plan ref="trainInitPlan" />
<notice-info ref="noticeInfo" /> <notice-info ref="noticeInfo" />
</div> </div>
</template> </template>

View File

@ -158,11 +158,11 @@ export default {
}; };
// //
const path = window.location.href; const path = window.location.href;
let mouseWheelFlag = false; const mouseWheelFlag = true;
let previewOrMapDraw = false; let previewOrMapDraw = false;
if (path.includes('design/userlist/map/draw') || path.includes('design/usermap/map/draw')) { // if (path.includes('design/userlist/map/draw') || path.includes('design/usermap/map/draw')) {
mouseWheelFlag = true; // mouseWheelFlag = true;
} // }
if (path.indexOf('map/draw') !== -1 || path.indexOf('mapPreviewNew') !== -1) { if (path.indexOf('map/draw') !== -1 || path.indexOf('mapPreviewNew') !== -1) {
previewOrMapDraw = true; previewOrMapDraw = true;
} }