From d993b0163840c726eeacce62ae63f86852e1f3df Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Wed, 11 Sep 2024 18:40:08 +0300 Subject: [PATCH] UI: Improve SCADA symbol icon function. --- .../widget/lib/scada/scada-symbol.models.ts | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts index 8bf3080433..1163351fb8 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts @@ -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); + } + } + }); + } } }); }