This commit is contained in:
zyy 2019-07-25 15:48:58 +08:00
commit 601d0e2d91
17 changed files with 1085 additions and 991 deletions

View File

@ -1,5 +1,5 @@
import Group from "zrender/src/container/Group";
import Text from "zrender/src/graphic/Text";
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
/** 文字描述 */
class ArrowText extends Group {
constructor(model) {

View File

@ -1,5 +1,5 @@
import Group from "zrender/src/container/Group";
import Text from "zrender/src/graphic/Text";
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
/** 目的码 */
export default class TextTrainNumber extends Group {
constructor(model) {
@ -22,17 +22,17 @@ export default class TextTrainNumber extends Group{
textStrokeWidth: 0,
textFont: model.textFont,
textAlign: 'left',
textVerticalAlign: 'top',
textVerticalAlign: 'top'
},
cursor: 'pointer',
onmouseover: this.onMouseOver(),
onmouseout: this.onMouseOut(),
onmouseout: this.onMouseOut()
});
this.add(this.textTrainNumber);
};
}
setShapeStyle(key, style) {
this.textTrainNumber.setStyle(key, style);
};
}
onMouseOver() {
if (this.model.trainBodyOnMouseOver.textTrainNumber) {
this.add(this.model.arrowText);

View File

@ -1,5 +1,5 @@
import Group from "zrender/src/container/Group";
import Text from "zrender/src/graphic/Text";
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
/** 服务号、表号 */
export default class TextTrainServer extends Group {
constructor(model) {
@ -22,16 +22,16 @@ export default class TextTrainServer extends Group{
},
cursor: 'pointer',
onmouseover: this.onMouseOver(),
onmouseout: this.onMouseOut(),
onmouseout: this.onMouseOut()
});
this.add(this.textTrainServer);
};
}
setColor(key, color) {
this.textTrainServer.setStyle(key, color);
};
}
setShapeStyle(key, style) {
this.textTrainServer.setStyle(key, style);
};
}
onMouseOver() {
if (this.model.trainBodyOnMouseOver.textTrainServer) {
this.add(this.model.arrowText);

View File

@ -1,5 +1,5 @@
import Group from "zrender/src/container/Group";
import Text from "zrender/src/graphic/Text";
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
export default class TextTrainTarget extends Group {
constructor(model) {
@ -22,16 +22,16 @@ export default class TextTrainTarget extends Group{
},
cursor: 'pointer',
onmouseover: this.onMouseOver(),
onmouseout: this.onMouseOut(),
onmouseout: this.onMouseOut()
});
this.add(this.textTrainTarget);
};
}
setColor(key, color) {
this.textTrainTarget.setStyle(key, color);
};
}
setShapeStyle(key, style) {
this.textTrainTarget.setStyle(key, style);
};
}
onMouseOver() {
if (this.model.trainBodyOnMouseOver.textTrainTarget) {
this.add(this.model.arrowText);

View File

@ -1,5 +1,5 @@
import Group from "zrender/src/container/Group";
import Text from "zrender/src/graphic/Text";
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
/** 车组号 */
export default class TextTrainTargetNumber extends Group {
constructor(model) {
@ -21,17 +21,17 @@ export default class TextTrainTargetNumber extends Group{
textStrokeWidth: 0,
textFont: model.textFont,
textAlign: 'left',
textVerticalAlign: 'top',
textVerticalAlign: 'top'
},
cursor: 'pointer',
onmouseover: this.onMouseOver(),
onmouseout: this.onMouseOut(),
onmouseout: this.onMouseOut()
});
this.add(this.textTrainTargetNumber);
}
setShapeStyle(key, style) {
this.textTrainTargetNumber.setStyle(key, style);
};
}
onMouseOver() {
if (this.model.trainBodyOnMouseOver.textTrainTargetNumber) {
this.add(this.model.arrowText);

View File

@ -1,8 +1,7 @@
import Group from "zrender/src/container/Group";
import Rect from "zrender/src/graphic/shape/Rect";
import Group from 'zrender/src/container/Group';
import Rect from 'zrender/src/graphic/shape/Rect';
import store from '@/store';
export default class Train extends Group {
constructor(model) {
super();
@ -18,7 +17,7 @@ export default class Train extends Group{
style: model.style,
cursor: model.cursor,
onmouseover: this.onMouseOver(),
onmouseout: this.onMouseOut(),
onmouseout: this.onMouseOut()
});
this.add(this.train);
}

View File

@ -1,12 +1,12 @@
import Group from "zrender/src/container/Group";
import ArrowText from "./ArrowText";
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 Group from 'zrender/src/container/Group';
import ArrowText from './ArrowText';
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';
/** 车身*/
export default class TrainBody extends Group {
constructor(model) {
@ -60,7 +60,7 @@ export default class TrainBody extends Group {
cursor: 'pointer',
trainBodyOnMouseOver: style.Train.trainBodyOnMouseOver,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut,
arrowText: this.arrowText,
arrowText: this.arrowText
});
/* let selectTrain = store.getters['map/trainDetails'];
if (selectTrain && selectTrain.model._code == model.model._code) {
@ -89,11 +89,11 @@ export default class TrainBody extends Group {
}) : '';
let serviceNumber = style.Train.serviceNumberPrefix + (model.serviceNumber || style.Train.defaultServiceNumber) + '';// 服务号(表号)
let tripNumber = style.Train.tripNumberPrefix + (style.Train.defaultDirectionCode?
(model.directionCode||style.Train.defaultDirectionCode) + (model.tripNumber || style.Train.defaultTripNumber)
const tripNumber = style.Train.tripNumberPrefix + (style.Train.defaultDirectionCode
?(model.directionCode||style.Train.defaultDirectionCode) + (model.tripNumber || style.Train.defaultTripNumber)
:model.tripNumber || style.Train.defaultTripNumber) + ''; // 车次号
let targetCode = style.Train.targetCodePrefix + (model.targetCode || style.Train.defaultTargetCode) + ''; // 目的地码
let groupNumber = style.Train.groupNumberPrefix + (model.groupNumber || style.Train.defaultGroupNumber) + ''; // 车组号
const targetCode = style.Train.targetCodePrefix + (model.targetCode || style.Train.defaultTargetCode) + ''; // 目的地码
const groupNumber = style.Train.groupNumberPrefix + (model.groupNumber || style.Train.defaultGroupNumber) + ''; // 车组号
this.textTrainServer = new TextTrainServer({
zlevel: model.zlevel,
@ -105,7 +105,7 @@ export default class TrainBody extends Group {
trainBrownColor: style.trainTextColor,
textFont: textFont,
trainBodyOnMouseOver: style.Train.trainBodyOnMouseOver,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut
});
this.textTrainTarget = new TextTrainTarget({
@ -119,7 +119,7 @@ export default class TrainBody extends Group {
trainYellowColor: style.trainTextColor,
textFont: textFont,
trainBodyOnMouseOver: style.Train.trainBodyOnMouseOver,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut
});
this.textTrainNumber = new TextTrainNumber({
@ -132,7 +132,7 @@ export default class TrainBody extends Group {
trainTextColor: style.trainTextColor,
textFont: textFont,
trainBodyOnMouseOver: style.Train.trainBodyOnMouseOver,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut
});
this.textTrainTargetNumber = new TextTrainTargetNumber({
@ -145,7 +145,7 @@ export default class TrainBody extends Group {
trainTextColor: style.trainTextColor,
textFont: textFont,
trainBodyOnMouseOver: style.Train.trainBodyOnMouseOver,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut,
trainBodyOnMouseOut: style.Train.trainBodyOnMouseOut
});
// 根据列车类型设置显示格式
if ( style.Train.specialTrainType.length > 0) {
@ -154,10 +154,10 @@ export default class TrainBody extends Group {
serviceNumber = item.serviceNumber;
model.nameFormat = item.nameFormat;
}
})
});
}
if ( style.Train.dynamicLoadingDisplay ) {
this.formatChangePosition(model,style)
this.formatChangePosition(model, style);
} else {
this.add(this.textTrainServer);
this.add(this.textTrainTarget);
@ -212,21 +212,21 @@ export default class TrainBody extends Group {
}
formatChangePosition(model, style) {
if (model.nameFormat) {
let arr = model.nameFormat.split(':');
const arr = model.nameFormat.split(':');
arr.forEach(ele => {
if (ele == 'targetCode') {
this.add(this.textTrainNumber);
} else if (ele == 'serviceNumber') {
let show = arr.includes('targetCode');
const show = arr.includes('targetCode');
if (show) {
this.textTrainServer.setShapeStyle('x', parseInt(model.point.x + (3 * model.fontSize * (2 / 3)) - 3 - style.Train.lrPadding));
}
this.add(this.textTrainServer);
} else if (ele == 'tripNumber') {
let show = arr.includes('targetCode');
let serverNoShow = arr.includes('serviceNumber');
const show = arr.includes('targetCode');
const serverNoShow = arr.includes('serviceNumber');
if (show) {
this.textTrainTarget.setStsetShapeStyleyle('x', parseInt(model.point.x + (3 * model.fontSize * (2 / 3)) - 3 - style.Train.lrPadding));
this.textTrainTarget.setShapeStyle('x', parseInt(model.point.x + (3 * model.fontSize * (2 / 3)) - 3 - style.Train.lrPadding));
}
if (serverNoShow) {
this.textTrainTarget.setShapeStyle('x', parseInt(model.point.x + (2 * model.fontSize * (2 / 3)) - 3 - style.Train.lrPadding));
@ -236,8 +236,8 @@ export default class TrainBody extends Group {
}
this.add(this.textTrainTarget);
} else if (ele == 'groupNumber') {
let show = arr.includes('targetCode');
let serverNoShow = arr.includes('serviceNumber');
const show = arr.includes('targetCode');
const serverNoShow = arr.includes('serviceNumber');
if (show) {
this.textTrainTargetNumber.setShapeStyle('x', parseInt(model.point.x + (3 * model.fontSize * (2 / 3)) - 3 - style.Train.lrPadding));
}
@ -251,8 +251,8 @@ export default class TrainBody extends Group {
}
});
} else {
this.textTrainServer.setStyle('x', parseInt(model.point.x + 27 - style.Train.lrPadding));
this.textTrainTarget.setStyle('x', parseInt(model.point.x + 43 - style.Train.lrPadding));
this.textTrainServer.setShapeStyle('x', parseInt(model.point.x + 27 - style.Train.lrPadding));
this.textTrainTarget.setShapeStyle('x', parseInt(model.point.x + 43 - style.Train.lrPadding));
this.add(this.textTrainServer);
this.add(this.textTrainTarget);
this.add(this.textTrainNumber);

View File

@ -1,6 +1,6 @@
import Group from "zrender/src/container/Group";
import Rect from "zrender/src/graphic/shape/Rect";
import Polygon from "zrender/src/graphic/shape/Polygon";
import Group from 'zrender/src/container/Group';
import Rect from 'zrender/src/graphic/shape/Rect';
import Polygon from 'zrender/src/graphic/shape/Polygon';
/** 车头*/
export default class TrainHead extends Group {
@ -20,7 +20,7 @@ export default class TrainHead extends Group {
x: model.point.x - baseMargin * (style.trainConntWidth),
y: model.point.y,
width: style.trainConntWidth * model.scale,
height: style.Train.trainHeadRectHeight,
height: style.Train.trainHeadRectHeight
},
style: {
lineWidth: 0.1,
@ -36,7 +36,7 @@ export default class TrainHead extends Group {
[model.point.x + model.drect * (style.Train.trainHeadTriangleFirst.x), model.point.y + style.Train.trainHeadTriangleFirst.y],
[model.point.x + model.drect * (style.Train.trainHeadTriangleSecond.x), model.point.y + style.Train.trainHeadTriangleSecond.y],
[model.point.x + model.drect * (style.Train.trainHeadTriangleThird.x), model.point.y + style.Train.trainHeadTriangleThird.y]
],
]
},
style: {
lineWidth: 0.1,

View File

@ -1,7 +1,8 @@
import Group from 'zrender/src/container/Group';
import BoundingRect from 'zrender/src/core/BoundingRect';
import TrainHead from './TrainHead/index';
import TrainBody from './TrainBody/index';
import BoundingRect from 'zrender/src/core/BoundingRect';
import Rect from 'zrender/src/graphic/shape/Rect';
/** 列车 */
export default class Train extends Group {
@ -99,6 +100,9 @@ export default class Train extends Group {
this.add(this.trainL);
this.add(this.trainR);
}
if (style.Train.haveTrainBorder) {
this.createTrainBorder();
}
}
// 获取设备提示坐标
@ -295,4 +299,46 @@ export default class Train extends Group {
removeTrainDetail() {
this.trainB.removeTrainDetail();
}
getBoundingRect() {
const list = [this.trainB, this.trainL, this.trainR];
let rect = null;
list.forEach(elem => {
if (elem) {
const tempRect = elem.getBoundingRect();
if (tempRect.x && tempRect.y && tempRect.width && tempRect.height) {
if (rect) {
rect.union(tempRect);
} else {
rect = tempRect;
}
}
}
});
return rect || new BoundingRect(0, 0, 0, 0);
}
createTrainBorder() {
const rect = Object.assign({}, this.getBoundingRect());
rect.x -= this.style.Train.trainWidth / 2;
rect.y -= 5;
rect.width += this.style.Train.trainWidth;
rect.height += 10;
this.trainBorder = new Rect({
zlevel: this.zlevel,
z: this.z,
silent: true,
shape: rect,
style: {
lineDash: [3, 3],
stroke: this.style.borderColor,
fill: this.style.transparentColor
}
});
this.add(this.trainBorder);
this.mouseStatusRecover();
}
}

View File

@ -13,12 +13,15 @@ class TrainWindow extends Group {
this.style = style;
this.z = 1;
this._create(model);
this.setState(state);
this.setStatus(state);
}
_create(model) {
const prdType = '02';// store.state.map.prdType;
if (prdType !== '01') {
this.createTrainWindow();
this.setTrainWindowEventShow(model.trainWindowShow);
this.setStatus(model);
this.mouseStatusRecover();
}
}
@ -31,7 +34,7 @@ class TrainWindow extends Group {
zlevel: this.zlevel - 1,
z: this.z,
shape: {
smooth: 0.01,
smooth: this.style.TrainWindow.trainWindowSmooth,
points: [
[point.x - model.width / 2, point.y],
[point.x + model.width / 2, point.y],
@ -40,9 +43,9 @@ class TrainWindow extends Group {
]
},
style: {
lineDash: [3, 3],
lineWidth: 1,
stroke: this.style.trainWindowColor,
lineDash: this.style.TrainWindow.trainWindowLineDash,
lineWidth: this.style.TrainWindow.trainWindowLineWidth,
stroke: this.style.TrainWindow.trainWindowColor,
fill: this.style.transparentColor
}
});
@ -59,8 +62,15 @@ class TrainWindow extends Group {
}
// 设置状态
setState(state) {
this.trainRect.hide();
setStatus() {
}
setTrainWindowEventShow(show) {
const lineWidth = show ? 1 : 0;
this.trainRect && this.trainRect.setStyle('lineWidth', lineWidth);
}
mouseStatusRecover(e) {
this.setTrainWindowEventShow(false);
// this.setSectionEventShow(e, false);
}
}

View File

@ -304,7 +304,7 @@ class Batong extends defaultSkin {
{status: '04', showColor: '#9B4A09'},
{status: '05', showColor: '#EF0C08'},
{status: '06', showColor: '#FFFFFF'},
{status: '07',showColor: '#FFFF00'},
{status: '07', showColor: '#FFFF00'}
],
/** 默认字体 族类*/
textFontFormat: '宋体',
@ -344,7 +344,17 @@ class Batong extends defaultSkin {
/** 列车车头矩形填充颜色 */
trainHeadFillColor: '#EF0C08',
/** 列车车身填充颜色 */
trainBodyFillColor: '#000000',
trainBodyFillColor: '#000000'
};
this[deviceType.TrainWindow] = {
/** 车次窗颜色*/
trainWindowColor: '#4DD43F',
/** 车次窗虚线间隔 */
trainWindowLineDash: null,
/** 车次窗线宽 */
trainWindowLineWidth: 1.5,
/** 车次窗矩形圆滑程度 */
trainWindowSmooth: 0
};
}
}

View File

@ -407,6 +407,16 @@ class Beijing extends defaultSkin {
/** 是否需创建trainBorder对象 */
haveTrainBorder: true
};
this[deviceType.TrainWindow] = {
/** 车次窗颜色*/
trainWindowColor: '#FFF',
/** 车次窗虚线间隔 */
lineDash: [3, 3],
/** 车次窗线宽 */
trainWindowLineWidth: 1,
/** 车次窗矩形圆滑程度 */
trainWindowSmooth: 0.01
};
}
}

