From c025053989ca42ea8a8a1529915aef15cd9abb0f Mon Sep 17 00:00:00 2001
From: Alexander Rose <alex.rose@rcsb.org>
Date: Tue, 27 Nov 2018 14:29:15 -0800
Subject: [PATCH] added default params to theme providers

---
 src/mol-plugin/behavior/dynamic/custom-props.ts   | 3 ++-
 src/mol-plugin/state/transforms/representation.ts | 6 ++----
 src/mol-theme/color.ts                            | 3 ++-
 src/mol-theme/color/carbohydrate-symbol.ts        | 3 ++-
 src/mol-theme/color/chain-id.ts                   | 3 ++-
 src/mol-theme/color/cross-link.ts                 | 3 ++-
 src/mol-theme/color/element-index.ts              | 3 ++-
 src/mol-theme/color/element-symbol.ts             | 3 ++-
 src/mol-theme/color/molecule-type.ts              | 3 ++-
 src/mol-theme/color/polymer-id.ts                 | 3 ++-
 src/mol-theme/color/polymer-index.ts              | 3 ++-
 src/mol-theme/color/residue-name.ts               | 3 ++-
 src/mol-theme/color/secondary-structure.ts        | 3 ++-
 src/mol-theme/color/sequence-id.ts                | 3 ++-
 src/mol-theme/color/shape-group.ts                | 3 ++-
 src/mol-theme/color/uniform.ts                    | 3 ++-
 src/mol-theme/color/unit-index.ts                 | 3 ++-
 src/mol-theme/size.ts                             | 3 ++-
 src/mol-theme/size/physical.ts                    | 3 ++-
 src/mol-theme/size/uniform.ts                     | 3 ++-
 20 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/src/mol-plugin/behavior/dynamic/custom-props.ts b/src/mol-plugin/behavior/dynamic/custom-props.ts
index 3b4c6f941..0c4680938 100644
--- a/src/mol-plugin/behavior/dynamic/custom-props.ts
+++ b/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: {}
             })
         }
 
diff --git a/src/mol-plugin/state/transforms/representation.ts b/src/mol-plugin/state/transforms/representation.ts
index 64c66e6c2..5ea400ae8 100644
--- a/src/mol-plugin/state/transforms/representation.ts
+++ b/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) },
diff --git a/src/mol-theme/color.ts b/src/mol-theme/color.ts
index e01bf5a66..32f98d654 100644
--- a/src/mol-theme/color.ts
+++ b/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> }[] = []
diff --git a/src/mol-theme/color/carbohydrate-symbol.ts b/src/mol-theme/color/carbohydrate-symbol.ts
index 237dc5caa..550c8f35d 100644
--- a/src/mol-theme/color/carbohydrate-symbol.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/chain-id.ts b/src/mol-theme/color/chain-id.ts
index f8c6065f6..eb37bf31c 100644
--- a/src/mol-theme/color/chain-id.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/cross-link.ts b/src/mol-theme/color/cross-link.ts
index 4c43e030a..bfe6cc0ac 100644
--- a/src/mol-theme/color/cross-link.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/element-index.ts b/src/mol-theme/color/element-index.ts
index 5605cde9a..c650f6c99 100644
--- a/src/mol-theme/color/element-index.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/element-symbol.ts b/src/mol-theme/color/element-symbol.ts
index 5ac58ef68..bc15c9f23 100644
--- a/src/mol-theme/color/element-symbol.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/molecule-type.ts b/src/mol-theme/color/molecule-type.ts
index e4bc92b93..b91c557af 100644
--- a/src/mol-theme/color/molecule-type.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/polymer-id.ts b/src/mol-theme/color/polymer-id.ts
index 8ef2a42b8..41b92030a 100644
--- a/src/mol-theme/color/polymer-id.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/polymer-index.ts b/src/mol-theme/color/polymer-index.ts
index 53ac66630..a51257fc8 100644
--- a/src/mol-theme/color/polymer-index.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/residue-name.ts b/src/mol-theme/color/residue-name.ts
index 9f4b8efc6..682ae8a4b 100644
--- a/src/mol-theme/color/residue-name.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/secondary-structure.ts b/src/mol-theme/color/secondary-structure.ts
index 3deb17a21..6f2d094fe 100644
--- a/src/mol-theme/color/secondary-structure.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/sequence-id.ts b/src/mol-theme/color/sequence-id.ts
index 96bf25a23..cb8e49ffa 100644
--- a/src/mol-theme/color/sequence-id.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/shape-group.ts b/src/mol-theme/color/shape-group.ts
index 052cd6d1f..b6cbba700 100644
--- a/src/mol-theme/color/shape-group.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/uniform.ts b/src/mol-theme/color/uniform.ts
index 3908ac4e8..8c702a998 100644
--- a/src/mol-theme/color/uniform.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/color/unit-index.ts b/src/mol-theme/color/unit-index.ts
index fa179d1bb..4f9d14883 100644
--- a/src/mol-theme/color/unit-index.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/size.ts b/src/mol-theme/size.ts
index fe5a3a352..6433b60f3 100644
--- a/src/mol-theme/size.ts
+++ b/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> }[] = []
diff --git a/src/mol-theme/size/physical.ts b/src/mol-theme/size/physical.ts
index 43da29365..b856912c4 100644
--- a/src/mol-theme/size/physical.ts
+++ b/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)
 }
\ No newline at end of file
diff --git a/src/mol-theme/size/uniform.ts b/src/mol-theme/size/uniform.ts
index c60239110..3d91d0c35 100644
--- a/src/mol-theme/size/uniform.ts
+++ b/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)
 }
\ No newline at end of file
-- 
GitLab