Browse Source

represention preset common props

David Sehnal 5 years ago
parent
commit
64b0713742

+ 2 - 2
src/apps/viewer/extensions/cellpack/model.ts

@@ -399,7 +399,7 @@ export const LoadCellPackModel = StateAction.build({
         cellpackTree
             .apply(StateTransforms.Representation.StructureRepresentation3D,
                 StructureRepresentation3DHelpers.createParams(ctx, Structure.Empty, {
-                    repr: getReprParams(ctx, params.preset),
+                    type: getReprParams(ctx, params.preset),
                     color: getColorParams(hue)
                 })
             )
@@ -415,7 +415,7 @@ export const LoadCellPackModel = StateAction.build({
             .apply(StateTransforms.Misc.CreateGroup, { label: 'HIV1_envelope_Membrane' })
             .apply(StateTransforms.Representation.StructureRepresentation3D,
                 StructureRepresentation3DHelpers.createParams(ctx, Structure.Empty, {
-                    repr: getReprParams(ctx, params.preset),
+                    type: getReprParams(ctx, params.preset),
                     color: UniformColorThemeProvider
                 })
             )

+ 2 - 2
src/examples/proteopedia-wrapper/index.ts

@@ -409,7 +409,7 @@ class MolStarProteopediaWrapper {
     private createSurVisualParams() {
         const asm = this.state.select(StateElements.Assembly)[0].obj as PluginStateObject.Molecule.Structure;
         return StructureRepresentation3DHelpers.createParams(this.plugin, asm.data, {
-            repr: BuiltInStructureRepresentations['ball-and-stick'],
+            type: BuiltInStructureRepresentations['ball-and-stick'],
             color: [BuiltInColorThemes.uniform, () => ({ value: ColorNames.gray })],
             size: [BuiltInSizeThemes.uniform, () => ({ value: 0.33 } )]
         });
@@ -418,7 +418,7 @@ class MolStarProteopediaWrapper {
     private createCoreVisualParams() {
         const asm = this.state.select(StateElements.Assembly)[0].obj as PluginStateObject.Molecule.Structure;
         return StructureRepresentation3DHelpers.createParams(this.plugin, asm.data, {
-            repr: BuiltInStructureRepresentations['ball-and-stick'],
+            type: BuiltInStructureRepresentations['ball-and-stick'],
             // color: [BuiltInColorThemes.uniform, () => ({ value: ColorNames.gray })],
             // size: [BuiltInSizeThemes.uniform, () => ({ value: 0.33 } )]
         });

+ 69 - 81
src/mol-plugin-state/builder/structure/preset.ts

@@ -5,45 +5,65 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { StateTransforms } from '../../transforms';
-import { StructureRepresentation3DHelpers } from '../../transforms/representation';
-import { StructureSelectionQueries as Q } from '../../helpers/structure-selection-query';
-import { BuiltInStructureRepresentations } from '../../../mol-repr/structure/registry';
-import { StructureRepresentationProvider, RepresentationProviderTags } from './provider';
+import { VisualQuality, VisualQualityOptions } from '../../../mol-geo/geometry/base';
+import { Structure } from '../../../mol-model/structure';
+import { PluginContext } from '../../../mol-plugin/context';
 import { StateObjectRef } from '../../../mol-state';
-import { PluginStateObject } from '../../objects';
+import { BuiltInColorThemeName } from '../../../mol-theme/color';
+import { ParamDefinition as PD } from '../../../mol-util/param-definition';
 import { StaticStructureComponentType } from '../../helpers/structure-component';
-import { PluginContext } from '../../../mol-plugin/context';
-import { Structure } from '../../../mol-model/structure';
+import { StructureSelectionQueries as Q } from '../../helpers/structure-selection-query';
+import { PluginStateObject } from '../../objects';
+import { RepresentationProviderTags, StructureRepresentationProvider } from './provider';
+
+export const CommonStructureRepresentationParams = {
+    ignoreHydrogens: PD.Optional(PD.Boolean(false)),
+    quality: PD.Optional(PD.Select<VisualQuality>('auto', VisualQualityOptions)),
+    globalThemeName: PD.Optional(PD.Text<BuiltInColorThemeName>(''))
+}
+export type CommonStructureRepresentationParams = PD.ValuesFor<typeof CommonStructureRepresentationParams>
 
 const auto = StructureRepresentationProvider({
     id: 'preset-structure-representation-auto',
     display: { name: 'Automatic', group: 'Preset' },
-    apply(ctx, state, structureCell, _, plugin) {
+    params: () => CommonStructureRepresentationParams,
+    apply(ctx, state, structureCell, params, plugin) {
         const structure = structureCell.obj!.data;
         const size = Structure.getSize(structure)
 
         switch (size) {
             case Structure.Size.Gigantic:
             case Structure.Size.Huge:
-                return coarseSurface.apply(ctx, state, structureCell, void 0, plugin);
+                return coarseSurface.apply(ctx, state, structureCell, params, plugin);
             case Structure.Size.Large:
-                return polymerCartoon.apply(ctx, state, structureCell, void 0, plugin);
+                return polymerCartoon.apply(ctx, state, structureCell, params, plugin);
             case Structure.Size.Medium:
-                return polymerAndLigand.apply(ctx, state, structureCell, void 0, plugin);
+                return polymerAndLigand.apply(ctx, state, structureCell, params, plugin);
             case Structure.Size.Small:
-                return atomicDetail.apply(ctx, state, structureCell, void 0, plugin);
+                return atomicDetail.apply(ctx, state, structureCell, params, plugin);
         }
     }
 });
 
+function reprBuilder(plugin: PluginContext, params: CommonStructureRepresentationParams) {
+    const update = plugin.state.dataState.build();
+    const builder = plugin.builders.structure.representation;
+    const typeParams = {
+        quality: plugin.managers.structure.component.state.options.visualQuality,
+        ignoreHydrogens: !plugin.managers.structure.component.state.options.showHydrogens,
+    };
+    if (params.quality && params.quality !== 'auto') typeParams.quality = params.quality;
+    if (params.ignoreHydrogens !== void 0) typeParams.ignoreHydrogens = !!params.ignoreHydrogens;
+    const color: BuiltInColorThemeName | undefined = params.globalThemeName ? params.globalThemeName : void 0;
+
+    return { update, builder, color, typeParams };
+}
+
 const polymerAndLigand = StructureRepresentationProvider({
     id: 'preset-structure-representation-polymer-and-ligand',
     display: { name: 'Polymer & Ligand', group: 'Preset' },
-    async apply(ctx, state, structureCell, _, plugin) {
-        const structure = structureCell.obj?.data!;
-        const reprTags = [this.id, RepresentationProviderTags.Representation];
-
+    params: () => CommonStructureRepresentationParams,
+    async apply(ctx, state, structureCell, params, plugin) {
         const components = {
             polymer: await presetStaticComponent(plugin, structureCell, 'polymer'),
             ligand: await presetStaticComponent(plugin, structureCell, 'ligand'),
@@ -53,30 +73,20 @@ const polymerAndLigand = StructureRepresentationProvider({
             coarse: await presetStaticComponent(plugin, structureCell, 'coarse')
         };
 
-        const builder = state.build();
+        const { update, builder, typeParams, color } = reprBuilder(plugin, params);
         const representations = {
-            polymer: components.polymer && builder
-                .to(components.polymer)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'cartoon', structure)).selector,
-            ligand: components.ligand && builder
-                .to(components.ligand)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'ball-and-stick', structure)).selector,
-            nonStandard: components.nonStandard && builder
-                .to(components.nonStandard)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParamsWithTheme(plugin, 'ball-and-stick', 'polymer-id', structure, void 0)).selector,
+            polymer: builder.buildInRepresentation(update, components.polymer, { type: 'cartoon', typeParams, color }),
+            ligand: builder.buildInRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams, color }),
+            nonStandard: builder.buildInRepresentation(update, components.nonStandard, { type: 'ball-and-stick', typeParams, color: color || 'polymer-id' }),
             branched: components.branched && {
-                ballAndStick: builder.to(components.branched).applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'ball-and-stick', structure, { alpha: 0.15 })).selector,
-                snfg3d: builder.to(components.branched).applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'carbohydrate', structure)).selector
+                ballAndStick: builder.buildInRepresentation(update, components.branched, { type: 'ball-and-stick', typeParams: { ...typeParams, alpha: 0.15 }, color }),
+                snfg3d: builder.buildInRepresentation(update, components.branched, { type: 'carbohydrate', typeParams, color }),
             },
-            water: components.water && builder
-                .to(components.water)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'ball-and-stick', structure, { alpha: 0.51 })).selector,
-            coarse: components.coarse && builder
-                .to(components.coarse)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParamsWithTheme(plugin, 'spacefill', 'polymer-id', structure, {}))
+            water: builder.buildInRepresentation(update, components.water, { type: 'ball-and-stick', typeParams: { ...typeParams, alpha: 0.51 }, color }),
+            coarse: builder.buildInRepresentation(update, components.coarse, { type: 'spacefill', typeParams, color: color || 'polymer-id' })
         };
 
-        await state.updateTree(builder, { revertOnError: false }).runInContext(ctx);
+        await state.updateTree(update, { revertOnError: false }).runInContext(ctx);
         return { components, representations };
     }
 });
