registry.ts 1.3 KB

12345678910111213141516171819202122232425262728
  1. /**
  2. * Copyright (c) 2018 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 { RepresentationProvider, RepresentationRegistry } from '../representation';
  8. import { CartoonRepresentationProvider } from './representation/cartoon';
  9. import { BallAndStickRepresentationProvider } from './representation/ball-and-stick';
  10. export class StructureRepresentationRegistry extends RepresentationRegistry<Structure> {
  11. constructor() {
  12. super()
  13. Object.keys(BuiltInStructureRepresentations).forEach(name => {
  14. const p = (BuiltInStructureRepresentations as { [k: string]: RepresentationProvider<Structure, any> })[name]
  15. this.add(name, p.factory, p.getParams)
  16. })
  17. }
  18. }
  19. export const BuiltInStructureRepresentations = {
  20. 'cartoon': CartoonRepresentationProvider,
  21. 'ball-and-stick': BallAndStickRepresentationProvider,
  22. }
  23. export type BuiltInStructureRepresentationsName = keyof typeof BuiltInStructureRepresentations
  24. export const BuiltInStructureRepresentationsNames = Object.keys(BuiltInStructureRepresentations)
  25. export const BuiltInStructureRepresentationsOptions = BuiltInStructureRepresentationsNames.map(n => [n, n] as [BuiltInStructureRepresentationsName, string])