diff --git a/src/mol-plugin/ui/structure/representation.tsx b/src/mol-plugin/ui/structure/representation.tsx index 026578b24cab176364a54382eafb92fb261c935c..83d746d307662c5eedd6ce93b1ab7cac27df6b28 100644 --- a/src/mol-plugin/ui/structure/representation.tsx +++ b/src/mol-plugin/ui/structure/representation.tsx @@ -10,9 +10,7 @@ import { Structure, StructureElement } from '../../../mol-model/structure'; import { isEmptyLoci } from '../../../mol-model/loci'; import { ColorOptions, ParameterControls } from '../controls/parameters'; import { Color } from '../../../mol-util/color'; -import { ButtonSelect, Options } from '../controls/common'; -import { StructureSelectionQueries as Q } from '../../util/structure-selection-helper'; -import { MolScriptBuilder as MS } from '../../../mol-script/language/builder'; +import { ButtonSelect, Options } from '../controls/common' import { ParamDefinition as PD } from '../../../mol-util/param-definition'; abstract class BaseStructureRepresentationControls extends PluginUIComponent { @@ -92,13 +90,7 @@ class SelectionStructureRepresentationControls extends BaseStructureRepresentati export class StructureRepresentationControls extends PluginUIComponent { preset = async () => { - const { structureRepresentation: rep } = this.plugin.helpers - await rep.clear() - await rep.setFromExpression('add', 'cartoon', Q.all) - await rep.setFromExpression('add', 'carbohydrate', Q.all) - await rep.setFromExpression('add', 'ball-and-stick', MS.struct.modifier.union([ - MS.struct.combinator.merge([ Q.ligandsPlusConnected, Q.branchedConnectedOnly, Q.water ]) - ])) + await this.plugin.helpers.structureRepresentation.preset() } onChange = async (p: { param: PD.Base<any>, name: string, value: any }) => { diff --git a/src/mol-plugin/util/structure-representation-helper.ts b/src/mol-plugin/util/structure-representation-helper.ts index ce08c72b61cd3e1eca578f6439f253d76d905031..f0a72891f080d1f578fba4227c3e20fcb31d5427 100644 --- a/src/mol-plugin/util/structure-representation-helper.ts +++ b/src/mol-plugin/util/structure-representation-helper.ts @@ -12,6 +12,8 @@ import { PluginContext } from '../context'; import { StructureRepresentation3DHelpers } from '../state/transforms/representation'; import Expression from '../../mol-script/language/expression'; import { compile } from '../../mol-script/runtime/query/compiler'; +import { StructureSelectionQueries as Q } from '../util/structure-selection-helper'; +import { MolScriptBuilder as MS } from '../../mol-script/language/builder'; type StructureTransform = StateObjectCell<PSO.Molecule.Structure, StateTransform<StateTransformer<any, PSO.Molecule.Structure, any>>> const RepresentationManagerTag = 'representation-controls' @@ -145,6 +147,16 @@ export class StructureRepresentationHelper { this._ignoreHydrogens = ignoreHydrogens } + async preset() { + // TODO generalize and make configurable + await this.clear() + await this.setFromExpression('add', 'cartoon', Q.all) + await this.setFromExpression('add', 'carbohydrate', Q.all) + await this.setFromExpression('add', 'ball-and-stick', MS.struct.modifier.union([ + MS.struct.combinator.merge([ Q.ligandsPlusConnected, Q.branchedConnectedOnly, Q.water ]) + ])) + } + constructor(private plugin: PluginContext) { }