UNPKG

molstar

Version:

A comprehensive macromolecular library.

54 lines (53 loc) 3.92 kB
"use strict"; /** * Copyright (c) 2020-2022 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.LineRepresentationProvider = exports.LineRepresentation = exports.getLineParams = exports.LineParams = void 0; var tslib_1 = require("tslib"); var bond_intra_unit_line_1 = require("../visual/bond-intra-unit-line"); var bond_inter_unit_line_1 = require("../visual/bond-inter-unit-line"); 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 element_point_1 = require("../visual/element-point"); var element_cross_1 = require("../visual/element-cross"); var LineVisuals = { 'intra-bond': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Intra-unit bond line', ctx, getParams, bond_intra_unit_line_1.IntraUnitBondLineVisual); }, 'inter-bond': function (ctx, getParams) { return (0, complex_representation_1.ComplexRepresentation)('Inter-unit bond line', ctx, getParams, bond_inter_unit_line_1.InterUnitBondLineVisual); }, 'element-point': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Points', ctx, getParams, element_point_1.ElementPointVisual); }, 'element-cross': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Crosses', ctx, getParams, element_cross_1.ElementCrossVisual); }, }; exports.LineParams = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, bond_intra_unit_line_1.IntraUnitBondLineParams), bond_inter_unit_line_1.InterUnitBondLineParams), element_point_1.ElementPointParams), element_cross_1.ElementCrossParams), { multipleBonds: param_definition_1.ParamDefinition.Select('offset', param_definition_1.ParamDefinition.arrayToOptions(['off', 'symmetric', 'offset'])), includeParent: param_definition_1.ParamDefinition.Boolean(false), sizeFactor: param_definition_1.ParamDefinition.Numeric(2, { min: 0.01, max: 10, step: 0.01 }), unitKinds: (0, params_1.getUnitKindsParam)(['atomic']), visuals: param_definition_1.ParamDefinition.MultiSelect(['intra-bond', 'inter-bond', 'element-point', 'element-cross'], param_definition_1.ParamDefinition.objectToOptions(LineVisuals)) }); function getLineParams(ctx, structure) { var params = param_definition_1.ParamDefinition.clone(exports.LineParams); params.pointStyle.defaultValue = 'circle'; return params; } exports.getLineParams = getLineParams; function LineRepresentation(ctx, getParams) { return representation_2.Representation.createMulti('Line', ctx, getParams, representation_1.StructureRepresentationStateBuilder, LineVisuals); } exports.LineRepresentation = LineRepresentation; exports.LineRepresentationProvider = (0, representation_1.StructureRepresentationProvider)({ name: 'line', label: 'Line', description: 'Displays bonds as lines and atoms as points or croses.', factory: LineRepresentation, getParams: getLineParams, defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.LineParams), defaultColorTheme: { name: 'element-symbol' }, defaultSizeTheme: { name: 'uniform' }, 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; } });