diff --git a/src/extensions/rcsb/assembly-symmetry/behavior.ts b/src/extensions/rcsb/assembly-symmetry/behavior.ts index bebc5e8688d058ceac415803d1fd22e34cf7d820..37e3ad3a54ed41a2da495be823b340befa6c995a 100644 --- a/src/extensions/rcsb/assembly-symmetry/behavior.ts +++ b/src/extensions/rcsb/assembly-symmetry/behavior.ts @@ -181,8 +181,8 @@ export const AssemblySymmetryPreset = StructureRepresentationPresetProvider({ } const assemblySymmetry = await tryCreateAssemblySymmetry(plugin, structureCell); - const globalThemeName = assemblySymmetry.isOk ? Tag.Cluster as any : undefined; - const preset = await PresetStructureRepresentations.auto.apply(ref, { ...params, globalThemeName }, plugin); + const colorTheme = assemblySymmetry.isOk ? Tag.Cluster as any : undefined; + const preset = await PresetStructureRepresentations.auto.apply(ref, { ...params, globalThemeName: colorTheme, focusThemeName: colorTheme }, plugin); return { components: preset.components, representations: { ...preset.representations, assemblySymmetry } }; } diff --git a/src/extensions/rcsb/validation-report/behavior.ts b/src/extensions/rcsb/validation-report/behavior.ts index 638dadbdf255a13c483fb23e0bb592796ab0a453..c995d197ef6ad04cbca8324e21f201ca195475d3 100644 --- a/src/extensions/rcsb/validation-report/behavior.ts +++ b/src/extensions/rcsb/validation-report/behavior.ts @@ -309,15 +309,15 @@ export const ValidationReportGeometryQualityPreset = StructureRepresentationPres params: () => StructureRepresentationPresetProvider.CommonParams, async apply(ref, params, plugin) { const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref); - const model = structureCell?.obj?.data.model; - if (!structureCell || !model) return {}; + const structure = structureCell?.obj?.data; + if (!structureCell || !structure) return {}; await plugin.runTask(Task.create('Validation Report', async runtime => { - await ValidationReportProvider.attach({ runtime, assetManager: plugin.managers.asset }, model); + await ValidationReportProvider.attach({ runtime, assetManager: plugin.managers.asset }, structure.models[0]); })); const colorTheme = GeometryQualityColorThemeProvider.name as any; - const { components, representations } = await PresetStructureRepresentations.auto.apply(ref, { ...params, globalThemeName: colorTheme }, plugin); + const { components, representations } = await PresetStructureRepresentations.auto.apply(ref, { ...params, globalThemeName: colorTheme, focusThemeName: colorTheme }, plugin); const clashes = await plugin.builders.structure.tryCreateComponentFromExpression(structureCell, hasClash.expression, 'clashes', { label: 'Clashes' }); @@ -329,6 +329,7 @@ export const ValidationReportGeometryQualityPreset = StructureRepresentationPres } await update.commit({ revertOnError: true }); + return { components: { ...components, clashes }, representations: { ...representations, clashesBallAndStick, clashesRepr } }; } }); @@ -345,15 +346,15 @@ export const ValidationReportDensityFitPreset = StructureRepresentationPresetPro params: () => StructureRepresentationPresetProvider.CommonParams, async apply(ref, params, plugin) { const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref); - const model = structureCell?.obj?.data.model; - if (!structureCell || !model) return {}; + const structure = structureCell?.obj?.data; + if (!structureCell || !structure) return {}; await plugin.runTask(Task.create('Validation Report', async runtime => { - await ValidationReportProvider.attach({ runtime, assetManager: plugin.managers.asset }, model); + await ValidationReportProvider.attach({ runtime, assetManager: plugin.managers.asset }, structure.models[0]); })); const colorTheme = DensityFitColorThemeProvider.name as any; - return await PresetStructureRepresentations.auto.apply(ref, { ...params, globalThemeName: colorTheme }, plugin); + return await PresetStructureRepresentations.auto.apply(ref, { ...params, globalThemeName: colorTheme, focusThemeName: colorTheme }, plugin); } }); @@ -369,14 +370,14 @@ export const ValidationReportRandomCoilIndexPreset = StructureRepresentationPres params: () => StructureRepresentationPresetProvider.CommonParams, async apply(ref, params, plugin) { const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref); - const model = structureCell?.obj?.data.model; - if (!structureCell || !model) return {}; + const structure = structureCell?.obj?.data; + if (!structureCell || !structure) return {}; await plugin.runTask(Task.create('Validation Report', async runtime => { - await ValidationReportProvider.attach({ runtime, assetManager: plugin.managers.asset }, model); + await ValidationReportProvider.attach({ runtime, assetManager: plugin.managers.asset }, structure.models[0]); })); const colorTheme = RandomCoilIndexColorThemeProvider.name as any; - return await PresetStructureRepresentations.auto.apply(ref, { ...params, globalThemeName: colorTheme }, plugin); + return await PresetStructureRepresentations.auto.apply(ref, { ...params, globalThemeName: colorTheme, focusThemeName: colorTheme }, plugin); } }); \ No newline at end of file diff --git a/src/mol-plugin-state/builder/structure/representation-preset.ts b/src/mol-plugin-state/builder/structure/representation-preset.ts index 88b2d561afca51f812ce544732f9507ec88da00f..da30873886040156661bbea378e957ac879b719c 100644 --- a/src/mol-plugin-state/builder/structure/representation-preset.ts +++ b/src/mol-plugin-state/builder/structure/representation-preset.ts @@ -16,6 +16,8 @@ import { StateObjectRef, StateObjectSelector } from '../../../mol-state'; import { StaticStructureComponentType } from '../../helpers/structure-component'; import { StructureSelectionQueries as Q } from '../../helpers/structure-selection-query'; import { PluginConfig } from '../../../mol-plugin/config'; +import { StructureFocusRepresentation } from '../../../mol-plugin/behavior/dynamic/selection/structure-focus-representation'; +import { createStructureColorThemeParams } from '../../helpers/structure-representation-params'; export interface StructureRepresentationPresetProvider<P = any, S extends _Result = _Result> extends PresetProvider<PluginStateObject.Molecule.Structure, P, S> { } export function StructureRepresentationPresetProvider<P, S extends _Result>(repr: StructureRepresentationPresetProvider<P, S>) { return repr; } @@ -30,7 +32,8 @@ export namespace StructureRepresentationPresetProvider { export const CommonParams = { ignoreHydrogens: PD.Optional(PD.Boolean(false)), quality: PD.Optional(PD.Select<VisualQuality>('auto', VisualQualityOptions)), - globalThemeName: PD.Optional(PD.Text<ColorTheme.BuiltIn>('')) + globalThemeName: PD.Optional(PD.Text<ColorTheme.BuiltIn>('')), + focusThemeName: PD.Optional(PD.Text<ColorTheme.BuiltIn>('')) }; export type CommonParams = PD.ValuesFor<typeof CommonParams> @@ -47,6 +50,14 @@ export namespace StructureRepresentationPresetProvider { return { update, builder, color, typeParams }; } + + export function updateFocusRepr(plugin: PluginContext, structure: Structure, themeName?: ColorTheme.BuiltIn) { + return plugin.state.updateBehavior(StructureFocusRepresentation, p => { + const c = createStructureColorThemeParams(plugin, structure, 'ball-and-stick', themeName); + p.surroundingsParams.colorTheme = c; + p.targetParams.colorTheme = c; + }); + } } type _Result = StructureRepresentationPresetProvider.Result @@ -54,6 +65,7 @@ type _Result = StructureRepresentationPresetProvider.Result const CommonParams = StructureRepresentationPresetProvider.CommonParams; type CommonParams = StructureRepresentationPresetProvider.CommonParams const reprBuilder = StructureRepresentationPresetProvider.reprBuilder; +const updateFocusRepr = StructureRepresentationPresetProvider.updateFocusRepr; const auto = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-auto', @@ -131,6 +143,7 @@ const polymerAndLigand = StructureRepresentationPresetProvider({ }; await update.commit({ revertOnError: false }); + await updateFocusRepr(plugin, structure, params.focusThemeName); return { components, representations }; } @@ -168,6 +181,8 @@ const proteinAndNucleic = StructureRepresentationPresetProvider({ }; await update.commit({ revertOnError: true }); + await updateFocusRepr(plugin, structure, params.focusThemeName); + return { components, representations }; } }); @@ -215,6 +230,8 @@ const coarseSurface = StructureRepresentationPresetProvider({ }; await update.commit({ revertOnError: true }); + await updateFocusRepr(plugin, structure, params.focusThemeName); + return { components, representations }; } }); @@ -245,6 +262,8 @@ const polymerCartoon = StructureRepresentationPresetProvider({ }; await update.commit({ revertOnError: true }); + await updateFocusRepr(plugin, structure, params.focusThemeName); + return { components, representations }; } }); 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 0e733fc8ff1c71552a54438ae0c10e29c3597943..05115266582d35080ed58d8e51ec2a34529d6f4c 100644 --- a/src/mol-plugin/behavior/dynamic/selection/structure-focus-representation.ts +++ b/src/mol-plugin/behavior/dynamic/selection/structure-focus-representation.ts @@ -29,7 +29,7 @@ const StructureFocusRepresentationParams = (plugin: PluginContext) => { }), surroundingsParams: PD.Group(reprParams, { label: 'Surroundings', - customDefault: createStructureRepresentationParams(plugin, void 0, { type: 'ball-and-stick', color: 'element-symbol', size: 'physical', typeParams: { sizeFactor: 0.16 } }) + customDefault: createStructureRepresentationParams(plugin, void 0, { type: 'ball-and-stick', size: 'physical', typeParams: { sizeFactor: 0.16 } }) }), nciParams: PD.Group(reprParams, { label: 'Non-covalent Int.', @@ -57,7 +57,7 @@ export enum StructureFocusRepresentationTags { const TagSet: Set<StructureFocusRepresentationTags> = new Set([StructureFocusRepresentationTags.TargetSel, StructureFocusRepresentationTags.TargetRepr, StructureFocusRepresentationTags.SurrSel, StructureFocusRepresentationTags.SurrRepr, StructureFocusRepresentationTags.SurrNciRepr]); -export class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscribers<StructureFocusRepresentationProps> { +class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscribers<StructureFocusRepresentationProps> { private get surrLabel() { return `[Focus] Surroundings (${this.params.expandRadius} Å)`; } private ensureShape(cell: StateObjectCell<PluginStateObject.Molecule.Structure>) {