/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose */ import { UnitsRepresentation } from '../units-representation'; import { ParamDefinition as PD } from '../../../mol-util/param-definition'; import { StructureRepresentation, StructureRepresentationProvider, StructureRepresentationStateBuilder } from '../representation'; import { Representation, RepresentationParamsGetter, RepresentationContext } from '../../../mol-repr/representation'; import { ThemeRegistryContext } from '../../../mol-theme/theme'; import { Structure } from '../../../mol-model/structure'; import { OrientationEllipsoidMeshParams, OrientationEllipsoidMeshVisual } from '../visual/orientation-ellipsoid-mesh'; const OrientationVisuals = { 'orientation-ellipsoid-mesh': (ctx: RepresentationContext, getParams: RepresentationParamsGetter) => UnitsRepresentation('Orientation ellipsoid mesh', ctx, getParams, OrientationEllipsoidMeshVisual), } type OrientationVisualName = keyof typeof OrientationVisuals const OrientationVisualOptions = Object.keys(OrientationVisuals).map(name => [name, name] as [OrientationVisualName, string]) export const OrientationParams = { ...OrientationEllipsoidMeshParams, visuals: PD.MultiSelect(['orientation-ellipsoid-mesh'], OrientationVisualOptions), } export type OrientationParams = typeof OrientationParams export function getOrientationParams(ctx: ThemeRegistryContext, structure: Structure) { return PD.clone(OrientationParams) } export type OrientationRepresentation = StructureRepresentation export function OrientationRepresentation(ctx: RepresentationContext, getParams: RepresentationParamsGetter): OrientationRepresentation { return Representation.createMulti('Orientation', ctx, getParams, StructureRepresentationStateBuilder, OrientationVisuals as unknown as Representation.Def) } export const OrientationRepresentationProvider: StructureRepresentationProvider = { label: 'Orientation', description: 'Displays orientation ellipsoids for polymer chains.', factory: OrientationRepresentation, getParams: getOrientationParams, defaultValues: PD.getDefaultValues(OrientationParams), defaultColorTheme: 'polymer-id', defaultSizeTheme: 'uniform', isApplicable: (structure: Structure) => structure.elementCount > 0 }