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

expmt: show last selected point

parent 3cf0bff1
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ import { EnumViewerEvt, TContextArg, TSupportedViewers, TViewerEvent } from "../
import { ContextMenuService, TContextMenuReg } from "src/contextMenuModule";
import { DialogService } from "src/services/dialogService.service";
import { SAPI } from "src/atlasComponents/sapi";
import { Feature, SxplrAtlas, SxplrRegion } from "src/atlasComponents/sapi/sxplrTypes"
import { Feature, SxplrAtlas, SxplrParcellation, SxplrRegion } from "src/atlasComponents/sapi/sxplrTypes"
import { atlasAppearance, atlasSelection, userInteraction } from "src/state";
import { SxplrTemplate } from "src/atlasComponents/sapi/sxplrTypes";
import { EntryComponent } from "src/features/entry/entry.component";
......@@ -191,10 +191,14 @@ export class ViewerCmp implements OnDestroy {
@ViewChild('viewerStatusCtxMenu', { read: TemplateRef })
private viewerStatusCtxMenu: TemplateRef<any>
@ViewChild('lastViewedPointTmpl', { read: TemplateRef })
private lastViewedPointTmpl: TemplateRef<unknown>
@ViewChild('viewerStatusRegionCtxMenu', { read: TemplateRef })
private viewerStatusRegionCtxMenu: TemplateRef<any>
private templateSelected: SxplrTemplate
#parcellationSelected: SxplrParcellation
constructor(
private store$: Store<any>,
......@@ -208,6 +212,7 @@ export class ViewerCmp implements OnDestroy {
this.templateSelected$.subscribe(
t => this.templateSelected = t
),
this.#parcellationSelected$.subscribe(parc => this.#parcellationSelected = parc),
combineLatest([
this.templateSelected$,
this.parcellationSelected$,
......@@ -250,6 +255,17 @@ export class ViewerCmp implements OnDestroy {
ngAfterViewInit(): void{
const cb: TContextMenuReg<TContextArg<'nehuba' | 'threeSurfer'>> = ({ append, context }) => {
if (this.#lastSelectedPoint && this.lastViewedPointTmpl) {
const { point, template, face, vertices } = this.#lastSelectedPoint
append({
tmpl: this.lastViewedPointTmpl,
data: {
point, face, vertices,
template
},
order: 15
})
}
/**
* first append general viewer info
*/
......@@ -330,6 +346,8 @@ export class ViewerCmp implements OnDestroy {
}
public selectPoint(pointSpec: {point?: number[], face?: number, vertices?: number[]}, template: SxplrTemplate){
this.#lastSelectedPoint = { ...pointSpec, template }
const { point, face, vertices } = pointSpec
const id = `${template.id}-${point ? point.join(',') : face}`
let pointOfInterest: TFace | TSandsPoint
......@@ -356,6 +374,14 @@ export class ViewerCmp implements OnDestroy {
}
}
if (pointOfInterest) {
this.store$.dispatch(
atlasSelection.actions.selectTemplate({
template,
requested: {
parcellation: this.#parcellationSelected
}
})
)
this.store$.dispatch(
atlasSelection.actions.selectPoint({
point: pointOfInterest
......@@ -363,6 +389,7 @@ export class ViewerCmp implements OnDestroy {
)
}
}
#lastSelectedPoint: { point?: number[], face?: number, vertices?: number[], template: SxplrTemplate }
public clearPoint(){
this.store$.dispatch(
......
......@@ -929,6 +929,66 @@
</mat-card>
</ng-template>
<ng-template
sxplrExperimentalFlag
[experimental]="true"
#lastSelPtExpmt="sxplrExperimentalFlag"
[ngIf]="lastSelPtExpmt.show$ | async">
<ng-template #lastViewedPointTmpl let-data>
<div class="text-muted sxplr-m-2">
Last selected spatial object
</div>
<button mat-button class="sxplr-list-like-button"
(click)="selectPoint(data, data.template)">
<div class="sxplr-list-like-button-icon">
<i class="fas fa-history"></i>
</div>
<div class="sxplr-list-like-button-body">
<ng-template [ngIf]="data.point">
<span class="sxplr-list-like-button-body-line">
{{ data.point | nmToMm | numbers | addUnitAndJoin : '' }} (mm)
</span>
<span class="sxplr-list-like-button-body-line text-muted">
Point
</span>
</ng-template>
<ng-template [ngIf]="data.face && data.vertices">
<span class="sxplr-list-like-button-body-line">
Face Index: {{ data.face }}, Vertices Index: {{ data.vertices | addUnitAndJoin : '' }}
</span>
<span class="sxplr-list-like-button-body-line text-muted">
Mesh Face
</span>
</ng-template>
<span class="sxplr-list-like-button-body-line text-muted">
<span>
{{ data.template.name }}
</span>
<ng-template [ngIf]="templateSelected$ | async" let-templateSelected>
<ng-template [ngIf]="templateSelected.id !== data.template.id">
<mat-icon fontSet="fas" fontIcon="fa-exclamation-triangle"
color="warn"
matTooltip="Different template spaces detected.">
</mat-icon>
</ng-template>
</ng-template>
</span>
</div>
<!-- {{ data.point | json }} -->
</button>
</ng-template>
</ng-template>
<!-- viewer status ctx menu -->
<ng-template #viewerStatusCtxMenu let-data>
......
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