Skip to content

Commit

Permalink
Performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
DraTeots committed Jun 7, 2024
1 parent 682dd17 commit effb90b
Show file tree
Hide file tree
Showing 10 changed files with 341 additions and 34 deletions.
4 changes: 4 additions & 0 deletions firebird-ng/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ export const routes: Routes = [
path: 'playground',
loadComponent: () => import('./playground/playground.component').then(m => m.PlaygroundComponent)
},
{
path: 'geometry',
loadComponent: () => import('./geometry-tree/geometry-tree.component').then(m => m.GeometryTreeComponent)
},
];
22 changes: 22 additions & 0 deletions firebird-ng/src/app/geometry-tree/geometry-tree.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<p>geometry-tree works!</p>

<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
<!-- This is the tree node template for leaf nodes -->
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding>
<!-- use a disabled button to provide padding for tree leaf -->
<button mat-icon-button disabled></button>
{{node.name}}
[{{node.type}}]
</mat-tree-node>
<!-- This is the tree node template for expandable nodes -->
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
<button mat-icon-button matTreeNodeToggle
[attr.aria-label]="'Toggle ' + node.name">
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
{{node.name}}
[{{node.type}}]
</mat-tree-node>
</mat-tree>
Empty file.
23 changes: 23 additions & 0 deletions firebird-ng/src/app/geometry-tree/geometry-tree.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { GeometryTreeComponent } from './geometry-tree.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [GeometryTreeComponent]
})
.compileComponents();

fixture = TestBed.createComponent(GeometryTreeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
119 changes: 119 additions & 0 deletions firebird-ng/src/app/geometry-tree/geometry-tree.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import {Component, OnInit} from '@angular/core';
import {
MatNestedTreeNode,
MatTree,
MatTreeNode,
MatTreeNodeDef,
MatTreeNodeOutlet, MatTreeNodePadding,
MatTreeNodeToggle
} from "@angular/material/tree";
import {NestedTreeControl, FlatTreeControl, } from '@angular/cdk/tree';
import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree';

import {MatIcon, MatIconModule} from '@angular/material/icon';
import {MatButtonModule, MatIconButton} from '@angular/material/button';
import {GeometryService} from "../geometry.service";
import {Object3D} from "three";

/**
* Food data with nested structure.
* Each node has a name and an optional list of children.
*/
interface FoodNode {
name: string;
children?: FoodNode[];
}

const TREE_DATA: FoodNode[] = [
{
name: 'Fruit',
children: [{name: 'Apple'}, {name: 'Banana'}, {name: 'Fruit loops'}],
},
{
name: 'Vegetables',
children: [
{
name: 'Green',
children: [{name: 'Broccoli'}, {name: 'Brussels sprouts'}],
},
{
name: 'Orange',
children: [{name: 'Pumpkins'}, {name: 'Carrots'}],
},
],
},
];

/** Flat node with expandable and level information */
interface ExampleFlatNode {
expandable: boolean;
name: string;
level: number;
type: string;
}

@Component({
selector: 'app-geometry-tree',
standalone: true,
imports: [
MatTree,
MatTreeNode,
MatNestedTreeNode,
MatIconButton,
MatTreeNodeToggle,
MatTreeNodeDef,
MatIcon,
MatTreeNodeOutlet,
MatTreeNodePadding
],
templateUrl: './geometry-tree.component.html',
styleUrl: './geometry-tree.component.scss'
})
export class GeometryTreeComponent implements OnInit{

private _transformer = (node: Object3D, level: number) => {
return {
expandable: !!node.children && node.children.length > 0,
name: node.name,
level: level,
type: node.type
};
};

treeControl = new FlatTreeControl<ExampleFlatNode>(
node => node.level,
node => node.expandable,
);

treeFlattener = new MatTreeFlattener(
this._transformer,
node => node.level,
node => node.expandable,
node => node.children,
);

dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);


hasChild = (_: number, node: ExampleFlatNode) => node.expandable;

constructor(private geomService: GeometryService) {
//this.dataSource.data = TREE_DATA;
}

ngOnInit(): void {
if(!this.geomService.geometry) this.geomService.loadGeometry().then(result => {
if(result.threeGeometry) {
this.dataSource.data = result.threeGeometry.children;
}
else {
console.error("this.geomService.loadGeometry() ! result.threeGeometry");
}
}).catch(reason=>{
console.error("ERROR LOADING GEOMETRY");
console.log(reason);
});
}


}
26 changes: 13 additions & 13 deletions firebird-ng/src/app/input-config/input-config.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ <h5 class="card-title">Events Source</h5>
<select class="form-control" [formControl]="selectedEventSource">
<option value="no-events">No events (may upload later)</option>
<option value="https://firebird-eic.org/dirc_event.json.zip">DIRC optical (load DIRC only geometry)</option>
<option value="py8_dis-cc_10x100_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_10x100_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-cc_18x275_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_18x275_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-cc_18x275_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_18x275_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-cc_5x41_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_5x41_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-cc_all_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_all_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-nc_10x100_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_10x100_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-nc_10x100_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_10x100_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-nc_10x100_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_10x100_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-nc_18x275_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_18x275_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-nc_18x275_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_18x275_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-nc_18x275_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_18x275_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-nc_5x41_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_5x41_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="py8_dis-nc_all_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_all_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-cc_10x100_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_10x100_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-cc_18x275_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_18x275_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-cc_18x275_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_18x275_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-cc_5x41_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_5x41_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-cc_all_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-cc_all_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-nc_10x100_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_10x100_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-nc_10x100_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_10x100_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-nc_10x100_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_10x100_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-nc_18x275_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_18x275_minq2-1000_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-nc_18x275_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_18x275_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-nc_18x275_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_18x275_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-nc_5x41_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_5x41_minq2-100_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
<option value="https://firebird-eic.org/py8_dis-nc_all_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip">py8_dis-nc_all_minq2-1_minp-300mev_vtxcut-5m_nevt-5.evt.zip</option>
</select>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions firebird-ng/src/app/main-display/main-display.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@

<div class="time-controls" style="background-color: #424242; padding: 2px; display: flex; gap: 3px; align-items: center; position: absolute; top:0px; left: 300px;">



<!-- <mat-select [(value)]="selectedEventKey" (selectionChange)="onUserSelectedEvent()">-->
<!-- <mat-option *ngFor="let key of eventsByName.keys()" [value]="key">-->
<!-- {{ key }}-->
<!-- </mat-option>-->
<!-- </mat-select>-->


<div>{{currentTime | number:'1.1-1'}}</div>
<mat-slider min="0" [max]="maxTime" step="1" showTickMarks discrete [displayWith]="formatCurrentTime" (input)="changeCurrentTime($event)">
<input matSliderThumb [value]="currentTime">
Expand Down Expand Up @@ -93,6 +102,10 @@
<div>{{message}}</div>
&nbsp;&nbsp;

<button mat-raised-button aria-label="Rewind" matTooltip="Rewind time to 0" class="tcontrol" (click)="nextRandomEvent()">
<mat-icon>last_page</mat-icon>
</button>

<button mat-raised-button aria-label="Stop" matTooltip="Stop and show all particles" class="tcontrol" (click)="cycleGeometry()" >
<mat-icon>view_in_ar</mat-icon>
</button>
Expand Down
Loading

0 comments on commit effb90b

Please sign in to comment.