Browse Source

wip, custom property refactoring

Alexander Rose 5 years ago
parent
commit
3d6ae08437

+ 1 - 128
src/mol-model-props/common/custom-property-registry.ts

@@ -2,14 +2,12 @@
  * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
 import { CustomPropertyDescriptor, Model, Structure } from '../../mol-model/structure';
 import { OrderedMap } from 'immutable';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
-import { Task, RuntimeContext } from '../../mol-task';
-import { ValueBox } from '../../mol-util';
+import { Task } from '../../mol-task';
 
 export { CustomPropertyRegistry }
 
@@ -68,128 +66,3 @@ namespace CustomPropertyRegistry {
     export type ModelProvider = Provider<Model>
     export type StructureProvider = Provider<Structure>
 }
-
-type AjaxTask = import('../../mol-util/data-source').AjaxTask
-
-export interface CustomPropertyContext {
-    runtime: RuntimeContext
-    fetch: AjaxTask
-}
-
-export { CustomStructureProperty }
-
-namespace CustomStructureProperty {
-    export interface Provider<Params extends PD.Params, Value> {
-        readonly label: string
-        readonly descriptor: CustomPropertyDescriptor
-        readonly getParams: (data: Structure) => Params
-        readonly isApplicable: (data: Structure) => boolean
-        readonly attach: (ctx: CustomPropertyContext, data: Structure, props?: Partial<PD.Values<Params>>) => Promise<void>
-        readonly get: (data: Structure) => ValueBox<Value | undefined>
-        readonly setProps: (data: Structure, props: PD.Values<Params>) => void
-    }
-
-    export interface ProviderBuilder<Params extends PD.Params, Value> {
-        readonly label: string
-        readonly descriptor: CustomPropertyDescriptor
-        readonly defaultParams: Params
-        readonly getParams: (data: Structure) => Params
-        readonly isApplicable: (data: Structure) => boolean
-        readonly obtain: (ctx: CustomPropertyContext, data: Structure, props: PD.Values<Params>) => Promise<Value>
-        readonly type: 'root' | 'local'
-    }
-
-    export function createProvider<Params extends PD.Params, Value>(builder: ProviderBuilder<Params, Value>): CustomStructureProperty.Provider<Params, Value> {
-        const descriptorName = builder.descriptor.name
-        const propertyDataName = builder.type === 'root' ? 'inheritedPropertyData' : 'currentPropertyData'
-
-        const get = (data: Structure) => {
-            if (!(descriptorName in data[propertyDataName])) {
-                (data[propertyDataName][descriptorName] as CustomStructureProperty.Property<PD.Values<Params>, Value>) = {
-                    props: { ...PD.getDefaultValues(builder.getParams(data)) },
-                    data: ValueBox.create(undefined)
-                }
-            }
-            return data[propertyDataName][descriptorName] as CustomStructureProperty.Property<PD.Values<Params>, Value>;
-        }
-        const set = (data: Structure, props: PD.Values<Params>, value: Value | undefined) => {
-            const property = get(data);
-            (data[propertyDataName][descriptorName] as CustomStructureProperty.Property<PD.Values<Params>, Value>) = {
-                props,
-                data: ValueBox.withValue(property.data, value)
-            };
-        }
-
-        return {
-            label: builder.label,
-            descriptor: builder.descriptor,
-            getParams: builder.getParams,
-            isApplicable: builder.isApplicable,
-            attach: async (ctx: CustomPropertyContext, data: Structure, props: Partial<PD.Values<Params>> = {}) => {
-                if (builder.type === 'root') data = data.root
-                const property = get(data)
-                const p = { ...property.props, ...props }
-                if (property.data.value && PD.areEqual(builder.defaultParams, property.props, p)) return
-                const value = await builder.obtain(ctx, data, p)
-                data.customPropertyDescriptors.add(builder.descriptor);
-                set(data, p, value);
-            },
-            get: (data: Structure) => get(data)?.data,
-            setProps: (data: Structure, props: Partial<PD.Values<Params>> = {}) => {
-                const property = get(data)
-                const p = { ...property.props, ...props }
-                if (!PD.areEqual(builder.defaultParams, property.props, p)) {
-                    // this invalidates property.value
-                    set(data, p, undefined)
-                }
-            }
-        }
-    }
-
-    export interface Property<P, V> {
-        readonly props: P
-        readonly data: ValueBox<V | undefined>
-    }
-
-    export class Registry {
-        private providers = OrderedMap<string, Provider<any, any>>().asMutable()
-        private defaultAutoAttachValues = new Map<string, boolean>()
-
-        /** Get params for all applicable property providers */
-        getParams(data: Structure) {
-            const values = this.providers.values();
-            const params: PD.Params = {}
-            while (true) {
-                const v = values.next()
-                if (v.done) break
-                const provider = v.value
-                if (!provider.isApplicable(data)) continue
-                params[provider.descriptor.name] = PD.Group({
-                    autoAttach: PD.Boolean(this.defaultAutoAttachValues.get(provider.descriptor.name)!),
-                    ...provider.getParams(data),
-                }, { label: v.value.label })
-            }
-            return params
-        }
-
-        setDefaultAutoAttach(name: string, value: boolean) {
-            this.defaultAutoAttachValues.set(name, value)
-        }
-
-        get(name: string) {
-            const prop = this.providers.get(name);
-            if (!prop) throw new Error(`Custom property '${name}' is not registered.`)
-            return this.providers.get(name)
-        }
-
-        register(provider: Provider<any, any>, defaultAutoAttach: boolean) {
-            this.providers.set(provider.descriptor.name, provider)
-            this.defaultAutoAttachValues.set(provider.descriptor.name, defaultAutoAttach)
-        }
-
-        unregister(name: string) {
-            this.providers.delete(name)
-            this.defaultAutoAttachValues.delete(name)
-        }
-    }
-}

