UNPKG

molstar

Version:

A comprehensive macromolecular library.

120 lines 10.9 kB
import { __assign, __extends } from "tslib"; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; /** * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import * as React from 'react'; import { Binding } from '../../mol-util/binding'; import { PluginUIComponent } from '../base'; import { StateSelection } from '../../mol-state'; import { SelectLoci } from '../../mol-plugin/behavior/dynamic/representation'; import { FocusLoci } from '../../mol-plugin/behavior/dynamic/representation'; import { Icon, ArrowDropDownSvg, ArrowRightSvg, CameraSvg } from '../controls/icons'; import { Button } from '../controls/common'; function getBindingsList(bindings) { return Object.keys(bindings).map(function (k) { return [k, bindings[k]]; }); } var BindingsHelp = /** @class */ (function (_super) { __extends(BindingsHelp, _super); function BindingsHelp() { return _super !== null && _super.apply(this, arguments) || this; } BindingsHelp.prototype.getBindingComponents = function () { var bindingsList = getBindingsList(this.props.bindings); return _jsx(_Fragment, { children: bindingsList.map(function (value) { var name = value[0], binding = value[1]; return !Binding.isEmpty(binding) ? _jsxs("div", __assign({ style: { marginBottom: '6px' } }, { children: [_jsx("b", { children: binding.action }, void 0), _jsx("br", {}, void 0), _jsx("span", { dangerouslySetInnerHTML: { __html: Binding.format(binding, name) } }, void 0)] }), name) : null; }) }, void 0); }; BindingsHelp.prototype.render = function () { return _jsx(HelpText, { children: this.getBindingComponents() }, void 0); }; return BindingsHelp; }(React.PureComponent)); export { BindingsHelp }; var HelpText = /** @class */ (function (_super) { __extends(HelpText, _super); function HelpText() { return _super !== null && _super.apply(this, arguments) || this; } HelpText.prototype.render = function () { return _jsx("div", __assign({ className: 'msp-help-text' }, { children: _jsx("div", { children: this.props.children }, void 0) }), void 0); }; return HelpText; }(React.PureComponent)); export { HelpText }; var HelpGroup = /** @class */ (function (_super) { __extends(HelpGroup, _super); function HelpGroup() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.state = { header: _this.props.header, isExpanded: !!_this.props.initiallyExpanded }; _this.toggleExpanded = function () { return _this.setState({ isExpanded: !_this.state.isExpanded }); }; return _this; } HelpGroup.prototype.render = function () { return _jsxs("div", __assign({ className: 'msp-control-group-wrapper' }, { children: [_jsx("div", __assign({ className: 'msp-control-group-header' }, { children: _jsxs(Button, __assign({ onClick: this.toggleExpanded }, { children: [_jsx(Icon, { svg: this.state.isExpanded ? ArrowDropDownSvg : ArrowRightSvg }, void 0), this.props.header] }), void 0) }), void 0), this.state.isExpanded && _jsx("div", __assign({ className: 'msp-control-offset', style: { display: this.state.isExpanded ? 'block' : 'none' } }, { children: this.props.children }), void 0)] }), void 0); }; return HelpGroup; }(React.PureComponent)); export { HelpGroup }; function HelpSection(props) { return _jsx("div", __assign({ className: 'msp-simple-help-section' }, { children: props.header }), void 0); } var ViewportHelpContent = /** @class */ (function (_super) { __extends(ViewportHelpContent, _super); function ViewportHelpContent() { return _super !== null && _super.apply(this, arguments) || this; } ViewportHelpContent.prototype.componentDidMount = function () { var _this = this; this.subscribe(this.plugin.events.canvas3d.settingsUpdated, function () { return _this.forceUpdate(); }); }; ViewportHelpContent.prototype.render = function () { var interactionBindings = {}; this.plugin.spec.behaviors.forEach(function (b) { var bindings = b.defaultParams.bindings; if (bindings) Object.assign(interactionBindings, bindings); }); return _jsxs(_Fragment, { children: [(!this.props.selectOnly && this.plugin.canvas3d) && _jsx(HelpGroup, __assign({ header: 'Moving in 3D' }, { children: _jsx(BindingsHelp, { bindings: this.plugin.canvas3d.props.trackball.bindings }, void 0) }), 'trackball'), _jsx(HelpGroup, __assign({ header: 'Mouse Controls' }, { children: _jsx(BindingsHelp, { bindings: interactionBindings }, void 0) }), 'interactions')] }, void 0); }; return ViewportHelpContent; }(PluginUIComponent)); export { ViewportHelpContent }; var HelpContent = /** @class */ (function (_super) { __extends(HelpContent, _super); function HelpContent() { return _super !== null && _super.apply(this, arguments) || this; } HelpContent.prototype.componentDidMount = function () { var _this = this; this.subscribe(this.plugin.events.canvas3d.settingsUpdated, function () { return _this.forceUpdate(); }); }; HelpContent.prototype.formatTriggers = function (binding) { return binding.triggers.map(function (t) { return Binding.Trigger.format(t); }).join(' or '); }; HelpContent.prototype.getTriggerFor = function (transformer, name) { var state = this.plugin.state.behaviors; var selections = state.select(StateSelection.Generators.ofTransformer(transformer)); var params = selections.length === 1 ? selections[0].params : undefined; var bindings = params ? params.values.bindings : {}; var binding = name in bindings ? bindings[name] : Binding.Empty; return this.formatTriggers(binding); }; HelpContent.prototype.render = function () { var selectToggleTriggers = this.getTriggerFor(SelectLoci, 'clickSelectToggle'); var focusTriggers = this.getTriggerFor(FocusLoci, 'clickFocus'); // TODO: interactive help, for example for density return _jsxs("div", { children: [_jsx(HelpSection, { header: 'Interface Controls' }, void 0), _jsxs(HelpGroup, __assign({ header: 'Inline Help' }, { children: [_jsx(HelpText, { children: "Many user interface elements show a little questionmark icon when hovered over. Clicking the icon toggles the display of an inline help text." }, void 0), _jsx(HelpText, { children: "Tooltips may provide additional information on a user interface element and are shown when hovering over it with the mouse." }, void 0)] }), void 0), _jsx(HelpGroup, __assign({ header: 'Selections' }, { children: _jsxs(HelpText, { children: ["The viewer allows changing colors and representations for selections of atoms, residues or chains. Selections can be created by", _jsxs("ul", __assign({ style: { paddingLeft: '20px' } }, { children: [_jsxs("li", { children: ["picking elements on the 3D canvas or the sequence view using the mouse, e.g. toggle selection using ", selectToggleTriggers, " (for more see help section on ", _jsx("i", { children: "Mouse Controls" }, void 0), ")"] }, void 0), _jsxs("li", { children: ["using the ", _jsx("i", { children: "Add" }, void 0), ", ", _jsx("i", { children: "Remove" }, void 0), " and ", _jsx("i", { children: "Only" }, void 0), " dropdown buttons in the ", _jsx("i", { children: "Manage Selection" }, void 0), " panel which allow modifing the current selection by predefined sets"] }, void 0)] }), void 0)] }, void 0) }), void 0), _jsx(HelpGroup, __assign({ header: 'Coloring' }, { children: _jsxs(HelpText, { children: ["There are two ways to color structures. Every representation (e.g. cartoon or spacefill) has a color theme which can be changed using the dropdown for each representation in the ", _jsx("i", { children: "Structure Settings" }, void 0), " panel. Additionally any selection atoms, residues or chains can by given a custom color. For that, first select the parts of the structure to be colored (see help section on ", _jsx("i", { children: "Selections" }, void 0), ") and, second, choose a color from the color dropdown botton in the ", _jsx("i", { children: "Selection" }, void 0), " row of the ", _jsx("i", { children: "Change Representation" }, void 0), " panel. The theme color can be seen as a base color that is overpainted by the custom color. Custom colors can be removed for a selection with the 'Clear' option in the color dropdown."] }, void 0) }), void 0), _jsx(HelpGroup, __assign({ header: 'Representations' }, { children: _jsxs(HelpText, { children: ["Structures can be shown with many different representations (e.g. cartoon or spacefill). The ", _jsx("i", { children: "Change Representation" }, void 0), " panel offers a collection of predefined styles which can be applied using the ", _jsx("i", { children: "Preset" }, void 0), " dropdown button. Additionally any selection atoms, residues or chains can by shown with a custom representation. For that, first select the parts of the structure to be mofified (see help section on ", _jsx("i", { children: "Selections" }, void 0), ") and, second, choose a representation to hide or show from the ", _jsx("i", { children: "Show" }, void 0), " and ", _jsx("i", { children: "Hide" }, void 0), " dropdown bottons in the ", _jsx("i", { children: "Selection" }, void 0), " row of the ", _jsx("i", { children: "Change Representation" }, void 0), " panel. The ", _jsx("i", { children: "Everything" }, void 0), " row applies the action to the whole structure instead of the current selection."] }, void 0) }), void 0), _jsx(HelpGroup, __assign({ header: 'Surroundings' }, { children: _jsxs(HelpText, { children: ["To show the surroundings of a residue or ligand, click it in the 3D scene or in the sequence widget using ", focusTriggers, "."] }, void 0) }), void 0), _jsx(HelpSection, { header: 'How-to Guides' }, void 0), _jsx(HelpGroup, __assign({ header: 'Create an Image' }, { children: _jsxs(HelpText, { children: [_jsxs("p", { children: ["Use the ", _jsx(Icon, { svg: CameraSvg }, void 0), " icon in the viewport to bring up the screenshot controls."] }, void 0), _jsxs("p", { children: ["To adjust the size of the image, use the ", _jsx("i", { children: "Resolution" }, void 0), " dropdown."] }, void 0)] }, void 0) }), void 0), _jsx(HelpSection, { header: 'Mouse Controls' }, void 0), _jsx(ViewportHelpContent, {}, void 0)] }, void 0); }; return HelpContent; }(PluginUIComponent)); export { HelpContent }; //# sourceMappingURL=help.js.map