@@ -84,26 +94,20 @@ const polymerAndLigand = StructureRepresentationProvider({
 const proteinAndNucleic = StructureRepresentationProvider({
     id: 'preset-structure-representation-protein-and-nucleic',
     display: { name: 'Protein & Nucleic', group: 'Preset' },
-    async apply(ctx, state, structureCell, _, plugin) {
-        const structure = structureCell.obj!.data;
-        const reprTags = [this.id, RepresentationProviderTags.Representation];
-
+    params: () => CommonStructureRepresentationParams,
+    async apply(ctx, state, structureCell, params, plugin) {
         const components = {
             protein: await presetSelectionComponent(plugin, structureCell, 'protein'),
             nucleic: await presetSelectionComponent(plugin, structureCell, 'nucleic'),
         };
 
-        const builder = state.build();
+        const { update, builder, typeParams, color } = reprBuilder(plugin, params);
         const representations = {
-            protein: components.protein && builder
-                .to(components.protein)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'cartoon', structure)).selector,
-            nucleic: components.nucleic && builder
-                .to(components.nucleic)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'gaussian-surface', structure)).selector,
+            protein: builder.buildInRepresentation(update, components.protein, { type: 'cartoon', typeParams, color }),
+            nucleic: builder.buildInRepresentation(update, components.nucleic, { type: 'gaussian-surface', typeParams, color })
         };
 
-        await state.updateTree(builder, { revertOnError: true }).runInContext(ctx);
+        await state.updateTree(update, { revertOnError: true }).runInContext(ctx);
         return { components, representations };
     }
 });
