representation.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * Copyright (c) 2018-2019 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 { ParamDefinition as PD } from '../../mol-util/param-definition';
  8. import { Representation, RepresentationProps, RepresentationProvider } from '../representation';
  9. import { StructureUnitTransforms } from '../../mol-model/structure/structure/util/unit-transforms';
  10. import { Structure } from '../../mol-model/structure';
  11. import { BaseGeometry } from '../../mol-geo/geometry/base';
  12. import { Mesh } from '../../mol-geo/geometry/mesh/mesh';
  13. import { Spheres } from '../../mol-geo/geometry/spheres/spheres';
  14. import { Points } from '../../mol-geo/geometry/points/points';
  15. import { Lines } from '../../mol-geo/geometry/lines/lines';
  16. import { DirectVolume } from '../../mol-geo/geometry/direct-volume/direct-volume';
  17. import { TextureMesh } from '../../mol-geo/geometry/texture-mesh/texture-mesh';
  18. import { Text } from '../../mol-geo/geometry/text/text';
  19. export interface StructureRepresentationState extends Representation.State {
  20. unitTransforms: StructureUnitTransforms | null,
  21. unitTransformsVersion: number
  22. }
  23. export const StructureRepresentationStateBuilder: Representation.StateBuilder<StructureRepresentationState> = {
  24. create: () => {
  25. return {
  26. ...Representation.createState(),
  27. unitTransforms: null,
  28. unitTransformsVersion: -1
  29. }
  30. },
  31. update: (state: StructureRepresentationState, update: Partial<StructureRepresentationState>) => {
  32. Representation.updateState(state, update)
  33. if (update.unitTransforms !== undefined) state.unitTransforms = update.unitTransforms
  34. }
  35. }
  36. export interface StructureRepresentation<P extends RepresentationProps = {}> extends Representation<Structure, P, StructureRepresentationState> { }
  37. export type StructureRepresentationProvider<P extends PD.Params, Id extends string = string> = RepresentationProvider<Structure, P, StructureRepresentationState, Id>
  38. export function StructureRepresentationProvider<P extends PD.Params, Id extends string>(p: StructureRepresentationProvider<P, Id>): StructureRepresentationProvider<P, Id> { return p; }
  39. //
  40. export const StructureParams = { ...BaseGeometry.Params }
  41. export type StructureParams = typeof StructureParams
  42. export const StructureMeshParams = { ...Mesh.Params, ...StructureParams }
  43. export type StructureMeshParams = typeof StructureMeshParams
  44. export const StructureSpheresParams = { ...Spheres.Params, ...StructureParams }
  45. export type StructureSpheresParams = typeof StructureSpheresParams
  46. export const StructurePointsParams = { ...Points.Params, ...StructureParams }
  47. export type StructurePointsParams = typeof StructurePointsParams
  48. export const StructureLinesParams = { ...Lines.Params, ...StructureParams }
  49. export type StructureLinesParams = typeof StructureLinesParams
  50. export const StructureTextParams = { ...Text.Params, ...StructureParams }
  51. export type StructureTextParams = typeof StructureTextParams
  52. export const StructureDirectVolumeParams = { ...DirectVolume.Params, ...StructureParams }
  53. export type StructureDirectVolumeParams = typeof StructureDirectVolumeParams
  54. export const StructureTextureMeshParams = { ...TextureMesh.Params, ...StructureParams }
  55. export type StructureTextureMeshParams = typeof StructureTextureMeshParams
  56. export { ComplexRepresentation } from './complex-representation'
  57. export { UnitsRepresentation } from './units-representation'
  58. export { ComplexVisual } from './complex-visual'
  59. export { UnitsVisual } from './units-visual'