UNPKG

molstar

Version:

A comprehensive macromolecular library.

688 lines (687 loc) 40.7 kB
"use strict"; /** * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> * @author Alexander Rose <alexander.rose@weirdbyte.de> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.StructureComponentManager = void 0; var tslib_1 = require("tslib"); var base_1 = require("../../../mol-geo/geometry/base"); var interactions_1 = require("../../../mol-model-props/computed/interactions"); var structure_1 = require("../../../mol-model/structure"); var structure_set_1 = require("../../../mol-model/structure/query/utils/structure-set"); var state_1 = require("../../../mol-plugin/behavior/static/state"); var mol_task_1 = require("../../../mol-task"); var mol_util_1 = require("../../../mol-util"); var names_1 = require("../../../mol-util/color/names"); var object_1 = require("../../../mol-util/object"); var param_definition_1 = require("../../../mol-util/param-definition"); var component_1 = require("../../component"); var structure_overpaint_1 = require("../../helpers/structure-overpaint"); var structure_representation_params_1 = require("../../helpers/structure-representation-params"); var structure_selection_query_1 = require("../../helpers/structure-selection-query"); var representation_1 = require("../../transforms/representation"); var clipping_1 = require("../../../mol-theme/clipping"); var structure_clipping_1 = require("../../helpers/structure-clipping"); var structure_transparency_1 = require("../../helpers/structure-transparency"); var structure_focus_representation_1 = require("../../../mol-plugin/behavior/dynamic/selection/structure-focus-representation"); var structure_substance_1 = require("../../helpers/structure-substance"); var material_1 = require("../../../mol-util/material"); var clip_1 = require("../../../mol-util/clip"); var StructureComponentManager = /** @class */ (function (_super) { tslib_1.__extends(StructureComponentManager, _super); function StructureComponentManager(plugin) { var _this = _super.call(this, { options: param_definition_1.ParamDefinition.getDefaultValues(StructureComponentManager.OptionsParams) }) || this; _this.plugin = plugin; _this.events = { optionsUpdated: _this.ev() }; return _this; } Object.defineProperty(StructureComponentManager.prototype, "currentStructures", { get: function () { return this.plugin.managers.structure.hierarchy.selection.structures; }, enumerable: false, configurable: true }); Object.defineProperty(StructureComponentManager.prototype, "pivotStructure", { get: function () { return this.currentStructures[0]; }, enumerable: false, configurable: true }); StructureComponentManager.prototype.setOptions = function (options) { return tslib_1.__awaiter(this, void 0, void 0, function () { var interactionChanged, update, _i, _a, s, _b, _c, c; var _this = this; return tslib_1.__generator(this, function (_d) { interactionChanged = options.interactions !== this.state.options.interactions; this.updateState({ options: options }); this.events.optionsUpdated.next(void 0); update = this.dataState.build(); for (_i = 0, _a = this.currentStructures; _i < _a.length; _i++) { s = _a[_i]; for (_b = 0, _c = s.components; _b < _c.length; _b++) { c = _c[_b]; this.updateReprParams(update, c); } } return [2 /*return*/, this.plugin.dataTransaction(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, update.commit()]; case 1: _a.sent(); return [4 /*yield*/, this.plugin.state.updateBehavior(structure_focus_representation_1.StructureFocusRepresentation, function (p) { p.ignoreHydrogens = !options.showHydrogens; p.ignoreLight = options.ignoreLight; p.material = options.materialStyle; p.clip = options.clipObjects; })]; case 2: _a.sent(); if (!interactionChanged) return [3 /*break*/, 4]; return [4 /*yield*/, this.updateInterationProps()]; case 3: _a.sent(); _a.label = 4; case 4: return [2 /*return*/]; } }); }); })]; }); }); }; StructureComponentManager.prototype.updateReprParams = function (update, component) { var _a = this.state.options, showHydrogens = _a.showHydrogens, quality = _a.visualQuality, ignoreLight = _a.ignoreLight, material = _a.materialStyle, clip = _a.clipObjects; var ignoreHydrogens = !showHydrogens; for (var _i = 0, _b = component.representations; _i < _b.length; _i++) { var r = _b[_i]; if (r.cell.transform.transformer !== representation_1.StructureRepresentation3D) continue; var params = r.cell.transform.params; if (!!params.type.params.ignoreHydrogens !== ignoreHydrogens || params.type.params.quality !== quality || params.type.params.ignoreLight !== ignoreLight || !(0, mol_util_1.shallowEqual)(params.type.params.material, material) || !param_definition_1.ParamDefinition.areEqual(clip_1.Clip.Params, params.type.params.clip, clip)) { update.to(r.cell).update(function (old) { old.type.params.ignoreHydrogens = ignoreHydrogens; old.type.params.quality = quality; old.type.params.ignoreLight = ignoreLight; old.type.params.material = material; old.type.params.clip = clip; }); } } }; StructureComponentManager.prototype.updateInterationProps = function () { var _a, _b, _c; return tslib_1.__awaiter(this, void 0, void 0, function () { var _i, _d, s, interactionParams, oldParams, pd, params; var _this = this; return tslib_1.__generator(this, function (_e) { switch (_e.label) { case 0: _i = 0, _d = this.currentStructures; _e.label = 1; case 1: if (!(_i < _d.length)) return [3 /*break*/, 6]; s = _d[_i]; interactionParams = interactions_1.InteractionsProvider.getParams((_a = s.cell.obj) === null || _a === void 0 ? void 0 : _a.data); if (!s.properties) return [3 /*break*/, 3]; oldParams = (_b = s.properties.cell.transform.params) === null || _b === void 0 ? void 0 : _b.properties[interactions_1.InteractionsProvider.descriptor.name]; if (param_definition_1.ParamDefinition.areEqual(interactionParams, oldParams, this.state.options.interactions)) return [3 /*break*/, 5]; return [4 /*yield*/, this.dataState.build().to(s.properties.cell) .update(function (old) { old.properties[interactions_1.InteractionsProvider.descriptor.name] = _this.state.options.interactions; }) .commit()]; case 2: _e.sent(); return [3 /*break*/, 5]; case 3: pd = this.plugin.customStructureProperties.getParams((_c = s.cell.obj) === null || _c === void 0 ? void 0 : _c.data); params = param_definition_1.ParamDefinition.getDefaultValues(pd); if (param_definition_1.ParamDefinition.areEqual(interactionParams, params.properties[interactions_1.InteractionsProvider.descriptor.name], this.state.options.interactions)) return [3 /*break*/, 5]; params.properties[interactions_1.InteractionsProvider.descriptor.name] = this.state.options.interactions; return [4 /*yield*/, this.plugin.builders.structure.insertStructureProperties(s.cell, params)]; case 4: _e.sent(); _e.label = 5; case 5: _i++; return [3 /*break*/, 1]; case 6: return [2 /*return*/]; } }); }); }; StructureComponentManager.prototype.applyPreset = function (structures, provider, params) { var _this = this; return this.plugin.dataTransaction(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { var _i, structures_1, s, preset; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: _i = 0, structures_1 = structures; _a.label = 1; case 1: if (!(_i < structures_1.length)) return [3 /*break*/, 5]; s = structures_1[_i]; return [4 /*yield*/, this.plugin.builders.structure.representation.applyPreset(s.cell, provider, params)]; case 2: preset = _a.sent(); return [4 /*yield*/, this.syncPreset(s, preset)]; case 3: _a.sent(); _a.label = 4; case 4: _i++; return [3 /*break*/, 1]; case 5: return [2 /*return*/]; } }); }); }, { canUndo: 'Preset' }); }; StructureComponentManager.prototype.syncPreset = function (root, preset) { if (!preset || !preset.components) return this.clearComponents([root]); var keptRefs = new Set(); (0, object_1.objectForEach)(preset.components, function (c) { if (c) keptRefs.add(c.ref); }); if (preset.representations) { (0, object_1.objectForEach)(preset.representations, function (r) { if (r) keptRefs.add(r.ref); }); } if (keptRefs.size === 0) return this.clearComponents([root]); var changed = false; var update = this.dataState.build(); var sync = function (r) { if (!keptRefs.has(r.cell.transform.ref)) { changed = true; update.delete(r.cell); } }; for (var _i = 0, _a = root.components; _i < _a.length; _i++) { var c = _a[_i]; sync(c); for (var _b = 0, _c = c.representations; _b < _c.length; _b++) { var r = _c[_b]; sync(r); } if (c.genericRepresentations) { for (var _d = 0, _e = c.genericRepresentations; _d < _e.length; _d++) { var r = _e[_d]; sync(r); } } } if (root.genericRepresentations) { for (var _f = 0, _g = root.genericRepresentations; _f < _g.length; _f++) { var r = _g[_f]; sync(r); } } if (changed) return update.commit(); }; StructureComponentManager.prototype.clear = function (structures) { return this.clearComponents(structures); }; StructureComponentManager.prototype.selectThis = function (components) { var _a; var mng = this.plugin.managers.structure.selection; mng.clear(); for (var _i = 0, components_1 = components; _i < components_1.length; _i++) { var c = components_1[_i]; var loci = structure_1.Structure.toSubStructureElementLoci(c.structure.cell.obj.data, (_a = c.cell.obj) === null || _a === void 0 ? void 0 : _a.data); mng.fromLoci('set', loci); } }; StructureComponentManager.prototype.canBeModified = function (ref) { return this.plugin.builders.structure.isComponentTransform(ref.cell); }; StructureComponentManager.prototype.modifyByCurrentSelection = function (components, action) { var _this = this; return this.plugin.runTask(mol_task_1.Task.create('Modify Component', function (taskCtx) { return tslib_1.__awaiter(_this, void 0, void 0, function () { var b, _i, components_2, c, selection; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: b = this.dataState.build(); for (_i = 0, components_2 = components; _i < components_2.length; _i++) { c = components_2[_i]; if (!this.canBeModified(c)) continue; selection = this.plugin.managers.structure.selection.getStructure(c.structure.cell.obj.data); if (!selection || selection.elementCount === 0) continue; this.modifyComponent(b, c, selection, action); } return [4 /*yield*/, this.dataState.updateTree(b, { canUndo: 'Modify Selection' }).runInContext(taskCtx)]; case 1: _a.sent(); return [2 /*return*/]; } }); }); })); }; StructureComponentManager.prototype.toggleVisibility = function (components, reprPivot) { if (components.length === 0) return; if (!reprPivot) { var isHidden = !components[0].cell.state.isHidden; for (var _i = 0, components_3 = components; _i < components_3.length; _i++) { var c = components_3[_i]; (0, state_1.setSubtreeVisibility)(this.dataState, c.cell.transform.ref, isHidden); } } else { var index = components[0].representations.indexOf(reprPivot); var isHidden = !reprPivot.cell.state.isHidden; for (var _a = 0, components_4 = components; _a < components_4.length; _a++) { var c = components_4[_a]; // TODO: is it ok to use just the index here? Could possible lead to ugly edge cases, but perhaps not worth the trouble to "fix". var repr = c.representations[index]; if (!repr) continue; (0, state_1.setSubtreeVisibility)(this.dataState, repr.cell.transform.ref, isHidden); } } }; StructureComponentManager.prototype.removeRepresentations = function (components, pivot) { if (components.length === 0) return; var toRemove = []; if (pivot) { var index = components[0].representations.indexOf(pivot); if (index < 0) return; for (var _i = 0, components_5 = components; _i < components_5.length; _i++) { var c = components_5[_i]; if (c.representations[index]) toRemove.push(c.representations[index]); } } else { for (var _a = 0, components_6 = components; _a < components_6.length; _a++) { var c = components_6[_a]; for (var _b = 0, _c = c.representations; _b < _c.length; _b++) { var r = _c[_b]; toRemove.push(r); } } } return this.plugin.managers.structure.hierarchy.remove(toRemove, true); }; StructureComponentManager.prototype.updateRepresentations = function (components, pivot, params) { if (components.length === 0) return Promise.resolve(); var index = components[0].representations.indexOf(pivot); if (index < 0) return Promise.resolve(); var update = this.dataState.build(); for (var _i = 0, components_7 = components; _i < components_7.length; _i++) { var c = components_7[_i]; // TODO: is it ok to use just the index here? Could possible lead to ugly edge cases, but perhaps not worth the trouble to "fix". var repr = c.representations[index]; if (!repr) continue; if (repr.cell.transform.transformer !== pivot.cell.transform.transformer) continue; update.to(repr.cell).update(params); } return update.commit({ canUndo: 'Update Representation' }); }; StructureComponentManager.prototype.updateRepresentationsTheme = function (components, paramsOrProvider) { var _a, _b, _c, _d; if (components.length === 0) return; var update = this.dataState.build(); for (var _i = 0, components_8 = components; _i < components_8.length; _i++) { var c = components_8[_i]; var _loop_1 = function (repr) { var old = repr.cell.transform.params; var params = typeof paramsOrProvider === 'function' ? paramsOrProvider(c, repr) : paramsOrProvider; var colorTheme = params.color === 'default' ? (0, structure_representation_params_1.createStructureColorThemeParams)(this_1.plugin, (_a = c.structure.cell.obj) === null || _a === void 0 ? void 0 : _a.data, old === null || old === void 0 ? void 0 : old.type.name) : params.color ? (0, structure_representation_params_1.createStructureColorThemeParams)(this_1.plugin, (_b = c.structure.cell.obj) === null || _b === void 0 ? void 0 : _b.data, old === null || old === void 0 ? void 0 : old.type.name, params.color, params.colorParams) : void 0; var sizeTheme = params.size === 'default' ? (0, structure_representation_params_1.createStructureSizeThemeParams)(this_1.plugin, (_c = c.structure.cell.obj) === null || _c === void 0 ? void 0 : _c.data, old === null || old === void 0 ? void 0 : old.type.name) : params.color ? (0, structure_representation_params_1.createStructureSizeThemeParams)(this_1.plugin, (_d = c.structure.cell.obj) === null || _d === void 0 ? void 0 : _d.data, old === null || old === void 0 ? void 0 : old.type.name, params.size, params.sizeParams) : void 0; if (colorTheme || sizeTheme) { update.to(repr.cell).update(function (prev) { if (colorTheme) prev.colorTheme = colorTheme; if (sizeTheme) prev.sizeTheme = sizeTheme; }); } }; var this_1 = this; for (var _e = 0, _f = c.representations; _e < _f.length; _e++) { var repr = _f[_e]; _loop_1(repr); } } return update.commit({ canUndo: 'Update Theme' }); }; StructureComponentManager.prototype.addRepresentation = function (components, type) { var _this = this; if (components.length === 0) return; var _a = this.state.options, showHydrogens = _a.showHydrogens, quality = _a.visualQuality, ignoreLight = _a.ignoreLight, material = _a.materialStyle, clip = _a.clipObjects; var ignoreHydrogens = !showHydrogens; var typeParams = { ignoreHydrogens: ignoreHydrogens, quality: quality, ignoreLight: ignoreLight, material: material, clip: clip }; return this.plugin.dataTransaction(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { var _i, components_9, component; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: _i = 0, components_9 = components; _a.label = 1; case 1: if (!(_i < components_9.length)) return [3 /*break*/, 4]; component = components_9[_i]; return [4 /*yield*/, this.plugin.builders.structure.representation.addRepresentation(component.cell, { type: this.plugin.representation.structure.registry.get(type), typeParams: typeParams })]; case 2: _a.sent(); _a.label = 3; case 3: _i++; return [3 /*break*/, 1]; case 4: return [2 /*return*/]; } }); }); }, { canUndo: 'Add Representation' }); }; StructureComponentManager.prototype.tryFindComponent = function (structure, selection) { var _this = this; if (structure.components.length === 0) return; return this.plugin.runTask(mol_task_1.Task.create('Find Component', function (taskCtx) { return tslib_1.__awaiter(_this, void 0, void 0, function () { var data, sel, _a, _b, _i, _c, c, comp; var _d, _e; return tslib_1.__generator(this, function (_f) { switch (_f.label) { case 0: data = (_d = structure.cell.obj) === null || _d === void 0 ? void 0 : _d.data; if (!data) return [2 /*return*/]; _b = (_a = structure_1.StructureSelection).unionStructure; return [4 /*yield*/, selection.getSelection(this.plugin, taskCtx, data)]; case 1: sel = _b.apply(_a, [_f.sent()]); for (_i = 0, _c = structure.components; _i < _c.length; _i++) { c = _c[_i]; comp = (_e = c.cell.obj) === null || _e === void 0 ? void 0 : _e.data; if (!comp || !c.cell.parent) continue; if ((0, structure_set_1.structureAreEqual)(sel, comp)) return [2 /*return*/, c.cell]; } return [2 /*return*/]; } }); }); })); }; StructureComponentManager.prototype.add = function (params, structures) { return tslib_1.__awaiter(this, void 0, void 0, function () { var _this = this; return tslib_1.__generator(this, function (_a) { return [2 /*return*/, this.plugin.dataTransaction(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { var xs, _a, showHydrogens, quality, ignoreLight, material, clip, ignoreHydrogens, typeParams, componentKey, _i, xs_1, s, component; return tslib_1.__generator(this, function (_b) { switch (_b.label) { case 0: xs = structures || this.currentStructures; if (xs.length === 0) return [2 /*return*/]; _a = this.state.options, showHydrogens = _a.showHydrogens, quality = _a.visualQuality, ignoreLight = _a.ignoreLight, material = _a.materialStyle, clip = _a.clipObjects; ignoreHydrogens = !showHydrogens; typeParams = { ignoreHydrogens: ignoreHydrogens, quality: quality, ignoreLight: ignoreLight, material: material, clip: clip }; componentKey = mol_util_1.UUID.create22(); _i = 0, xs_1 = xs; _b.label = 1; case 1: if (!(_i < xs_1.length)) return [3 /*break*/, 8]; s = xs_1[_i]; component = void 0; if (!params.options.checkExisting) return [3 /*break*/, 3]; return [4 /*yield*/, this.tryFindComponent(s, params.selection)]; case 2: component = _b.sent(); _b.label = 3; case 3: if (!!component) return [3 /*break*/, 5]; return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentFromSelection(s.cell, params.selection, componentKey, { label: params.options.label || (params.selection === structure_selection_query_1.StructureSelectionQueries.current ? 'Custom Selection' : ''), })]; case 4: component = _b.sent(); _b.label = 5; case 5: if (params.representation === 'none' || !component) return [3 /*break*/, 7]; return [4 /*yield*/, this.plugin.builders.structure.representation.addRepresentation(component, { type: this.plugin.representation.structure.registry.get(params.representation), typeParams: typeParams })]; case 6: _b.sent(); _b.label = 7; case 7: _i++; return [3 /*break*/, 1]; case 8: return [2 /*return*/]; } }); }); }, { canUndo: 'Add Selection' })]; }); }); }; StructureComponentManager.prototype.applyTheme = function (params, structures) { return tslib_1.__awaiter(this, void 0, void 0, function () { var _this = this; return tslib_1.__generator(this, function (_a) { return [2 /*return*/, this.plugin.dataTransaction(function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () { var xs, getLoci, _i, xs_2, s, p, p, p, p; var _this = this; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: xs = structures || this.currentStructures; if (xs.length === 0) return [2 /*return*/]; getLoci = function (s) { return tslib_1.__awaiter(_this, void 0, void 0, function () { var _a, _b; return tslib_1.__generator(this, function (_c) { switch (_c.label) { case 0: _b = (_a = structure_1.StructureSelection).toLociWithSourceUnits; return [4 /*yield*/, params.selection.getSelection(this.plugin, ctx, s)]; case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])]; } }); }); }; _i = 0, xs_2 = xs; _a.label = 1; case 1: if (!(_i < xs_2.length)) return [3 /*break*/, 14]; s = xs_2[_i]; if (!(params.action.name === 'color')) return [3 /*break*/, 3]; p = params.action.params; return [4 /*yield*/, (0, structure_overpaint_1.setStructureOverpaint)(this.plugin, s.components, p.color, getLoci, params.representations)]; case 2: _a.sent(); return [3 /*break*/, 13]; case 3: if (!(params.action.name === 'resetColor')) return [3 /*break*/, 5]; return [4 /*yield*/, (0, structure_overpaint_1.setStructureOverpaint)(this.plugin, s.components, -1, getLoci, params.representations)]; case 4: _a.sent(); return [3 /*break*/, 13]; case 5: if (!(params.action.name === 'transparency')) return [3 /*break*/, 7]; p = params.action.params; return [4 /*yield*/, (0, structure_transparency_1.setStructureTransparency)(this.plugin, s.components, p.value, getLoci, params.representations)]; case 6: _a.sent(); return [3 /*break*/, 13]; case 7: if (!(params.action.name === 'material')) return [3 /*break*/, 9]; p = params.action.params; return [4 /*yield*/, (0, structure_substance_1.setStructureSubstance)(this.plugin, s.components, p.material, getLoci, params.representations)]; case 8: _a.sent(); return [3 /*break*/, 13]; case 9: if (!(params.action.name === 'resetMaterial')) return [3 /*break*/, 11]; return [4 /*yield*/, (0, structure_substance_1.setStructureSubstance)(this.plugin, s.components, void 0, getLoci, params.representations)]; case 10: _a.sent(); return [3 /*break*/, 13]; case 11: if (!(params.action.name === 'clipping')) return [3 /*break*/, 13]; p = params.action.params; return [4 /*yield*/, (0, structure_clipping_1.setStructureClipping)(this.plugin, s.components, clipping_1.Clipping.Groups.fromNames(p.excludeGroups), getLoci, params.representations)]; case 12: _a.sent(); _a.label = 13; case 13: _i++; return [3 /*break*/, 1]; case 14: return [2 /*return*/]; } }); }); }, { canUndo: 'Apply Theme' })]; }); }); }; StructureComponentManager.prototype.modifyComponent = function (builder, component, by, action) { var _a, _b, _c; var structure = (_a = component.cell.obj) === null || _a === void 0 ? void 0 : _a.data; if (!structure) return; if ((action === 'subtract' || action === 'intersect') && !(0, structure_set_1.structureAreIntersecting)(structure, by)) return; var parent = (_b = component.structure.cell.obj) === null || _b === void 0 ? void 0 : _b.data; var modified = action === 'union' ? (0, structure_set_1.structureUnion)(parent, [structure, by]) : action === 'intersect' ? (0, structure_set_1.structureIntersect)(structure, by) : (0, structure_set_1.structureSubtract)(structure, by); if (modified.elementCount === 0) { builder.delete(component.cell.transform.ref); } else { var bundle = structure_1.StructureElement.Bundle.fromSubStructure(parent, modified); var params = { type: { name: 'bundle', params: bundle }, nullIfEmpty: true, label: (_c = component.cell.obj) === null || _c === void 0 ? void 0 : _c.label }; builder.to(component.cell).update(params); } }; StructureComponentManager.prototype.updateLabel = function (component, label) { var _a, _b; var params = { type: (_a = component.cell.params) === null || _a === void 0 ? void 0 : _a.values.type, nullIfEmpty: (_b = component.cell.params) === null || _b === void 0 ? void 0 : _b.values.nullIfEmpty, label: label }; this.dataState.build().to(component.cell).update(params).commit(); }; Object.defineProperty(StructureComponentManager.prototype, "dataState", { get: function () { return this.plugin.state.data; }, enumerable: false, configurable: true }); StructureComponentManager.prototype.clearComponents = function (structures) { var deletes = this.dataState.build(); for (var _i = 0, structures_2 = structures; _i < structures_2.length; _i++) { var s = structures_2[_i]; for (var _a = 0, _b = s.components; _a < _b.length; _a++) { var c = _b[_a]; deletes.delete(c.cell.transform.ref); } } return deletes.commit({ canUndo: 'Clear Selections' }); }; return StructureComponentManager; }(component_1.StatefulPluginComponent)); exports.StructureComponentManager = StructureComponentManager; (function (StructureComponentManager) { StructureComponentManager.OptionsParams = { showHydrogens: param_definition_1.ParamDefinition.Boolean(true, { description: 'Toggle display of hydrogen atoms in representations' }), visualQuality: param_definition_1.ParamDefinition.Select('auto', base_1.VisualQualityOptions, { description: 'Control the visual/rendering quality of representations' }), ignoreLight: param_definition_1.ParamDefinition.Boolean(false, { description: 'Ignore light for stylized rendering of representtions' }), materialStyle: material_1.Material.getParam(), clipObjects: param_definition_1.ParamDefinition.Group(clip_1.Clip.Params), interactions: param_definition_1.ParamDefinition.Group(interactions_1.InteractionsProvider.defaultParams, { label: 'Non-covalent Interactions' }), }; function getAddParams(plugin, params) { var options = plugin.query.structure.registry.options; params = tslib_1.__assign({ pivot: plugin.managers.structure.component.pivotStructure, allowNone: true, hideSelection: false, checkExisting: false }, params); return { selection: param_definition_1.ParamDefinition.Select(options[1][0], options, { isHidden: params === null || params === void 0 ? void 0 : params.hideSelection }), representation: getRepresentationTypesSelect(plugin, params === null || params === void 0 ? void 0 : params.pivot, (params === null || params === void 0 ? void 0 : params.allowNone) ? [['none', '< Create Later >']] : []), options: param_definition_1.ParamDefinition.Group({ label: param_definition_1.ParamDefinition.Text(''), checkExisting: param_definition_1.ParamDefinition.Boolean(!!(params === null || params === void 0 ? void 0 : params.checkExisting), { help: function () { return ({ description: 'Checks if a selection with the specifield elements already exists to avoid creating duplicate components.' }); } }), }) }; } StructureComponentManager.getAddParams = getAddParams; function getThemeParams(plugin, pivot) { var options = plugin.query.structure.registry.options; return { selection: param_definition_1.ParamDefinition.Select(options[1][0], options, { isHidden: false }), action: param_definition_1.ParamDefinition.MappedStatic('color', { color: param_definition_1.ParamDefinition.Group({ color: param_definition_1.ParamDefinition.Color(names_1.ColorNames.blue, { isExpanded: true }), }, { isFlat: true }), resetColor: param_definition_1.ParamDefinition.EmptyGroup({ label: 'Reset Color' }), transparency: param_definition_1.ParamDefinition.Group({ value: param_definition_1.ParamDefinition.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), }, { isFlat: true }), material: param_definition_1.ParamDefinition.Group({ material: material_1.Material.getParam({ isFlat: true }), }, { isFlat: true }), resetMaterial: param_definition_1.ParamDefinition.EmptyGroup({ label: 'Reset Material' }), clipping: param_definition_1.ParamDefinition.Group({ excludeGroups: param_definition_1.ParamDefinition.MultiSelect([], param_definition_1.ParamDefinition.objectToOptions(clipping_1.Clipping.Groups.Names)), }, { isFlat: true }), }), representations: param_definition_1.ParamDefinition.MultiSelect([], getRepresentationTypes(plugin, pivot), { emptyValue: 'All' }) }; } StructureComponentManager.getThemeParams = getThemeParams; function getRepresentationTypes(plugin, pivot) { var _a, _b; return ((_a = pivot === null || pivot === void 0 ? void 0 : pivot.cell.obj) === null || _a === void 0 ? void 0 : _a.data) ? plugin.representation.structure.registry.getApplicableTypes((_b = pivot.cell.obj) === null || _b === void 0 ? void 0 : _b.data) : plugin.representation.structure.registry.types; } StructureComponentManager.getRepresentationTypes = getRepresentationTypes; function getRepresentationTypesSelect(plugin, pivot, custom, label) { var types = tslib_1.__spreadArray(tslib_1.__spreadArray([], custom, true), getRepresentationTypes(plugin, pivot), true); return param_definition_1.ParamDefinition.Select(types[0][0], types, { label: label }); } })(StructureComponentManager || (StructureComponentManager = {})); exports.StructureComponentManager = StructureComponentManager;