diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5e1428404b5cc13954ece72bca5bf77838ab54..4883b6e8b6d4892d2ded0e994f4101087d4d8943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf ## [Unreleased] -- Fix xrayShader & ignoreLight not working at the same time +- Fix ``xrayShader`` & ``ignoreLight`` params not working at the same time +- Add ``ignoreLight`` to component params ## [v3.0.2] - 2022-01-30 diff --git a/src/mol-plugin-state/builder/structure/representation-preset.ts b/src/mol-plugin-state/builder/structure/representation-preset.ts index 28d178b9e26791859e498c07b461697f893f3cf2..b59ca04d791918891de2f4943160a05d0abf0c73 100644 --- a/src/mol-plugin-state/builder/structure/representation-preset.ts +++ b/src/mol-plugin-state/builder/structure/representation-preset.ts @@ -39,6 +39,7 @@ export namespace StructureRepresentationPresetProvider { export const CommonParams = { ignoreHydrogens: PD.Optional(PD.Boolean(false)), + ignoreLight: PD.Optional(PD.Boolean(false)), quality: PD.Optional(PD.Select<VisualQuality>('auto', VisualQualityOptions)), theme: PD.Optional(PD.Group({ globalName: PD.Optional(PD.Text<ColorTheme.BuiltIn>('')), @@ -70,9 +71,11 @@ export namespace StructureRepresentationPresetProvider { const typeParams = { quality: plugin.managers.structure.component.state.options.visualQuality, ignoreHydrogens: !plugin.managers.structure.component.state.options.showHydrogens, + ignoreLight: plugin.managers.structure.component.state.options.ignoreLight, }; if (params.quality && params.quality !== 'auto') typeParams.quality = params.quality; if (params.ignoreHydrogens !== void 0) typeParams.ignoreHydrogens = !!params.ignoreHydrogens; + if (params.ignoreLight !== void 0) typeParams.ignoreLight = !!params.ignoreLight; const color: ColorTheme.BuiltIn | undefined = params.theme?.globalName ? params.theme?.globalName : void 0; const ballAndStickColor: ColorTheme.BuiltInParams<'element-symbol'> = params.theme?.carbonColor !== undefined ? { carbonColor: getCarbonColorParams(params.theme?.carbonColor) } diff --git a/src/mol-plugin-state/manager/structure/component.ts b/src/mol-plugin-state/manager/structure/component.ts index f484c679f994f6777bbd1679587ba15ce2705f70..229ece724ee5a43a85473309cbba47870268bfb3 100644 --- a/src/mol-plugin-state/manager/structure/component.ts +++ b/src/mol-plugin-state/manager/structure/component.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * 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> @@ -71,6 +71,7 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone await update.commit(); await this.plugin.state.updateBehavior(StructureFocusRepresentation, p => { p.ignoreHydrogens = !options.showHydrogens; + p.ignoreLight = options.ignoreLight; p.material = options.materialStyle; p.clip = options.clipObjects; }); @@ -79,16 +80,17 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone } private updateReprParams(update: StateBuilder.Root, component: StructureComponentRef) { - const { showHydrogens, visualQuality: quality, materialStyle: material, clipObjects: clip } = this.state.options; + const { showHydrogens, visualQuality: quality, ignoreLight, materialStyle: material, clipObjects: clip } = this.state.options; const ignoreHydrogens = !showHydrogens; for (const r of component.representations) { if (r.cell.transform.transformer !== StructureRepresentation3D) continue; const params = r.cell.transform.params as StateTransformer.Params<StructureRepresentation3D>; - if (!!params.type.params.ignoreHydrogens !== ignoreHydrogens || params.type.params.quality !== quality || !shallowEqual(params.type.params.material, material) || !PD.areEqual(Clip.Params, params.type.params.clip, clip)) { + if (!!params.type.params.ignoreHydrogens !== ignoreHydrogens || params.type.params.quality !== quality || params.type.params.ignoreLight !== ignoreLight || !shallowEqual(params.type.params.material, material) || !PD.areEqual(Clip.Params, params.type.params.clip, clip)) { update.to(r.cell).update(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; }); @@ -309,9 +311,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone addRepresentation(components: ReadonlyArray<StructureComponentRef>, type: string) { if (components.length === 0) return; - const { showHydrogens, visualQuality: quality, materialStyle: material, clipObjects: clip } = this.state.options; + const { showHydrogens, visualQuality: quality, ignoreLight, materialStyle: material, clipObjects: clip } = this.state.options; const ignoreHydrogens = !showHydrogens; - const typeParams = { ignoreHydrogens, quality, material, clip }; + const typeParams = { ignoreHydrogens, quality, ignoreLight, material, clip }; return this.plugin.dataTransaction(async () => { for (const component of components) { @@ -346,9 +348,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone const xs = structures || this.currentStructures; if (xs.length === 0) return; - const { showHydrogens, visualQuality: quality, materialStyle: material, clipObjects: clip } = this.state.options; + const { showHydrogens, visualQuality: quality, ignoreLight, materialStyle: material, clipObjects: clip } = this.state.options; const ignoreHydrogens = !showHydrogens; - const typeParams = { ignoreHydrogens, quality, material, clip }; + const typeParams = { ignoreHydrogens, quality, ignoreLight, material, clip }; const componentKey = UUID.create22(); for (const s of xs) { @@ -458,6 +460,7 @@ namespace StructureComponentManager { export const OptionsParams = { showHydrogens: PD.Boolean(true, { description: 'Toggle display of hydrogen atoms in representations' }), visualQuality: PD.Select('auto', VisualQualityOptions, { description: 'Control the visual/rendering quality of representations' }), + ignoreLight: PD.Boolean(false, { description: 'Ignore light for stylized rendering of representtions' }), materialStyle: Material.getParam(), clipObjects: PD.Group(Clip.Params), interactions: PD.Group(InteractionsProvider.defaultParams, { label: 'Non-covalent Interactions' }), diff --git a/src/mol-plugin/behavior/dynamic/selection/structure-focus-representation.ts b/src/mol-plugin/behavior/dynamic/selection/structure-focus-representation.ts index a2b23346f5059c8ca64364b6c41e1a86f11f1884..97aa8960215c6b847d7915ba9943a7aabeccd030 100644 --- a/src/mol-plugin/behavior/dynamic/selection/structure-focus-representation.ts +++ b/src/mol-plugin/behavior/dynamic/selection/structure-focus-representation.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * 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> @@ -44,6 +44,7 @@ const StructureFocusRepresentationParams = (plugin: PluginContext) => { components: PD.MultiSelect(FocusComponents, PD.arrayToOptions(FocusComponents)), excludeTargetFromSurroundings: PD.Boolean(false, { label: 'Exclude Target', description: 'Exclude the focus "target" from the surroudings component.' }), ignoreHydrogens: PD.Boolean(false), + ignoreLight: PD.Boolean(false), material: Material.getParam(), clip: PD.Group(Clip.Params), }; @@ -68,10 +69,10 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber private getReprParams(reprParams: PD.Values<PD.Params>) { return { - ...this.params.targetParams, + ...reprParams, type: { name: reprParams.type.name, - params: { ...reprParams.type.params, ignoreHydrogens: this.params.ignoreHydrogens, material: this.params.material, clip: this.params.clip } + params: { ...reprParams.type.params, ignoreHydrogens: this.params.ignoreHydrogens, ignoreLight: this.params.ignoreLight, material: this.params.material, clip: this.params.clip } } }; } @@ -114,7 +115,7 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber if (components.indexOf('interactions') >= 0 && !refs[StructureFocusRepresentationTags.SurrNciRepr] && cell.obj && InteractionsRepresentationProvider.isApplicable(cell.obj?.data)) { refs[StructureFocusRepresentationTags.SurrNciRepr] = builder .to(refs[StructureFocusRepresentationTags.SurrSel]!) - .apply(StateTransforms.Representation.StructureRepresentation3D, this.params.nciParams, { tags: StructureFocusRepresentationTags.SurrNciRepr }).ref; + .apply(StateTransforms.Representation.StructureRepresentation3D, this.getReprParams(this.params.nciParams), { tags: StructureFocusRepresentationTags.SurrNciRepr }).ref; } return { state, builder, refs }; @@ -216,7 +217,7 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber hasComponent = components.indexOf('interactions') >= 0; for (const repr of state.select(all.withTag(StructureFocusRepresentationTags.SurrNciRepr))) { if (!hasComponent) builder.delete(repr.transform.ref); - else builder.to(repr).update(this.params.nciParams); + else builder.to(repr).update(this.getReprParams(this.params.nciParams)); } await PluginCommands.State.Update(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });