UI: Improve SCADA symbol icon function.
This commit is contained in:
parent
b5e898a397
commit
d993b01638
@ -883,16 +883,27 @@ export class ScadaSymbolObject {
|
||||
center = true) {
|
||||
this.elements(e).forEach(element => {
|
||||
if (element.type === 'g') {
|
||||
element.clear();
|
||||
this.createIconElement(icon, size, color).subscribe((iconElement) => {
|
||||
if (iconElement) {
|
||||
element.add(iconElement);
|
||||
if (center) {
|
||||
const box = iconElement.bbox();
|
||||
iconElement.translate(-box.cx, -box.cy);
|
||||
}
|
||||
let skip = false;
|
||||
const firstChild = element.first();
|
||||
if (firstChild) {
|
||||
const iconData: {icon: string; size: number; color: string} = firstChild.remember('iconData');
|
||||
if (iconData && iconData.icon === icon && iconData.size === size && iconData.color === color) {
|
||||
skip = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!skip) {
|
||||
element.clear();
|
||||
this.createIconElement(icon, size, color).subscribe((iconElement) => {
|
||||
if (iconElement) {
|
||||
iconElement.remember('iconData', {icon, size, color});
|
||||
element.add(iconElement);
|
||||
if (center) {
|
||||
const box = iconElement.bbox();
|
||||
iconElement.translate(-box.cx, -box.cy);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user