143 lines
4.5 KiB
JavaScript
143 lines
4.5 KiB
JavaScript
/*
|
|
* 计轴复位 控制器
|
|
*/
|
|
import Group from 'zrender/src/container/Group';
|
|
import Arc from 'zrender/src/graphic/shape/Arc';
|
|
import Text from 'zrender/src/graphic/Text';
|
|
import EMouse from './EMouse';
|
|
import {isShowThePrdType} from '../../utils/handlePath';
|
|
|
|
export default class AxleReset extends Group {
|
|
constructor(model, style) {
|
|
super();
|
|
this.z = 20;
|
|
this._code = model.code;
|
|
this._type = model._type;
|
|
this.zlevel = model.zlevel;
|
|
this.model = model;
|
|
this.style = style;
|
|
this.isShowShape = true;
|
|
if (isShowThePrdType(model.prdType, style.AxleReset.displayCondition) || model.previewOrMapDraw) {
|
|
this.create();
|
|
this.createMouseEvent();
|
|
this.setState(model);
|
|
}
|
|
if (model.previewOrMapDraw) {
|
|
this.setShowMode();
|
|
}
|
|
}
|
|
|
|
create() {
|
|
const model = this.model;
|
|
this.control = new Arc({
|
|
_subType: 'Control',
|
|
zlevel: this.zlevel,
|
|
z: this.z,
|
|
shape: {
|
|
cx: model.position.x,
|
|
cy: model.position.y,
|
|
r: this.style.AxleReset.lamp.radiusR
|
|
},
|
|
style: {
|
|
lineWidth: 0,
|
|
fill: this.style.AxleReset.lamp.controlColor
|
|
}
|
|
});
|
|
|
|
this.text = new Text({
|
|
_subType: 'Text',
|
|
zlevel: this.zlevel,
|
|
z: this.z,
|
|
position: [0, 0],
|
|
style: {
|
|
x: model.position.x,
|
|
y: model.position.y + this.style.AxleReset.lamp.radiusR + this.style.AxleReset.text.distance,
|
|
fontWeight: this.style.AxleReset.text.fontWeight,
|
|
fontSize: this.style.AxleReset.text.fontSize,
|
|
fontFamily: this.style.fontFamily,
|
|
text: model.name,
|
|
textFill: '#fff',
|
|
textAlign: 'middle',
|
|
textVerticalAlign: 'top'
|
|
}
|
|
});
|
|
|
|
if (this.model.subtitleName) {
|
|
this.subtitleText = new Text({
|
|
_subType: 'Text',
|
|
zlevel: this.zlevel,
|
|
z: this.z,
|
|
position: [0, 0],
|
|
style: {
|
|
x: model.position.x,
|
|
y: model.position.y + this.style.AxleReset.lamp.radiusR + this.style.AxleReset.subtitleText.distance,
|
|
fontWeight: this.style.AxleReset.subtitleText.fontWeight,
|
|
fontSize: this.style.AxleReset.subtitleText.fontSize,
|
|
fontFamily: this.style.fontFamily,
|
|
text: model.subtitleName,
|
|
textFill: '#fff',
|
|
textAlign: 'middle',
|
|
textVerticalAlign: 'top'
|
|
}
|
|
});
|
|
this.add(this.subtitleText);
|
|
}
|
|
this.add(this.control);
|
|
this.add(this.text);
|
|
}
|
|
|
|
// 设置状态
|
|
setState(model) {
|
|
if (!this.isShowShape) return;
|
|
}
|
|
|
|
createMouseEvent() {
|
|
if (this.style.LcControl.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); });
|
|
}
|
|
}
|
|
getShapeTipPoint() {
|
|
if (this.control) {
|
|
var distance = 2;
|
|
var rect = this.control.getBoundingRect();
|
|
return {
|
|
x: rect.x + rect.width / 2,
|
|
y: rect.y - distance
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
setShowMode() {
|
|
const showMode = this.model.showMode;
|
|
const showConditions = this.style.AxleReset.displayCondition;
|
|
if (!showConditions || showConditions === '01' || showMode === showConditions) {
|
|
this.show();
|
|
} else {
|
|
this.hide();
|
|
}
|
|
}
|
|
setShowStation(stationCode) {
|
|
if (!stationCode || this.model.stationCode === stationCode) {
|
|
this.isShowShape = true;
|
|
this.show();
|
|
} else {
|
|
this.isShowShape = false;
|
|
this.hide();
|
|
}
|
|
}
|
|
show() {
|
|
this.control && this.control.show();
|
|
this.text && this.text.show();
|
|
this.subtitleText && this.subtitleText.show();
|
|
this.setState(this.model);
|
|
}
|
|
hide() {
|
|
this.control && this.control.hide();
|
|
this.text && this.text.hide();
|
|
this.subtitleText && this.subtitleText.hide();
|
|
}
|
|
}
|