+ 79 - 0
src/mol-model-props/common/custom-property.ts

@@ -0,0 +1,79 @@
+/**
+ * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
+import { RuntimeContext } from '../../mol-task';
+import { CustomPropertyDescriptor } from '../../mol-model/structure';
+import { ParamDefinition as PD } from '../../mol-util/param-definition';
+import { ValueBox } from '../../mol-util';
+import { OrderedMap } from 'immutable';
+
+type AjaxTask = import('../../mol-util/data-source').AjaxTask
+
+export { CustomProperty }
+
+namespace CustomProperty {
+    export interface Context {
+        runtime: RuntimeContext
+        fetch: AjaxTask
+    }
+
+    export interface Container<P, V> {
+        readonly props: P
+        readonly data: ValueBox<V | undefined>
+    }
+
+    export interface Provider<Data, Params extends PD.Params, Value> {
+        readonly label: string
+        readonly descriptor: CustomPropertyDescriptor
+        readonly getParams: (data: Data) => Params
+        readonly isApplicable: (data: Data) => boolean
+        readonly attach: (ctx: Context, data: Data, props?: Partial<PD.Values<Params>>) => Promise<void>
+        readonly get: (data: Data) => ValueBox<Value | undefined>
+        readonly setProps: (data: Data, props: PD.Values<Params>) => void
+    }
+
+    export class Registry<Data> {
+        private providers = OrderedMap<string, Provider<Data, any, any>>().asMutable()
+        private defaultAutoAttachValues = new Map<string, boolean>()
+
+        /** Get params for all applicable property providers */
+        getParams(data: Data) {
+            const values = this.providers.values();
+            const params: PD.Params = {}
+            while (true) {
+                const v = values.next()
+                if (v.done) break
+                const provider = v.value
+                if (!provider.isApplicable(data)) continue
+                params[provider.descriptor.name] = PD.Group({
+                    autoAttach: PD.Boolean(this.defaultAutoAttachValues.get(provider.descriptor.name)!),
+                    ...provider.getParams(data),
+                }, { label: v.value.label })
+            }
+            return params
+        }
+
+        setDefaultAutoAttach(name: string, value: boolean) {
+            this.defaultAutoAttachValues.set(name, value)
+        }
+
+        get(name: string) {
+            const prop = this.providers.get(name);
+            if (!prop) throw new Error(`Custom property '${name}' is not registered.`)
+            return this.providers.get(name)
+        }
+
+        register(provider: Provider<Data, any, any>, defaultAutoAttach: boolean) {
+            this.providers.set(provider.descriptor.name, provider)
+            this.defaultAutoAttachValues.set(provider.descriptor.name, defaultAutoAttach)
+        }
+
+        unregister(name: string) {
+            this.providers.delete(name)
+            this.defaultAutoAttachValues.delete(name)
+        }
+    }
+}

