From ca09b7b19cb017a10eea63e2cf33572c1a8cd85b Mon Sep 17 00:00:00 2001 From: fsdavid <daviti1@mail.com> Date: Thu, 21 Oct 2021 14:42:48 +0200 Subject: [PATCH] Fix and merge dev snap to nav --- ...hangePerspectiveOrientation.component.html | 40 +++++++++++++++++++ ...hangePerspectiveOrientation.component.sass | 0 ...gePerspectiveOrientation.component.spec.ts | 25 ++++++++++++ .../changePerspectiveOrientation.component.ts | 36 +++++++++++++++++ src/viewerModule/nehuba/viewerCtrl/module.ts | 2 + .../viewerCtrlCmp/viewerCtrlCmp.template.html | 1 + 6 files changed, 104 insertions(+) create mode 100644 src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.html create mode 100644 src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.sass create mode 100644 src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.spec.ts create mode 100644 src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.ts diff --git a/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.html b/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.html new file mode 100644 index 000000000..ad8aca317 --- /dev/null +++ b/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.html @@ -0,0 +1,40 @@ +<button mat-menu-item [mat-menu-trigger-for]="perspectiveOrientationMenu"> + Change orientation to +</button> + +<mat-menu #perspectiveOrientationMenu="matMenu"> + + <div class="d-flex align-items-center text-light"> + <button mat-button color="basic" class="flex-grow-1 text-left" + (click)="set3DViewPoint('coronal', 'first')"> + Coronal view + </button> + <button class="flex-grow-0" mat-button + (click)="set3DViewPoint('coronal', 'second')"> + <i class="fas fa-arrows-alt-h"></i> + </button> + </div> + + <div class="d-flex align-items-center text-light"> <!--mat-menu-item--> + <button mat-button color="basic" class="flex-grow-1 text-left" + (click)="set3DViewPoint('sagittal', 'first')"> + Sagittal view + </button> + <button class="flex-grow-0" mat-button + (click)="set3DViewPoint('sagittal', 'second')"> + <i class="fas fa-arrows-alt-h"></i> + </button> + </div> + + <div class="d-flex align-items-center text-light"> <!--mat-menu-item--> + <button mat-button color="basic" class="flex-grow-1 text-left" + (click)="set3DViewPoint('axial', 'first')"> + Axial view + </button> + <button class="flex-grow-0" mat-button + (click)="set3DViewPoint('axial', 'second')"> + <i class="fas fa-arrows-alt-h"></i> + </button> + </div> + +</mat-menu> diff --git a/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.sass b/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.sass new file mode 100644 index 000000000..e69de29bb diff --git a/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.spec.ts b/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.spec.ts new file mode 100644 index 000000000..78767efbb --- /dev/null +++ b/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ChangePerspectiveOrientationComponent } from './changePerspectiveOrientation.component'; + +describe('ChangePerspectiveOrientationComponent', () => { + let component: ChangePerspectiveOrientationComponent; + let fixture: ComponentFixture<ChangePerspectiveOrientationComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ChangePerspectiveOrientationComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ChangePerspectiveOrientationComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.ts b/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.ts new file mode 100644 index 000000000..dbe8a4189 --- /dev/null +++ b/src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component.ts @@ -0,0 +1,36 @@ +import { Component, OnInit } from '@angular/core'; +import {viewerStateChangeNavigation} from "src/services/state/viewerState/actions"; +import {Store} from "@ngrx/store"; + +@Component({ + selector: 'app-change-perspective-orientation', + templateUrl: './changePerspectiveOrientation.component.html', + styleUrls: ['./changePerspectiveOrientation.component.sass'] +}) +export class ChangePerspectiveOrientationComponent implements OnInit { + + private viewOrientations = { + coronal: [[0,-1,1,0], [-1,0,0,1]], + sagittal: [[-1,-1,1,1], [-1,1,-1,1]], + axial: [[0,0,1,0], [0,0,1,0]] + } + + constructor(private store$: Store<any>,) { } + + ngOnInit(): void { + } + + public set3DViewPoint(plane: 'coronal' | 'sagittal' | 'axial', view: 'first' | 'second') { + + const orientation = this.viewOrientations[plane][view === 'first'? 0 : 1] + + this.store$.dispatch( + viewerStateChangeNavigation({ + navigation: { + perspectiveOrientation: orientation, + } + }) + ) + } + +} diff --git a/src/viewerModule/nehuba/viewerCtrl/module.ts b/src/viewerModule/nehuba/viewerCtrl/module.ts index dbf9ed121..7be118647 100644 --- a/src/viewerModule/nehuba/viewerCtrl/module.ts +++ b/src/viewerModule/nehuba/viewerCtrl/module.ts @@ -5,6 +5,7 @@ import { ComponentsModule } from "src/components"; import { AngularMaterialModule } from "src/sharedModules"; import { UtilModule } from "src/util"; import { ViewerCtrlCmp } from "./viewerCtrlCmp/viewerCtrlCmp.component"; +import {ChangePerspectiveOrientationComponent} from "src/viewerModule/nehuba/viewerCtrl/change-perspective-orientation/changePerspectiveOrientation.component"; @NgModule({ imports: [ @@ -17,6 +18,7 @@ import { ViewerCtrlCmp } from "./viewerCtrlCmp/viewerCtrlCmp.component"; ], declarations: [ ViewerCtrlCmp, + ChangePerspectiveOrientationComponent ], exports: [ ViewerCtrlCmp diff --git a/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.template.html b/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.template.html index a1a1507ee..60a004bbd 100644 --- a/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.template.html +++ b/src/viewerModule/nehuba/viewerCtrl/viewerCtrlCmp/viewerCtrlCmp.template.html @@ -41,3 +41,4 @@ </form> </ng-container> +<app-change-perspective-orientation></app-change-perspective-orientation> -- GitLab