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

feat: check for orientation, allow reset if abnormal

parent f8da8497
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ import { EnumPanelMode } from "../../store/store";
import { NEHUBA_INSTANCE_INJTKN } from "../../util";
import { EnumClassicalView } from "src/atlasComponents/constants"
import { atlasSelection } from "src/state";
import { floatEquality } from "common/util"
const MINIMAP_SIZE = {
width: 200,
......@@ -190,11 +191,18 @@ export class PerspectiveViewSlider implements OnDestroy {
})
)
public sliceviewIsNormal$ = this.store$.pipe(
select(atlasSelection.selectors.navigation),
map(navigation => [0, 0, 0, 1].every((v, idx) => floatEquality(navigation.orientation[idx], v, 1e-3)))
)
public textToDisplay$ = combineLatest([
this.sliceviewIsNormal$,
this.navPosition$,
this.maximisedPanelIndex$,
]).pipe(
map(([ nav, maximisedIdx ]) => {
map(([ sliceviewIsNormal, nav, maximisedIdx ]) => {
if (!sliceviewIsNormal) return null
if (!(nav?.real) || (maximisedIdx === null)) return null
return `${(nav.real[maximisedIdx === 0? 1 : maximisedIdx === 1? 0 : 2] / 1e6).toFixed(3)}mm`
})
......@@ -330,6 +338,17 @@ export class PerspectiveViewSlider implements OnDestroy {
ngOnDestroy(): void {
this.subscriptions.forEach(s => s.unsubscribe());
}
resetSliceview() {
this.store$.dispatch(
atlasSelection.actions.navigateTo({
animation: true,
navigation: {
orientation: [0, 0, 0, 1]
}
})
)
}
}
......
......@@ -93,7 +93,3 @@ img
bottom: 5px;
}
:host-context([darktheme="true"]) .range-value {
color: white;
}
<div class="range-container"
*ngIf="sliceviewIsNormal$ | async else resetOrientationTmpl"
[ngClass]="{
'r-270': rangeControlIsVertical$ | async
}">
......@@ -28,6 +29,18 @@
</div>
</div>
<div class="position-absolute range-value" *ngIf="textToDisplay$ | async as textToDisplay">
<ng-template #resetOrientationTmpl>
<div class="sxplr-custom-cmp text sxplr-p-2 bg">
Minimap disabled until orientation is reset.
<button mat-button
(click)="resetSliceview()">
Reset Orientation
</button>
</div>
</ng-template>
<div *ngIf="textToDisplay$ | async as textToDisplay"
class="position-absolute range-value sxplr-custom-cmp text">
{{ textToDisplay }}
</div>
\ No newline at end of file
</div>
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