233 lines
8.2 KiB
JavaScript
233 lines
8.2 KiB
JavaScript
import Group from 'zrender/src/container/Group';
|
|
// 站台元素
|
|
import ESolidStand from './safeStand/ESolidStand';
|
|
import EHollowStand from './safeStand/EHollowStand';
|
|
import EGapStand from './safeStand/EGapStand';
|
|
// 扣车元素
|
|
import EDetain from './detain/EDetain';
|
|
import EDetainHollow from './detain/EDetainHollow';
|
|
import EDetainCircle from './detain/EDetainCircle';
|
|
import EDetainRect from './detain/EDetainRect';
|
|
// 跳停元素
|
|
import EJump from './jump/EJump';
|
|
import EJumpCircle from './jump/EJumpCircle';
|
|
|
|
import ETime from './ETime';
|
|
import ELevel from './ELevel';
|
|
import EReentry from './EReentry';
|
|
|
|
// 紧急停车
|
|
import EEmergentCross from './emergent/EEmergentCross';
|
|
import EEmergentArrow from './emergent/EEmergentArrow';
|
|
import EEmergentRhombus from './emergent/EEmergentRhombus';
|
|
|
|
import EMouse from './EMouse';
|
|
|
|
import EHighlight from '../element/EHighlight';
|
|
import ETrainStop from './ETrainStop';
|
|
import ETrainDepart from './ETrainDepart';
|
|
|
|
import EPatternFilter from './EPatternFilter';
|
|
import EStopJumpLamp from './functionButton/EStopJumpLamp';
|
|
import ECancelStopJumpLamp from './functionButton/ECancelStopJumpLamp';
|
|
import EUpDetainLamp from './functionButton/EUpDetainLamp';
|
|
import EDownDetainLamp from './functionButton/EDownDetainLamp';
|
|
|
|
import {isShowThePrdType} from '../../utils/handlePath';
|
|
import {traverseLineElements, traverseStatusElements} from '../utils/ShapeStatusCovert';
|
|
|
|
class StationStand extends Group {
|
|
constructor(model, style) {
|
|
super();
|
|
this._code = model.code;
|
|
this._type = model._type;
|
|
this.model = model;
|
|
this.style = style;
|
|
this.zlevel = model.zlevel;
|
|
this.z = 1;
|
|
this.isShowShape = true;
|
|
this.create();
|
|
this.createMouseEvent();
|
|
// if (isShowThePrdType(model.prdType, style.StationStand.common.functionButtonShow) || model.previewOrMapDraw) {
|
|
// this.createFunctionButton();
|
|
// }
|
|
// if (model.previewOrMapDraw) {
|
|
// this.setShowMode();
|
|
// }
|
|
this.setVisible(model.visible);
|
|
this.setState(model);
|
|
}
|
|
create() {
|
|
// 加载皮肤控制的元素
|
|
const model = this.model;
|
|
const style = this.style;
|
|
// // 站台所有的绘图元素
|
|
const elementTypeList = {
|
|
'solidStand':ESolidStand, // 矩形实心站台 (普通站台样式)
|
|
'hollowStand':EHollowStand, // 矩形空心站台 (西安二号线站台样式)
|
|
'gapStand':EGapStand, // 分割站台(哈尔滨站台特有)
|
|
|
|
'emergentCross':EEmergentCross, // 站台紧急关闭 西安二号线 正八边形
|
|
'emergentArrow':EEmergentArrow, // 站台紧急关闭 哈尔滨 箭头型
|
|
'emergentRhombus':EEmergentRhombus, // 站台紧急关闭 普通 菱形
|
|
|
|
'jump':EJump, // 列车跳停
|
|
'jumpCircle':EJumpCircle, // 列车跳停(带圆圈)
|
|
|
|
'detainNormal':EDetain, // 普通扣车图标
|
|
'detainHollow':EDetainHollow, // 含空心圆的扣车图标
|
|
'detainCircle':EDetainCircle, // 圆形扣车图标
|
|
'detainRect':EDetainRect, // 矩形扣车图标
|
|
|
|
'stopTime':ETime, // 停站时间
|
|
'level':ELevel, // 运行等级
|
|
'patternFilter':EPatternFilter, // 模式筛选标识(西安二号线特殊的情况)
|
|
|
|
'reentry':EReentry, // 站台折返策略
|
|
'trainStop':ETrainStop, // 列车停车点标识 哈尔滨一号线
|
|
'trainDepart':ETrainDepart// 列车停站时间 哈尔滨一号线
|
|
};
|
|
// 遍历当前线路下的绘图元素 组合模式
|
|
traverseLineElements(style.StationStand, elementTypeList, model, style, this);
|
|
|
|
// 加载后端返回的状态控制的绘图
|
|
const statusElementList = {
|
|
'stopJumpLamp':EStopJumpLamp,
|
|
'cancelStopJumpLamp':ECancelStopJumpLamp,
|
|
'upDetainLamp':EUpDetainLamp,
|
|
'downDetainLamp':EDownDetainLamp
|
|
};
|
|
// 遍历后端返回的状态控制的绘图
|
|
if (model.previewOrMapDraw || isShowThePrdType(model.prdType, style.StationStand.common.functionButtonShow)) {
|
|
traverseStatusElements(statusElementList, model, style, this);
|
|
}
|
|
}
|
|
|
|
createMouseEvent() {
|
|
const path = window.location.href;
|
|
if (path.includes('/map/draw')) {
|
|
this.highlight = new EHighlight(this);
|
|
this.add(this.highlight);
|
|
this.on('mouseout', () => { this.highlight.mouseout(); });
|
|
this.on('mouseover', () => { this.highlight.mouseover(); });
|
|
} else {
|
|
if (this.style.StationStand.mouseOverStyle) {
|
|
this.mouseEvent = new EMouse(this);
|
|
this.add(this.mouseEvent);
|
|
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
|
|
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
|
|
}
|
|
}
|
|
}
|
|
|
|
setVisible(visible) {
|
|
if (visible) {
|
|
this.eachChild(elem => { elem.show(); });
|
|
} else {
|
|
this.eachChild(elem => { elem.hide(); });
|
|
}
|
|
}
|
|
|
|
/** 恢复初始状态*/
|
|
recover() {
|
|
const currentTypeList = this.style.StationStand.elemnetType;
|
|
currentTypeList.forEach(element => {
|
|
this[element].recover();
|
|
});
|
|
}
|
|
|
|
setState(model) {
|
|
if (!this.isShowShape) return;
|
|
// // 新版地图使用新版状态变更方式
|
|
this.recover();
|
|
|
|
// 更新状态
|
|
const currentTypeList = this.style.StationStand.elemnetType;
|
|
currentTypeList.forEach(element => {
|
|
this[element].setState(model);
|
|
});
|
|
}
|
|
|
|
getBoundingRect() {
|
|
const element = this.style.StationStand.elemnetType[0];
|
|
const rect = this[element].getBoundingRect().clone();
|
|
return rect;
|
|
}
|
|
|
|
getShapeTipPoint(opts) {
|
|
let rect;
|
|
if (opts.subDeviceType == 'DetainLamp') {
|
|
if (this.model.right) {
|
|
opts.subDeviceType = 'UpDetainLamp';
|
|
} else {
|
|
opts.subDeviceType = 'DownDetainLamp';
|
|
}
|
|
}
|
|
switch (opts.subDeviceType) {
|
|
case 'StopJumpLamp': {
|
|
rect = this.stopJumpLamp.getBoundingRect();
|
|
break;
|
|
}
|
|
case 'CancelStopJumpLamp': {
|
|
rect = this.cancelStopJumpLamp.getBoundingRect();
|
|
break;
|
|
}
|
|
case 'UpDetainLamp': {
|
|
rect = this.upDetainLamp.getBoundingRect();
|
|
break;
|
|
}
|
|
case 'DownDetainLamp': {
|
|
rect = this.downDetainLamp.getBoundingRect();
|
|
break;
|
|
}
|
|
default: {
|
|
rect = this.getBoundingRect();
|
|
break;
|
|
}
|
|
}
|
|
if (rect) {
|
|
return {
|
|
x: rect.x + rect.width / 2,
|
|
y: rect.y
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
|
|
drawSelected(selected) {
|
|
this.highlight && this.highlight.drawSelected(selected);
|
|
}
|
|
|
|
// 设置显示模式
|
|
setShowMode() {
|
|
const showMode = this.model.showMode;
|
|
const showConditions = this.style.StationStand.common.functionButtonShow;
|
|
if (!showConditions || showConditions === '01' || showMode === showConditions) {
|
|
this.stopJumpLamp && this.stopJumpLamp.show();
|
|
this.cancelStopJumpLamp && this.cancelStopJumpLamp.show();
|
|
this.upDetainLamp && this.upDetainLamp.show();
|
|
this.downDetainLamp && this.downDetainLamp.show();
|
|
} else {
|
|
this.stopJumpLamp && this.stopJumpLamp.hide();
|
|
this.cancelStopJumpLamp && this.cancelStopJumpLamp.hide();
|
|
this.upDetainLamp && this.upDetainLamp.hide();
|
|
this.downDetainLamp && this.downDetainLamp.hide();
|
|
}
|
|
}
|
|
setShowStation(stationCode) {
|
|
if ((!stationCode || this.model.deviceStationCode === stationCode) && this.model.visible) {
|
|
this.eachChild(item => {
|
|
item.show();
|
|
});
|
|
this.isShowShape = true;
|
|
this.setState(this.model);
|
|
} else {
|
|
this.eachChild(item => {
|
|
item.hide();
|
|
});
|
|
this.isShowShape = false;
|
|
}
|
|
}
|
|
}
|
|
export default StationStand;
|