Parcourir la source

added default params to theme providers

Alexander Rose il y a 6 ans
Parent
commit
c025053989

+ 2 - 1
src/mol-plugin/behavior/dynamic/custom-props.ts

@@ -39,7 +39,8 @@ export const PDBeStructureQualityReport = PluginBehavior.create<{ autoAttach: bo
             this.ctx.structureRepresentation.themeCtx.colorThemeRegistry.add('pdbe-structure-quality-report', {
                 label: 'PDBe Structure Quality Report',
                 factory: StructureQualityReportColorTheme,
-                getParams: () => ({})
+                getParams: () => ({}),
+                defaultValues: {}
             })
         }
 

+ 2 - 4
src/mol-plugin/state/transforms/representation.ts

@@ -33,10 +33,8 @@ export namespace StructureRepresentation3DHelpers {
     export function getDefaultParamsStatic(ctx: PluginContext, name: BuiltInStructureRepresentationsName, meshParams?: Partial<PD.Values<UnitsMeshParams>>): Transformer.Params<StructureRepresentation3D> {
         const type = ctx.structureRepresentation.registry.get(name);
 
-        // TODO: there should be "static default properties" for the themes.
-        const themeDataCtx = { };
-        const colorParams = ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(type.defaultColorTheme).getParams(themeDataCtx);
-        const sizeParams = ctx.structureRepresentation.themeCtx.sizeThemeRegistry.get(type.defaultSizeTheme).getParams(themeDataCtx)
+        const colorParams = ctx.structureRepresentation.themeCtx.colorThemeRegistry.get(type.defaultColorTheme).defaultValues;
+        const sizeParams = ctx.structureRepresentation.themeCtx.sizeThemeRegistry.get(type.defaultSizeTheme).defaultValues
         return ({
             type: { name, params: meshParams ? { ...type.defaultValues, ...meshParams } : type.defaultValues },
             colorTheme: { name: type.defaultColorTheme, params: PD.getDefaultValues(colorParams) },

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

@@ -55,8 +55,9 @@ namespace ColorTheme {
         readonly label: string
         readonly factory: (ctx: ThemeDataContext, props: PD.Values<P>) => ColorTheme<P>
         readonly getParams: (ctx: ThemeDataContext) => P
+        readonly defaultValues: PD.Values<P>
     }
-    export const EmptyProvider: Provider<{}> = { label: '', factory: EmptyFactory, getParams: () => ({}) }
+    export const EmptyProvider: Provider<{}> = { label: '', factory: EmptyFactory, getParams: () => ({}), defaultValues: {} }
 
     export class Registry {
         private _list: { name: string, provider: Provider<any> }[] = []

+ 2 - 1
src/mol-theme/color/carbohydrate-symbol.ts

@@ -77,5 +77,6 @@ export function CarbohydrateSymbolColorTheme(ctx: ThemeDataContext, props: PD.Va
 export const CarbohydrateSymbolColorThemeProvider: ColorTheme.Provider<CarbohydrateSymbolColorThemeParams> = {
     label: 'Carbohydrate Symbol',
     factory: CarbohydrateSymbolColorTheme,
-    getParams: getCarbohydrateSymbolColorThemeParams
+    getParams: getCarbohydrateSymbolColorThemeParams,
+    defaultValues: PD.getDefaultValues(CarbohydrateSymbolColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/chain-id.ts

@@ -94,5 +94,6 @@ export function ChainIdColorTheme(ctx: ThemeDataContext, props: PD.Values<ChainI
 export const ChainIdColorThemeProvider: ColorTheme.Provider<ChainIdColorThemeParams> = {
     label: 'Chain Id',
     factory: ChainIdColorTheme,
-    getParams: getChainIdColorThemeParams
+    getParams: getChainIdColorThemeParams,
+    defaultValues: PD.getDefaultValues(ChainIdColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/cross-link.ts

@@ -71,5 +71,6 @@ export function CrossLinkColorTheme(ctx: ThemeDataContext, props: PD.Values<Cros
 export const CrossLinkColorThemeProvider: ColorTheme.Provider<CrossLinkColorThemeParams> = {
     label: 'Cross Link',
     factory: CrossLinkColorTheme,
-    getParams: getCrossLinkColorThemeParams
+    getParams: getCrossLinkColorThemeParams,
+    defaultValues: PD.getDefaultValues(CrossLinkColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/element-index.ts

@@ -71,5 +71,6 @@ export function ElementIndexColorTheme(ctx: ThemeDataContext, props: PD.Values<E
 export const ElementIndexColorThemeProvider: ColorTheme.Provider<ElementIndexColorThemeParams> = {
     label: 'Element Index',
     factory: ElementIndexColorTheme,
-    getParams: getElementIndexColorThemeParams
+    getParams: getElementIndexColorThemeParams,
+    defaultValues: PD.getDefaultValues(ElementIndexColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/element-symbol.ts

@@ -63,5 +63,6 @@ export function ElementSymbolColorTheme(ctx: ThemeDataContext, props: PD.Values<
 export const ElementSymbolColorThemeProvider: ColorTheme.Provider<ElementSymbolColorThemeParams> = {
     label: 'Element Symbol',
     factory: ElementSymbolColorTheme,
-    getParams: getElementSymbolColorThemeParams
+    getParams: getElementSymbolColorThemeParams,
+    defaultValues: PD.getDefaultValues(ElementSymbolColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/molecule-type.ts

@@ -72,5 +72,6 @@ export function MoleculeTypeColorTheme(ctx: ThemeDataContext, props: PD.Values<M
 export const MoleculeTypeColorThemeProvider: ColorTheme.Provider<MoleculeTypeColorThemeParams> = {
     label: 'Molecule Type',
     factory: MoleculeTypeColorTheme,
-    getParams: getMoleculeTypeColorThemeParams
+    getParams: getMoleculeTypeColorThemeParams,
+    defaultValues: PD.getDefaultValues(MoleculeTypeColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/polymer-id.ts

@@ -101,5 +101,6 @@ export function PolymerIdColorTheme(ctx: ThemeDataContext, props: PD.Values<Poly
 export const PolymerIdColorThemeProvider: ColorTheme.Provider<PolymerIdColorThemeParams> = {
     label: 'Polymer Id',
     factory: PolymerIdColorTheme,
-    getParams: getPolymerIdColorThemeParams
+    getParams: getPolymerIdColorThemeParams,
+    defaultValues: PD.getDefaultValues(PolymerIdColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/polymer-index.ts

@@ -69,5 +69,6 @@ export function PolymerIndexColorTheme(ctx: ThemeDataContext, props: PD.Values<P
 export const PolymerIndexColorThemeProvider: ColorTheme.Provider<PolymerIndexColorThemeParams> = {
     label: 'Polymer Index',
     factory: PolymerIndexColorTheme,
-    getParams: getPolymerIndexColorThemeParams
+    getParams: getPolymerIndexColorThemeParams,
+    defaultValues: PD.getDefaultValues(PolymerIndexColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/residue-name.ts

@@ -128,5 +128,6 @@ export function ResidueNameColorTheme(ctx: ThemeDataContext, props: PD.Values<Re
 export const ResidueNameColorThemeProvider: ColorTheme.Provider<ResidueNameColorThemeParams> = {
     label: 'Residue Name',
     factory: ResidueNameColorTheme,
-    getParams: getResidueNameColorThemeParams
+    getParams: getResidueNameColorThemeParams,
+    defaultValues: PD.getDefaultValues(ResidueNameColorThemeParams)
 }

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

@@ -95,5 +95,6 @@ export function SecondaryStructureColorTheme(ctx: ThemeDataContext, props: PD.Va
 export const SecondaryStructureColorThemeProvider: ColorTheme.Provider<SecondaryStructureColorThemeParams> = {
     label: 'Secondary Structure',
     factory: SecondaryStructureColorTheme,
-    getParams: getSecondaryStructureColorThemeParams
+    getParams: getSecondaryStructureColorThemeParams,
+    defaultValues: PD.getDefaultValues(SecondaryStructureColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/sequence-id.ts

@@ -102,5 +102,6 @@ export function SequenceIdColorTheme(ctx: ThemeDataContext, props: PD.Values<Seq
 export const SequenceIdColorThemeProvider: ColorTheme.Provider<SequenceIdColorThemeParams> = {
     label: 'Sequence Id',
     factory: SequenceIdColorTheme,
-    getParams: getSequenceIdColorThemeParams
+    getParams: getSequenceIdColorThemeParams,
+    defaultValues: PD.getDefaultValues(SequenceIdColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/shape-group.ts

@@ -38,5 +38,6 @@ export function ShapeGroupColorTheme(ctx: ThemeDataContext, props: PD.Values<Sha
 export const ShapeGroupColorThemeProvider: ColorTheme.Provider<ShapeGroupColorThemeParams> = {
     label: 'Shape Group',
     factory: ShapeGroupColorTheme,
-    getParams: getShapeGroupColorThemeParams
+    getParams: getShapeGroupColorThemeParams,
+    defaultValues: PD.getDefaultValues(ShapeGroupColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/uniform.ts

@@ -37,5 +37,6 @@ export function UniformColorTheme(ctx: ThemeDataContext, props: PD.Values<Unifor
 export const UniformColorThemeProvider: ColorTheme.Provider<UniformColorThemeParams> = {
     label: 'Uniform',
     factory: UniformColorTheme,
-    getParams: getUniformColorThemeParams
+    getParams: getUniformColorThemeParams,
+    defaultValues: PD.getDefaultValues(UniformColorThemeParams)
 }

+ 2 - 1
src/mol-theme/color/unit-index.ts

@@ -60,5 +60,6 @@ export function UnitIndexColorTheme(ctx: ThemeDataContext, props: PD.Values<Unit
 export const UnitIndexColorThemeProvider: ColorTheme.Provider<UnitIndexColorThemeParams> = {
     label: 'Unit Index',
     factory: UnitIndexColorTheme,
-    getParams: getUnitIndexColorThemeParams
+    getParams: getUnitIndexColorThemeParams,
+    defaultValues: PD.getDefaultValues(UnitIndexColorThemeParams)
 }

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

@@ -33,8 +33,9 @@ namespace SizeTheme {
         readonly label: string
         readonly factory: Factory<P>
         readonly getParams: (ctx: ThemeDataContext) => P
+        readonly defaultValues: PD.Values<P>
     }
-    export const EmptyProvider: Provider<{}> = { label: '', factory: EmptyFactory, getParams: () => ({}) }
+    export const EmptyProvider: Provider<{}> = { label: '', factory: EmptyFactory, getParams: () => ({}), defaultValues: {} }
 
     export class Registry {
         private _list: { name: string, provider: Provider<any> }[] = []

+ 2 - 1
src/mol-theme/size/physical.ts

@@ -59,5 +59,6 @@ export function PhysicalSizeTheme(ctx: ThemeDataContext, props: PD.Values<Physic
 export const PhysicalSizeThemeProvider: SizeTheme.Provider<PhysicalSizeThemeParams> = {
     label: 'Physical',
     factory: PhysicalSizeTheme,
-    getParams: getPhysicalSizeThemeParams
+    getParams: getPhysicalSizeThemeParams,
+    defaultValues: PD.getDefaultValues(PhysicalSizeThemeParams)
 }

+ 2 - 1
src/mol-theme/size/uniform.ts

@@ -33,5 +33,6 @@ export function UniformSizeTheme(ctx: ThemeDataContext, props: PD.Values<Uniform
 export const UniformSizeThemeProvider: SizeTheme.Provider<UniformSizeThemeParams> = {
     label: 'Uniform',
     factory: UniformSizeTheme,
-    getParams: getUniformSizeThemeParams
+    getParams: getUniformSizeThemeParams,
+    defaultValues: PD.getDefaultValues(UniformSizeThemeParams)
 }