representation.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. * @author David Sehnal <david.sehnal@gmail.com>
  6. */
  7. import { Structure } from '../../mol-model/structure';
  8. import { StructureUnitTransforms } from '../../mol-model/structure/structure/util/unit-transforms';
  9. import { ParamDefinition as PD } from '../../mol-util/param-definition';
  10. import { Representation, RepresentationProps, RepresentationProvider } from '../representation';
  11. export interface StructureRepresentationState extends Representation.State {
  12. unitTransforms: StructureUnitTransforms | null,
  13. unitTransformsVersion: number
  14. }
  15. export const StructureRepresentationStateBuilder: Representation.StateBuilder<StructureRepresentationState> = {
  16. create: () => {
  17. return {
  18. ...Representation.createState(),
  19. unitTransforms: null,
  20. unitTransformsVersion: -1
  21. }
  22. },
  23. update: (state: StructureRepresentationState, update: Partial<StructureRepresentationState>) => {
  24. Representation.updateState(state, update)
  25. if (update.unitTransforms !== undefined) state.unitTransforms = update.unitTransforms
  26. }
  27. }
  28. export interface StructureRepresentation<P extends RepresentationProps = {}> extends Representation<Structure, P, StructureRepresentationState> { }
  29. export type StructureRepresentationProvider<P extends PD.Params, Id extends string = string> = RepresentationProvider<Structure, P, StructureRepresentationState, Id>
  30. export function StructureRepresentationProvider<P extends PD.Params, Id extends string>(p: StructureRepresentationProvider<P, Id>): StructureRepresentationProvider<P, Id> { return p; }
  31. //
  32. export { ComplexRepresentation } from './complex-representation';
  33. export { ComplexVisual } from './complex-visual';
  34. export { UnitsRepresentation } from './units-representation';
  35. export { UnitsVisual } from './units-visual';