/** * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose */ import * as React from 'react'; import { Binding } from '../../mol-util/binding'; import { PluginUIComponent } from '../base'; import { StateTransformer, StateSelection } from '../../mol-state'; import { SelectLoci } from '../../mol-plugin/behavior/dynamic/representation'; import { FocusLoci } from '../../mol-plugin/behavior/dynamic/representation'; import { Icon } from '../controls/icons'; import { Button } from '../controls/common'; function getBindingsList(bindings: { [k: string]: Binding }) { return Object.keys(bindings).map(k => [k, bindings[k]] as [string, Binding]) } export class BindingsHelp extends React.PureComponent<{ bindings: { [k: string]: Binding } }> { getBindingComponents() { const bindingsList = getBindingsList(this.props.bindings) return <> {bindingsList.map(value => { const [name, binding] = value return !Binding.isEmpty(binding) ?
{binding.action}
: null })} } render() { return {this.getBindingComponents()} } } class HelpText extends React.PureComponent { render() { return
{this.props.children}
} } class HelpGroup extends React.PureComponent<{ header: string, initiallyExpanded?: boolean }, { isExpanded: boolean }> { state = { header: this.props.header, isExpanded: !!this.props.initiallyExpanded } toggleExpanded = () => this.setState({ isExpanded: !this.state.isExpanded }); render() { return
{this.state.isExpanded &&
{this.props.children}
}
} } function HelpSection(props: { header: string }) { return
{props.header}
; } export class ViewportHelpContent extends PluginUIComponent { componentDidMount() { this.subscribe(this.plugin.events.canvas3d.settingsUpdated, () => this.forceUpdate()); } render() { const interactionBindings: { [k: string]: Binding } = {} this.plugin.spec.behaviors.forEach(b => { const { bindings } = b.defaultParams if (bindings) Object.assign(interactionBindings, bindings) }) return <> {this.plugin.canvas3d && } } } export class HelpContent extends PluginUIComponent { componentDidMount() { this.subscribe(this.plugin.events.canvas3d.settingsUpdated, () => this.forceUpdate()); } private formatTriggers(binding: Binding) { return binding.triggers.map(t => Binding.Trigger.format(t)).join(' or ') } private getTriggerFor(transformer: StateTransformer, name: string) { const state = this.plugin.state.behaviors const selections = state.select(StateSelection.Generators.ofTransformer(transformer)) const params = selections.length === 1 ? selections[0].params : undefined const bindings = params ? params.values.bindings : {} const binding: Binding = name in bindings ? bindings[name] : Binding.Empty return this.formatTriggers(binding) } render() { const selectToggleTriggers = this.getTriggerFor(SelectLoci, 'clickSelectToggle') const focusTriggers = this.getTriggerFor(FocusLoci, 'clickFocus') // TODO: interactive help, for example for density return
Many user interface elements show a little questionmark icon when hovered over. Clicking the icon toggles the display of an inline help text. Tooltips may provide additional information on a user interface element and are shown when hovering over it with the mouse. The viewer allows changing colors and representations for selections of atoms, residues or chains. Selections can be created by
  • 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 Mouse Controls)
  • using the Add, Remove and Only dropdown buttons in the Manage Selection panel which allow modifing the current selection by predefined sets
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 Structure Settings 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 Selections) and, second, choose a color from the color dropdown botton in the Selection row of the Change Representation 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. Structures can be shown with many different representations (e.g. cartoon or spacefill). The Change Representation panel offers a collection of predefined styles which can be applied using the Preset 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 Selections) and, second, choose a representation to hide or show from the Show and Hide dropdown bottons in the Selection row of the Change Representation panel. The Everything row applies the action to the whole structure instead of the current selection. To show the surroundings of a residue or ligand, click it in the 3D scene or in the sequence widget using {focusTriggers}.

Use the icon in the viewport to bring up the screenshot controls.

To adjust the size of the image, use the Resolution dropdown.

} }