2019-11-29 12:51:58 +08:00
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
import Rect from 'zrender/src/graphic/shape/Rect';
|
|
|
|
|
|
|
|
export default class EMouse extends Group {
|
2020-03-20 17:17:23 +08:00
|
|
|
constructor(device) {
|
|
|
|
super();
|
|
|
|
this.device = device;
|
|
|
|
this.zlevel = device.zlevel;
|
|
|
|
this.style = device.style;
|
|
|
|
this.create();
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-20 17:17:23 +08:00
|
|
|
create() {
|
|
|
|
this.lampRect = new Rect({
|
|
|
|
silent: true,
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: 6,
|
|
|
|
shape: this.device.getBoundingRect(),
|
|
|
|
style: {
|
|
|
|
lineDash: this.style.Signal.mouseOverStyle.borderLineDash,
|
|
|
|
stroke: this.style.Signal.mouseOverStyle.borderLineColor,
|
|
|
|
fill: this.style.transparentColor
|
|
|
|
}
|
|
|
|
});
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-20 17:17:23 +08:00
|
|
|
this.nameRect = new Rect({
|
|
|
|
silent: true,
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: 5,
|
|
|
|
shape: this.device.sigName.getBoundingRect(),
|
|
|
|
style: {
|
|
|
|
lineDash: this.style.Signal.mouseOverStyle.borderLineDash,
|
|
|
|
stroke: this.style.Signal.mouseOverStyle.borderLineColor,
|
|
|
|
fill: this.style.Signal.mouseOverStyle.nameBackgroundColor
|
|
|
|
}
|
|
|
|
});
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-20 17:17:23 +08:00
|
|
|
this.lampRect.hide();
|
|
|
|
this.nameRect.hide();
|
|
|
|
this.add(this.lampRect);
|
|
|
|
this.add(this.nameRect);
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-20 17:17:23 +08:00
|
|
|
mouseover(e) {
|
|
|
|
this.nameRect.show();
|
|
|
|
this.lampRect.show();
|
|
|
|
this.device.lamps.forEach(elem => {
|
|
|
|
elem.setBorderColor(this.style.Signal.mouseOverStyle.lampBorderLineColor);
|
|
|
|
});
|
|
|
|
this.device.sigName && this.device.sigName.setColor(this.style.backgroundColor);
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-20 17:17:23 +08:00
|
|
|
mouseout(e) {
|
|
|
|
if (!this.device.model.down) {
|
|
|
|
this.nameRect.hide();
|
|
|
|
this.lampRect.hide();
|
|
|
|
this.device.lamps.forEach(elem => {
|
|
|
|
elem.setBorderColor(this.style.Signal.lamp.borderColor);
|
|
|
|
});
|
|
|
|
this.device.setState(this.device.model);
|
|
|
|
}
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|