Просмотр исходного кода

tweaked default color for coarse spheres

Alexander Rose 6 лет назад
Родитель
Сommit
ea2b12fb5b

+ 2 - 0
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') {

+ 1 - 1
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'));
     }
 }
 

+ 4 - 3
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 }
         })
     }