diff --git a/src/mol-gl/renderer.ts b/src/mol-gl/renderer.ts index c8af797234542f72d0b0106a736272c7b2af5a87..53968cc381ad2144680640e369e0c0b4ead71116 100644 --- a/src/mol-gl/renderer.ts +++ b/src/mol-gl/renderer.ts @@ -52,7 +52,7 @@ export const RendererParams = { ambientIntensity: PD.Numeric(0.4, { min: 0.0, max: 1.0, step: 0.01 }), metalness: PD.Numeric(0.0, { min: 0.0, max: 1.0, step: 0.01 }), - roughness: PD.Numeric(0.4, { min: 0.0, max: 1.0, step: 0.01 }), + roughness: PD.Numeric(1.0, { min: 0.0, max: 1.0, step: 0.01 }), reflectivity: PD.Numeric(0.5, { min: 0.0, max: 1.0, step: 0.01 }), } export type RendererProps = PD.Values<typeof RendererParams> diff --git a/src/mol-model/structure/structure/element.ts b/src/mol-model/structure/structure/element.ts index 7204322462b19d0cf3c94bf457cf9c7d353b9f52..25baf1bd57dd31f851ede425e24c9b3a8aed9667 100644 --- a/src/mol-model/structure/structure/element.ts +++ b/src/mol-model/structure/structure/element.ts @@ -473,7 +473,6 @@ namespace StructureElement { atom: { set, ranges }, chain: { opName: [ opName ] }, } - } } diff --git a/src/mol-plugin/ui/structure/representation.tsx b/src/mol-plugin/ui/structure/representation.tsx index d5dc2337eacef22f1979b092e385a937089754ff..435eaef23a20e2cebdc7e1005362d51515054d84 100644 --- a/src/mol-plugin/ui/structure/representation.tsx +++ b/src/mol-plugin/ui/structure/representation.tsx @@ -12,6 +12,7 @@ import { ColorOptions } 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'; abstract class BaseStructureRepresentationControls extends PluginUIComponent { onChange = (value: string) => { @@ -83,22 +84,12 @@ class SelectionStructureRepresentationControls extends BaseStructureRepresentati export class StructureRepresentationControls extends PluginUIComponent { preset = async () => { - const { structureSelection: sel, structureRepresentation: rep } = this.plugin.helpers - const lociGetter = (structure: Structure) => { - const loci = this.plugin.helpers.structureSelectionManager.get(structure) - return isEmptyLoci(loci) ? StructureElement.Loci.none(structure) : loci - } - - sel.set('add', Q.all()) - await rep.set('add', 'cartoon', lociGetter) - await rep.set('add', 'carbohydrate', lociGetter) - - sel.set('only', Q.ligandsPlusConnected()) - sel.set('add', Q.branchedConnectedOnly()) - sel.set('add', Q.water()) - await rep.set('add', 'ball-and-stick', lociGetter) - - sel.set('remove', Q.all()) + const { structureRepresentation: rep } = this.plugin.helpers + 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 ]) + ])) } render() { diff --git a/src/mol-plugin/ui/structure/selection.tsx b/src/mol-plugin/ui/structure/selection.tsx index ea41a211c7060a1f2c4d1ba89cd9707ffe2257c6..42778028043bfb88376e00e5d9ca5285b0ea8db2 100644 --- a/src/mol-plugin/ui/structure/selection.tsx +++ b/src/mol-plugin/ui/structure/selection.tsx @@ -51,7 +51,7 @@ export class StructureSelectionControls extends PluginUIComponent<{}, {}> { } set = (modifier: SelectionModifier, value: string) => { - const query = StructureSelectionQueries[value as keyof typeof StructureSelectionQueries]() + const query = StructureSelectionQueries[value as keyof typeof StructureSelectionQueries] this.plugin.helpers.structureSelection.set(modifier, query) } diff --git a/src/mol-plugin/util/structure-representation-helper.ts b/src/mol-plugin/util/structure-representation-helper.ts index 7db921f500afaa9e61ef52712c3cda2b96feac20..0b17b1418f8b3ee3d16993498409146ddd52e20c 100644 --- a/src/mol-plugin/util/structure-representation-helper.ts +++ b/src/mol-plugin/util/structure-representation-helper.ts @@ -7,9 +7,11 @@ import { PluginStateObject } from '../../mol-plugin/state/objects'; import { StateTransforms } from '../../mol-plugin/state/transforms'; import { StateTransformer, StateSelection, StateObjectCell, StateTransform } from '../../mol-state'; -import { StructureElement, Structure } from '../../mol-model/structure'; +import { StructureElement, Structure, StructureSelection, QueryContext } from '../../mol-model/structure'; 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'; type StructureTransform = StateObjectCell<PluginStateObject.Molecule.Structure, StateTransform<StateTransformer<any, PluginStateObject.Molecule.Structure, any>>> const RepresentationManagerTag = 'representation-controls' @@ -76,6 +78,14 @@ export class StructureRepresentationHelper { } } + async setFromExpression(modifier: SelectionModifier, type: string, expression: Expression) { + return this.set(modifier, type, (structure) => { + const compiled = compile<StructureSelection>(expression) + const result = compiled(new QueryContext(structure)) + return StructureSelection.toLoci2(result) + }) + } + constructor(private plugin: PluginContext) { } diff --git a/src/mol-plugin/util/structure-selection-helper.ts b/src/mol-plugin/util/structure-selection-helper.ts index 89e229e5f9d653f8dca50b58c5403fedd6ffe2fb..c474561bd3a0c508c5461bcb6d3ab0281e0c2df3 100644 --- a/src/mol-plugin/util/structure-selection-helper.ts +++ b/src/mol-plugin/util/structure-selection-helper.ts @@ -7,10 +7,13 @@ import { MolScriptBuilder as MS } from '../../mol-script/language/builder'; import { StateSelection } from '../../mol-state'; import { PluginStateObject } from '../state/objects'; -import { QueryContext, StructureSelection, QueryFn } from '../../mol-model/structure'; +import { QueryContext, StructureSelection } from '../../mol-model/structure'; import { compile } from '../../mol-script/runtime/query/compiler'; import { Loci } from '../../mol-model/loci'; import { PluginContext } from '../context'; +import Expression from '../../mol-script/language/expression'; + +const all = MS.struct.generator.all() const polymers = MS.struct.modifier.union([ MS.struct.generator.atomGroups({ @@ -89,16 +92,16 @@ const coarse = MS.struct.modifier.union([ ]) export const StructureSelectionQueries = { - all: () => compile<StructureSelection>(MS.struct.generator.all()), - polymers: () => compile<StructureSelection>(polymers), - backboneTrace: () => compile<StructureSelection>(backboneTrace), - water: () => compile<StructureSelection>(water), - branched: () => compile<StructureSelection>(branched), - branchedPlusConnected: () => compile<StructureSelection>(branchedPlusConnected), - branchedConnectedOnly: () => compile<StructureSelection>(branchedConnectedOnly), - ligands: () => compile<StructureSelection>(ligands), - ligandsPlusConnected: () => compile<StructureSelection>(ligandsPlusConnected), - coarse: () => compile<StructureSelection>(coarse), + all, + polymers, + backboneTrace, + water, + branched, + branchedPlusConnected, + branchedConnectedOnly, + ligands, + ligandsPlusConnected, + coarse, } // @@ -125,10 +128,12 @@ export class StructureSelectionHelper { } } - set(modifier: SelectionModifier, query: QueryFn<StructureSelection>) { + set(modifier: SelectionModifier, query: Expression) { + const compiled = compile<StructureSelection>(query) + for (const so of this.structures) { const s = so.obj!.data - const result = query(new QueryContext(s)) + const result = compiled(new QueryContext(s)) const loci = StructureSelection.toLoci2(result) this._set(modifier, loci) }