diff --git a/src/services/state/uiState.store.helper.ts b/src/services/state/uiState.store.helper.ts index 0c0070f8d074b5ee25ded0830a9b48e9380bf84a..24d247b73b62db609cae7110f6a44a57a0b02049 100644 --- a/src/services/state/uiState.store.helper.ts +++ b/src/services/state/uiState.store.helper.ts @@ -11,6 +11,8 @@ export { uiActionHideDatasetWithId, uiActionShowDatasetWtihId, uiActionSnackbarMessage, + uiActionMouseoverLandmark, + uiActionMouseoverSegments, } from './uiState/actions' export { diff --git a/src/services/state/uiState.store.ts b/src/services/state/uiState.store.ts index a31d256de9126b42201220596aa7985cad63caab..b657e976144637106eba52a874f01c353fe4ffb3 100644 --- a/src/services/state/uiState.store.ts +++ b/src/services/state/uiState.store.ts @@ -10,7 +10,7 @@ import { MatBottomSheetRef, MatBottomSheet } from '@angular/material/bottom-shee import { uiStateCloseSidePanel, uiStateOpenSidePanel, uiStateCollapseSidePanel, uiStateExpandSidePanel, uiActionSetPreviewingDatasetFiles, uiStateShowBottomSheet, uiActionShowSidePanelConnectivity } from './uiState.store.helper'; import { viewerStateMouseOverCustomLandmark } from './viewerState/actions'; import { IUiState } from './uiState/common' -import { uiActionHideAllDatasets, uiActionHideDatasetWithId, uiActionShowDatasetWtihId, uiActionSnackbarMessage } from './uiState/actions'; +import { uiActionHideAllDatasets, uiActionHideDatasetWithId, uiActionMouseoverLandmark, uiActionMouseoverSegments, uiActionShowDatasetWtihId, uiActionSnackbarMessage } from './uiState/actions'; export const defaultState: IUiState = { shownDatasetId: [], @@ -67,7 +67,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: IUiS previewingDatasetFiles } } - case MOUSE_OVER_SEGMENTS: { + case uiActionMouseoverSegments.type: { const { segments } = action return { ...prevState, @@ -87,7 +87,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: IUiS mouseOverUserLandmark, } } - case MOUSE_OVER_LANDMARK: + case uiActionMouseoverLandmark.type: return { ...prevState, mouseOverLandmark : action.landmark, @@ -259,8 +259,6 @@ export class UiStateUseEffect implements OnDestroy{ } export const MOUSE_OVER_SEGMENT = `MOUSE_OVER_SEGMENT` -export const MOUSE_OVER_SEGMENTS = `MOUSE_OVER_SEGMENTS` -export const MOUSE_OVER_LANDMARK = `MOUSE_OVER_LANDMARK` export const CLOSE_SIDE_PANEL = `CLOSE_SIDE_PANEL` export const OPEN_SIDE_PANEL = `OPEN_SIDE_PANEL` diff --git a/src/services/state/uiState/actions.ts b/src/services/state/uiState/actions.ts index 961511e110429f46b0a5e850b06b720c44e47a9d..60c71113bbd08b529f8bdfaf1c7f5cc12cb830d7 100644 --- a/src/services/state/uiState/actions.ts +++ b/src/services/state/uiState/actions.ts @@ -24,6 +24,16 @@ export const uiStateShowBottomSheet = createAction( props<{ bottomSheetTemplate: TemplateRef<unknown>, config?: MatBottomSheetConfig }>() ) +export const uiActionMouseoverLandmark = createAction( + `[uiState] mouseoverLandmark`, + props<{ landmark: any }>() +) + +export const uiActionMouseoverSegments = createAction( + `[uiState] mouseoverSegments`, + props<{ segments: any[] }>() +) + export const uiActionSetPreviewingDatasetFiles = createAction( `[uiState] setDatasetPreviews`, props<{previewingDatasetFiles: {datasetId: string, filename: string}[]}>() diff --git a/src/services/state/viewerConfig.store.ts b/src/services/state/viewerConfig.store.ts index b3a80aeb9d2b4e4ab379f39d83e32bd1a143ebe9..a80981b30db8fc07b5bb3c33a77534c635264ccd 100644 --- a/src/services/state/viewerConfig.store.ts +++ b/src/services/state/viewerConfig.store.ts @@ -23,7 +23,6 @@ export const CONFIG_CONSTANTS = { export const VIEWER_CONFIG_ACTION_TYPES = { SET_ANIMATION: `SET_ANIMATION`, UPDATE_CONFIG: `UPDATE_CONFIG`, - CHANGE_GPU_LIMIT: `CHANGE_GPU_LIMIT`, SET_MOBILE_UI: actionSetMobileUi.type, } @@ -74,18 +73,6 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat ...prevState, ...action.config, } - case VIEWER_CONFIG_ACTION_TYPES.CHANGE_GPU_LIMIT: { - const newGpuLimit = Math.min( - CONFIG_CONSTANTS.gpuLimitMax, - Math.max( - (prevState.gpuLimit || CONFIG_CONSTANTS.defaultGpuLimit) + action.payload.delta, - CONFIG_CONSTANTS.gpuLimitMin, - )) - return { - ...prevState, - gpuLimit: newGpuLimit, - } - } default: return prevState } } diff --git a/src/services/state/viewerState.store.helper.ts b/src/services/state/viewerState.store.helper.ts index 8bfe2d676df861a97eb62a58259b877f4a6bd4d9..0e3b6dc333de2d8dc85b8fa1fb7d57c4dd47feb5 100644 --- a/src/services/state/viewerState.store.helper.ts +++ b/src/services/state/viewerState.store.helper.ts @@ -15,6 +15,7 @@ import { viewerStateSelectParcellation, viewerStateSelectTemplateWithId, viewerStateSetConnectivityRegion, + viewerStateNehubaLayerchanged, viewerStateSetFetchedAtlases, viewerStateSetSelectedRegions, viewerStateSetSelectedRegionsWithIds, @@ -38,6 +39,7 @@ export { viewerStateSelectParcellation, viewerStateSelectTemplateWithId, viewerStateSetConnectivityRegion, + viewerStateNehubaLayerchanged, viewerStateSetFetchedAtlases, viewerStateSetSelectedRegions, viewerStateSetSelectedRegionsWithIds, diff --git a/src/services/state/viewerState.store.ts b/src/services/state/viewerState.store.ts index 543350c50da30bb7cf5c2f0d33a303c3d3322cd3..f3cc540b4371de0f7c5f19113170008b14171ed2 100644 --- a/src/services/state/viewerState.store.ts +++ b/src/services/state/viewerState.store.ts @@ -24,7 +24,7 @@ import { viewerStateNewViewer } from './viewerState.store.helper'; import { cvtNehubaConfigToNavigationObj } from 'src/state'; -import { viewerStateChangeNavigation } from './viewerState/actions'; +import { viewerStateChangeNavigation, viewerStateNehubaLayerchanged } from './viewerState/actions'; import { serialiseParcellationRegion } from "common/util" export interface StateInterface { @@ -185,7 +185,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Part * TODO * duplicated with ngViewerState.layers ? */ - case NEHUBA_LAYER_CHANGED: { + case viewerStateNehubaLayerchanged.type: { const viewer = getViewer() if (!viewer) { return { @@ -261,7 +261,6 @@ export const USER_LANDMARKS = `USER_LANDMARKS` export const ADD_TO_REGIONS_SELECTION_WITH_IDS = `ADD_TO_REGIONS_SELECTION_WITH_IDS` -export const NEHUBA_LAYER_CHANGED = `NEHUBA_LAYER_CHANGED` export const SET_CONNECTIVITY_REGION = `SET_CONNECTIVITY_REGION` export const CLEAR_CONNECTIVITY_REGION = `CLEAR_CONNECTIVITY_REGION` export const SET_OVERWRITTEN_COLOR_MAP = `SET_OVERWRITTEN_COLOR_MAP` diff --git a/src/services/state/viewerState/actions.ts b/src/services/state/viewerState/actions.ts index 1a066605fe47e1962e03dda67f1c93247f895203..68787f5b45cb6053bb99557bd1b34f42c004db62 100644 --- a/src/services/state/viewerState/actions.ts +++ b/src/services/state/viewerState/actions.ts @@ -25,6 +25,10 @@ export const viewerStateSetConnectivityRegion = createAction( props<{ connectivityRegion: any }>() ) +export const viewerStateNehubaLayerchanged = createAction( + `[viewerState] nehubaLayerChanged`, +) + export const viewerStateNavigateToRegion = createAction( `[viewerState] navigateToRegion`, props<{ payload: { region: any } }>() diff --git a/src/services/stateStore.service.ts b/src/services/stateStore.service.ts index fab546d7876dee4ec5a2d06c7285753715ba0381..ca7024f3bea863024b1b637934596119859f9a7f 100644 --- a/src/services/stateStore.service.ts +++ b/src/services/stateStore.service.ts @@ -55,7 +55,7 @@ export { userConfigState, USER_CONFIG_ACTION_TYPES} export { CHANGE_NAVIGATION, DESELECT_LANDMARKS, FETCHED_TEMPLATE, NEWVIEWER, SELECT_LANDMARKS, SELECT_PARCELLATION, SELECT_REGIONS, USER_LANDMARKS } from './state/viewerState.store' export { IDataEntry, IParcellationRegion, FETCHED_DATAENTRIES, FETCHED_SPATIAL_DATA, ILandmark, IOtherLandmarkGeometry, IPlaneLandmarkGeometry, IPointLandmarkGeometry, IProperty, IPublication, IReferenceSpace, IFile, IFileSupplementData } from './state/dataStore.store' -export { CLOSE_SIDE_PANEL, MOUSE_OVER_LANDMARK, MOUSE_OVER_SEGMENT, OPEN_SIDE_PANEL, COLLAPSE_SIDE_PANEL_CURRENT_VIEW, EXPAND_SIDE_PANEL_CURRENT_VIEW } from './state/uiState.store' +export { CLOSE_SIDE_PANEL, MOUSE_OVER_SEGMENT, OPEN_SIDE_PANEL, COLLAPSE_SIDE_PANEL_CURRENT_VIEW, EXPAND_SIDE_PANEL_CURRENT_VIEW } from './state/uiState.store' export { UserConfigStateUseEffect } from './state/userConfigState.store' export { GENERAL_ACTION_TYPES, generalActionError } from './stateStore.helper' diff --git a/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.spec.ts b/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.spec.ts index 91c8e5847a0b025b882057e7a2255fcad7bb5f7a..e9f734d0946a85785b1f4ac5f7a56f646c55d14e 100644 --- a/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.spec.ts +++ b/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.spec.ts @@ -108,14 +108,30 @@ describe('> nehubaViewerInterface.directive.ts', () => { }) describe('> on createNehubaInstance called', () => { - const template = {} + const template = { } const lifecycle = {} - beforeEach(() => { - directiveInstance.createNehubaInstance(template, lifecycle) - }) it('> method el.clear gets called before el.createComponent', () => { + directiveInstance.createNehubaInstance(template, lifecycle) expect(elClearSpy).toHaveBeenCalledBefore(elCreateComponentSpy) }) + + it('> if viewerConfig has gpuLimit, gpuMemoryLimit will be in initialNgSTate', () => { + template['nehubaConfig'] = { + dataset: { + initialNgState: {} + } + } + directiveInstance['viewerConfig'] = { + gpuLimit: 5e8 + } + directiveInstance.createNehubaInstance(template, lifecycle) + expect( + directiveInstance.nehubaViewerInstance?.config?.dataset?.initialNgState?.gpuMemoryLimit + ).toEqual(5e8) + expect( + directiveInstance.nehubaViewerInstance?.config?.dataset?.initialNgState?.gpuLimit + ).toBeFalsy() + }) }) describe('> on clear called', () => { @@ -143,6 +159,7 @@ describe('> nehubaViewerInterface.directive.ts', () => { expect(elClearSpy).toHaveBeenCalled() }) }) + }) }) }) diff --git a/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.ts b/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.ts index e0f0678a4d20ff05f1dee4ce9f8d9d21e6b5e685..f66351553f38016391f1ba4a71d2edfda56190f2 100644 --- a/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.ts +++ b/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.ts @@ -1,19 +1,17 @@ import { Directive, ViewContainerRef, ComponentFactoryResolver, ComponentFactory, ComponentRef, OnInit, OnDestroy, Output, EventEmitter, Optional } from "@angular/core"; import { NehubaViewerUnit, INehubaLifecycleHook } from "../nehubaViewer/nehubaViewer.component"; import { Store, select } from "@ngrx/store"; -import { IavRootStoreInterface } from "src/services/stateStore.service"; import { Subscription, Observable, fromEvent } from "rxjs"; import { distinctUntilChanged, filter, debounceTime, scan, map, throttleTime, switchMapTo } from "rxjs/operators"; -import { StateInterface as ViewerConfigStateInterface } from "src/services/state/viewerConfig.store"; import { getNavigationStateFromConfig, takeOnePipe } from "../util"; -import { NEHUBA_LAYER_CHANGED, CHANGE_NAVIGATION } from "src/services/state/viewerState.store"; import { timedValues } from "src/util/generator"; -import { MOUSE_OVER_SEGMENTS, MOUSE_OVER_LANDMARK } from "src/services/state/uiState.store"; import { ngViewerActionNehubaReady } from "src/services/state/ngViewerState/actions"; -import { viewerStateMouseOverCustomLandmarkInPerspectiveView } from "src/services/state/viewerState/actions"; +import { viewerStateChangeNavigation, viewerStateMouseOverCustomLandmarkInPerspectiveView, viewerStateNehubaLayerchanged } from "src/services/state/viewerState/actions"; import { viewerStateStandAloneVolumes, viewerStateSelectorNavigation } from "src/services/state/viewerState/selectors"; import { ngViewerSelectorOctantRemoval } from "src/services/state/ngViewerState/selectors"; import { LoggingService } from "src/logging"; +import { uiActionMouseoverLandmark, uiActionMouseoverSegments } from "src/services/state/uiState/actions"; +import { IViewerConfigState } from "src/services/state/viewerConfig.store.helper"; const defaultNehubaConfig = { "configName": "", @@ -272,7 +270,7 @@ export class NehubaViewerContainerDirective implements OnInit, OnDestroy{ constructor( private el: ViewContainerRef, private cfr: ComponentFactoryResolver, - private store$: Store<IavRootStoreInterface>, + private store$: Store<any>, @Optional() private log: LoggingService, ){ this.nehubaViewerFactory = this.cfr.resolveComponentFactory(NehubaViewerUnit) @@ -299,8 +297,8 @@ export class NehubaViewerContainerDirective implements OnInit, OnDestroy{ private nehubaViewerPerspectiveOctantRemoval$: Observable<boolean> private navigationChanges$: Observable<any> - private viewerPerformanceConfig$: Observable<ViewerConfigStateInterface> - private viewerConfig: Partial<ViewerConfigStateInterface> = {} + private viewerPerformanceConfig$: Observable<IViewerConfigState> + private viewerConfig: Partial<IViewerConfigState> = {} public oldNavigation: any = {} private storedNav: any @@ -403,7 +401,8 @@ export class NehubaViewerContainerDirective implements OnInit, OnDestroy{ if (gpuLimit) { const initialNgState = nehubaConfig && nehubaConfig.dataset && nehubaConfig.dataset.initialNgState - initialNgState.gpuLimit = gpuLimit + // the correct key is gpuMemoryLimit + initialNgState.gpuMemoryLimit = gpuLimit } /* TODO replace with id from KG */ @@ -419,9 +418,9 @@ export class NehubaViewerContainerDirective implements OnInit, OnDestroy{ }), this.nehubaViewerInstance.layersChanged.subscribe(() => { - this.store$.dispatch({ - type: NEHUBA_LAYER_CHANGED - }) + this.store$.dispatch( + viewerStateNehubaLayerchanged() + ) }), this.nehubaViewerInstance.nehubaReady.subscribe(() => { @@ -439,26 +438,28 @@ export class NehubaViewerContainerDirective implements OnInit, OnDestroy{ scan(accumulatorFn, new Map()), map((map: Map<string, any>) => Array.from(map.entries()).filter(([_ngId, { segmentId }]) => segmentId)), ).subscribe(arrOfArr => { - this.store$.dispatch({ - type: MOUSE_OVER_SEGMENTS, - segments: arrOfArr.map( ([ngId, {segment, segmentId}]) => { - return { - layer: { - name: ngId, - }, - segment: segment || `${ngId}#${segmentId}`, - } - } ), - }) + this.store$.dispatch( + uiActionMouseoverSegments({ + segments: arrOfArr.map( ([ngId, {segment, segmentId}]) => { + return { + layer: { + name: ngId, + }, + segment: segment || `${ngId}#${segmentId}`, + } + } ) + }) + ) }), this.nehubaViewerInstance.mouseoverLandmarkEmitter.pipe( distinctUntilChanged() ).subscribe(label => { - this.store$.dispatch({ - type : MOUSE_OVER_LANDMARK, - landmark : label, - }) + this.store$.dispatch( + uiActionMouseoverLandmark({ + landmark: label + }) + ) }), this.nehubaViewerInstance.mouseoverUserlandmarkEmitter.pipe( @@ -529,10 +530,11 @@ export class NehubaViewerContainerDirective implements OnInit, OnDestroy{ /* navigation changed actively (by user interaction with the viewer) probagate the changes to the store */ - this.store$.dispatch({ - type : CHANGE_NAVIGATION, - navigation, - }) + this.store$.dispatch( + viewerStateChangeNavigation({ + navigation, + }) + ) }