From ea2b12fb5bc963f89e8fbd4bb3937bd7b2dc0e30 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Thu, 2 May 2019 17:00:54 -0700 Subject: [PATCH] tweaked default color for coarse spheres --- src/mol-plugin/state/actions/data-format.ts | 2 ++ src/mol-plugin/state/actions/structure.ts | 2 +- src/mol-plugin/state/transforms/representation.ts | 7 ++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mol-plugin/state/actions/data-format.ts b/src/mol-plugin/state/actions/data-format.ts index 3cb8a05da..9a0ffd829 100644 --- a/src/mol-plugin/state/actions/data-format.ts +++ b/src/mol-plugin/state/actions/data-format.ts @@ -150,6 +150,8 @@ type cifVariants = 'dscif' | -1 export function guessCifVariant(info: FileInfo, data: Uint8Array | string): cifVariants { if (info.ext === 'bcif') { try { + // TODO find a way to run msgpackDecode only once + // now it is run twice, here and during file parsing if (msgpackDecode(data as Uint8Array).encoder.startsWith('VolumeServer')) return 'dscif' } catch { } } else if (info.ext === 'cif') { diff --git a/src/mol-plugin/state/actions/structure.ts b/src/mol-plugin/state/actions/structure.ts index e8f8bfb09..f9ff6c4a9 100644 --- a/src/mol-plugin/state/actions/structure.ts +++ b/src/mol-plugin/state/actions/structure.ts @@ -228,7 +228,7 @@ export function complexRepresentation( if (!params || !params.hideCoarse) { root.apply(StateTransforms.Model.StructureComplexElement, { type: 'spheres' }) .apply(StateTransforms.Representation.StructureRepresentation3D, - StructureRepresentation3DHelpers.getDefaultParamsStatic(ctx, 'spacefill')); + StructureRepresentation3DHelpers.getDefaultParamsStatic(ctx, 'spacefill', {}, 'polymer-id')); } } diff --git a/src/mol-plugin/state/transforms/representation.ts b/src/mol-plugin/state/transforms/representation.ts index f0873a69e..127a50758 100644 --- a/src/mol-plugin/state/transforms/representation.ts +++ b/src/mol-plugin/state/transforms/representation.ts @@ -108,13 +108,14 @@ namespace StructureRepresentation3DHelpers { }) } - export function getDefaultParamsStatic(ctx: PluginContext, name: BuiltInStructureRepresentationsName, structureParams?: Partial<PD.Values<StructureParams>>): StateTransformer.Params<StructureRepresentation3D> { + export function getDefaultParamsStatic(ctx: PluginContext, name: BuiltInStructureRepresentationsName, structureParams?: Partial<PD.Values<StructureParams>>, colorName?: BuiltInColorThemeName): StateTransformer.Params<StructureRepresentation3D> { const type = ctx.structureRepresentation.registry.get(name); - const colorParams = ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(type.defaultColorTheme).defaultValues; + const color = colorName || type.defaultColorTheme; + const colorParams = ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(color).defaultValues; const sizeParams = ctx.structureRepresentation.themeCtx.sizeThemeRegistry.get(type.defaultSizeTheme).defaultValues return ({ type: { name, params: structureParams ? { ...type.defaultValues, ...structureParams } : type.defaultValues }, - colorTheme: { name: type.defaultColorTheme, params: colorParams }, + colorTheme: { name: color, params: colorParams }, sizeTheme: { name: type.defaultSizeTheme, params: sizeParams } }) } -- GitLab