property.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * Copyright (c) 2020 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. color: boolean
  16. colors: Color[]
  17. }
  18. const CellPackInfoParams = {
  19. info: PD.Value<CellPackInfoValue>({ packingsCount: 1, packingIndex: 0, color: false, colors:[] }, { isHidden: true })
  20. };
  21. type CellPackInfoParams = PD.Values<typeof CellPackInfoParams>
  22. export const CellPackInfoProvider: CustomStructureProperty.Provider<typeof CellPackInfoParams, CellPackInfoValue> = CustomStructureProperty.createProvider({
  23. label: 'CellPack Info',
  24. descriptor: CustomPropertyDescriptor({ name: 'cellpack-info' }),
  25. type: 'root',
  26. defaultParams: CellPackInfoParams,
  27. getParams: (data: Structure) => CellPackInfoParams,
  28. isApplicable: (data: Structure) => true,
  29. obtain: async (ctx: CustomProperty.Context, data: Structure, props: CellPackInfoParams) => {
  30. return {
  31. value: { ...CellPackInfoParams.info.defaultValue, ...props.info }
  32. };
  33. }
  34. });