Back to home page

EIC code displayed by LXR

 
 

    


Warning, /firebird/packages/firebird-ng/src/lib/with-firebird-builtins.ts is written in an unsupported language. File is not indexed.

0001 /**
0002  * The built-in feature pack: Firebird's own piece factories, painters,
0003  * loaders, commands and UI parts, registered through the public extension
0004  * API - exactly how an experiment pack registers its own. If a built-in
0005  * cannot live on this surface, a user's feature cannot either.
0006  *
0007  * `provideFirebird()` installs `withFirebirdBuiltins()` before the
0008  * application's features. Each part is a named sub-feature with a feature
0009  * id, so an application drops a part with `withoutFeatures('<id>')`:
0010  *
0011  * | Sub-feature                     | Feature id                          |
0012  * |---------------------------------|-------------------------------------|
0013  * | `withServerConfig()` (generic)  | `server-config`                     |
0014  * | `withFirebirdUrlShorthands()`   | `firebird.url-shorthands`           |
0015  * | `withBoxHits()`                 | `firebird.box-hits`                 |
0016  * | `withTrajectories()`            | `firebird.trajectories`             |
0017  * | `withDexEvents()`               | `firebird.dex-events`               |
0018  * | `withRootEventsInBrowser()`     | `firebird.root-events-in-browser`   |
0019  * | `withServerConversion()`        | `firebird.server-conversion`        |
0020  * | `withRootGeometry()`            | `firebird.root-geometry`            |
0021  * | `withFirebirdCommands()`        | `firebird.commands`                 |
0022  * | `withStandardCameraPresets()`   | `firebird.camera-presets`           |
0023  * | `withNavigationCube()`          | `firebird.navigation-cube`          |
0024  * | `withDataSelectorTabs()`        | `firebird.data-selector-tabs`       |
0025  *
0026  * The whole pack is `firebird.builtins`, a pack of defaults
0027  * (`appFeatureDefaults()`): replacing one of its parts by id is the intended
0028  * customization and draws no collision warning.
0029  */
0030 
0031 // The /model subpath on purpose: this file is in the INITIAL bundle, and the
0032 // @dexvis/firebird-core root re-exports painters whose modules pull three.js.
0033 // The model imports no three.js.
0034 import {
0035   BoxHitPiece,
0036   BoxHitPieceFactory,
0037   PointTrajectoryPiece,
0038   PointTrajectoryPieceFactory,
0039 } from '@dexvis/firebird-core/model';
0040 import { appFeatureDefaults, withCommandHandler, withConfigDefaults, withServerConfig } from '@dexvis/app-features';
0041 import {
0042   defaultFirebirdConfig,
0043   FirebirdFeature,
0044   firebirdPack,
0045   withCameraPreset,
0046   withDataSelectorTab,
0047   withEventLoader,
0048   withEventPiece,
0049   withFirebirdUrlShorthands,
0050   withGeometryLoader,
0051   withGeometryTheme,
0052   withLazyPainter,
0053   withLazyThreeExtension,
0054 } from '@dexvis/firebird-ng/api';
0055 import {
0056   DexEventLoader,
0057   Edm4eicEventLoader,
0058   Root2DexEventLoader,
0059   RootGeometryLoader,
0060 } from './builtin-loaders';
0061 import {
0062   AnimateCollisionCommandHandler,
0063   CameraPresetCommandHandler,
0064   OpenDexCommandHandler,
0065   OpenGeometryCommandHandler,
0066   SetConfigCommandHandler,
0067   ShowEventCommandHandler,
0068 } from './builtin-command-handlers';
0069 
0070 /** BoxHit pieces (tracker hits as boxes): DEX decoder and painter. */
0071 export function withBoxHits(): FirebirdFeature {
0072   return firebirdPack('firebird.box-hits',
0073     withEventPiece(BoxHitPieceFactory),
0074     // Lazy: painter classes pull three.js material code, which must stay out
0075     // of the initial bundle (the display route chunk shares the same
0076     // modules, so nothing loads twice).
0077     withLazyPainter(BoxHitPiece.type, () => import('@dexvis/firebird-core').then(m => m.BoxHitSimplePainter)),
0078   );
0079 }
0080 
0081 /** PointTrajectory pieces (tracks, MC particles): DEX decoder and two painters. */
0082 export function withTrajectories(): FirebirdFeature {
0083   return firebirdPack('firebird.trajectories',
0084     withEventPiece(PointTrajectoryPieceFactory),
0085     // The first painter is the default: the per-track painter. The batched
0086     // one (2 draw calls for the whole piece, for huge pieces like MCParticles
0087     // background frames) is the selectable alternative:
0088     // painters.byPiece.<name> = trajectory-lines-batched
0089     withLazyPainter(PointTrajectoryPiece.type, () => import('@dexvis/firebird-core').then(m => m.TrajectoryPainter)),
0090     withLazyPainter(PointTrajectoryPiece.type, () => import('@dexvis/firebird-core').then(m => m.BatchedTrajectoryPainter)),
0091   );
0092 }
0093 
0094 /** Firebird DEX event files (.firebird.json / .firebird.zip), by URL or picked file. */
0095 export function withDexEvents(): FirebirdFeature {
0096   return firebirdPack('firebird.dex-events', withEventLoader(DexEventLoader));
0097 }
0098 
0099 /**
0100  * EDM4eic/EDM4hep ROOT event files converted in the browser (@dexvis/root2dex),
0101  * for what the browser can byte-range itself: http/asset URLs and picked files.
0102  */
0103 export function withRootEventsInBrowser(): FirebirdFeature {
0104   return firebirdPack('firebird.root-events-in-browser', withEventLoader(Root2DexEventLoader));
0105 }
0106 
0107 /**
0108  * EDM4eic/EDM4hep ROOT event files converted by the pyrobird server: XRootD
0109  * `root://` URLs and paths the server serves.
0110  */
0111 export function withServerConversion(): FirebirdFeature {
0112   return firebirdPack('firebird.server-conversion', withEventLoader(Edm4eicEventLoader));
0113 }
0114 
0115 /** ROOT TGeo detector geometry, and the experiment-neutral 'grey' theme. */
0116 export function withRootGeometry(): FirebirdFeature {
0117   return firebirdPack('firebird.root-geometry',
0118     withGeometryLoader(RootGeometryLoader),
0119     withGeometryTheme({
0120       id: 'grey', label: 'Grey - mono colors',
0121       load: () => import('@dexvis/firebird-ng/display').then(m => m.monoColorRules),
0122     }),
0123   );
0124 }
0125 
0126 /** Firebird's command vocabulary (URL deep links, server startup, batch, toolbar actions). */
0127 export function withFirebirdCommands(): FirebirdFeature {
0128   return firebirdPack('firebird.commands',
0129     withCommandHandler(OpenGeometryCommandHandler),
0130     withCommandHandler(OpenDexCommandHandler),
0131     withCommandHandler(ShowEventCommandHandler),
0132     withCommandHandler(SetConfigCommandHandler),
0133     withCommandHandler(CameraPresetCommandHandler),
0134     withCommandHandler(AnimateCollisionCommandHandler),
0135   );
0136 }
0137 
0138 /**
0139  * The face views and the home view of the HENP axis convention: beam along Z
0140  * (screen-right in the front view), Y up, X toward the accelerator center
0141  * (into the screen in the front view). Face views keep the current orbit
0142  * target and distance; `up` sets the screen roll, so the top and bottom
0143  * views keep Z pointing right. Home is the top view framing the loaded
0144  * geometry; a pack pins another home by registering a 'home' preset.
0145  */
0146 export function withStandardCameraPresets(): FirebirdFeature {
0147   return firebirdPack('firebird.camera-presets',
0148     withCameraPreset({ name: 'front', direction: [-1, 0, 0], up: [0, 1, 0] }),
0149     withCameraPreset({ name: 'back', direction: [1, 0, 0], up: [0, 1, 0] }),
0150     withCameraPreset({ name: 'right', direction: [0, 0, 1], up: [0, 1, 0] }),
0151     withCameraPreset({ name: 'left', direction: [0, 0, -1], up: [0, 1, 0] }),
0152     withCameraPreset({ name: 'top', direction: [0, 1, 0], up: [1, 0, 0] }),
0153     withCameraPreset({ name: 'bottom', direction: [0, -1, 0], up: [-1, 0, 0] }),
0154     withCameraPreset({ name: 'home', direction: [0, 1, 0], up: [1, 0, 0], fitGeometry: true }),
0155   );
0156 }
0157 
0158 /**
0159  * The camera navigation cube. Lazy: it pulls three.js code through
0160  * @dexvis/viewport-gizmo, which must stay out of the initial bundle.
0161  */
0162 export function withNavigationCube(): FirebirdFeature {
0163   return firebirdPack('firebird.navigation-cube',
0164     withLazyThreeExtension(() => import('@dexvis/firebird-ng/display').then(m => m.ViewportGizmoExtension)),
0165   );
0166 }
0167 
0168 /**
0169  * The data selector's tabs. Presets and Physics list catalog content and hide
0170  * themselves when no catalog is contributed; Manual (URL/file pick) always
0171  * shows. Lazy: tab UI must stay out of the initial bundle. Each tab has its
0172  * own feature id (`data-selector-tab:presets`, `:physics`, `:manual`).
0173  */
0174 export function withDataSelectorTabs(): FirebirdFeature {
0175   return firebirdPack('firebird.data-selector-tabs',
0176     withDataSelectorTab({
0177       id: 'presets', label: 'Presets', order: 10,
0178       load: () => import('@dexvis/firebird-ng/display').then(m => m.PresetsTabComponent),
0179     }),
0180     withDataSelectorTab({
0181       id: 'physics', label: 'Physics', order: 20,
0182       load: () => import('@dexvis/firebird-ng/display').then(m => m.PhysicsTabComponent),
0183     }),
0184     withDataSelectorTab({
0185       id: 'manual', label: 'Manual', order: 30, needsCatalog: false,
0186       load: () => import('@dexvis/firebird-ng/display').then(m => m.ManualTabComponent),
0187     }),
0188   );
0189 }
0190 
0191 /**
0192  * Every built-in part; `provideFirebird()` installs it. A pack of defaults:
0193  * a pack that replaces a built-in part by id draws no collision warning.
0194  */
0195 export function withFirebirdBuiltins(): FirebirdFeature {
0196   return appFeatureDefaults('firebird.builtins',
0197     // Firebird's server config shape, and the deep-link shorthands ?geometry=, ?dex=, ?event=
0198     withServerConfig({ defaults: defaultFirebirdConfig }),
0199     withFirebirdUrlShorthands(),
0200 
0201     // Event model and painters
0202     withBoxHits(),
0203     withTrajectories(),
0204 
0205     // IO. Event loader order matters: the in-browser ROOT converter is asked
0206     // before the server-conversion loader and claims only what the browser
0207     // can byte-range itself, so XRootD `root://` sources and pyrobird-served
0208     // paths fall through to the server.
0209     withDexEvents(),
0210     withRootEventsInBrowser(),
0211     withServerConversion(),
0212     withRootGeometry(),
0213 
0214     withFirebirdCommands(),
0215     withStandardCameraPresets(),
0216     withNavigationCube(),
0217     withDataSelectorTabs(),
0218 
0219     // MCParticles straight lines convert by default but start hidden: every
0220     // particle of the event is a lot of lines, so the user opts in per piece
0221     // through the model tree eye (normal config precedence: a deep link or a
0222     // saved user toggle overrides this default).
0223     withConfigDefaults({
0224       'painters.byPiece.MCParticles.visible': false,
0225     }),
0226   );
0227 }