Skip to content

Commit

Permalink
feat(app): added button to close/open the VP
Browse files Browse the repository at this point in the history
  • Loading branch information
9inpachi authored Jul 27, 2022
2 parents d04e3f4 + 2d670f9 commit 7fbdb13
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { HomeComponent } from './home/home.component';
import { GeometryComponent } from './sections/geometry/geometry.component';
import { AtlasComponent } from './sections/atlas/atlas.component';
import { LHCbComponent } from './sections/lhcb/lhcb.component';
import { VPToggleComponent } from './sections/lhcb/vp-toggle/vp-toggle.component';
import { CMSComponent } from './sections/cms/cms.component';
import { TrackmlComponent } from './sections/trackml/trackml.component';
import { PhoenixUIModule } from 'phoenix-ui-components';
Expand Down Expand Up @@ -39,6 +40,7 @@ if (environment?.singleEvent) {
GeometryComponent,
AtlasComponent,
LHCbComponent,
VPToggleComponent,
CMSComponent,
TrackmlComponent,
PlaygroundComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
[eventDataImportOptions]="eventDataImportOptions"
></app-io-options>
<app-share-link></app-share-link>
<app-vp-toggle></app-vp-toggle>
</app-ui-menu-wrapper>
<app-embed-menu></app-embed-menu>
<app-experiment-info
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<app-menu-toggle
[tooltip]="(open ? 'Close' : 'Open') + 'VP'"
[icon]="open ? 'closevp' : 'openvp'"
(click)="toggleVP()"
>
</app-menu-toggle>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { VPToggleComponent } from './vp-toggle.component';

describe('VPToggleComponent', () => {
let component: VPToggleComponent;
let fixture: ComponentFixture<VPToggleComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [VPToggleComponent],
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(VPToggleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should toggle VP opening/closing', () => {
expect(component.open).toBe(false);
component.toggleVP();
expect(component.open).toBe(true);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Component, ComponentRef, OnDestroy, OnInit } from '@angular/core';
import { EventDisplayService } from 'phoenix-ui-components';

@Component({
selector: 'app-vp-toggle',
templateUrl: './vp-toggle.component.html',
styleUrls: ['./vp-toggle.component.scss'],
})
export class VPToggleComponent {
open = false;

constructor(private eventDisplay: EventDisplayService) {}

moveVP(sceneManager, pos) {
// changes Velo position symetrically by the given amount
for (const item of ['Modules', 'Support', 'RFFoil', 'DeliveryPipes']) {
sceneManager
.getObjectByName('VP > Left > ' + item)
.position.setComponent(0, pos);
sceneManager
.getObjectByName('VP > Right > ' + item)
.position.setComponent(0, -pos);
}
}

toggleVP() {
this.open = !this.open;
this.moveVP(
this.eventDisplay.getThreeManager().getSceneManager(),
this.open ? 30 : 0
);
}
}

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7fbdb13

Please sign in to comment.