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

chore: disallow allen v3 root to be selected

parent af426fe2
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,7 @@ import { viewerStateSetSelectedRegions, viewerStateRemoveAdditionalLayer, viewer ...@@ -44,6 +44,7 @@ import { viewerStateSetSelectedRegions, viewerStateRemoveAdditionalLayer, viewer
import { viewerStateGetOverlayingAdditionalParcellations, viewerStateParcVersionSelector } from "src/services/state/viewerState/selectors"; import { viewerStateGetOverlayingAdditionalParcellations, viewerStateParcVersionSelector } from "src/services/state/viewerState/selectors";
import { ngViewerSelectorClearViewEntries } from "src/services/state/ngViewerState/selectors"; import { ngViewerSelectorClearViewEntries } from "src/services/state/ngViewerState/selectors";
import { ngViewerActionClearView } from "src/services/state/ngViewerState/actions"; import { ngViewerActionClearView } from "src/services/state/ngViewerState/actions";
import { uiStateMouseOverSegmentsSelector } from "src/services/state/uiState/selectors";
/** /**
* TODO * TODO
...@@ -193,8 +194,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { ...@@ -193,8 +194,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
// TODO temporary hack. even though the front octant is hidden, it seems if a mesh is present, hover will select the said mesh // TODO temporary hack. even though the front octant is hidden, it seems if a mesh is present, hover will select the said mesh
this.onhoverSegments$ = this.store.pipe( this.onhoverSegments$ = this.store.pipe(
select('uiState'), select(uiStateMouseOverSegmentsSelector),
select('mouseOverSegments'),
filter(v => !!v), filter(v => !!v),
distinctUntilChanged((o, n) => o.length === n.length && n.every(segment => o.find(oSegment => oSegment.layer.name === segment.layer.name && oSegment.segment === segment.segment) ) ), distinctUntilChanged((o, n) => o.length === n.length && n.every(segment => o.find(oSegment => oSegment.layer.name === segment.layer.name && oSegment.segment === segment.segment) ) ),
/* cannot filter by state, as the template expects a default value, or it will throw ExpressionChangedAfterItHasBeenCheckedError */ /* cannot filter by state, as the template expects a default value, or it will throw ExpressionChangedAfterItHasBeenCheckedError */
......
...@@ -5,6 +5,7 @@ import { combineLatest, merge, Observable } from "rxjs"; ...@@ -5,6 +5,7 @@ import { combineLatest, merge, Observable } from "rxjs";
import { distinctUntilChanged, filter, map, scan, shareReplay, startWith, withLatestFrom } from "rxjs/operators"; import { distinctUntilChanged, filter, map, scan, shareReplay, startWith, withLatestFrom } from "rxjs/operators";
import { TransformOnhoverSegmentPipe } from "src/atlasViewer/onhoverSegment.pipe"; import { TransformOnhoverSegmentPipe } from "src/atlasViewer/onhoverSegment.pipe";
import { LoggingService } from "src/logging"; import { LoggingService } from "src/logging";
import { uiStateMouseOverSegmentsSelector } from "src/services/state/uiState/selectors";
import { getNgIdLabelIndexFromId } from "src/services/stateStore.service"; import { getNgIdLabelIndexFromId } from "src/services/stateStore.service";
/** /**
...@@ -85,8 +86,7 @@ export class MouseHoverDirective { ...@@ -85,8 +86,7 @@ export class MouseHoverDirective {
) )
const onHoverSegments$ = this.store$.pipe( const onHoverSegments$ = this.store$.pipe(
select('uiState'), select(uiStateMouseOverSegmentsSelector),
select('mouseOverSegments'),
filter(v => !!v), filter(v => !!v),
withLatestFrom( withLatestFrom(
this.store$.pipe( this.store$.pipe(
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
], ],
"name": "root", "name": "root",
"labelIndex": 997, "labelIndex": 997,
"unselectable": true,
"relatedAreas": [ "relatedAreas": [
{ {
"name": "Whole brain", "name": "Whole brain",
import { uiStateMouseOverSegmentsSelector } from './selectors'
describe('> uiState/selectors.ts', () => {
describe('> mouseOverSegments', () => {
it('> should filter out regions explicitly designated as unselectable', () => {
const unSelSeg = {
segment: {
unselectable: true
}
}
const selSeg0 = {
segment: 1
}
const selSeg1 = {
segment: {
name: 'hello world',
unselectable: false
}
}
const filteredResult = uiStateMouseOverSegmentsSelector.projector([unSelSeg, selSeg0, selSeg1])
expect(filteredResult).toEqual([selSeg0, selSeg1])
})
})
})
...@@ -4,3 +4,19 @@ export const uiStatePreviewingDatasetFilesSelector = createSelector( ...@@ -4,3 +4,19 @@ export const uiStatePreviewingDatasetFilesSelector = createSelector(
state => state['uiState'], state => state['uiState'],
uiState => uiState['previewingDatasetFiles'] uiState => uiState['previewingDatasetFiles']
) )
export const uiStateMouseOverSegmentsSelector = createSelector(
state => state['uiState']['mouseOverSegments'],
mouseOverSegments => {
/**
* filter out the regions explicitly declared `unselectable`
*/
return mouseOverSegments
.filter(({ segment }) => {
if (typeof segment === 'object' && segment !== null) {
if (segment.unselectable) return false
}
return true
})
}
)
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