+ 74 - 0
src/mol-model-props/common/custom-structure-property.ts

@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
+import { CustomPropertyDescriptor, Structure } from '../../mol-model/structure';
+
+import { ParamDefinition as PD } from '../../mol-util/param-definition';
+import { ValueBox } from '../../mol-util';
+import { CustomProperty } from './custom-property';
+
+export { CustomStructureProperty }
+
+namespace CustomStructureProperty {
+    export interface Provider<Params extends PD.Params, Value> extends CustomProperty.Provider<Structure, Params, Value> { }
+
+    export interface ProviderBuilder<Params extends PD.Params, Value> {
+        readonly label: string
+        readonly descriptor: CustomPropertyDescriptor
+        readonly defaultParams: Params
+        readonly getParams: (data: Structure) => Params
+        readonly isApplicable: (data: Structure) => boolean
+        readonly obtain: (ctx: CustomProperty.Context, data: Structure, props: PD.Values<Params>) => Promise<Value>
+        readonly type: 'root' | 'local'
+    }
+
+    export function createProvider<Params extends PD.Params, Value>(builder: ProviderBuilder<Params, Value>): CustomProperty.Provider<Structure, Params, Value> {
+        const descriptorName = builder.descriptor.name
+        const propertyDataName = builder.type === 'root' ? 'inheritedPropertyData' : 'currentPropertyData'
+
+        const get = (data: Structure) => {
+            if (!(descriptorName in data[propertyDataName])) {
+                (data[propertyDataName][descriptorName] as CustomProperty.Container<PD.Values<Params>, Value>) = {
+                    props: { ...PD.getDefaultValues(builder.getParams(data)) },
+                    data: ValueBox.create(undefined)
+                }
+            }
+            return data[propertyDataName][descriptorName] as CustomProperty.Container<PD.Values<Params>, Value>;
+        }
+        const set = (data: Structure, props: PD.Values<Params>, value: Value | undefined) => {
+            const property = get(data);
+            (data[propertyDataName][descriptorName] as CustomProperty.Container<PD.Values<Params>, Value>) = {
+                props,
+                data: ValueBox.withValue(property.data, value)
+            };
+        }
+
+        return {
+            label: builder.label,
+            descriptor: builder.descriptor,
+            getParams: builder.getParams,
+            isApplicable: builder.isApplicable,
+            attach: async (ctx: CustomProperty.Context, data: Structure, props: Partial<PD.Values<Params>> = {}) => {
+                if (builder.type === 'root') data = data.root
+                const property = get(data)
+                const p = { ...property.props, ...props }
+                if (property.data.value && PD.areEqual(builder.defaultParams, property.props, p)) return
+                const value = await builder.obtain(ctx, data, p)
+                data.customPropertyDescriptors.add(builder.descriptor);
+                set(data, p, value);
+            },
+            get: (data: Structure) => get(data)?.data,
+            setProps: (data: Structure, props: Partial<PD.Values<Params>> = {}) => {
+                const property = get(data)
+                const p = { ...property.props, ...props }
+                if (!PD.areEqual(builder.defaultParams, property.props, p)) {
+                    // this invalidates property.value
+                    set(data, p, undefined)
+                }
+            }
+        }
+    }
+}

+ 3 - 2
src/mol-model-props/computed/accessible-surface-area.ts

@@ -8,7 +8,8 @@
 import { ParamDefinition as PD } from '../../mol-util/param-definition'
 import { ShrakeRupleyComputationParams, AccessibleSurfaceArea } from './accessible-surface-area/shrake-rupley';
 import { Structure, CustomPropertyDescriptor } from '../../mol-model/structure';
