Skip to content
Snippets Groups Projects
Commit 384f589c authored by David Sehnal's avatar David Sehnal
Browse files

mol-plugin: StructureRepresentation3D default params

parent fc4bcfce
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,23 @@ import { PluginStateObject as SO } from '../objects'; ...@@ -12,7 +12,23 @@ import { PluginStateObject as SO } from '../objects';
import { PluginContext } from 'mol-plugin/context'; import { PluginContext } from 'mol-plugin/context';
import { ParamDefinition as PD } from 'mol-util/param-definition'; import { ParamDefinition as PD } from 'mol-util/param-definition';
import { createTheme } from 'mol-theme/theme'; import { createTheme } from 'mol-theme/theme';
import { BuiltInStructureRepresentationsName } from 'mol-repr/structure/registry';
import { Structure } from 'mol-model/structure';
export namespace StructureRepresentation3DHelpers {
export function getDefaultParams(ctx: PluginContext, name: BuiltInStructureRepresentationsName, structure: Structure): Transformer.Params<StructureRepresentation3D> {
const type = ctx.structureRepresentation.registry.get(name);
const themeDataCtx = { structure };
const colorParams = ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(type.defaultColorTheme).getParams(themeDataCtx);
const sizeParams = ctx.structureRepresentation.themeCtx.sizeThemeRegistry.get(type.defaultSizeTheme).getParams(themeDataCtx)
return ({
type: { name, params: type.defaultValues },
colorTheme: { name: type.defaultColorTheme, params: PD.getDefaultValues(colorParams) },
sizeTheme: { name: type.defaultSizeTheme, params: PD.getDefaultValues(sizeParams) }
})
}
}
export { StructureRepresentation3D } export { StructureRepresentation3D }
type StructureRepresentation3D = typeof StructureRepresentation3D type StructureRepresentation3D = typeof StructureRepresentation3D
const StructureRepresentation3D = PluginStateTransform.BuiltIn({ const StructureRepresentation3D = PluginStateTransform.BuiltIn({
...@@ -20,24 +36,25 @@ const StructureRepresentation3D = PluginStateTransform.BuiltIn({ ...@@ -20,24 +36,25 @@ const StructureRepresentation3D = PluginStateTransform.BuiltIn({
display: '3D Representation', display: '3D Representation',
from: SO.Molecule.Structure, from: SO.Molecule.Structure,
to: SO.Molecule.Representation3D, to: SO.Molecule.Representation3D,
params: (a, ctx: PluginContext) => ({ params: (a, ctx: PluginContext) => {
type: PD.Mapped<any>( const type = ctx.structureRepresentation.registry.get(ctx.structureRepresentation.registry.default.name);
ctx.structureRepresentation.registry.default.name, return ({
ctx.structureRepresentation.registry.types, type: PD.Mapped<any>(
name => PD.Group<any>(ctx.structureRepresentation.registry.get(name).getParams(ctx.structureRepresentation.themeCtx, a.data))), ctx.structureRepresentation.registry.default.name,
colorTheme: PD.Mapped<any>( ctx.structureRepresentation.registry.types,
// TODO how to get a default color theme dependent on the repr type? name => PD.Group<any>(ctx.structureRepresentation.registry.get(name).getParams(ctx.structureRepresentation.themeCtx, a.data))),
ctx.structureRepresentation.themeCtx.colorThemeRegistry.default.name, colorTheme: PD.Mapped<any>(
ctx.structureRepresentation.themeCtx.colorThemeRegistry.types, type.defaultColorTheme,
name => PD.Group<any>(ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(name).getParams({ structure: a.data })) ctx.structureRepresentation.themeCtx.colorThemeRegistry.types,
), name => PD.Group<any>(ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(name).getParams({ structure: a.data }))
sizeTheme: PD.Mapped<any>( ),
// TODO how to get a default size theme dependent on the repr type? sizeTheme: PD.Mapped<any>(
ctx.structureRepresentation.themeCtx.sizeThemeRegistry.default.name, type.defaultSizeTheme,
ctx.structureRepresentation.themeCtx.sizeThemeRegistry.types, ctx.structureRepresentation.themeCtx.sizeThemeRegistry.types,
name => PD.Group<any>(ctx.structureRepresentation.themeCtx.sizeThemeRegistry.get(name).getParams({ structure: a.data })) name => PD.Group<any>(ctx.structureRepresentation.themeCtx.sizeThemeRegistry.get(name).getParams({ structure: a.data }))
) )
}) })
}
})({ })({
canAutoUpdate({ oldParams, newParams }) { canAutoUpdate({ oldParams, newParams }) {
// TODO: allow for small molecules // TODO: allow for small molecules
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment