/** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose */ import { ElementSphereVisual, ElementSphereParams } from '../visual/element-sphere'; import { IntraUnitLinkVisual, IntraUnitLinkParams } from '../visual/intra-unit-link-cylinder'; import { InterUnitLinkVisual, InterUnitLinkParams } from '../visual/inter-unit-link-cylinder'; import { ParamDefinition as PD } from 'mol-util/param-definition'; import { UnitsRepresentation } from '../units-representation'; import { ComplexRepresentation } from '../complex-representation'; import { StructureRepresentation, StructureRepresentationProvider } from '../representation'; import { Representation, RepresentationParamsGetter } from 'mol-repr/representation'; import { ThemeRegistryContext } from 'mol-theme/theme'; import { Structure } from 'mol-model/structure'; import { BuiltInSizeThemeName, BuiltInSizeThemeOptions } from 'mol-theme/size'; import { BuiltInColorThemeName, BuiltInColorThemeOptions } from 'mol-theme/color'; import { UnitKind, UnitKindOptions } from '../visual/util/common'; const BallAndStickVisuals = { 'element-sphere': (getParams: RepresentationParamsGetter) => UnitsRepresentation('Element sphere mesh', getParams, ElementSphereVisual), 'intra-link': (getParams: RepresentationParamsGetter) => UnitsRepresentation('Intra-unit link cylinder', getParams, IntraUnitLinkVisual), 'inter-link': (getParams: RepresentationParamsGetter) => ComplexRepresentation('Inter-unit link cylinder', getParams, InterUnitLinkVisual), } type BallAndStickVisualName = keyof typeof BallAndStickVisuals const BallAndStickVisualOptions = Object.keys(BallAndStickVisuals).map(name => [name, name] as [BallAndStickVisualName, string]) export const BallAndStickParams = { ...ElementSphereParams, ...IntraUnitLinkParams, ...InterUnitLinkParams, unitKinds: PD.MultiSelect('Unit Kind', '', ['atomic'], UnitKindOptions), sizeFactor: PD.Numeric('Size Factor', '', 0.2, 0.01, 10, 0.01), sizeTheme: PD.Select('Size Theme', '', 'uniform', BuiltInSizeThemeOptions), colorTheme: PD.Select('Color Theme', '', 'polymer-index', BuiltInColorThemeOptions), visuals: PD.MultiSelect('Visuals', '', ['element-sphere', 'intra-link', 'inter-link'], BallAndStickVisualOptions), } export type BallAndStickParams = typeof BallAndStickParams export function getBallAndStickParams(ctx: ThemeRegistryContext, structure: Structure) { return PD.clone(BallAndStickParams) } export type BallAndStickRepresentation = StructureRepresentation export function BallAndStickRepresentation(getParams: RepresentationParamsGetter): BallAndStickRepresentation { return Representation.createMulti('Ball & Stick', getParams, BallAndStickVisuals as unknown as Representation.Def) } export const BallAndStickRepresentationProvider: StructureRepresentationProvider = { factory: BallAndStickRepresentation, getParams: getBallAndStickParams }