rt-sim-training-client/src/jmap/shape/LcControl/index.js

67 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-07-15 15:56:41 +08:00
/*
* lC区域控制模式
*/
import Group from 'zrender/src/container/Group';
2019-07-18 10:05:16 +08:00
import EControl from '../element/EControl';
2019-07-15 15:56:41 +08:00
export default class LcControl extends Group {
2019-07-30 09:18:24 +08:00
constructor(model, style) {
2019-07-16 12:01:43 +08:00
super();
2019-07-15 15:56:41 +08:00
this.z = 20;
this._code = model.code;
2019-07-30 09:18:24 +08:00
this._type = model._type;
this.zlevel = model.zlevel;
2019-07-15 15:56:41 +08:00
this.model = model;
this.style = style;
this._create();
}
_create() {
const model = this.model;
2019-07-17 09:08:23 +08:00
this.control = new EControl({
2019-07-15 15:56:41 +08:00
zlevel: this.zlevel,
z: this.z,
2019-07-17 09:08:23 +08:00
arc: {
shape: {
cx: model.position.x,
cy: model.position.y,
2019-07-25 10:30:30 +08:00
r: this.style.LcControl.lamp.radiusR
2019-07-17 09:08:23 +08:00
},
2019-07-15 15:56:41 +08:00
lineWidth: 0,
2019-07-25 10:30:30 +08:00
fill: this.style.LcControl.lamp.controlColor
2019-07-17 09:08:23 +08:00
},
text: {
position: [0, 0],
2019-07-15 15:56:41 +08:00
x: model.position.x,
2019-07-25 10:30:30 +08:00
y: model.position.y + this.style.LcControl.lamp.radiusR + this.style.LcControl.text.distance,
2019-07-24 13:50:37 +08:00
fontWeight: 'normal',
2019-07-25 10:30:30 +08:00
fontSize: this.style.LcControl.text.fontSize,
2019-07-24 13:50:37 +08:00
fontFamily: this.style.textFontFormat,
2019-07-15 15:56:41 +08:00
text: model.name,
2019-07-17 09:08:23 +08:00
textFill: '#fff',
2019-07-15 15:56:41 +08:00
textAlign: 'middle',
2019-07-24 13:50:37 +08:00
textVerticalAlign: 'top'
2019-07-17 09:08:23 +08:00
},
style: this.style
2019-07-15 15:56:41 +08:00
});
this.add(this.control);
2019-07-30 09:18:24 +08:00
this.setState(model);
2019-07-15 15:56:41 +08:00
}
// 设置状态
2019-07-30 09:18:24 +08:00
setState(model) {}
2019-07-15 15:56:41 +08:00
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;
}
}