@@ -111,10 +115,11 @@ const proteinAndNucleic = StructureRepresentationProvider({
 const coarseSurface = StructureRepresentationProvider({
     id: 'preset-structure-representation-coarse-surface',
     display: { name: 'Coarse Surface', group: 'Preset' },
-    async apply(ctx, state, structureCell, _, plugin) {
+    params: () => CommonStructureRepresentationParams,
+    async apply(ctx, state, structureCell, params, plugin) {
         const structure = structureCell.obj!.data;
         const size = Structure.getSize(structure)
-
+        
         const gaussianProps = Object.create(null);
         const components = Object.create(null);
 
@@ -134,23 +139,13 @@ const coarseSurface = StructureRepresentationProvider({
             components.trace = await presetSelectionComponent(plugin, structureCell, 'polymer')
         }
 
-        const params = StructureRepresentation3DHelpers.createParams(plugin, structure, {
-            repr: [
-                BuiltInStructureRepresentations['gaussian-surface'],
-                () => gaussianProps
-            ]
-        });
-
-        const reprTags = [this.id, RepresentationProviderTags.Representation];
-
-        const builder = state.build();
+        
+        const { update, builder, typeParams, color } = reprBuilder(plugin, params);
         const representations = {
-            trace: components.trace && builder
-                .to(components.trace)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, params).selector,
+            trace: builder.buildInRepresentation(update, components.trace, { type: 'gaussian-surface', typeParams: { ...typeParams, ...gaussianProps }, color })
         };
 
-        await state.updateTree(builder, { revertOnError: true }).runInContext(ctx);
+        await state.updateTree(update, { revertOnError: true }).runInContext(ctx);
         return { components, representations };
     }
 });
@@ -158,22 +153,18 @@ const coarseSurface = StructureRepresentationProvider({
 const polymerCartoon = StructureRepresentationProvider({
     id: 'preset-structure-representation-polymer-cartoon',
     display: { name: 'Polymer Cartoon', group: 'Preset' },
-    async apply(ctx, state, structureCell, _, plugin) {
-        const structure = structureCell.obj!.data;
-        const reprTags = [this.id, RepresentationProviderTags.Representation];
-
+    params: () => CommonStructureRepresentationParams,
+    async apply(ctx, state, structureCell, params, plugin) {
         const components = {
             polymer: await presetSelectionComponent(plugin, structureCell, 'polymer'),
         };
 
-        const builder = state.build();
+        const { update, builder, typeParams, color } = reprBuilder(plugin, params);
         const representations = {
-            polymer: components.polymer && builder
-                .to(components.polymer)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'cartoon', structure)).selector,
+            polymer: builder.buildInRepresentation(update, components.polymer, { type: 'cartoon', typeParams, color })
         };
 
-        await state.updateTree(builder, { revertOnError: true }).runInContext(ctx);
+        await state.updateTree(update, { revertOnError: true }).runInContext(ctx);
         return { components, representations };
     }
 });
@@ -181,22 +172,19 @@ const polymerCartoon = StructureRepresentationProvider({
 const atomicDetail = StructureRepresentationProvider({
     id: 'preset-structure-representation-atomic-detail',
     display: { name: 'Atomic Detail', group: 'Preset' },
-    async apply(ctx, state, structureCell, _, plugin) {
-        const structure = structureCell.obj!.data;
-        const reprTags = [this.id, RepresentationProviderTags.Representation];
+    params: () => CommonStructureRepresentationParams,
+    async apply(ctx, state, structureCell, params, plugin) {
 
         const components = {
             all: await presetSelectionComponent(plugin, structureCell, 'all'),
         };
 
-        const builder = state.build();
+        const { update, builder, typeParams, color } = reprBuilder(plugin, params);
         const representations = {
-            all: components.all && builder
-                .to(components.all)
-                .applyOrUpdateTagged(reprTags, StateTransforms.Representation.StructureRepresentation3D, StructureRepresentation3DHelpers.getDefaultParams(plugin, 'ball-and-stick', structure)).selector,
+            all: builder.buildInRepresentation(update, components.all, { type: 'ball-and-stick', typeParams, color })
         };
 
-        await state.updateTree(builder, { revertOnError: true }).runInContext(ctx);
+        await state.updateTree(update, { revertOnError: true }).runInContext(ctx);
         return { components, representations };
     }
 });

+ 2 - 4
src/mol-plugin-state/builder/structure/provider.ts

@@ -15,10 +15,8 @@ export interface StructureRepresentationProvider<P = any, S = {}> {
     id: string,
     display: { name: string, group: string, description?: string },
     isApplicable?(structure: Structure, plugin: PluginContext): boolean,
-    params?(structure: Structure | undefined, plugin: PluginContext): PD.Def<P>,
-    apply(ctx: RuntimeContext, state: State, structure: StateObjectCell<PluginStateObject.Molecule.Structure>, params: P, plugin: PluginContext): Promise<S> | S,
-    // TODO: Custom remove function for more complicated things
-    // remove?(state: State, ref: string, plugin: PluginContext): void
+    params?(structure: Structure | undefined, plugin: PluginContext): PD.For<P>,
+    apply(ctx: RuntimeContext, state: State, structure: StateObjectCell<PluginStateObject.Molecule.Structure>, params: P, plugin: PluginContext): Promise<S> | S
 }
 
 export namespace StructureRepresentationProvider {

+ 20 - 5
src/mol-plugin-state/builder/structure/representation.ts

@@ -6,7 +6,7 @@
 
 import { arrayFind } from '../../../mol-data/util';
 import { Structure } from '../../../mol-model/structure';
-import { StateTransform, StateTree, StateSelection, StateObjectRef } from '../../../mol-state';
+import { StateTransform, StateTree, StateSelection, StateObjectRef, StateBuilder } from '../../../mol-state';
 import { Task } from '../../../mol-task';
 import { isProductionMode } from '../../../mol-util/debug';
 import { objectForEach } from '../../../mol-util/object';
@@ -18,8 +18,9 @@ import { UniqueArray } from '../../../mol-data/generic';
 import { PluginStateObject } from '../../objects';
 import { StructureRepresentation3D, StructureRepresentation3DHelpers } from '../../transforms/representation';
 import { RepresentationProvider } from '../../../mol-repr/representation';
-import { SizeTheme } from '../../../mol-theme/size';
-import { ColorTheme } from '../../../mol-theme/color';
+import { SizeTheme, BuiltInSizeThemeName } from '../../../mol-theme/size';
+import { ColorTheme, BuiltInColorThemeName } from '../../../mol-theme/color';
+import { BuiltInStructureRepresentationsName } from '../../../mol-repr/structure/registry';
 
 export type StructureRepresentationProviderRef = keyof PresetStructureReprentations | StructureRepresentationProvider | string
 
@@ -134,7 +135,7 @@ export class StructureRepresentationBuilder {
         }
 
         const prms = params || (provider.params
-            ? PD.getDefaultValues(provider.params(cell.obj!.data, this.plugin))
+            ? PD.getDefaultValues(provider.params(cell.obj!.data, this.plugin) as PD.Params)
             : {})
 
 
@@ -143,7 +144,7 @@ export class StructureRepresentationBuilder {
     }
 
     async addRepresentation<R extends RepresentationProvider<Structure, any, any>, C extends ColorTheme.Provider<any>, S extends SizeTheme.Provider<any>>
-        (structure: StateObjectRef<PluginStateObject.Molecule.Structure>, props: StructureRepresentation3DHelpers.Props<R, C, S>) {
+        (structure: StateObjectRef<PluginStateObject.Molecule.Structure>, props?: StructureRepresentation3DHelpers.Props<R, C, S>) {
 
         const data = StateObjectRef.resolveAndCheck(this.dataState, structure)?.obj?.data;
         if (!data) return;
@@ -157,6 +158,20 @@ export class StructureRepresentationBuilder {
         return  repr.selector;
     }
 
+    buildInRepresentation<R extends BuiltInStructureRepresentationsName, C extends BuiltInColorThemeName, S extends BuiltInSizeThemeName>
+        (builder: StateBuilder.Root, structure: StateObjectRef<PluginStateObject.Molecule.Structure> | undefined, props?: StructureRepresentation3DHelpers.BuildInProps<R, C, S>) {
+
+        if (!structure) return;
+        const data = StateObjectRef.resolveAndCheck(this.dataState, structure)?.obj?.data;
+        if (!data) return;
+
+        const params = StructureRepresentation3DHelpers.createBuiltInParams(this.plugin, data, props);
+        return builder
+            .to(structure)
+            .apply(StructureRepresentation3D, params, { tags: RepresentationProviderTags.Representation })
+            .selector;
+    }
+
     constructor(public plugin: PluginContext) {
         objectForEach(PresetStructureReprentations, r => this.registerPreset(r));
     }

+ 2 - 2
src/mol-plugin-state/manager/structure/component.ts

@@ -199,7 +199,7 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
 
         for (const component of components) {
             await this.plugin.builders.structure.representation.addRepresentation(component.cell, {
-                repr: [this.plugin.structureRepresentation.registry.get(type), params]
+                type: [this.plugin.structureRepresentation.registry.get(type), params]
             });
         }
     }
@@ -219,7 +219,7 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
                 });
                 if (params.representation === 'none' || !component) continue;
                 await this.plugin.builders.structure.representation.addRepresentation(component, {
-                    repr: this.plugin.structureRepresentation.registry.get(params.representation)
+                    type: this.plugin.structureRepresentation.registry.get(params.representation)
                 });
             }
         });

+ 2 - 2
src/mol-plugin-state/manager/structure/hierarchy.ts

@@ -135,7 +135,7 @@ export class StructureHierarchyManager extends PluginComponent<StructureHierarch
         this.updateState({ current: { trajectories, models, structures }});
         this.behaviors.current.next({ hierarchy, trajectories, models, structures });
     }
-    
+
     remove(refs: HierarchyRef[]) {
         if (refs.length === 0) return;
         const deletes = this.plugin.state.dataState.build();
@@ -153,7 +153,7 @@ export class StructureHierarchyManager extends PluginComponent<StructureHierarch
             for (let i = 0; i < tr.length; i++) {
                 const model = await this.plugin.builders.structure.createModel(trajectory.cell, { modelIndex: i });
                 const structure = await this.plugin.builders.structure.createStructure(model, { name: 'deposited', params: { } });
-                await this.plugin.builders.structure.representation.structurePreset(structure, 'auto');
+                await this.plugin.builders.structure.representation.structurePreset(structure, 'auto', { globalThemeName: 'model-index' });
             }
         })
     }

+ 37 - 8
src/mol-plugin-state/transforms/representation.ts

@@ -9,14 +9,14 @@ import { Structure, StructureElement } from '../../mol-model/structure';
 import { VolumeData, VolumeIsoValue } from '../../mol-model/volume';
 import { PluginContext } from '../../mol-plugin/context';
 import { RepresentationProvider } from '../../mol-repr/representation';
-import { BuiltInStructureRepresentationsName } from '../../mol-repr/structure/registry';
+import { BuiltInStructureRepresentationsName, BuiltInStructureRepresentations } from '../../mol-repr/structure/registry';
 import { StructureParams } from '../../mol-repr/structure/representation';
 import { BuiltInVolumeRepresentationsName } from '../../mol-repr/volume/registry';
 import { VolumeParams } from '../../mol-repr/volume/representation';
 import { StateTransformer, StateObject } from '../../mol-state';
 import { Task } from '../../mol-task';
-import { BuiltInColorThemeName, ColorTheme } from '../../mol-theme/color';
-import { BuiltInSizeThemeName, SizeTheme } from '../../mol-theme/size';
+import { BuiltInColorThemeName, BuiltInColorThemes, ColorTheme } from '../../mol-theme/color';
+import { BuiltInSizeThemeName, BuiltInSizeThemes, SizeTheme } from '../../mol-theme/size';
 import { Theme, ThemeRegistryContext } from '../../mol-theme/theme';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { PluginStateObject as SO, PluginStateTransform } from '../objects';
@@ -63,24 +63,53 @@ namespace StructureRepresentation3DHelpers {
         })
     }
 
