diff --git a/src/util/pureConstant.service.ts b/src/util/pureConstant.service.ts index da6a4b63a5357539ddcf30c413ddef449b1bd44a..a57f78652be8408800992629a55686f3a4aba71d 100644 --- a/src/util/pureConstant.service.ts +++ b/src/util/pureConstant.service.ts @@ -56,6 +56,16 @@ type TIAVAtlas = { } & THasId)[] } & THasId +type NgLayerObj = { + [key: string]: { + [key: string]: { + source: string + transform: number[][] + type: 'segmentation' | 'image' + } + } +} + export const spaceMiscInfoMap = new Map([ ['minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588', { name: 'bigbrain', @@ -515,7 +525,12 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" shareReplay(1) ) - public ngLayerObj = {} + private ngLayerObj: NgLayerObj = {} + + getNgLayers(templateId: string) { + return this.ngLayerObj && this.ngLayerObj[templateId] + ? this.ngLayerObj[templateId] : [] + } public initFetchTemplate$ = this.fetchedAtlases$.pipe( switchMap(atlases => { diff --git a/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.component.spec.ts b/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.component.spec.ts index 44a1fb490ccdfeb69020a48fa9a25154ef92a9dd..3d3df1491bad099d2ae5231b095199f4d4dae64f 100644 --- a/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.component.spec.ts +++ b/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.component.spec.ts @@ -7,7 +7,7 @@ import { ComponentsModule } from "src/components" import { ngViewerSelectorOctantRemoval } from "src/services/state/ngViewerState.store.helper" import { viewerStateCustomLandmarkSelector, viewerStateSelectedTemplatePureSelector } from "src/services/state/viewerState/selectors" import { AngularMaterialModule } from "src/sharedModules" -import { UtilModule } from "src/util" +import {PureContantService, UtilModule} from "src/util" import { actionSetAuxMeshes, selectorAuxMeshes } from "../../store" import { NEHUBA_INSTANCE_INJTKN } from "../../util" import { ViewerCtrlCmp } from "./viewerCtrlCmp.component" @@ -44,6 +44,12 @@ describe('> viewerCtrlCmp.component.ts', () => { { provide: NEHUBA_INSTANCE_INJTKN, useValue: new BehaviorSubject(mockNehubaViewer) + }, + { + provide: PureContantService, + useValue: { + backendUrl: `http://localhost:3000/` + } } ] }).compileComponents() diff --git a/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.component.ts b/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.component.ts index db5bea46b74d1711d4ee7aac6ebe8613c67b39e9..a6397e7e38fd010772661160cdaf9147b6226426 100644 --- a/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.component.ts +++ b/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.component.ts @@ -4,7 +4,7 @@ import { combineLatest, merge, Observable, of, Subscription } from "rxjs"; import {filter, map, pairwise, withLatestFrom} from "rxjs/operators"; import { ngViewerActionSetPerspOctantRemoval } from "src/services/state/ngViewerState/actions"; import { ngViewerSelectorOctantRemoval } from "src/services/state/ngViewerState/selectors"; -import { viewerStateCustomLandmarkSelector, viewerStateSelectedTemplatePureSelector } from "src/services/state/viewerState/selectors"; +import { viewerStateCustomLandmarkSelector, viewerStateGetSelectedAtlas, viewerStateSelectedTemplatePureSelector } from "src/services/state/viewerState/selectors"; import { NehubaViewerUnit } from "src/viewerModule/nehuba"; import { NEHUBA_INSTANCE_INJTKN } from "src/viewerModule/nehuba/util"; import { ARIA_LABELS } from 'common/constants' @@ -28,6 +28,7 @@ export class ViewerCtrlCmp{ @HostBinding('attr.darktheme') darktheme = false + private selectedAtlasId: string private selectedTemplateId: string private _flagDelin = true @@ -98,6 +99,9 @@ export class ViewerCtrlCmp{ } this.sub.push( + this.store$.select(viewerStateGetSelectedAtlas) + .pipe(filter(a => !!a)) + .subscribe(sa => this.selectedAtlasId = sa.id), this.store$.pipe( select(viewerStateSelectedTemplatePureSelector) ).subscribe(tmpl => { @@ -161,7 +165,11 @@ export class ViewerCtrlCmp{ const visibleParcLayers = ((window as any).viewer.layerManager.managedLayers) .slice(1) .filter(({ visible }) => visible) - .filter(l => Object.keys(this.pureConstantService.ngLayerObj[this.selectedTemplateId]).includes(l.name)) + + .filter(l => { + const layers = this.pureConstantService.getNgLayers(this.selectedTemplateId) + return layers && Object.keys(layers).includes(l.name) + }) .filter(layer => !this.auxMeshesNamesSet.has(layer.name)) if (this.flagDelin) {