registry.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { Structure } from '../../mol-model/structure';
  7. import { objectForEach } from '../../mol-util/object';
  8. import { RepresentationRegistry, RepresentationProvider } from '../representation';
  9. import { StructureRepresentationState } from './representation';
  10. import { BallAndStickRepresentationProvider } from './representation/ball-and-stick';
  11. import { CarbohydrateRepresentationProvider } from './representation/carbohydrate';
  12. import { CartoonRepresentationProvider } from './representation/cartoon';
  13. import { EllipsoidRepresentationProvider } from './representation/ellipsoid';
  14. import { GaussianSurfaceRepresentationProvider } from './representation/gaussian-surface';
  15. import { LabelRepresentationProvider } from './representation/label';
  16. import { MolecularSurfaceRepresentationProvider } from './representation/molecular-surface';
  17. import { OrientationRepresentationProvider } from './representation/orientation';
  18. import { PointRepresentationProvider } from './representation/point';
  19. import { PuttyRepresentationProvider } from './representation/putty';
  20. import { SpacefillRepresentationProvider } from './representation/spacefill';
  21. import { LineRepresentationProvider } from './representation/line';
  22. import { GaussianVolumeRepresentationProvider } from './representation/gaussian-volume';
  23. import { BackboneRepresentationProvider } from './representation/backbone';
  24. export class StructureRepresentationRegistry extends RepresentationRegistry<Structure, StructureRepresentationState> {
  25. constructor() {
  26. super();
  27. objectForEach(StructureRepresentationRegistry.BuiltIn, (p, k) => {
  28. if (p.name !== k) throw new Error(`Fix BuiltInStructureRepresentations to have matching names. ${p.name} ${k}`);
  29. this.add(p as any);
  30. });
  31. }
  32. }
  33. export namespace StructureRepresentationRegistry {
  34. export const BuiltIn = {
  35. 'cartoon': CartoonRepresentationProvider,
  36. 'backbone': BackboneRepresentationProvider,
  37. 'ball-and-stick': BallAndStickRepresentationProvider,
  38. 'carbohydrate': CarbohydrateRepresentationProvider,
  39. 'ellipsoid': EllipsoidRepresentationProvider,
  40. 'gaussian-surface': GaussianSurfaceRepresentationProvider,
  41. 'gaussian-volume': GaussianVolumeRepresentationProvider, // TODO disabled for now, needs more work
  42. 'label': LabelRepresentationProvider,
  43. 'line': LineRepresentationProvider,
  44. 'molecular-surface': MolecularSurfaceRepresentationProvider,
  45. 'orientation': OrientationRepresentationProvider,
  46. 'point': PointRepresentationProvider,
  47. 'putty': PuttyRepresentationProvider,
  48. 'spacefill': SpacefillRepresentationProvider,
  49. };
  50. type _BuiltIn = typeof BuiltIn
  51. export type BuiltIn = keyof _BuiltIn
  52. export type BuiltInParams<T extends BuiltIn> = Partial<RepresentationProvider.ParamValues<_BuiltIn[T]>>
  53. }