+
+    export type BuildInProps<R extends BuiltInStructureRepresentationsName, C extends BuiltInColorThemeName, S extends BuiltInSizeThemeName> = {
+        type?: R,
+        typeParams?: Partial<RepresentationProvider.ParamValues<BuiltInStructureRepresentations[R]>>,
+        color?: C,
+        colorParams?: Partial<ColorTheme.ParamValues<BuiltInColorThemes[C]>>,
+        size?: S,
+        sizeParams?: Partial<SizeTheme.ParamValues<BuiltInSizeThemes[S]>>
+    }
+
     export type Props<R extends RepresentationProvider<Structure, any, any> = any, C extends ColorTheme.Provider<any> = any, S extends SizeTheme.Provider<any> = any> = {
-        repr?: R | [R, (r: R, ctx: ThemeRegistryContext, s: Structure) => Partial<RepresentationProvider.ParamValues<R>>],
+        type?: R | [R, (r: R, ctx: ThemeRegistryContext, s: Structure) => Partial<RepresentationProvider.ParamValues<R>>],
         color?: C | [C, (c: C, ctx: ThemeRegistryContext) => Partial<ColorTheme.ParamValues<C>>],
         size?: S | [S, (c: S, ctx: ThemeRegistryContext) => Partial<SizeTheme.ParamValues<S>>]
     }
 
