From 200ebe9ddc09b384e151cfa07019bc6c9bc3f2b3 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Wed, 4 Oct 2023 17:02:05 +0200 Subject: [PATCH] fix: previously selected point not rendering feat: added button to navigate to point assignment UI --- docs/releases/v2.13.4.md | 2 ++ .../point-assignment.component.html | 9 ++++++++ .../point-assignment.component.spec.ts | 14 +++++++---- .../point-assignment.component.ts | 23 +++++++++++++++---- .../sapiViews/volumes/sandsToNum.pipe.ts | 14 +++++++++++ .../sapiViews/volumes/volumes.module.ts | 8 ++++++- .../threeSurferGlue/threeSurfer.component.ts | 3 +++ .../viewerCmp/viewerCmp.template.html | 2 +- 8 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 src/atlasComponents/sapiViews/volumes/sandsToNum.pipe.ts diff --git a/docs/releases/v2.13.4.md b/docs/releases/v2.13.4.md index d91f82286..666387071 100644 --- a/docs/releases/v2.13.4.md +++ b/docs/releases/v2.13.4.md @@ -5,10 +5,12 @@ - Properly navigate to volume of interest based on volume meta: - properly calculate the orientation - properly calculate enclosed, and navigate to closest point if outside +- Added button to navigate to the point assignment UI ## Bugfix - Fixed expected siibra-api version +- Fixed previously selected point not rendering ## Behind the scenes diff --git a/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.html b/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.html index f031edbf5..2691032bb 100644 --- a/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.html +++ b/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.html @@ -12,6 +12,15 @@ </div> <ng-template [ngIf]="df$ | async" let-df> + + <ng-template [ngIf]="point$ | async | sandsToNum" let-coordinates> + <button mat-icon-button class="sxplr-m-2" + (click)="navigateToPoint(coordinates.coords)" + [matTooltip]="'Navigate To ' + (coordinates.coords | numbers : 2 | addUnitAndJoin : '')"> + <i class="fas fa-map-marker-alt"></i> + </button> + </ng-template> + <button mat-raised-button class="sxplr-m-2" (click)="openDialog(datatableTmpl)"> diff --git a/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.spec.ts b/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.spec.ts index 2f1a0ef9f..86fd2406a 100644 --- a/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.spec.ts +++ b/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.spec.ts @@ -5,6 +5,7 @@ import { SAPI } from 'src/atlasComponents/sapi/sapi.service'; import { EMPTY } from 'rxjs'; import { MatDialogModule } from '@angular/material/dialog'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { provideMockStore } from '@ngrx/store/testing'; describe('PointAssignmentComponent', () => { let component: PointAssignmentComponent; @@ -14,12 +15,15 @@ describe('PointAssignmentComponent', () => { await TestBed.configureTestingModule({ declarations: [ PointAssignmentComponent ], imports: [ MatDialogModule, NoopAnimationsModule ], - providers: [{ - provide: SAPI, - useValue: { - v3Get: () => EMPTY + providers: [ + provideMockStore(), + { + provide: SAPI, + useValue: { + v3Get: () => EMPTY + } } - }] + ] }) .compileComponents(); diff --git a/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.ts b/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.ts index 00ee69f55..0dbe66f73 100644 --- a/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.ts +++ b/src/atlasComponents/sapiViews/volumes/point-assignment/point-assignment.component.ts @@ -9,6 +9,8 @@ import { PathReturn } from 'src/atlasComponents/sapi/typeV3'; import { TFace, TSandsPoint } from 'src/util/types'; import { TZipFileConfig } from "src/zipFilesOutput/type" import { environment } from "src/environments/environment" +import { Store } from '@ngrx/store'; +import { atlasSelection } from 'src/state'; const DOING_PROB_ASGMT = "Performing probabilistic assignment ..." const DOING_LABEL_ASGMT = "Probabilistic assignment failed. Performing labelled assignment ..." @@ -31,14 +33,14 @@ export class PointAssignmentComponent implements OnDestroy { #error$ = new BehaviorSubject<string>(null) error$ = this.#error$.asObservable() - #point = new BehaviorSubject<TSandsPoint>(null) + point$ = new BehaviorSubject<TSandsPoint>(null) @Input() set point(val: TSandsPoint|TFace) { const { '@type': type } = val if (type === "siibra-explorer/surface/face") { return } - this.#point.next(val) + this.point$.next(val) } #template = new BehaviorSubject<SxplrTemplate>(null) @@ -57,7 +59,7 @@ export class PointAssignmentComponent implements OnDestroy { clickOnRegion = new EventEmitter<{ target: SxplrRegion, event: MouseEvent }>() df$: Observable<PathReturn<"/map/assign">> = combineLatest([ - this.#point, + this.point$, this.#parcellation, this.#template, ]).pipe( @@ -112,7 +114,7 @@ export class PointAssignmentComponent implements OnDestroy { map(df => df.columns as string[]) ) - constructor(private sapi: SAPI, private dialog: MatDialog) {} + constructor(private sapi: SAPI, private dialog: MatDialog, private store: Store) {} #dialogRef: MatDialogRef<unknown> openDialog(tmpl: TemplateRef<unknown>){ @@ -135,7 +137,7 @@ export class PointAssignmentComponent implements OnDestroy { } zipfileConfig$: Observable<TZipFileConfig[]> = combineLatest([ - this.#point, + this.point$, this.#parcellation, this.#template, this.df$ @@ -150,6 +152,17 @@ export class PointAssignmentComponent implements OnDestroy { }] as TZipFileConfig[] }) ) + + navigateToPoint(coordsInMm: number[]){ + this.store.dispatch( + atlasSelection.actions.navigateTo({ + animation: true, + navigation: { + position: coordsInMm.map(v => v * 1e6) + } + }) + ) + } } function generateReadMe(pt: TSandsPoint, parc: SxplrParcellation, tmpl: SxplrTemplate){ diff --git a/src/atlasComponents/sapiViews/volumes/sandsToNum.pipe.ts b/src/atlasComponents/sapiViews/volumes/sandsToNum.pipe.ts new file mode 100644 index 000000000..5f254ad5c --- /dev/null +++ b/src/atlasComponents/sapiViews/volumes/sandsToNum.pipe.ts @@ -0,0 +1,14 @@ +import { Pipe, PipeTransform } from "@angular/core"; +import { TSandsPoint } from "src/util/types"; + +@Pipe({ + name: 'sandsToNum', + pure: true +}) +export class SandsToNumPipe implements PipeTransform{ + public transform(val: TSandsPoint) { + return { + coords: val.coordinates.map(v => v.value / 1e6) + } + } +} diff --git a/src/atlasComponents/sapiViews/volumes/volumes.module.ts b/src/atlasComponents/sapiViews/volumes/volumes.module.ts index 1a5a32d0f..a2e461bff 100644 --- a/src/atlasComponents/sapiViews/volumes/volumes.module.ts +++ b/src/atlasComponents/sapiViews/volumes/volumes.module.ts @@ -8,12 +8,16 @@ import { MatDialogModule } from '@angular/material/dialog'; import { MatButtonModule } from '@angular/material/button'; import { MatSortModule } from '@angular/material/sort'; import { ZipFilesOutputModule } from 'src/zipFilesOutput/module'; +import { SandsToNumPipe } from "./sandsToNum.pipe" +import { SapiViewsUtilModule } from '../util'; +import { MatTooltipModule } from '@angular/material/tooltip'; @NgModule({ declarations: [ - PointAssignmentComponent + PointAssignmentComponent, + SandsToNumPipe, ], imports: [ CommonModule, @@ -24,6 +28,8 @@ import { ZipFilesOutputModule } from 'src/zipFilesOutput/module'; MatButtonModule, MatSortModule, ZipFilesOutputModule, + SapiViewsUtilModule, + MatTooltipModule, ], exports: [ PointAssignmentComponent diff --git a/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts b/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts index 968979314..05b5d7f43 100644 --- a/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts +++ b/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts @@ -356,6 +356,9 @@ export class ThreeSurferGlueCmp implements IViewer<'threeSurfer'>, AfterViewInit map(([ latIdxReg, cms ]) => { const cm = cms[0] const returnValue: TLatCm = {} + if (!cm) { + return returnValue + } for (const lat in latIdxReg) { returnValue[lat] = { labelIndices: [], diff --git a/src/viewerModule/viewerCmp/viewerCmp.template.html b/src/viewerModule/viewerCmp/viewerCmp.template.html index 14259c7f4..ecdd84d7e 100644 --- a/src/viewerModule/viewerCmp/viewerCmp.template.html +++ b/src/viewerModule/viewerCmp/viewerCmp.template.html @@ -902,7 +902,7 @@ <div class="sxplr-list-like-button-body"> - <ng-template [ngIf]="data?.point?.point"> + <ng-template [ngIf]="data?.point"> <span class="sxplr-list-like-button-body-line"> {{ data.point | nmToMm | numbers | addUnitAndJoin : '' }} (mm) </span> -- GitLab