-import { CustomStructureProperty, CustomPropertyContext } from '../common/custom-property-registry';
+import { CustomStructureProperty } from '../common/custom-structure-property';
+import { CustomProperty } from '../common/custom-property';
 
 export const AccessibleSurfaceAreaParams = {
     ...ShrakeRupleyComputationParams
@@ -29,7 +30,7 @@ export const AccessibleSurfaceAreaProvider: CustomStructureProperty.Provider<Acc
     defaultParams: AccessibleSurfaceAreaParams,
     getParams: (data: Structure) => AccessibleSurfaceAreaParams,
     isApplicable: (data: Structure) => true,
-    obtain: async (ctx: CustomPropertyContext, data: Structure, props: Partial<AccessibleSurfaceAreaProps>) => {
+    obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<AccessibleSurfaceAreaProps>) => {
         const p = { ...PD.getDefaultValues(AccessibleSurfaceAreaParams), ...props }
         return await AccessibleSurfaceArea.compute(data, p).runInContext(ctx.runtime)
     }

+ 3 - 2
src/mol-model-props/computed/interactions.ts

@@ -7,7 +7,8 @@
 import { CustomPropertyDescriptor, Structure } from '../../mol-model/structure';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { computeInteractions, Interactions, InteractionsParams as _InteractionsParams } from './interactions/interactions';
-import { CustomStructureProperty, CustomPropertyContext } from '../common/custom-property-registry';
+import { CustomStructureProperty } from '../common/custom-structure-property';
+import { CustomProperty } from '../common/custom-property';
 
 export const InteractionsParams = {
     ..._InteractionsParams
@@ -28,7 +29,7 @@ export const InteractionsProvider: CustomStructureProperty.Provider<Interactions
     defaultParams: InteractionsParams,
     getParams: (data: Structure) => InteractionsParams,
     isApplicable: (data: Structure) => true,
-    obtain: async (ctx: CustomPropertyContext, data: Structure, props: Partial<InteractionsProps>) => {
+    obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<InteractionsProps>) => {
         const p = { ...PD.getDefaultValues(InteractionsParams), ...props }
         return await computeInteractions(ctx, data, p)
     }

+ 2 - 2
src/mol-model-props/computed/interactions/interactions.ts

@@ -21,7 +21,7 @@ import { SetUtils } from '../../../mol-util/set';
 import { MetalCoordinationProvider, MetalProvider, MetalBindingProvider } from './metal';
 import { refineInteractions } from './refine';
 import { Result } from '../../../mol-math/geometry';
-import { CustomPropertyContext } from '../../common/custom-property-registry';
+import { CustomProperty } from '../../common/custom-property';
 
 export { Interactions }
 
@@ -148,7 +148,7 @@ export const InteractionsParams = {
 export type InteractionsParams = typeof InteractionsParams
 export type InteractionsProps = PD.Values<InteractionsParams>
 
-export async function computeInteractions(ctx: CustomPropertyContext, structure: Structure, props: Partial<InteractionsProps>): Promise<Interactions> {
+export async function computeInteractions(ctx: CustomProperty.Context, structure: Structure, props: Partial<InteractionsProps>): Promise<Interactions> {
     const p = { ...PD.getDefaultValues(InteractionsParams), ...props }
     await ValenceModelProvider.attach(ctx, structure)
 

+ 3 - 2
src/mol-model-props/computed/secondary-structure.ts

@@ -9,7 +9,8 @@ import { DSSPComputationParams, DSSPComputationProps, computeUnitDSSP } from './
 import { SecondaryStructure } from '../../mol-model/structure/model/properties/seconday-structure';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { Unit } from '../../mol-model/structure/structure';
-import { CustomStructureProperty, CustomPropertyContext } from '../common/custom-property-registry';
+import { CustomStructureProperty } from '../common/custom-structure-property';
+import { CustomProperty } from '../common/custom-property';
 
 function getSecondaryStructureParams(data?: Structure) {
     let defaultType = 'mmcif' as 'mmcif' | 'dssp'
@@ -55,7 +56,7 @@ export const SecondaryStructureProvider: CustomStructureProperty.Provider<Second
     defaultParams: SecondaryStructureParams,
     getParams: getSecondaryStructureParams,
     isApplicable: (data: Structure) => true,
-    obtain: async (ctx: CustomPropertyContext, data: Structure, props: Partial<SecondaryStructureProps>) => {
+    obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<SecondaryStructureProps>) => {
         const p = { ...PD.getDefaultValues(SecondaryStructureParams), ...props }
         switch (p.type.name) {
             case 'dssp': return await computeDssp(data, p.type.params)

+ 3 - 2
src/mol-model-props/computed/valence-model.ts

@@ -7,7 +7,8 @@
 import { CustomPropertyDescriptor, Structure } from '../../mol-model/structure';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { calcValenceModel, ValenceModel, ValenceModelParams as _ValenceModelParams } from './chemistry/valence-model';
-import { CustomStructureProperty, CustomPropertyContext } from '../common/custom-property-registry';
+import { CustomStructureProperty } from '../common/custom-structure-property';
+import { CustomProperty } from '../common/custom-property';
 
 export const ValenceModelParams = {
     ..._ValenceModelParams
@@ -28,7 +29,7 @@ export const ValenceModelProvider: CustomStructureProperty.Provider<ValenceModel
     defaultParams: ValenceModelParams,
     getParams: (data: Structure) => ValenceModelParams,
     isApplicable: (data: Structure) => true,
-    obtain: async (ctx: CustomPropertyContext, data: Structure, props: Partial<ValenceModelProps>) => {
+    obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<ValenceModelProps>) => {
         const p = { ...PD.getDefaultValues(ValenceModelParams), ...props }
         return await calcValenceModel(ctx.runtime, data, p)
     }

+ 4 - 3
src/mol-model-props/rcsb/assembly-symmetry.ts

@@ -11,8 +11,9 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition'
 import { CustomPropertyDescriptor, Structure } from '../../mol-model/structure';
 import { Database as _Database } from '../../mol-data/db'
 import { GraphQLClient } from '../../mol-util/graphql-client';
-import { CustomStructureProperty, CustomPropertyContext } from '../common/custom-property-registry';
+import { CustomProperty } from '../common/custom-property';
 import { NonNullableArray } from '../../mol-util/type-helpers';
+import { CustomStructureProperty } from '../common/custom-structure-property';
 
 export namespace AssemblySymmetry {
     export const DefaultServerUrl = 'http://data-staging.rcsb.org/graphql'
@@ -27,7 +28,7 @@ export namespace AssemblySymmetry {
         )
     }
 
-    export async function fetch(ctx: CustomPropertyContext, structure: Structure, props: AssemblySymmetryProps): Promise<AssemblySymmetryValue> {
+    export async function fetch(ctx: CustomProperty.Context, structure: Structure, props: AssemblySymmetryProps): Promise<AssemblySymmetryValue> {
         const client = new GraphQLClient(props.serverUrl, ctx.fetch)
         const variables: AssemblySymmetryQueryVariables = {
             assembly_id: structure.units[0].conformation.operator.assembly.id,
@@ -80,7 +81,7 @@ export const AssemblySymmetryProvider: CustomStructureProperty.Provider<Assembly
     defaultParams: AssemblySymmetryParams,
     getParams: (data: Structure) => AssemblySymmetryParams,
     isApplicable: (data: Structure) => AssemblySymmetry.isApplicable(data),
-    obtain: async (ctx: CustomPropertyContext, data: Structure, props: Partial<AssemblySymmetryProps>) => {
+    obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<AssemblySymmetryProps>) => {
         const p = { ...PD.getDefaultValues(AssemblySymmetryParams), ...props }
         return await AssemblySymmetry.fetch(ctx, data, p)
     }

+ 2 - 2
src/mol-model-props/rcsb/themes/assembly-symmetry-cluster.ts

@@ -13,7 +13,7 @@ import { Unit, StructureElement, StructureProperties } from '../../../mol-model/
 import { Location } from '../../../mol-model/location';
 import { ScaleLegend, TableLegend } from '../../../mol-util/legend';
 import { getPalette, getPaletteParams } from '../../../mol-util/color/palette';
-import { CustomPropertyContext } from '../../common/custom-property-registry';
+import { CustomProperty } from '../../common/custom-property';
 
 const DefaultColor = Color(0xCCCCCC)
 
@@ -95,7 +95,7 @@ export const AssemblySymmetryClusterColorThemeProvider: ColorTheme.Provider<Asse
     getParams: getAssemblySymmetryClusterColorThemeParams,
     defaultValues: PD.getDefaultValues(AssemblySymmetryClusterColorThemeParams),
     isApplicable: (ctx: ThemeDataContext) => AssemblySymmetry.isApplicable(ctx.structure),
-    ensureCustomProperties: (ctx: CustomPropertyContext, data: ThemeDataContext) => {
+    ensureCustomProperties: (ctx: CustomProperty.Context, data: ThemeDataContext) => {
         return data.structure ? AssemblySymmetryProvider.attach(ctx, data.structure) : Promise.resolve()
     }
 }

+ 4 - 3
src/mol-plugin/context.ts

@@ -7,7 +7,7 @@
 
 import { List } from 'immutable';
 import { Canvas3D } from '../mol-canvas3d/canvas3d';
-import { CustomPropertyRegistry, CustomStructureProperty } from '../mol-model-props/common/custom-property-registry';
+import { CustomPropertyRegistry } from '../mol-model-props/common/custom-property-registry';
 import { StructureRepresentationRegistry } from '../mol-repr/structure/registry';
 import { VolumeRepresentationRegistry } from '../mol-repr/volume/registry';
 import { State, StateTransform, StateTransformer } from '../mol-state';
@@ -35,7 +35,7 @@ import { StructureElementSelectionManager } from './util/structure-element-selec
 import { SubstructureParentHelper } from './util/substructure-parent-helper';
 import { ModifiersKeys } from '../mol-util/input/input-observer';
 import { isProductionMode, isDebugMode } from '../mol-util/debug';
-import { Model } from '../mol-model/structure';
+import { Model, Structure } from '../mol-model/structure';
 import { Interactivity } from './util/interactivity';
 import { StructureRepresentationHelper } from './util/structure-representation-helper';
 import { StructureSelectionHelper } from './util/structure-selection-helper';
@@ -44,6 +44,7 @@ import { PluginToastManager } from './state/toast';
 import { StructureMeasurementManager } from './util/structure-measurement';
 import { ViewportScreenshotHelper } from './util/viewport-screenshot';
 import { StructureRepresentationManager } from './state/representation/structure';
+import { CustomProperty } from '../mol-model-props/common/custom-property';
 
 interface Log {
     entries: List<LogEntry>
@@ -129,7 +130,7 @@ export class PluginContext {
     } as const
 
     readonly customModelProperties = new CustomPropertyRegistry<Model>();
-    readonly customStructureProperties = new CustomStructureProperty.Registry();
+    readonly customStructureProperties = new CustomProperty.Registry<Structure>();
     readonly customParamEditors = new Map<string, StateTransformParameters.Class>();
 
     readonly helpers = {

+ 2 - 2
src/mol-repr/representation.ts

@@ -21,7 +21,7 @@ import { Mat4 } from '../mol-math/linear-algebra';
 import { getQualityProps } from './util';
 import { BaseGeometry } from '../mol-geo/geometry/base';
 import { Visual } from './visual';
-import { CustomPropertyContext } from '../mol-model-props/common/custom-property-registry';
+import { CustomProperty } from '../mol-model-props/common/custom-property';
 
 // export interface RepresentationProps {
 //     visuals?: string[]
@@ -48,7 +48,7 @@ export interface RepresentationProvider<D, P extends PD.Params, S extends Repres
     readonly defaultColorTheme: string
     readonly defaultSizeTheme: string
     readonly isApplicable: (data: D) => boolean
-    readonly ensureCustomProperties?: (ctx: CustomPropertyContext, data: D) => Promise<void>
+    readonly ensureCustomProperties?: (ctx: CustomProperty.Context, data: D) => Promise<void>
 }
 
 export namespace RepresentationProvider {

+ 2 - 2
src/mol-repr/structure/representation/cartoon.ts

@@ -16,7 +16,7 @@ import { PolymerDirectionParams, PolymerDirectionVisual } from '../visual/polyme
 import { PolymerGapParams, PolymerGapVisual } from '../visual/polymer-gap-cylinder';
 import { PolymerTraceParams, PolymerTraceVisual } from '../visual/polymer-trace-mesh';
 import { SecondaryStructureProvider } from '../../../mol-model-props/computed/secondary-structure';
-import { CustomPropertyContext } from '../../../mol-model-props/common/custom-property-registry';
+import { CustomProperty } from '../../../mol-model-props/common/custom-property';
 
 const CartoonVisuals = {
     'polymer-trace': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, PolymerTraceParams>) => UnitsRepresentation('Polymer trace mesh', ctx, getParams, PolymerTraceVisual),
@@ -64,7 +64,7 @@ export const CartoonRepresentationProvider: StructureRepresentationProvider<Cart
     defaultColorTheme: 'polymer-id',
     defaultSizeTheme: 'uniform',
     isApplicable: (structure: Structure) => structure.polymerResidueCount > 0,
-    ensureCustomProperties: (ctx: CustomPropertyContext, structure: Structure) => {
+    ensureCustomProperties: (ctx: CustomProperty.Context, structure: Structure) => {
         return SecondaryStructureProvider.attach(ctx, structure)
     }
 }

+ 2 - 2
src/mol-repr/structure/representation/interactions.ts

@@ -13,7 +13,7 @@ import { InteractionsIntraUnitParams, InteractionsIntraUnitVisual } from '../vis
 import { UnitKindOptions, UnitKind } from '../visual/util/common';
 import { InteractionsProvider } from '../../../mol-model-props/computed/interactions';
 import { InteractionsInterUnitParams, InteractionsInterUnitVisual } from '../visual/interactions-inter-unit-cylinder';
-import { CustomPropertyContext } from '../../../mol-model-props/common/custom-property-registry';
+import { CustomProperty } from '../../../mol-model-props/common/custom-property';
 
 const InteractionsVisuals = {
     'intra-unit': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, InteractionsIntraUnitParams>) => UnitsRepresentation('Intra-unit interactions cylinder', ctx, getParams, InteractionsIntraUnitVisual),
@@ -46,7 +46,7 @@ export const InteractionsRepresentationProvider: StructureRepresentationProvider
     defaultColorTheme: 'interaction-type',
     defaultSizeTheme: 'uniform',
     isApplicable: (structure: Structure) => structure.elementCount > 0,
-    ensureCustomProperties: (ctx: CustomPropertyContext, structure: Structure) => {
+    ensureCustomProperties: (ctx: CustomProperty.Context, structure: Structure) => {
         return InteractionsProvider.attach(ctx, structure)
     }
 }

+ 2 - 2
src/mol-theme/color/accessible-surface-area.ts

@@ -14,7 +14,7 @@ import { Location } from '../../mol-model/location';
 import { AccessibleSurfaceAreaProvider } from '../../mol-model-props/computed/accessible-surface-area';
 import { ColorListName, ColorListOptionsScale } from '../../mol-util/color/lists';
 import { AccessibleSurfaceArea } from '../../mol-model-props/computed/accessible-surface-area/shrake-rupley';
-import { CustomPropertyContext } from '../../mol-model-props/common/custom-property-registry';
+import { CustomProperty } from '../../mol-model-props/common/custom-property';
 
 const DefaultColor = Color(0xFAFAFA)
 const Description = 'Assigns a color based on the relative accessible surface area of a residue.'
@@ -72,7 +72,7 @@ export const AccessibleSurfaceAreaColorThemeProvider: ColorTheme.Provider<Access
     getParams: getAccessibleSurfaceAreaColorThemeParams,
     defaultValues: PD.getDefaultValues(AccessibleSurfaceAreaColorThemeParams),
     isApplicable: (ctx: ThemeDataContext) => !!ctx.structure,
-    ensureCustomProperties: (ctx: CustomPropertyContext, data: ThemeDataContext) => {
+    ensureCustomProperties: (ctx: CustomProperty.Context, data: ThemeDataContext) => {
         return data.structure ? AccessibleSurfaceAreaProvider.attach(ctx, data.structure) : Promise.resolve()
     }
 }

+ 2 - 2
src/mol-theme/color/interaction-type.ts

@@ -13,7 +13,7 @@ import { ColorTheme, LocationColor } from '../color';
 import { InteractionType } from '../../mol-model-props/computed/interactions/common';
 import { TableLegend } from '../../mol-util/legend';
 import { Interactions } from '../../mol-model-props/computed/interactions/interactions';
-import { CustomPropertyContext } from '../../mol-model-props/common/custom-property-registry';
+import { CustomProperty } from '../../mol-model-props/common/custom-property';
 
 const DefaultColor = Color(0xCCCCCC)
 const Description = 'Assigns colors according the interaction type of a link.'
@@ -111,7 +111,7 @@ export const InteractionTypeColorThemeProvider: ColorTheme.Provider<InteractionT
     getParams: getInteractionTypeColorThemeParams,
     defaultValues: PD.getDefaultValues(InteractionTypeColorThemeParams),
     isApplicable: (ctx: ThemeDataContext) => !!ctx.structure,
-    ensureCustomProperties: (ctx: CustomPropertyContext, data: ThemeDataContext) => {
+    ensureCustomProperties: (ctx: CustomProperty.Context, data: ThemeDataContext) => {
         return data.structure ? InteractionsProvider.attach(ctx, data.structure) : Promise.resolve()
     }
 }

+ 2 - 2
src/mol-theme/color/secondary-structure.ts

@@ -15,7 +15,7 @@ import { ThemeDataContext } from '../theme';
 import { TableLegend } from '../../mol-util/legend';
 import { SecondaryStructureProvider, SecondaryStructureValue } from '../../mol-model-props/computed/secondary-structure';
 import { getAdjustedColorMap } from '../../mol-util/color/color';
-import { CustomPropertyContext } from '../../mol-model-props/common/custom-property-registry';
+import { CustomProperty } from '../../mol-model-props/common/custom-property';
 
 // from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)
 const SecondaryStructureColors = ColorMap({
@@ -117,7 +117,7 @@ export const SecondaryStructureColorThemeProvider: ColorTheme.Provider<Secondary
     getParams: getSecondaryStructureColorThemeParams,
     defaultValues: PD.getDefaultValues(SecondaryStructureColorThemeParams),
     isApplicable: (ctx: ThemeDataContext) => !!ctx.structure,
-    ensureCustomProperties: (ctx: CustomPropertyContext, data: ThemeDataContext) => {
+    ensureCustomProperties: (ctx: CustomProperty.Context, data: ThemeDataContext) => {
         return data.structure ? SecondaryStructureProvider.attach(ctx, data.structure) : Promise.resolve()
     }
 }

+ 3 - 3
src/mol-theme/theme.ts

@@ -10,7 +10,7 @@ import { Structure } from '../mol-model/structure';
 import { VolumeData } from '../mol-model/volume';
 import { ParamDefinition as PD } from '../mol-util/param-definition';
 import { Shape } from '../mol-model/shape';
-import { CustomPropertyContext } from '../mol-model-props/common/custom-property-registry';
+import { CustomProperty } from '../mol-model-props/common/custom-property';
 
 export interface ThemeRegistryContext {
     colorThemeRegistry: ColorTheme.Registry
@@ -51,7 +51,7 @@ namespace Theme {
         return { color: ColorTheme.Empty, size: SizeTheme.Empty }
     }
 
-    export async function ensureDependencies(ctx: CustomPropertyContext, theme: ThemeRegistryContext, data: ThemeDataContext, props: Props) {
+    export async function ensureDependencies(ctx: CustomProperty.Context, theme: ThemeRegistryContext, data: ThemeDataContext, props: Props) {
         await theme.colorThemeRegistry.get(props.colorTheme.name).ensureCustomProperties?.(ctx, data)
         await theme.sizeThemeRegistry.get(props.sizeTheme.name).ensureCustomProperties?.(ctx, data)
     }
@@ -65,7 +65,7 @@ export interface ThemeProvider<T extends ColorTheme<P> | SizeTheme<P>, P extends
     readonly getParams: (ctx: ThemeDataContext) => P
     readonly defaultValues: PD.Values<P>
     readonly isApplicable: (ctx: ThemeDataContext) => boolean
-    readonly ensureCustomProperties?: (ctx: CustomPropertyContext, data: ThemeDataContext) => Promise<void>
+    readonly ensureCustomProperties?: (ctx: CustomProperty.Context, data: ThemeDataContext) => Promise<void>
 }
 
 function getTypes(list: { name: string, provider: ThemeProvider<any, any> }[]) {