Skip to content
Snippets Groups Projects
Commit a4592f2e authored by fsdavid's avatar fsdavid
Browse files

Merge branch 'dev_region_exploring_9_1' into dev_merged_region_exploring

# Conflicts:
#	src/services/state/viewerState.store.ts
parents 942b280d dc046852
No related branches found
No related tags found
No related merge requests found
import {EventEmitter, Input, Output} from "@angular/core"; import {EventEmitter, Input, Output} from "@angular/core";
import { Store } from "@ngrx/store"; import {select, Store} from "@ngrx/store";
import {SET_CONNECTIVITY_REGION} from "src/services/state/viewerState.store"; import {NEWVIEWER, SET_CONNECTIVITY_REGION} from "src/services/state/viewerState.store";
import { import {
EXPAND_SIDE_PANEL_CURRENT_VIEW, EXPAND_SIDE_PANEL_CURRENT_VIEW,
IavRootStoreInterface, OPEN_SIDE_PANEL, IavRootStoreInterface, OPEN_SIDE_PANEL,
SHOW_SIDE_PANEL_CONNECTIVITY, SHOW_SIDE_PANEL_CONNECTIVITY,
} from "src/services/stateStore.service"; } from "src/services/stateStore.service";
import { VIEWERSTATE_CONTROLLER_ACTION_TYPES } from "../viewerStateController/viewerState.base"; import { VIEWERSTATE_CONTROLLER_ACTION_TYPES } from "../viewerStateController/viewerState.base";
import {distinctUntilChanged, shareReplay} from "rxjs/operators";
import {Observable} from "rxjs";
export class RegionBase { export class RegionBase {
...@@ -20,10 +22,40 @@ export class RegionBase { ...@@ -20,10 +22,40 @@ export class RegionBase {
@Output() public closeRegionMenu: EventEmitter<boolean> = new EventEmitter() @Output() public closeRegionMenu: EventEmitter<boolean> = new EventEmitter()
public loadedTemplate$: Observable<any[]>
public templateSelected$: Observable<any[]>
public parcellationSelected$: Observable<any[]>
protected loadedTemplates: any[]
protected selectedTemplate: any
protected selectedParcellation: any
public sameRegionTemplate: any[] = []
private parcellationRegions: any[] = []
constructor( constructor(
private store$: Store<IavRootStoreInterface>, private store$: Store<IavRootStoreInterface>,
) { ) {
const viewerState$ = this.store$.pipe(
select('viewerState'),
shareReplay(1),
)
this.loadedTemplate$ = viewerState$.pipe(
select('fetchedTemplates'),
distinctUntilChanged()
)
this.templateSelected$ = viewerState$.pipe(
select('templateSelected'),
distinctUntilChanged(),
)
this.parcellationSelected$ = viewerState$.pipe(
select('parcellationSelected'),
distinctUntilChanged(),
)
} }
public navigateToRegion() { public navigateToRegion() {
...@@ -56,4 +88,65 @@ export class RegionBase { ...@@ -56,4 +88,65 @@ export class RegionBase {
connectivityRegion: regionName, connectivityRegion: regionName,
}) })
} }
getDifferentTemplatesSameRegion() {
this.sameRegionTemplate = []
this.loadedTemplates.forEach(template => {
if (this.selectedTemplate.name !== template.name) {
template.parcellations.forEach(parcellation => {
this.parcellationRegions = []
this.getAllRegionsFromParcellation(parcellation.regions)
this.parcellationRegions.forEach(pr => {
if (JSON.stringify(pr.fullId) === JSON.stringify(this.region.fullId)) {
const baseAreaHemisphere =
this.region.name.includes(' - right hemisphere')? 'Right' :
this.region.name.includes(' - left hemisphere')? 'Left'
: null
const areaHemisphere =
pr.name.includes(' - right hemisphere')? 'Right'
: pr.name.includes(' - left hemisphere')? 'Left'
: null
const sameRegionSpace = {template: template, parcellation: parcellation, region: pr}
if (!baseAreaHemisphere && areaHemisphere) {
this.sameRegionTemplate.push({
...sameRegionSpace,
hemisphere: areaHemisphere
})
} else
if (!this.sameRegionTemplate.map(sr => sr.template).includes(template)) {
if (!(baseAreaHemisphere && areaHemisphere && baseAreaHemisphere !== areaHemisphere)) {
this.sameRegionTemplate.push(sameRegionSpace)
}
}
}
})
})
}
})
}
changeView(index) {
this.closeRegionMenu.emit()
this.store$.dispatch({
type : NEWVIEWER,
selectTemplate : this.sameRegionTemplate[index].template,
selectParcellation : this.sameRegionTemplate[index].parcellation,
navigation: {position: this.sameRegionTemplate[index].region.position},
})
}
public getAllRegionsFromParcellation = (regions) => {
for (const region of regions) {
if (region.children && region.children.length) {
this.getAllRegionsFromParcellation(region.children)
} else {
this.parcellationRegions.push(region)
}
}
}
} }
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