+    export function createBuiltInParams<R extends BuiltInStructureRepresentationsName, C extends BuiltInColorThemeName, S extends BuiltInSizeThemeName>(
+        ctx: PluginContext, structure: Structure, props: BuildInProps<R, C, S> = {}
+    ) {
+        const type = (props.type && ctx.structureRepresentation.registry.get(props.type))
+            || ctx.structureRepresentation.registry.default.provider;
+        const color = (props.color && ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(props.color)) 
+            || ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(type.defaultColorTheme.name);
+        const size = (props.size && ctx.structureRepresentation.themeCtx.sizeThemeRegistry.get(props.size))
+            || ctx.structureRepresentation.themeCtx.sizeThemeRegistry.get(type.defaultSizeTheme.name);
+
+        const ps: Props = {
+            type: props.typeParams ? [type, () => props.typeParams] : type,
+            color: props.colorParams ? [color, () => props.colorParams] : color,
+            size: props.sizeParams ? [size, () => props.sizeParams] : size
+        };
+
+        return createParams(ctx, structure, ps);
+    }
+
     export function createParams<R extends RepresentationProvider<Structure, any, any>, C extends ColorTheme.Provider<any>, S extends SizeTheme.Provider<any>>(
         ctx: PluginContext, structure: Structure, props: Props<R, C, S> = {}): StateTransformer.Params<StructureRepresentation3D> {
 
         const { themeCtx } = ctx.structureRepresentation
         const themeDataCtx = { structure }
 
-        const repr = props.repr
-            ? props.repr instanceof Array ? props.repr[0] : props.repr
+        const repr = props.type
+            ? props.type instanceof Array ? props.type[0] : props.type
             : ctx.structureRepresentation.registry.default.provider;
         const reprDefaultParams = PD.getDefaultValues(repr.getParams(themeCtx, structure));
-        const reprParams = props.repr instanceof Array
-            ? { ...reprDefaultParams, ...props.repr[1](repr as R, themeCtx, structure) }
+        const reprParams = props.type instanceof Array
+            ? { ...reprDefaultParams, ...props.type[1](repr as R, themeCtx, structure) }
             : reprDefaultParams;
 
         const color = props.color

+ 3 - 3
src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts

@@ -49,14 +49,14 @@ const TagSet: Set<StructureRepresentationInteractionTags> = new Set([StructureRe
 export class StructureRepresentationInteractionBehavior extends PluginBehavior.WithSubscribers<StructureRepresentationInteractionProps> {
     private createResVisualParams(s: Structure) {
         return StructureRepresentation3DHelpers.createParams(this.plugin, s, {
-            repr: [BuiltInStructureRepresentations['ball-and-stick'], () => ({ })],
+            type: [BuiltInStructureRepresentations['ball-and-stick'], () => ({ })],
             size: [BuiltInSizeThemes.uniform, () => ({ })]
         });
     }
 
     private createSurVisualParams(s: Structure) {
         return StructureRepresentation3DHelpers.createParams(this.plugin, s, {
-            repr: [BuiltInStructureRepresentations['ball-and-stick'], () => ({ })],
+            type: [BuiltInStructureRepresentations['ball-and-stick'], () => ({ })],
             color: [BuiltInColorThemes['element-symbol'], () => ({ })],
             size: [BuiltInSizeThemes.uniform, () => ({ })]
         });
@@ -64,7 +64,7 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W
 
     private createSurNciVisualParams(s: Structure) {
         return StructureRepresentation3DHelpers.createParams(this.plugin, s, {
-            repr: [InteractionsRepresentationProvider, () => ({ })],
+            type: [InteractionsRepresentationProvider, () => ({ })],
             color: [InteractionTypeColorThemeProvider, () => ({ })],
             size: [BuiltInSizeThemes.uniform, () => ({ })]
         });

+ 1 - 0
src/mol-repr/structure/registry.ts

@@ -43,6 +43,7 @@ export const BuiltInStructureRepresentations = {
     'putty': PuttyRepresentationProvider,
     'spacefill': SpacefillRepresentationProvider,
 }
+export type BuiltInStructureRepresentations = typeof BuiltInStructureRepresentations
 export type BuiltInStructureRepresentationsName = keyof typeof BuiltInStructureRepresentations
 export const BuiltInStructureRepresentationsNames = Object.keys(BuiltInStructureRepresentations)
 export const BuiltInStructureRepresentationsOptions = BuiltInStructureRepresentationsNames.map(n => [n, n] as [BuiltInStructureRepresentationsName, string])

+ 1 - 0
src/mol-theme/color.ts

@@ -104,4 +104,5 @@ export const BuiltInColorThemes = {
     'unit-index': UnitIndexColorThemeProvider,
     'uniform': UniformColorThemeProvider,
 }
+export type BuiltInColorThemes = typeof BuiltInColorThemes
 export type BuiltInColorThemeName = keyof typeof BuiltInColorThemes

+ 1 - 0
src/mol-theme/size.ts

@@ -48,4 +48,5 @@ export const BuiltInSizeThemes = {
     'uncertainty': UncertaintySizeThemeProvider,
     'uniform': UniformSizeThemeProvider
 }
+export type BuiltInSizeThemes = typeof BuiltInSizeThemes
 export type BuiltInSizeThemeName = keyof typeof BuiltInSizeThemes