molstar
Version:
A comprehensive macromolecular library.
46 lines (45 loc) • 3.21 kB
JavaScript
/**
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { __assign } from "tslib";
import { IntraUnitBondCylinderVisual, IntraUnitBondCylinderParams } from '../visual/bond-intra-unit-cylinder';
import { InterUnitBondCylinderParams, InterUnitBondCylinderVisual } from '../visual/bond-inter-unit-cylinder';
import { ElementSphereVisual, ElementSphereParams } from '../visual/element-sphere';
import { ParamDefinition as PD } from '../../../mol-util/param-definition';
import { UnitsRepresentation } from '../units-representation';
import { ComplexRepresentation } from '../complex-representation';
import { StructureRepresentationProvider, StructureRepresentationStateBuilder } from '../representation';
import { Representation } from '../../../mol-repr/representation';
import { getUnitKindsParam } from '../params';
import { BaseGeometry } from '../../../mol-geo/geometry/base';
var BallAndStickVisuals = {
'element-sphere': function (ctx, getParams) { return UnitsRepresentation('Element sphere', ctx, getParams, ElementSphereVisual); },
'intra-bond': function (ctx, getParams) { return UnitsRepresentation('Intra-unit bond cylinder', ctx, getParams, IntraUnitBondCylinderVisual); },
'inter-bond': function (ctx, getParams) { return ComplexRepresentation('Inter-unit bond cylinder', ctx, getParams, InterUnitBondCylinderVisual); },
};
export var BallAndStickParams = __assign(__assign(__assign(__assign(__assign({}, ElementSphereParams), { traceOnly: PD.Boolean(false, { isHidden: true }) }), IntraUnitBondCylinderParams), InterUnitBondCylinderParams), { includeParent: PD.Boolean(false), unitKinds: getUnitKindsParam(['atomic']), sizeFactor: PD.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: PD.Numeric(2 / 3, { min: 0.01, max: 3, step: 0.01 }), visuals: PD.MultiSelect(['element-sphere', 'intra-bond', 'inter-bond'], PD.objectToOptions(BallAndStickVisuals)), bumpFrequency: PD.Numeric(0, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory) });
export function getBallAndStickParams(ctx, structure) {
return PD.clone(BallAndStickParams);
}
export function BallAndStickRepresentation(ctx, getParams) {
return Representation.createMulti('Ball & Stick', ctx, getParams, StructureRepresentationStateBuilder, BallAndStickVisuals);
}
export var BallAndStickRepresentationProvider = StructureRepresentationProvider({
name: 'ball-and-stick',
label: 'Ball & Stick',
description: 'Displays atoms as spheres and bonds as cylinders.',
factory: BallAndStickRepresentation,
getParams: getBallAndStickParams,
defaultValues: PD.getDefaultValues(BallAndStickParams),
defaultColorTheme: { name: 'element-symbol' },
defaultSizeTheme: { name: 'physical' },
isApplicable: function (structure) { return structure.elementCount > 0; },
getData: function (structure, props) {
return props.includeParent ? structure.asParent() : structure;
},
mustRecreate: function (oldProps, newProps) {
return oldProps.includeParent !== newProps.includeParent;
}
});