From 7a829cbafa99faef550840f0b335a5298787f06e Mon Sep 17 00:00:00 2001 From: Edward Moyse Date: Sat, 12 Oct 2024 12:13:14 +0200 Subject: [PATCH] Make sure we continue to use the JiveXMLLoader configuration, even if we load new data This requires access to EventDisplay configuration, so make this public. Also, make sure that we handle the possibility that the configuration.eventDataLoader is not the correct type. --- .../phoenix-event-display/src/event-display.ts | 2 +- .../src/app/sections/atlas/atlas.component.ts | 7 ++++++- .../io-options-dialog.component.ts | 15 +++++++++++++-- .../lib/services/file-loader.service.ts | 10 +++++++++- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/phoenix-event-display/src/event-display.ts b/packages/phoenix-event-display/src/event-display.ts index d4554513..08e9e4a0 100644 --- a/packages/phoenix-event-display/src/event-display.ts +++ b/packages/phoenix-event-display/src/event-display.ts @@ -29,7 +29,7 @@ declare global { */ export class EventDisplay { /** Configuration for preset views and event data loader. */ - private configuration: Configuration; + public configuration: Configuration; /** An object containing event data. */ private eventsData: any; /** Array containing callbacks to be called when events change. */ diff --git a/packages/phoenix-ng/projects/phoenix-app/src/app/sections/atlas/atlas.component.ts b/packages/phoenix-ng/projects/phoenix-app/src/app/sections/atlas/atlas.component.ts index a71d8ec2..ccf71e5b 100644 --- a/packages/phoenix-ng/projects/phoenix-app/src/app/sections/atlas/atlas.component.ts +++ b/packages/phoenix-ng/projects/phoenix-app/src/app/sections/atlas/atlas.component.ts @@ -48,7 +48,12 @@ export class AtlasComponent implements OnInit { // Define the configuration const configuration: Configuration = { - eventDataLoader: new JiveXMLLoader(['CombinedMuonTracks']), + eventDataLoader: new JiveXMLLoader([ + 'CombinedMuonTracks', + 'MuonSpectrometerTracks', + 'CombinedInDetTracks', + 'Muons_xAOD', + ]), presetViews: [ new PresetView('Left View', [0, 0, -12000], [0, 0, 0], 'left-cube'), new PresetView('Center View', [-500, 12000, 0], [0, 0, 0], 'top-cube'), diff --git a/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/io-options/io-options-dialog/io-options-dialog.component.ts b/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/io-options/io-options-dialog/io-options-dialog.component.ts index cb276c94..da43ffe1 100644 --- a/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/io-options/io-options-dialog/io-options-dialog.component.ts +++ b/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/io-options/io-options-dialog/io-options-dialog.component.ts @@ -121,7 +121,7 @@ export class IOOptionsDialogComponent implements OnInit { handleJiveXMLDataInput(files: FileList) { const callback = (content: any) => { - const jiveloader = new JiveXMLLoader(); + const jiveloader = this.getJiveXMLLoader(); jiveloader.process(content); const eventData = jiveloader.getEventData(); this.eventDisplay.buildEventDataFromJSON(eventData); @@ -129,6 +129,16 @@ export class IOOptionsDialogComponent implements OnInit { this.handleFileInput(files[0], 'xml', callback); } + private getJiveXMLLoader(): JiveXMLLoader { + if ( + this.eventDisplay.configuration.eventDataLoader instanceof JiveXMLLoader + ) { + return this.eventDisplay.configuration.eventDataLoader as JiveXMLLoader; + } else { + return new JiveXMLLoader(); + } + } + handleOBJInput(files: FileList) { const callback = (content: any, name: string) => { this.eventDisplay.parseOBJGeometry(content, name); @@ -219,7 +229,8 @@ export class IOOptionsDialogComponent implements OnInit { }); // JiveXML event data - const jiveloader = new JiveXMLLoader(); + const jiveloader = this.getJiveXMLLoader(); + Object.keys(filesWithData) .filter((fileName) => { return fileName.endsWith('.xml') || fileName.startsWith('JiveXML'); diff --git a/packages/phoenix-ng/projects/phoenix-ui-components/lib/services/file-loader.service.ts b/packages/phoenix-ng/projects/phoenix-ui-components/lib/services/file-loader.service.ts index 9bf573e1..509d862a 100644 --- a/packages/phoenix-ng/projects/phoenix-ui-components/lib/services/file-loader.service.ts +++ b/packages/phoenix-ng/projects/phoenix-ui-components/lib/services/file-loader.service.ts @@ -62,7 +62,15 @@ export class FileLoaderService { } loadJiveXMLEvent(eventData: string, eventDisplay: EventDisplayService) { - const jiveXMLLoader = new JiveXMLLoader(); + let jiveXMLLoader = undefined; + + if (eventDisplay.configuration.eventDataLoader instanceof JiveXMLLoader) { + jiveXMLLoader = eventDisplay.configuration + .eventDataLoader as JiveXMLLoader; + } else { + jiveXMLLoader = new JiveXMLLoader(); + } + jiveXMLLoader.process(eventData); const processedEventData = jiveXMLLoader.getEventData(); eventDisplay.buildEventDataFromJSON(processedEventData);