From aa3b8201f45c3207c5615d96edcf2302497132e2 Mon Sep 17 00:00:00 2001
From: fsdavid <daviti1@mail.com>
Date: Mon, 15 Jun 2020 19:25:10 +0200
Subject: [PATCH] fix region coloring

---
 src/ui/nehubaContainer/nehubaContainer.component.ts | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts
index 1ee340abf..275b2ffa1 100644
--- a/src/ui/nehubaContainer/nehubaContainer.component.ts
+++ b/src/ui/nehubaContainer/nehubaContainer.component.ts
@@ -516,6 +516,8 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy {
       this.selectedParcellation$.subscribe((this.handleParcellation).bind(this)),
     )
 
+    let prevParcellation = null
+
     this.subscriptions.push(
 
       combineLatest(
@@ -538,13 +540,16 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy {
         const { ngId: defaultNgId } = selectedParcellation
 
         /* selectedregionindexset needs to be updated regardless of forceshowsegment */
-        this.selectedRegionIndexSet = new Set(regions.map(({ngId = defaultNgId, labelIndex}) => generateLabelIndexId({ ngId, labelIndex })))
+        this.selectedRegionIndexSet = !prevParcellation || prevParcellation === selectedParcellation?
+          new Set(regions.map(({ngId = defaultNgId, labelIndex}) => generateLabelIndexId({ ngId, labelIndex }))) : new Set()
 
         if ( forceShowSegment === false || (forceShowSegment === null && hideSegmentFlag) ) {
           this.nehubaViewer.hideAllSeg()
           return
         }
 
+        prevParcellation = selectedParcellation
+
         this.selectedRegionIndexSet.size > 0
           ? this.nehubaViewer.showSegs([...this.selectedRegionIndexSet])
           : this.nehubaViewer.showAllSeg()
-- 
GitLab