Skip to content
Snippets Groups Projects
Commit b99026bb authored by Alexander Rose's avatar Alexander Rose
Browse files

add ignoreLight to component params

parent 6fa50eb8
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf ...@@ -6,7 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
## [Unreleased] ## [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 ## [v3.0.2] - 2022-01-30
......
...@@ -39,6 +39,7 @@ export namespace StructureRepresentationPresetProvider { ...@@ -39,6 +39,7 @@ export namespace StructureRepresentationPresetProvider {
export const CommonParams = { export const CommonParams = {
ignoreHydrogens: PD.Optional(PD.Boolean(false)), ignoreHydrogens: PD.Optional(PD.Boolean(false)),
ignoreLight: PD.Optional(PD.Boolean(false)),
quality: PD.Optional(PD.Select<VisualQuality>('auto', VisualQualityOptions)), quality: PD.Optional(PD.Select<VisualQuality>('auto', VisualQualityOptions)),
theme: PD.Optional(PD.Group({ theme: PD.Optional(PD.Group({
globalName: PD.Optional(PD.Text<ColorTheme.BuiltIn>('')), globalName: PD.Optional(PD.Text<ColorTheme.BuiltIn>('')),
...@@ -70,9 +71,11 @@ export namespace StructureRepresentationPresetProvider { ...@@ -70,9 +71,11 @@ export namespace StructureRepresentationPresetProvider {
const typeParams = { const typeParams = {
quality: plugin.managers.structure.component.state.options.visualQuality, quality: plugin.managers.structure.component.state.options.visualQuality,
ignoreHydrogens: !plugin.managers.structure.component.state.options.showHydrogens, 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.quality && params.quality !== 'auto') typeParams.quality = params.quality;
if (params.ignoreHydrogens !== void 0) typeParams.ignoreHydrogens = !!params.ignoreHydrogens; 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 color: ColorTheme.BuiltIn | undefined = params.theme?.globalName ? params.theme?.globalName : void 0;
const ballAndStickColor: ColorTheme.BuiltInParams<'element-symbol'> = params.theme?.carbonColor !== undefined const ballAndStickColor: ColorTheme.BuiltInParams<'element-symbol'> = params.theme?.carbonColor !== undefined
? { carbonColor: getCarbonColorParams(params.theme?.carbonColor) } ? { carbonColor: getCarbonColorParams(params.theme?.carbonColor) }
......
/** /**
* 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 David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
...@@ -71,6 +71,7 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone ...@@ -71,6 +71,7 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
await update.commit(); await update.commit();
await this.plugin.state.updateBehavior(StructureFocusRepresentation, p => { await this.plugin.state.updateBehavior(StructureFocusRepresentation, p => {
p.ignoreHydrogens = !options.showHydrogens; p.ignoreHydrogens = !options.showHydrogens;
p.ignoreLight = options.ignoreLight;
p.material = options.materialStyle; p.material = options.materialStyle;
p.clip = options.clipObjects; p.clip = options.clipObjects;
}); });
...@@ -79,16 +80,17 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone ...@@ -79,16 +80,17 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
} }
private updateReprParams(update: StateBuilder.Root, component: StructureComponentRef) { 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; const ignoreHydrogens = !showHydrogens;
for (const r of component.representations) { for (const r of component.representations) {
if (r.cell.transform.transformer !== StructureRepresentation3D) continue; if (r.cell.transform.transformer !== StructureRepresentation3D) continue;
const params = r.cell.transform.params as StateTransformer.Params<StructureRepresentation3D>; 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 => { update.to(r.cell).update(old => {
old.type.params.ignoreHydrogens = ignoreHydrogens; old.type.params.ignoreHydrogens = ignoreHydrogens;
old.type.params.quality = quality; old.type.params.quality = quality;
old.type.params.ignoreLight = ignoreLight;
old.type.params.material = material; old.type.params.material = material;
old.type.params.clip = clip; old.type.params.clip = clip;
}); });
...@@ -309,9 +311,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone ...@@ -309,9 +311,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
addRepresentation(components: ReadonlyArray<StructureComponentRef>, type: string) { addRepresentation(components: ReadonlyArray<StructureComponentRef>, type: string) {
if (components.length === 0) return; 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 ignoreHydrogens = !showHydrogens;
const typeParams = { ignoreHydrogens, quality, material, clip }; const typeParams = { ignoreHydrogens, quality, ignoreLight, material, clip };
return this.plugin.dataTransaction(async () => { return this.plugin.dataTransaction(async () => {
for (const component of components) { for (const component of components) {
...@@ -346,9 +348,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone ...@@ -346,9 +348,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
const xs = structures || this.currentStructures; const xs = structures || this.currentStructures;
if (xs.length === 0) return; 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 ignoreHydrogens = !showHydrogens;
const typeParams = { ignoreHydrogens, quality, material, clip }; const typeParams = { ignoreHydrogens, quality, ignoreLight, material, clip };
const componentKey = UUID.create22(); const componentKey = UUID.create22();
for (const s of xs) { for (const s of xs) {
...@@ -458,6 +460,7 @@ namespace StructureComponentManager { ...@@ -458,6 +460,7 @@ namespace StructureComponentManager {
export const OptionsParams = { export const OptionsParams = {
showHydrogens: PD.Boolean(true, { description: 'Toggle display of hydrogen atoms in representations' }), 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' }), 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(), materialStyle: Material.getParam(),
clipObjects: PD.Group(Clip.Params), clipObjects: PD.Group(Clip.Params),
interactions: PD.Group(InteractionsProvider.defaultParams, { label: 'Non-covalent Interactions' }), interactions: PD.Group(InteractionsProvider.defaultParams, { label: 'Non-covalent Interactions' }),
......
/** /**
* 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 David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
...@@ -44,6 +44,7 @@ const StructureFocusRepresentationParams = (plugin: PluginContext) => { ...@@ -44,6 +44,7 @@ const StructureFocusRepresentationParams = (plugin: PluginContext) => {
components: PD.MultiSelect(FocusComponents, PD.arrayToOptions(FocusComponents)), components: PD.MultiSelect(FocusComponents, PD.arrayToOptions(FocusComponents)),
excludeTargetFromSurroundings: PD.Boolean(false, { label: 'Exclude Target', description: 'Exclude the focus "target" from the surroudings component.' }), excludeTargetFromSurroundings: PD.Boolean(false, { label: 'Exclude Target', description: 'Exclude the focus "target" from the surroudings component.' }),
ignoreHydrogens: PD.Boolean(false), ignoreHydrogens: PD.Boolean(false),
ignoreLight: PD.Boolean(false),
material: Material.getParam(), material: Material.getParam(),
clip: PD.Group(Clip.Params), clip: PD.Group(Clip.Params),
}; };
...@@ -68,10 +69,10 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber ...@@ -68,10 +69,10 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber
private getReprParams(reprParams: PD.Values<PD.Params>) { private getReprParams(reprParams: PD.Values<PD.Params>) {
return { return {
...this.params.targetParams, ...reprParams,
type: { type: {
name: reprParams.type.name, 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 ...@@ -114,7 +115,7 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber
if (components.indexOf('interactions') >= 0 && !refs[StructureFocusRepresentationTags.SurrNciRepr] && cell.obj && InteractionsRepresentationProvider.isApplicable(cell.obj?.data)) { if (components.indexOf('interactions') >= 0 && !refs[StructureFocusRepresentationTags.SurrNciRepr] && cell.obj && InteractionsRepresentationProvider.isApplicable(cell.obj?.data)) {
refs[StructureFocusRepresentationTags.SurrNciRepr] = builder refs[StructureFocusRepresentationTags.SurrNciRepr] = builder
.to(refs[StructureFocusRepresentationTags.SurrSel]!) .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 }; return { state, builder, refs };
...@@ -216,7 +217,7 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber ...@@ -216,7 +217,7 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber
hasComponent = components.indexOf('interactions') >= 0; hasComponent = components.indexOf('interactions') >= 0;
for (const repr of state.select(all.withTag(StructureFocusRepresentationTags.SurrNciRepr))) { for (const repr of state.select(all.withTag(StructureFocusRepresentationTags.SurrNciRepr))) {
if (!hasComponent) builder.delete(repr.transform.ref); 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 } }); await PluginCommands.State.Update(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment