property.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { CustomStructureProperty } from '../../mol-model-props/common/custom-structure-property';
  7. import { Structure } from '../../mol-model/structure';
  8. import { CustomProperty } from '../../mol-model-props/common/custom-property';
  9. import { ParamDefinition as PD } from '../../mol-util/param-definition';
  10. import { Color } from '../../mol-util/color';
  11. import { CustomPropertyDescriptor } from '../../mol-model/custom-property';
  12. export type CellPackInfoValue = {
  13. packingsCount: number
  14. packingIndex: number
  15. colors?: Color[]
  16. }
  17. const CellPackInfoParams = {
  18. info: PD.Value<CellPackInfoValue>({ packingsCount: 1, packingIndex: 0, colors: undefined }, { isHidden: true })
  19. };
  20. type CellPackInfoParams = PD.Values<typeof CellPackInfoParams>
  21. export const CellPackInfoProvider: CustomStructureProperty.Provider<typeof CellPackInfoParams, CellPackInfoValue> = CustomStructureProperty.createProvider({
  22. label: 'CellPack Info',
  23. descriptor: CustomPropertyDescriptor({ name: 'cellpack-info' }),
  24. type: 'root',
  25. defaultParams: CellPackInfoParams,
  26. getParams: (data: Structure) => CellPackInfoParams,
  27. isApplicable: (data: Structure) => true,
  28. obtain: async (ctx: CustomProperty.Context, data: Structure, props: CellPackInfoParams) => {
  29. return {
  30. value: { ...CellPackInfoParams.info.defaultValue, ...props.info }
  31. };
  32. }
  33. });