UNPKG

molstar

Version:

A comprehensive macromolecular library.

51 lines (50 loc) 4.03 kB
"use strict"; /** * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.BallAndStickRepresentationProvider = exports.BallAndStickRepresentation = exports.getBallAndStickParams = exports.BallAndStickParams = void 0; var tslib_1 = require("tslib"); var bond_intra_unit_cylinder_1 = require("../visual/bond-intra-unit-cylinder"); var bond_inter_unit_cylinder_1 = require("../visual/bond-inter-unit-cylinder"); var element_sphere_1 = require("../visual/element-sphere"); var param_definition_1 = require("../../../mol-util/param-definition"); var units_representation_1 = require("../units-representation"); var complex_representation_1 = require("../complex-representation"); var representation_1 = require("../representation"); var representation_2 = require("../../../mol-repr/representation"); var params_1 = require("../params"); var base_1 = require("../../../mol-geo/geometry/base"); var BallAndStickVisuals = { 'element-sphere': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Element sphere', ctx, getParams, element_sphere_1.ElementSphereVisual); }, 'intra-bond': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Intra-unit bond cylinder', ctx, getParams, bond_intra_unit_cylinder_1.IntraUnitBondCylinderVisual); }, 'inter-bond': function (ctx, getParams) { return (0, complex_representation_1.ComplexRepresentation)('Inter-unit bond cylinder', ctx, getParams, bond_inter_unit_cylinder_1.InterUnitBondCylinderVisual); }, }; exports.BallAndStickParams = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, element_sphere_1.ElementSphereParams), { traceOnly: param_definition_1.ParamDefinition.Boolean(false, { isHidden: true }) }), bond_intra_unit_cylinder_1.IntraUnitBondCylinderParams), bond_inter_unit_cylinder_1.InterUnitBondCylinderParams), { includeParent: param_definition_1.ParamDefinition.Boolean(false), unitKinds: (0, params_1.getUnitKindsParam)(['atomic']), sizeFactor: param_definition_1.ParamDefinition.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: param_definition_1.ParamDefinition.Numeric(2 / 3, { min: 0.01, max: 3, step: 0.01 }), visuals: param_definition_1.ParamDefinition.MultiSelect(['element-sphere', 'intra-bond', 'inter-bond'], param_definition_1.ParamDefinition.objectToOptions(BallAndStickVisuals)), bumpFrequency: param_definition_1.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, base_1.BaseGeometry.ShadingCategory) }); function getBallAndStickParams(ctx, structure) { return param_definition_1.ParamDefinition.clone(exports.BallAndStickParams); } exports.getBallAndStickParams = getBallAndStickParams; function BallAndStickRepresentation(ctx, getParams) { return representation_2.Representation.createMulti('Ball & Stick', ctx, getParams, representation_1.StructureRepresentationStateBuilder, BallAndStickVisuals); } exports.BallAndStickRepresentation = BallAndStickRepresentation; exports.BallAndStickRepresentationProvider = (0, representation_1.StructureRepresentationProvider)({ name: 'ball-and-stick', label: 'Ball & Stick', description: 'Displays atoms as spheres and bonds as cylinders.', factory: BallAndStickRepresentation, getParams: getBallAndStickParams, defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.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; } });