diff --git a/src/atlasViewer/atlasViewer.urlService.service.ts b/src/atlasViewer/atlasViewer.urlService.service.ts index de1759e11dff8ef87a3f3a0706c8fd83302330ca..77cfd7e1e5210ee4d8a8d63997c409ca676def96 100644 --- a/src/atlasViewer/atlasViewer.urlService.service.ts +++ b/src/atlasViewer/atlasViewer.urlService.service.ts @@ -215,8 +215,14 @@ export class AtlasViewerURLService{ /* pushing state to url */ combineLatest( - this.changeQueryObservable$.pipe( - map(state=>{ + combineLatest( + this.changeQueryObservable$, + this.store.pipe( + select('viewerState'), + select('parcellationSelected') + ) + ).pipe( + map(([state, parcellationSelected])=>{ let _ = {} for(const key in state){ if(isDefined(state[key])){ @@ -239,7 +245,7 @@ export class AtlasViewerURLService{ } break; case 'regionsSelected': - _[key] = state[key].map(({ ngId, labelIndex })=> generateLabelIndexId({ ngId,labelIndex })).join('_') + _[key] = state[key].map(({ ngId = parcellationSelected && parcellationSelected.ngId, labelIndex })=> generateLabelIndexId({ ngId,labelIndex })).join('_') break; case 'templateSelected': case 'parcellationSelected': diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index a4b62b13cc30648f4c0e3646d9400d3079ed70c4..cd15e7e6f43858e9df505928641e41ab98cb32fc 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -497,13 +497,16 @@ export class NehubaContainer implements OnInit, OnDestroy{ ), this.ngLayers$.pipe( map(state => state.forceShowSegment) - ) + ), + this.selectedParcellation$ ) - .subscribe(([regions,hideSegmentFlag,forceShowSegment])=>{ + .subscribe(([regions,hideSegmentFlag,forceShowSegment, selectedParcellation])=>{ if(!this.nehubaViewer) return + const { ngId: defaultNgId } = selectedParcellation + /* selectedregionindexset needs to be updated regardless of forceshowsegment */ - this.selectedRegionIndexSet = new Set(regions.map(({ngId, labelIndex})=>generateLabelIndexId({ ngId, labelIndex }))) + this.selectedRegionIndexSet = new Set(regions.map(({ngId = defaultNgId, labelIndex})=>generateLabelIndexId({ ngId, labelIndex }))) if( forceShowSegment === false || (forceShowSegment === null && hideSegmentFlag) ){ this.nehubaViewer.hideAllSeg() @@ -557,12 +560,14 @@ export class NehubaContainer implements OnInit, OnDestroy{ combineLatest( this.navigationChanges$, this.selectedRegions$, - ).subscribe(([navigation,regions])=>{ + this.selectedParcellation$ + ).subscribe(([navigation,regions, selectedParcellation])=>{ this.nehubaViewer.initNav = Object.assign({},navigation,{ positionReal : true }) - this.nehubaViewer.initRegions = regions.map(({ ngId, labelIndex }) =>generateLabelIndexId({ ngId, labelIndex })) + const { ngId : defaultNgId } = selectedParcellation + this.nehubaViewer.initRegions = regions.map(({ ngId = defaultNgId, labelIndex }) =>generateLabelIndexId({ ngId, labelIndex })) }) this.subscriptions.push( diff --git a/src/ui/regionHierachy/regionHierarchy.component.ts b/src/ui/regionHierachy/regionHierarchy.component.ts index f04dc7b1b501c71e5b5cc48ce5181cab4275e896..bb0be7c3dffe5b4be964d500f97402346638781c 100644 --- a/src/ui/regionHierachy/regionHierarchy.component.ts +++ b/src/ui/regionHierachy/regionHierarchy.component.ts @@ -11,11 +11,11 @@ const insertHighlight :(name:string, searchTerm:string) => string = (name:string name.replace(regex, (s) => `<span class = "highlight">${s}</span>`) } -const getDisplayTreeNode : (searchTerm:string, selectedRegions:any[]) => (item:any) => string = (searchTerm:string = '', selectedRegions:any[] = []) => ({ ngId, name, status, labelIndex }) => { +const getDisplayTreeNode : (searchTerm:string, selectedRegions:any[], defaultNgId: string) => (item:any) => string = (searchTerm:string = '', selectedRegions:any[] = [], defaultNgId) => ({ ngId = defaultNgId, name, status, labelIndex }) => { return !!labelIndex && !!ngId && selectedRegions.findIndex(re => - generateLabelIndexId({ labelIndex: re.labelIndex, ngId: re.ngId }) === generateLabelIndexId({ ngId, labelIndex }) + generateLabelIndexId({ labelIndex: re.labelIndex, ngId: re.ngId || defaultNgId }) === generateLabelIndexId({ ngId, labelIndex }) ) >= 0 ? `<span class="regionSelected">${insertHighlight(name, searchTerm)}</span>` + (status ? ` <span class="text-muted">(${insertHighlight(status, searchTerm)})</span>` : ``) : `<span class="regionNotSelected">${insertHighlight(name, searchTerm)}</span>` + (status ? ` <span class="text-muted">(${insertHighlight(status, searchTerm)})</span>` : ``) @@ -86,7 +86,7 @@ export class RegionHierarchy implements OnInit, AfterViewInit{ name: this.selectedParcellation.name, children: this.selectedParcellation.regions } - this.displayTreeNode = getDisplayTreeNode(this.searchTerm, this.selectedRegions) + this.displayTreeNode = getDisplayTreeNode(this.searchTerm, this.selectedRegions, this.selectedParcellation.ngId) this.filterTreeBySearch = getFilterTreeBySearch(this.filterNameBySearchPipe, this.searchTerm) } @@ -105,7 +105,7 @@ export class RegionHierarchy implements OnInit, AfterViewInit{ } ngOnInit(){ - this.displayTreeNode = getDisplayTreeNode(this.searchTerm, this.selectedRegions) + this.displayTreeNode = getDisplayTreeNode(this.searchTerm, this.selectedRegions, this.selectedParcellation.ngId) this.filterTreeBySearch = getFilterTreeBySearch(this.filterNameBySearchPipe, this.searchTerm) this.subscriptions.push( @@ -130,7 +130,7 @@ export class RegionHierarchy implements OnInit, AfterViewInit{ fromEvent(this.searchTermInput.nativeElement, 'focus').pipe( ).subscribe(() => { - this.displayTreeNode = getDisplayTreeNode(this.searchTerm, this.selectedRegions) + this.displayTreeNode = getDisplayTreeNode(this.searchTerm, this.selectedRegions, this.selectedParcellation.ngId) this.filterTreeBySearch = getFilterTreeBySearch(this.filterNameBySearchPipe, this.searchTerm) }) )