diff --git a/e2e/src/basic/layout.e2e-spec.js b/e2e/src/layout/layout.e2e-spec.js similarity index 100% rename from e2e/src/basic/layout.e2e-spec.js rename to e2e/src/layout/layout.e2e-spec.js diff --git a/e2e/src/selecting/template.e2e-spec.js b/e2e/src/selecting/template.e2e-spec.js index 5e73bc195bde80e24aa3d23eb6018082c2eba6b3..6009f709fa4ee07450a0c83a96ad74db7bfff7b1 100644 --- a/e2e/src/selecting/template.e2e-spec.js +++ b/e2e/src/selecting/template.e2e-spec.js @@ -1,50 +1,79 @@ const { AtlasPage } = require("../util") -describe('selecting template', () => { +describe('templates > ', () => { + let iavPage - beforeEach(async () => { iavPage = new AtlasPage() await iavPage.init() }) - it('can select template by clicking main card', async () => { - await iavPage.goto() - await iavPage.selectTitleCard('ICBM 2009c Nonlinear Asymmetric') - await iavPage.wait(1000) - - const viewerIsPopulated = await iavPage.viewerIsPopulated() - expect(viewerIsPopulated).toBe(true) - }) + describe('selecting template', () => { + + it('can select template by clicking main card', async () => { + await iavPage.goto() + await iavPage.selectTitleCard('ICBM 2009c Nonlinear Asymmetric') + await iavPage.wait(1000) - - it('switching template after template init by clicking select should work', async () => { - - await iavPage.goto() - - await iavPage.selectTitleCard('ICBM 2009c Nonlinear Asymmetric') - await iavPage.wait(1000) - - await iavPage.selectDropdownTemplate('Big Brain (Histology)') - await iavPage.wait(7000) - - const viewerIsPopulated = await iavPage.viewerIsPopulated() - expect(viewerIsPopulated).toBe(true) + const viewerIsPopulated = await iavPage.viewerIsPopulated() + expect(viewerIsPopulated).toBe(true) + }) + + + it('switching template after template init by clicking select should work', async () => { + + await iavPage.goto() + + await iavPage.selectTitleCard('ICBM 2009c Nonlinear Asymmetric') + await iavPage.wait(1000) + + await iavPage.selectDropdownTemplate('Big Brain (Histology)') + await iavPage.wait(7000) + + const viewerIsPopulated = await iavPage.viewerIsPopulated() + expect(viewerIsPopulated).toBe(true) + }) + + it('MNI152 should return desc', async () => { + + const expectedDesc = `An unbiased non-linear average of multiple subjects from the MNI152 database, which provides high-spatial resolution and signal-to-noise while not being biased towards a single brain (Fonov et al., 2011). This template space is widely used as a reference space in neuroimaging. HBP provides the JuBrain probabilistic cytoarchitectonic atlas (Amunts/Zilles, 2015) as well as a probabilistic atlas of large fibre bundles (Guevara, Mangin et al., 2017) in this space.` + + await iavPage.goto() + + await iavPage.selectTitleCard('ICBM 2009c Nonlinear Asymmetric') + await iavPage.wait(1000) + + const info = await iavPage.getTemplateInfo() + + expect( + info.indexOf(expectedDesc) + ).toBeGreaterThanOrEqual(0) + }) }) + + describe('switching template > ', () => { + it('works in history navigation', async () => { + await iavPage.goto() + await iavPage.selectTitleCard('ICBM 2009c Nonlinear Asymmetric') + await iavPage.wait(500) + await iavPage.waitUntilAllChunksLoaded() - it('MNI152 should return desc', async () => { - - const expectedDesc = `An unbiased non-linear average of multiple subjects from the MNI152 database, which provides high-spatial resolution and signal-to-noise while not being biased towards a single brain (Fonov et al., 2011). This template space is widely used as a reference space in neuroimaging. HBP provides the JuBrain probabilistic cytoarchitectonic atlas (Amunts/Zilles, 2015) as well as a probabilistic atlas of large fibre bundles (Guevara, Mangin et al., 2017) in this space.` - - await iavPage.goto() + await iavPage.selectDropdownTemplate('MNI Colin 27') + await iavPage.wait(500) + await iavPage.waitUntilAllChunksLoaded() - await iavPage.selectTitleCard('ICBM 2009c Nonlinear Asymmetric') - await iavPage.wait(1000) + await iavPage.historyBack() + await iavPage.wait(500) + await iavPage.historyBack() + await iavPage.wait(2000) - const info = await iavPage.getTemplateInfo() + const visible = await iavPage.sideNavIsVisible() + if (!visible) await iavPage.clickSideNavTab() + const templateInfo = await iavPage.getTemplateInfo() - expect( - info.indexOf(expectedDesc) - ).toBeGreaterThanOrEqual(0) + expect( + templateInfo.indexOf('ICBM 2009c Nonlinear Asymmetric') + ).toBeGreaterThanOrEqual(0) + }) }) -}) +}) \ No newline at end of file diff --git a/e2e/src/util.js b/e2e/src/util.js index 5aad51bf46cfdaf97fbd44f3bcd2cd9f711a7b1d..f79d341a931755b53dd5e4413dc32b21bed30797 100644 --- a/e2e/src/util.js +++ b/e2e/src/util.js @@ -33,6 +33,15 @@ class WdBase{ get _driver(){ return this._browser.driver } + + historyBack() { + return this._browser.navigate().back() + } + + historyForward() { + return this._browser.navigate().forward() + } + async init() { const wSizeArg = chromeOpts.find(arg => arg.indexOf('--window-size') >= 0) const [ _, width, height ] = /\=([0-9]{1,})\,([0-9]{1,})$/.exec(wSizeArg) diff --git a/src/services/effect/effect.ts b/src/services/effect/effect.ts index 16f5a3b1e9aebd4a41030d888c5aa829083a730f..21d0fa53fed58f5dcb7a3a6dfd5131dd5285d73d 100644 --- a/src/services/effect/effect.ts +++ b/src/services/effect/effect.ts @@ -192,17 +192,8 @@ export class UseEffects implements OnDestroy { /** * side effects of loading a new template space - * reset navigation (navigation translation is done by a different service) * Landmarks will no longer be accurate (differente template space) */ - @Effect() - public onNewViewerResetNavigation$ = this.actions$.pipe( - ofType(NEWVIEWER), - mapTo({ - type: CHANGE_NAVIGATION, - navigation: {} - }) - ) @Effect() public onNewViewerResetLandmarkSelected$ = this.actions$.pipe( diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index 694ff1e98af6a20d4189181ecb10d31411f395d1..2b194f08441a451af6fde30a42fa0578becfec09 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -32,7 +32,7 @@ import { AtlasViewerAPIServices, IUserLandmark } from "../../atlasViewer/atlasVi import { AtlasViewerConstantsServices } from "../../atlasViewer/atlasViewer.constantService.service"; import { timedValues } from "../../util/generator"; import { computeDistance, NehubaViewerUnit } from "./nehubaViewer/nehubaViewer.component"; -import { getFourPanel, getHorizontalOneThree, getSinglePanel, getVerticalOneThree } from "./util"; +import { getFourPanel, getHorizontalOneThree, getSinglePanel, getVerticalOneThree, getNavigationStateFromConfig } from "./util"; const isFirstRow = (cell: HTMLElement) => { const { parentElement: row } = cell @@ -605,12 +605,9 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { withLatestFrom( this.selectedParcellation$.pipe( startWith(null), - ), - this.navigationChanges$.pipe( - startWith({}) ) ), - ).subscribe(([templateSelected, parcellationSelected, navigation]) => { + ).subscribe(([templateSelected, parcellationSelected]) => { this.store.dispatch({ type: NEHUBA_READY, nehubaReady: false, @@ -618,7 +615,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { this.nehubaViewerSubscriptions.forEach(s => s.unsubscribe()) this.selectedTemplate = templateSelected - this.createNewNehuba(templateSelected, navigation) + this.createNewNehuba(templateSelected) const foundParcellation = parcellationSelected && templateSelected.parcellations.find(parcellation => parcellationSelected.name === parcellation.name) this.handleParcellation(foundParcellation || templateSelected.parcellations[0]) @@ -742,7 +739,9 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { }) this.subscriptions.push( - this.navigationChanges$.subscribe(this.handleDispatchedNavigationChange.bind(this)), + this.navigationChanges$.subscribe(ev => { + this.handleDispatchedNavigationChange(ev) + }), ) /* handler to open/select landmark */ @@ -989,7 +988,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { this.cdr.detectChanges() } - private createNewNehuba(template: any, overwriteInitNavigation: any) { + private createNewNehuba(template: any) { this.viewerLoaded = true this.cr = this.container.createComponent(this.nehubaViewerFactory) @@ -999,31 +998,13 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { * apply viewer config such as gpu limit */ const { gpuLimit = null } = this.viewerConfig + const { nehubaConfig } = template - const { navigation = {}, perspectiveOrientation = [0, 0, 0, 1], perspectiveZoom = 1e7 } = nehubaConfig.dataset.initialNgState || {} - const { zoomFactor = 3e5, pose = {} } = navigation || {} - const { voxelSize = [1e6, 1e6, 1e6], voxelCoordinates = [0, 0, 0] } = (pose && pose.position) || {} - const { orientation = [0, 0, 0, 1] } = pose || {} - - const { - orientation: owOrientation, - perspectiveOrientation: owPerspectiveOrientation, - perspectiveZoom: owPerspectiveZoom, - position: owPosition, - zoom: owZoom - } = overwriteInitNavigation - - const initNavigation = { - orientation: owOrientation || [0, 0, 0, 1], - perspectiveOrientation: owPerspectiveOrientation || perspectiveOrientation, - perspectiveZoom: owPerspectiveZoom || perspectiveZoom, - position: owPosition || [0, 1, 2].map(idx => voxelSize[idx] * voxelCoordinates[idx]), - zoom: owZoom || zoomFactor, - } - this.handleEmittedNavigationChange(initNavigation) + const navState = getNavigationStateFromConfig(nehubaConfig) - this.oldNavigation = initNavigation + this.oldNavigation = navState + this.handleEmittedNavigationChange(navState) if (gpuLimit) { const initialNgState = nehubaConfig && nehubaConfig.dataset && nehubaConfig.dataset.initialNgState diff --git a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts index 09b8cd4edf97100568c3a42840b088c91aa91b0c..8fc25f1827ad0e28b22b9b4479f6d16ef8b4b716 100644 --- a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts +++ b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts @@ -636,9 +636,7 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { public setNavigationState(newViewerState: Partial<ViewerState>) { if (!this.nehubaViewer) { - if (!PRODUCTION) { - this.log.warn('setNavigationState > this.nehubaViewer is not yet defined') - } + this.log.warn('setNavigationState > this.nehubaViewer is not yet defined') return } @@ -775,7 +773,7 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { perspectiveOrientation : Array.from(perspectiveOrientation), perspectiveZoom, zoom, - position, + position: Array.from(position), positionReal : true, }) }) diff --git a/src/ui/nehubaContainer/util.ts b/src/ui/nehubaContainer/util.ts index 14c416a4b0bf55e0e44cb4635a0ed053c4118825..7e2786490864e1b879d875c9ba388b91c738bffb 100644 --- a/src/ui/nehubaContainer/util.ts +++ b/src/ui/nehubaContainer/util.ts @@ -157,3 +157,33 @@ export const isIdentityQuat = ori => Math.abs(ori[0]) < 1e-6 && Math.abs(ori[1]) < 1e-6 && Math.abs(ori[2]) < 1e-6 && Math.abs(ori[3] - 1) < 1e-6 + +export const getNavigationStateFromConfig = nehubaConfig => { + const { + navigation = {}, + perspectiveOrientation = [0, 0, 0, 1], + perspectiveZoom = 1e7 + } = (nehubaConfig && nehubaConfig.dataset && nehubaConfig.dataset.initialNgState) || {} + + const { + zoomFactor = 3e5, + pose = {} + } = navigation || {} + + const { + voxelSize = [1e6, 1e6, 1e6], + voxelCoordinates = [0, 0, 0] + } = (pose && pose.position) || {} + + const { + orientation = [0, 0, 0, 1] + } = pose || {} + + return { + orientation, + perspectiveOrientation, + perspectiveZoom, + position: [0, 1, 2].map(idx => voxelSize[idx] * voxelCoordinates[idx]), + zoom: zoomFactor + } +} \ No newline at end of file