UNPKG

molstar

Version:

A comprehensive macromolecular library.

109 lines 6.43 kB
/** * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ 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'; import { CellPackInfoProvider } from './property'; import { CellPackProvidedColorThemeProvider } from './color/provided'; export var CellpackPackingPresetParams = { traceOnly: PD.Boolean(true), 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) { var _a, _b; return __awaiter(this, void 0, void 0, function () { var structureCell, reprProps, components, info, color, _c, update, builder, typeParams, representations; var _d; return __generator(this, function (_e) { switch (_e.label) { case 0: structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return [2 /*return*/, {}]; reprProps = { ignoreHydrogens: true, traceOnly: params.traceOnly }; _d = {}; return [4 /*yield*/, presetStaticComponent(plugin, structureCell, 'polymer')]; case 1: components = (_d.polymer = _e.sent(), _d); if (params.representation === 'gaussian-surface') { Object.assign(reprProps, { quality: 'custom', resolution: 10, radiusOffset: 2, doubleSided: false }); } else if (params.representation === 'spacefill' && params.traceOnly) { Object.assign(reprProps, { sizeFactor: 2 }); } info = ((_a = structureCell.obj) === null || _a === void 0 ? void 0 : _a.data) && CellPackInfoProvider.get((_b = structureCell.obj) === null || _b === void 0 ? void 0 : _b.data).value; color = (info === null || info === void 0 ? void 0 : info.colors) ? CellPackProvidedColorThemeProvider.name : CellPackGenerateColorThemeProvider.name; _c = StructureRepresentationPresetProvider.reprBuilder(plugin, {}), update = _c.update, builder = _c.builder, typeParams = _c.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: _e.sent(); return [2 /*return*/, { components: components, representations: representations }]; } }); }); } }); // export var CellpackMembranePresetParams = { 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, }; _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: 'gaussian-surface', 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 }]; } }); }); } }); //# sourceMappingURL=preset.js.map