Skip to content

Commit

Permalink
fixed collectioninfo dropdown order
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratz2005 committed Dec 17, 2024
1 parent deb9e7f commit 63c5f80
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 40 deletions.
21 changes: 10 additions & 11 deletions packages/phoenix-event-display/src/event-display.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { httpRequest, openFile } from 'jsroot';
import { settings as jsrootSettings } from 'jsroot';
import { httpRequest, settings as jsrootSettings, openFile } from 'jsroot';
import { build } from 'jsroot/geom';
import { ThreeManager } from './managers/three-manager/index';
import { UIManager } from './managers/ui-manager/index';
import { ActiveVariable } from './helpers/active-variable';
import { InfoLogger } from './helpers/info-logger';
import { getLabelTitle } from './helpers/labels';
import type { Configuration } from './lib/types/configuration';
import { StateManager } from './managers/state-manager';
import { PhoenixLoader } from './loaders/phoenix-loader';
import { LoadingManager } from './managers/loading-manager';
import { URLOptionsManager } from './managers/url-options-manager';
import { ActiveVariable } from './helpers/active-variable';
import { StateManager } from './managers/state-manager';
import type { AnimationPreset } from './managers/three-manager/animations-manager';
import { ThreeManager } from './managers/three-manager/index';
import { XRSessionType } from './managers/three-manager/xr/xr-manager';
import { getLabelTitle } from './helpers/labels';
import { PhoenixLoader } from './loaders/phoenix-loader';
import { UIManager } from './managers/ui-manager/index';
import { URLOptionsManager } from './managers/url-options-manager';

declare global {
/**
Expand Down Expand Up @@ -540,11 +539,11 @@ export class EventDisplay {
* Get the different collections for the current stored event.
* @returns List of strings, each representing a collection of the event displayed.
*/
public getCollections(): string[] {
public getCollections(): { [key: string]: string[] } {
if (this.configuration.eventDataLoader) {
return this.configuration.eventDataLoader.getCollections();
}
return [];
return {};
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InfoLogger } from '../helpers/info-logger';
import { ThreeManager } from '../managers/three-manager/index';
import { UIManager } from '../managers/ui-manager/index';
import { InfoLogger } from '../helpers/info-logger';

/**
* Event data loader for implementing different event data loaders.
Expand Down Expand Up @@ -32,7 +32,7 @@ export interface EventDataLoader {
* Get the different collections for the current stored event.
* @returns List of strings, each representing a collection of the event displayed.
*/
getCollections(): string[];
getCollections(): { [key: string]: string[] };

/**
* Get all the objects inside a collection.
Expand Down
37 changes: 19 additions & 18 deletions packages/phoenix-event-display/src/loaders/phoenix-loader.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Group, Object3D, Vector3 } from 'three';
import { GUI } from 'dat.gui';
import type { EventDataLoader } from './event-data-loader';
import { UIManager } from '../managers/ui-manager/index';
import { ThreeManager } from '../managers/three-manager/index';
import { Cut } from '../lib/models/cut.model';
import { PhoenixObjects } from './objects/phoenix-objects';
import * as _ from 'lodash';
import { Group, Object3D, Vector3 } from 'three';
import { CoordinateHelper } from '../helpers/coordinate-helper';
import { InfoLogger } from '../helpers/info-logger';
import { PhoenixMenuNode } from '../managers/ui-manager/phoenix-menu/phoenix-menu-node';
import { getLabelTitle } from '../helpers/labels';
import { Cut } from '../lib/models/cut.model';
import { LoadingManager } from '../managers/loading-manager';
import { StateManager } from '../managers/state-manager';
import { CoordinateHelper } from '../helpers/coordinate-helper';
import { getLabelTitle } from '../helpers/labels';
import { ThreeManager } from '../managers/three-manager/index';
import { DatGUIMenuUI } from '../managers/ui-manager/dat-gui-ui';
import { UIManager } from '../managers/ui-manager/index';
import { PhoenixMenuNode } from '../managers/ui-manager/phoenix-menu/phoenix-menu-node';
import { PhoenixMenuUI } from '../managers/ui-manager/phoenix-menu/phoenix-menu-ui';
import * as _ from 'lodash';
import type { EventDataLoader } from './event-data-loader';
import { PhoenixObjects } from './objects/phoenix-objects';

/**
* Loader for processing and loading an event.
Expand Down Expand Up @@ -100,23 +100,24 @@ export class PhoenixLoader implements EventDataLoader {
* Get list of collections in the event data.
* @returns List of all collection names.
*/
public getCollections(): string[] {
public getCollections(): { [key: string]: string[] } {
if (!this.eventData) {
return [];
return {};
}

const collections = [];
const collectionsByType: { [key: string]: string[] } = {};

for (const objectType in this.eventData) {
if (
this.eventData[objectType] &&
typeof this.eventData[objectType] === 'object'
typeof this.eventData[objectType] == 'object'
) {
for (const collection in this.eventData[objectType]) {
collections.push(collection);
}
collectionsByType[objectType] = Object.keys(
this.eventData[objectType],
).sort();
}
}
return collections;
return collectionsByType;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@
(change)="changeCollection($event.target.value)"
>
<option value="" selected disabled hidden>Choose Collection</option>
<option *ngFor="let collection of collections" [value]="collection">
{{ collection }}
</option>
<optgroup *ngFor="let group of collections" [label]="group.type">
<option
*ngFor="let collection of group.collections"
[value]="collection"
>
{{ collection }}
</option>
</optgroup>
</select>
</div>
<mat-checkbox
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, type OnInit, Input, ElementRef } from '@angular/core';
import { Component, ElementRef, Input, type OnInit } from '@angular/core';
import {
PrettySymbols,
ActiveVariable,
PrettySymbols,
SceneManager,
} from 'phoenix-event-display';
import { EventDisplayService } from '../../../../services/event-display.service';
Expand All @@ -14,7 +14,7 @@ import { EventDisplayService } from '../../../../services/event-display.service'
export class CollectionsInfoOverlayComponent implements OnInit {
@Input() showObjectsInfo: boolean;
hideInvisible: boolean;
collections: string[];
collections: { type: string; collections: string[] }[];
selectedCollection: string;
showingCollection: any;
collectionColumns: string[];
Expand All @@ -27,9 +27,17 @@ export class CollectionsInfoOverlayComponent implements OnInit {
) {}

ngOnInit() {
this.eventDisplay.listenToDisplayedEventChange(
(_event) => (this.collections = this.eventDisplay.getCollections()),
);
this.eventDisplay.listenToDisplayedEventChange(() => {
const collectionsGrouped: { [key: string]: string[] } =
this.eventDisplay.getCollections();
this.collections = Object.entries(collectionsGrouped).map(
([type, collections]: [string, string[]]) => ({
type,
collections,
}),
);
});

this.activeObject = this.eventDisplay.getActiveObjectId();
this.activeObject.onUpdate((value: string) => {
if (document.getElementById(value)) {
Expand Down

0 comments on commit 63c5f80

Please sign in to comment.