Skip to content
Snippets Groups Projects
Commit 04a305bf authored by Xiao Gui's avatar Xiao Gui
Browse files

hotfix: fix regions that does not have individual ngId entries

parent 15daf684
No related branches found
No related tags found
No related merge requests found
......@@ -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':
......
......@@ -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(
......
......@@ -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)
})
)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment