From dd12e22184dee25a2b05c328e8dcbe90c3642da2 Mon Sep 17 00:00:00 2001 From: Edward Moyse Date: Mon, 29 Jul 2024 16:18:00 +0200 Subject: [PATCH] Add configurable option to make some track collections thicker Remove extraneous debugging --- .../src/loaders/jivexml-loader.ts | 15 ++++++++++++++- .../src/loaders/objects/phoenix-objects.ts | 5 +++-- .../src/loaders/phoenix-loader.ts | 1 + .../src/managers/url-options-manager.ts | 11 ++++++++--- .../phoenix-app/src/app/home/home.component.ts | 1 - .../src/app/sections/atlas/atlas.component.ts | 4 ++-- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/packages/phoenix-event-display/src/loaders/jivexml-loader.ts b/packages/phoenix-event-display/src/loaders/jivexml-loader.ts index 0759cf58..417093f5 100644 --- a/packages/phoenix-event-display/src/loaders/jivexml-loader.ts +++ b/packages/phoenix-event-display/src/loaders/jivexml-loader.ts @@ -7,13 +7,16 @@ import { CoordinateHelper } from '../helpers/coordinate-helper.js'; export class JiveXMLLoader extends PhoenixLoader { /** Event data in JiveXML data format */ private data: any; + thickTrackCollections: string[]; /** * Constructor for the JiveXMLLoader. + * @param thickTrackCollections A list of names of track collections which should be drawn thicker */ - constructor() { + constructor(thickTrackCollections: string[] = []) { super(); this.data = {}; + this.thickTrackCollections = thickTrackCollections; } /** @@ -173,6 +176,15 @@ export class JiveXMLLoader extends PhoenixLoader { trackCollectionName = 'Tracks_'; //We have problems if the name of the collection is a type } + let thickTracks = false; + if ( + this.thickTrackCollections.find( + (collection) => collection === trackCollectionName, + ) + ) { + thickTracks = true; + } + // if (!trackCollectionName.includes('MuonSpectrometer')) continue; const numOfTracks = Number(collection.getAttribute('count')); const jsontracks = []; @@ -265,6 +277,7 @@ export class JiveXMLLoader extends PhoenixLoader { hits: {}, author: {}, badtrack: [] as string[], + linewidth: thickTracks ? 20.0 : undefined, }; if (chi2.length >= i) track.chi2 = chi2[i]; if (numDoF.length >= i) track.dof = numDoF[i]; diff --git a/packages/phoenix-event-display/src/loaders/objects/phoenix-objects.ts b/packages/phoenix-event-display/src/loaders/objects/phoenix-objects.ts index 36f19202..032e5d4d 100644 --- a/packages/phoenix-event-display/src/loaders/objects/phoenix-objects.ts +++ b/packages/phoenix-event-display/src/loaders/objects/phoenix-objects.ts @@ -140,6 +140,7 @@ export class PhoenixObjects { ? parseInt(trackParams.color, 16) : EVENT_DATA_TYPE_COLORS.Tracks.getHex(); + const linewidth = trackParams.linewidth ? trackParams.linewidth : 2; const points = []; for (let i = 0; i < positions.length; i++) { @@ -162,7 +163,7 @@ export class PhoenixObjects { const curve = new CatmullRomCurve3(points); // TubeGeometry - const geometry = new TubeGeometry(curve, undefined, 2); + const geometry = new TubeGeometry(curve, undefined, linewidth); const material = new MeshToonMaterial({ color: objectColor }); const tubeObject = new Mesh(geometry, material); @@ -171,7 +172,7 @@ export class PhoenixObjects { const lineGeometry = new BufferGeometry().setFromPoints(vertices); const lineMaterial = new LineBasicMaterial({ color: objectColor, - linewidth: 2, + linewidth: linewidth, }); const lineObject = new Line(lineGeometry, lineMaterial); lineObject.name = 'Track'; diff --git a/packages/phoenix-event-display/src/loaders/phoenix-loader.ts b/packages/phoenix-event-display/src/loaders/phoenix-loader.ts index 78114c52..cc3a5ce2 100644 --- a/packages/phoenix-event-display/src/loaders/phoenix-loader.ts +++ b/packages/phoenix-event-display/src/loaders/phoenix-loader.ts @@ -470,6 +470,7 @@ export class PhoenixLoader implements EventDataLoader { continue; } + this.addCollection( objectCollection, collectionName, diff --git a/packages/phoenix-event-display/src/managers/url-options-manager.ts b/packages/phoenix-event-display/src/managers/url-options-manager.ts index 8ef007d8..713ef11a 100644 --- a/packages/phoenix-event-display/src/managers/url-options-manager.ts +++ b/packages/phoenix-event-display/src/managers/url-options-manager.ts @@ -142,9 +142,11 @@ export class URLOptionsManager { */ private async handleJiveXMLEvent(fileURL: string) { const fileData = await (await fetch(fileURL)).text(); - const loader = new JiveXMLLoader(); - this.configuration.eventDataLoader = loader; + if (!this.configuration.eventDataLoader) { + this.configuration.eventDataLoader = new JiveXMLLoader(); + } // Parse the XML to extract events and their data + const loader = this.configuration.eventDataLoader as JiveXMLLoader; loader.process(fileData); const eventData = loader.getEventData(); this.eventDisplay.buildEventDataFromJSON(eventData); @@ -188,7 +190,10 @@ export class URLOptionsManager { }); // JiveXML event data - const jiveloader = new JiveXMLLoader(); + const jiveloader = + this.configuration.eventDataLoader instanceof JiveXMLLoader + ? (this.configuration.eventDataLoader as JiveXMLLoader) + : new JiveXMLLoader(); Object.keys(filesWithData) .filter((fileName) => { return fileName.endsWith('.xml') || fileName.startsWith('JiveXML'); diff --git a/packages/phoenix-ng/projects/phoenix-app/src/app/home/home.component.ts b/packages/phoenix-ng/projects/phoenix-app/src/app/home/home.component.ts index d36deb86..6959cfd7 100644 --- a/packages/phoenix-ng/projects/phoenix-app/src/app/home/home.component.ts +++ b/packages/phoenix-ng/projects/phoenix-app/src/app/home/home.component.ts @@ -10,7 +10,6 @@ export class HomeComponent implements AfterViewInit { year: number; constructor(private eventDisplay: EventDisplayService) { - console.log('Home component created'); this.year = new Date().getFullYear(); this.eventDisplay.getThreeManager().stopAnimationLoop(); } 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 2975d2e2..a71d8ec2 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 @@ -7,7 +7,7 @@ import { import { PresetView, PhoenixMenuNode, - PhoenixLoader, + JiveXMLLoader, StateManager, } from 'phoenix-event-display'; import type { Configuration } from 'phoenix-event-display'; @@ -48,7 +48,7 @@ export class AtlasComponent implements OnInit { // Define the configuration const configuration: Configuration = { - eventDataLoader: new PhoenixLoader(), + eventDataLoader: new JiveXMLLoader(['CombinedMuonTracks']), 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'),