UNPKG

molstar

Version:

A comprehensive macromolecular library.

112 lines (111 loc) 6.31 kB
/** * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Ludovic Autin <ludovic.autin@gmail.com> */ import { __assign, __awaiter, __generator } from "tslib"; import { StateObjectRef } from '../../mol-state'; import { StructureRepresentationPresetProvider, presetStaticComponent } from '../../mol-plugin-state/builder/structure/representation-preset'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ColorNames } from '../../mol-util/color/names'; import { CellPackGenerateColorThemeProvider } from './color/generate'; export var CellpackPackingPresetParams = { traceOnly: PD.Boolean(true), ignoreLight: PD.Boolean(false), representation: PD.Select('gaussian-surface', PD.arrayToOptions(['gaussian-surface', 'spacefill', 'point', 'orientation'])), }; export var CellpackPackingPreset = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-cellpack-packing', display: { name: 'CellPack Packing' }, params: function () { return CellpackPackingPresetParams; }, apply: function (ref, params, plugin) { return __awaiter(this, void 0, void 0, function () { var structureCell, reprProps, components, color, _a, update, builder, typeParams, representations; var _b; return __generator(this, function (_c) { switch (_c.label) { case 0: structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return [2 /*return*/, {}]; reprProps = { ignoreHydrogens: true, traceOnly: params.traceOnly, instanceGranularity: true, ignoreLight: params.ignoreLight, }; _b = {}; return [4 /*yield*/, presetStaticComponent(plugin, structureCell, 'polymer')]; case 1: components = (_b.polymer = _c.sent(), _b); if (params.representation === 'gaussian-surface') { Object.assign(reprProps, { quality: 'custom', resolution: 10, radiusOffset: 2, doubleSided: false }); } else if (params.representation === 'spacefill') { Object.assign(reprProps, { sizeFactor: params.traceOnly ? 2 : 1 }); } color = CellPackGenerateColorThemeProvider.name; _a = StructureRepresentationPresetProvider.reprBuilder(plugin, {}), update = _a.update, builder = _a.builder, typeParams = _a.typeParams; representations = { polymer: builder.buildRepresentation(update, components.polymer, { type: params.representation, typeParams: __assign(__assign({}, typeParams), reprProps), color: color }, { tag: 'polymer' }) }; return [4 /*yield*/, update.commit({ revertOnError: true })]; case 2: _c.sent(); return [2 /*return*/, { components: components, representations: representations }]; } }); }); } }); // export var CellpackMembranePresetParams = { ignoreLight: PD.Boolean(false), representation: PD.Select('gaussian-surface', PD.arrayToOptions(['gaussian-surface', 'spacefill', 'point', 'orientation'])), }; export var CellpackMembranePreset = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-cellpack-membrane', display: { name: 'CellPack Membrane' }, params: function () { return CellpackMembranePresetParams; }, apply: function (ref, params, plugin) { return __awaiter(this, void 0, void 0, function () { var structureCell, reprProps, components, _a, update, builder, typeParams, representations; var _b; return __generator(this, function (_c) { switch (_c.label) { case 0: structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return [2 /*return*/, {}]; reprProps = { ignoreHydrogens: true, instanceGranularity: true, ignoreLight: params.ignoreLight, }; _b = {}; return [4 /*yield*/, presetStaticComponent(plugin, structureCell, 'all', { label: 'Membrane' })]; case 1: components = (_b.membrane = _c.sent(), _b); if (params.representation === 'gaussian-surface') { Object.assign(reprProps, { quality: 'custom', resolution: 10, radiusOffset: 2, doubleSided: false }); } _a = StructureRepresentationPresetProvider.reprBuilder(plugin, {}), update = _a.update, builder = _a.builder, typeParams = _a.typeParams; representations = { membrane: builder.buildRepresentation(update, components.membrane, { type: params.representation, typeParams: __assign(__assign({}, typeParams), reprProps), color: 'uniform', colorParams: { value: ColorNames.lightgrey } }, { tag: 'all' }) }; return [4 /*yield*/, update.commit({ revertOnError: true })]; case 2: _c.sent(); return [2 /*return*/, { components: components, representations: representations }]; } }); }); } });