View File

@ -352,7 +352,23 @@ class Beijing extends defaultSkin {
textDContent: '门',
/** textA文本 */
textAContent: '警',
}
/** 是否需创建textHSDA对象 */
haveTextHSDA: true,
/** 是否需创建arrowText对象 */
haveArrowText: false,
/** 是否需创建trainBorder对象 */
haveTrainBorder: true
};
this[deviceType.TrainWindow] = {
/** 车次窗颜色*/
trainWindowColor: '#C0C0C0',
/** 车次窗虚线间隔 */
lineDash: [3, 3],
/** 车次窗线宽 */
trainWindowLineWidth: 1,
/** 车次窗矩形圆滑程度 */
trainWindowSmooth: 0.01
};
}
}

View File

@ -303,7 +303,7 @@ class Fuzhou extends defaultSkin {
{status: '04', showColor: '#9B4A09'},
{status: '05', showColor: '#EF0C08'},
{status: '06', showColor: '#FFFFFF'},
{status: '07',showColor: '#FFFF00'},
{status: '07', showColor: '#FFFF00'}
],
/** 默认字体 族类*/
textFontFormat: '宋体',
@ -343,8 +343,18 @@ class Fuzhou extends defaultSkin {
/** 列车车头矩形填充颜色 */
trainHeadFillColor: '#EF0C08',
/** 列车车身填充颜色 */
trainBodyFillColor: '#000000',
}
trainBodyFillColor: '#000000'
};
this[deviceType.TrainWindow] = {
/** 车次窗颜色*/
trainWindowColor: '#4DD43F',
/** 车次窗虚线间隔 */
lineDash: null,
/** 车次窗线宽 */
trainWindowLineWidth: 1.5,
/** 车次窗矩形圆滑程度 */
trainWindowSmooth: 0
};
}
}

View File

@ -181,30 +181,23 @@ export default {
},
//
setShowLevel(level) {
if (this.$jlmap) {
console.log(level);
console.log('设置显示图层');
// this.$jlmap.setShowLevel(level);
}
// this.$jlmap && this.$jlmap.setShowLevel(level);
},
// Level
setShowLogicalLevel(levels) {
if (this.$jlmap) {
console.log('设置逻辑视图Level');
// this.$jlmap.setShowLogicalLevel(levels);
}
// this.$jlmap && this.$jlmap.setShowLogicalLevel(levels);
},
// Level
setShowPhysicalLevel(levels) {
if (this.$jlmap) {
console.log('设置物理视图Level');
// this.$jlmap.setShowPhysicalLevel(levels);
}
// this$jlmap && this.$jlmap.setShowPhysicalLevel(levels);
},
//
setShowCenter(deviceCode) {
if (this.$jlmap) {
this.$jlmap.setCenter(deviceCode);
}
this.$jlmap && this.$jlmap.setCenter(deviceCode);
},
//
onDataZoom(dataZoom) {