From 1eb9d0ed5c3786229ca400e74e7f70743824cec1 Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Tue, 6 Nov 2018 13:42:22 +0100 Subject: [PATCH] wip: param refactroing --- src/mol-app/component/parameter/boolean.tsx | 2 +- .../component/parameter/multi-select.tsx | 2 +- src/mol-app/component/parameter/number.tsx | 2 +- src/mol-app/component/parameter/range.tsx | 2 +- src/mol-app/component/parameter/select.tsx | 2 +- src/mol-app/component/parameter/text.tsx | 2 +- src/mol-app/component/parameters.tsx | 2 +- .../geometry/direct-volume/direct-volume.ts | 10 ++-- src/mol-geo/geometry/geometry.ts | 18 +++--- src/mol-geo/geometry/lines/lines.ts | 10 ++-- src/mol-geo/geometry/mesh/mesh.ts | 8 +-- src/mol-geo/geometry/points/points.ts | 14 ++--- .../structure/unit/gaussian-density.ts | 12 ++-- src/mol-repr/index.ts | 2 +- src/mol-repr/shape/index.ts | 4 +- src/mol-repr/structure/complex-visual.ts | 8 +-- src/mol-repr/structure/index.ts | 14 ++--- .../structure/representation/backbone.ts | 2 +- .../representation/ball-and-stick.ts | 10 ++-- .../structure/representation/carbohydrate.ts | 8 +-- .../structure/representation/cartoon.ts | 6 +- .../representation/distance-restraint.ts | 6 +- .../representation/molecular-surface.ts | 4 +- .../structure/representation/point.ts | 2 +- .../structure/representation/spacefill.ts | 2 +- src/mol-repr/structure/units-visual.ts | 12 ++-- .../visual/carbohydrate-link-cylinder.ts | 8 +-- .../visual/carbohydrate-symbol-mesh.ts | 8 +-- .../visual/cross-link-restraint-cylinder.ts | 6 +- .../structure/visual/element-point.ts | 8 +-- .../structure/visual/element-sphere.ts | 10 ++-- .../visual/gaussian-density-point.ts | 8 +-- .../visual/gaussian-density-volume.ts | 2 +- .../structure/visual/gaussian-surface-mesh.ts | 2 +- .../visual/gaussian-surface-wireframe.ts | 8 +-- .../visual/inter-unit-link-cylinder.ts | 8 +-- .../visual/intra-unit-link-cylinder.ts | 8 +-- .../structure/visual/nucleotide-block-mesh.ts | 2 +- .../visual/polymer-backbone-cylinder.ts | 10 ++-- .../visual/polymer-direction-wedge.ts | 8 +-- .../structure/visual/polymer-gap-cylinder.ts | 20 +++---- .../structure/visual/polymer-trace-mesh.ts | 18 +++--- src/mol-repr/structure/visual/util/link.ts | 16 +++--- src/mol-repr/volume/direct-volume.ts | 2 +- src/mol-repr/volume/index.ts | 6 +- src/mol-repr/volume/isosurface-mesh.ts | 6 +- src/mol-state/transformer.ts | 2 +- src/mol-util/param-definition.ts | 56 +++++++++---------- 48 files changed, 194 insertions(+), 194 deletions(-) diff --git a/src/mol-app/component/parameter/boolean.tsx b/src/mol-app/component/parameter/boolean.tsx index 70c5c76df..11f4f0bd1 100644 --- a/src/mol-app/component/parameter/boolean.tsx +++ b/src/mol-app/component/parameter/boolean.tsx @@ -8,7 +8,7 @@ import * as React from 'react' import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface BooleanParamComponentProps { - param: PD.BooleanParam + param: PD.Boolean value: boolean onChange(v: boolean): void } diff --git a/src/mol-app/component/parameter/multi-select.tsx b/src/mol-app/component/parameter/multi-select.tsx index d399f4f84..26b3a767c 100644 --- a/src/mol-app/component/parameter/multi-select.tsx +++ b/src/mol-app/component/parameter/multi-select.tsx @@ -8,7 +8,7 @@ import * as React from 'react' import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface MultiSelectParamComponentProps<T extends string> { - param: PD.MultiSelectParam<T> + param: PD.MultiSelect<T> value: T[] onChange(v: T[]): void } diff --git a/src/mol-app/component/parameter/number.tsx b/src/mol-app/component/parameter/number.tsx index cbf766ec9..fee73d651 100644 --- a/src/mol-app/component/parameter/number.tsx +++ b/src/mol-app/component/parameter/number.tsx @@ -8,7 +8,7 @@ import * as React from 'react' import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface NumberParamComponentProps { - param: PD.NumberParam + param: PD.Numeric value: number onChange(v: number): void } diff --git a/src/mol-app/component/parameter/range.tsx b/src/mol-app/component/parameter/range.tsx index 7fe8d6d7f..45b9cf639 100644 --- a/src/mol-app/component/parameter/range.tsx +++ b/src/mol-app/component/parameter/range.tsx @@ -8,7 +8,7 @@ import * as React from 'react' import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface RangeParamComponentProps { - param: PD.RangeParam + param: PD.Range value: number onChange(v: number): void } diff --git a/src/mol-app/component/parameter/select.tsx b/src/mol-app/component/parameter/select.tsx index 45374f177..0af63a6c4 100644 --- a/src/mol-app/component/parameter/select.tsx +++ b/src/mol-app/component/parameter/select.tsx @@ -8,7 +8,7 @@ import * as React from 'react' import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface SelectParamComponentProps<T extends string> { - param: PD.SelectParam<T> + param: PD.Select<T> value: T onChange(v: T): void } diff --git a/src/mol-app/component/parameter/text.tsx b/src/mol-app/component/parameter/text.tsx index d902e09bd..aa00d7cb1 100644 --- a/src/mol-app/component/parameter/text.tsx +++ b/src/mol-app/component/parameter/text.tsx @@ -8,7 +8,7 @@ import * as React from 'react' import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface TextParamComponentProps { - param: PD.TextParam + param: PD.Text value: string onChange(v: string): void } diff --git a/src/mol-app/component/parameters.tsx b/src/mol-app/component/parameters.tsx index 88b68e910..5c1748b7c 100644 --- a/src/mol-app/component/parameters.tsx +++ b/src/mol-app/component/parameters.tsx @@ -21,7 +21,7 @@ interface ParametersProps<P extends PD.Params> { type ParametersState = {} -function getParamComponent<P extends PD.Param>(p: PD.Param, value: P['defaultValue'], onChange: (v: P['defaultValue']) => void) { +function getParamComponent<P extends PD.Any>(p: PD.Any, value: P['defaultValue'], onChange: (v: P['defaultValue']) => void) { switch (p.type) { case 'boolean': return <BooleanParamComponent param={p} value={value} onChange={onChange} /> diff --git a/src/mol-geo/geometry/direct-volume/direct-volume.ts b/src/mol-geo/geometry/direct-volume/direct-volume.ts index e50fd86a1..1022a453f 100644 --- a/src/mol-geo/geometry/direct-volume/direct-volume.ts +++ b/src/mol-geo/geometry/direct-volume/direct-volume.ts @@ -67,12 +67,12 @@ export namespace DirectVolume { export const Params = { ...Geometry.Params, - isoValueAbsolute: PD.RangeParam('Iso Value Absolute', '', 0.22, -1, 1, 0.01), - isoValueRelative: PD.RangeParam('Iso Value Relative', '', 2, -10, 10, 0.1), - renderMode: PD.SelectParam('Render Mode', '', 'isosurface', RenderModeOptions), - controlPoints: PD.TextParam('Control Points', '', '0.19:0.1, 0.2:0.5, 0.21:0.1, 0.4:0.3'), + isoValueAbsolute: PD.Range('Iso Value Absolute', '', 0.22, -1, 1, 0.01), + isoValueRelative: PD.Range('Iso Value Relative', '', 2, -10, 10, 0.1), + renderMode: PD.Select('Render Mode', '', 'isosurface', RenderModeOptions), + controlPoints: PD.Text('Control Points', '', '0.19:0.1, 0.2:0.5, 0.21:0.1, 0.4:0.3'), } - export const DefaultProps = PD.paramDefaultValues(Params) + export const DefaultProps = PD.getDefaultValues(Params) export type Props = typeof DefaultProps export async function createValues(ctx: RuntimeContext, directVolume: DirectVolume, transform: TransformData, locationIt: LocationIterator, props: Props): Promise<DirectVolumeValues> { diff --git a/src/mol-geo/geometry/geometry.ts b/src/mol-geo/geometry/geometry.ts index 72b6be162..e9c453d14 100644 --- a/src/mol-geo/geometry/geometry.ts +++ b/src/mol-geo/geometry/geometry.ts @@ -59,16 +59,16 @@ export namespace Geometry { // export const Params = { - alpha: PD.RangeParam('Opacity', '', 1, 0, 1, 0.01), - visible: PD.BooleanParam('Visible', '', true), - depthMask: PD.BooleanParam('Depth Mask', '', true), - useFog: PD.BooleanParam('Use Fog', '', false), - quality: PD.SelectParam<VisualQuality>('Quality', '', 'auto', VisualQualityOptions), - colorTheme: PD.SelectParam<ColorThemeName>('Color Theme', '', 'uniform', ColorThemeOptions), - colorList: PD.SelectParam<ColorScaleName>('Color Scale', '', 'default', ColorScaleOptions), - colorValue: PD.ColorParam('Color Value', '', Color(0xCCCCCC)), + alpha: PD.Range('Opacity', '', 1, 0, 1, 0.01), + visible: PD.Boolean('Visible', '', true), + depthMask: PD.Boolean('Depth Mask', '', true), + useFog: PD.Boolean('Use Fog', '', false), + quality: PD.Select<VisualQuality>('Quality', '', 'auto', VisualQualityOptions), + colorTheme: PD.Select<ColorThemeName>('Color Theme', '', 'uniform', ColorThemeOptions), + colorList: PD.Select<ColorScaleName>('Color Scale', '', 'default', ColorScaleOptions), + colorValue: PD.Color('Color Value', '', Color(0xCCCCCC)), } - export const DefaultProps = PD.paramDefaultValues(Params) + export const DefaultProps = PD.getDefaultValues(Params) export type Props = typeof DefaultProps export type Counts = { drawCount: number, groupCount: number, instanceCount: number } diff --git a/src/mol-geo/geometry/lines/lines.ts b/src/mol-geo/geometry/lines/lines.ts index 8e23ce62f..22624aae7 100644 --- a/src/mol-geo/geometry/lines/lines.ts +++ b/src/mol-geo/geometry/lines/lines.ts @@ -93,12 +93,12 @@ export namespace Lines { export const Params = { ...Geometry.Params, - lineSizeAttenuation: PD.BooleanParam('Line Size Attenuation', '', false), - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 10, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 1, 0, 10, 0.1), + lineSizeAttenuation: PD.Boolean('Line Size Attenuation', '', false), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 10, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 1, 0, 10, 0.1), } - export const DefaultProps = PD.paramDefaultValues(Params) + export const DefaultProps = PD.getDefaultValues(Params) export type Props = typeof DefaultProps export async function createValues(ctx: RuntimeContext, lines: Lines, transform: TransformData, locationIt: LocationIterator, props: Props): Promise<LinesValues> { diff --git a/src/mol-geo/geometry/mesh/mesh.ts b/src/mol-geo/geometry/mesh/mesh.ts index 14325482d..e42c7f401 100644 --- a/src/mol-geo/geometry/mesh/mesh.ts +++ b/src/mol-geo/geometry/mesh/mesh.ts @@ -339,11 +339,11 @@ export namespace Mesh { export const Params = { ...Geometry.Params, - doubleSided: PD.BooleanParam('Double Sided', '', false), - flipSided: PD.BooleanParam('Flip Sided', '', false), - flatShaded: PD.BooleanParam('Flat Shaded', '', false), + doubleSided: PD.Boolean('Double Sided', '', false), + flipSided: PD.Boolean('Flip Sided', '', false), + flatShaded: PD.Boolean('Flat Shaded', '', false), } - export const DefaultProps = PD.paramDefaultValues(Params) + export const DefaultProps = PD.getDefaultValues(Params) export type Props = typeof DefaultProps export async function createValues(ctx: RuntimeContext, mesh: Mesh, transform: TransformData, locationIt: LocationIterator, props: Props): Promise<MeshValues> { diff --git a/src/mol-geo/geometry/points/points.ts b/src/mol-geo/geometry/points/points.ts index 9c33fb0c9..7dce2416f 100644 --- a/src/mol-geo/geometry/points/points.ts +++ b/src/mol-geo/geometry/points/points.ts @@ -55,14 +55,14 @@ export namespace Points { export const Params = { ...Geometry.Params, - pointSizeAttenuation: PD.BooleanParam('Point Size Attenuation', '', false), - pointFilledCircle: PD.BooleanParam('Point Filled Circle', '', false), - pointEdgeBleach: PD.NumberParam('Point Edge Bleach', '', 0.2, 0, 1, 0.05), - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 1, 0, 10, 0.1), + pointSizeAttenuation: PD.Boolean('Point Size Attenuation', '', false), + pointFilledCircle: PD.Boolean('Point Filled Circle', '', false), + pointEdgeBleach: PD.Numeric('Point Edge Bleach', '', 0.2, 0, 1, 0.05), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 20, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 1, 0, 10, 0.1), } - export const DefaultProps = PD.paramDefaultValues(Params) + export const DefaultProps = PD.getDefaultValues(Params) export type Props = typeof DefaultProps export async function createValues(ctx: RuntimeContext, points: Points, transform: TransformData, locationIt: LocationIterator, props: Props): Promise<PointsValues> { diff --git a/src/mol-model/structure/structure/unit/gaussian-density.ts b/src/mol-model/structure/structure/unit/gaussian-density.ts index 7a0ca0126..9e63a7ee5 100644 --- a/src/mol-model/structure/structure/unit/gaussian-density.ts +++ b/src/mol-model/structure/structure/unit/gaussian-density.ts @@ -15,13 +15,13 @@ import { Texture } from 'mol-gl/webgl/texture'; import { WebGLContext } from 'mol-gl/webgl/context'; export const GaussianDensityParams = { - resolution: PD.NumberParam('Resolution', '', 1, 0.1, 10, 0.1), - radiusOffset: PD.NumberParam('Radius Offset', '', 0, 0, 10, 0.1), - smoothness: PD.NumberParam('Smoothness', '', 1.5, 0.5, 2.5, 0.1), - useGpu: PD.BooleanParam('Use GPU', '', true), - ignoreCache: PD.BooleanParam('Ignore Cache', '', false), + resolution: PD.Numeric('Resolution', '', 1, 0.1, 10, 0.1), + radiusOffset: PD.Numeric('Radius Offset', '', 0, 0, 10, 0.1), + smoothness: PD.Numeric('Smoothness', '', 1.5, 0.5, 2.5, 0.1), + useGpu: PD.Boolean('Use GPU', '', true), + ignoreCache: PD.Boolean('Ignore Cache', '', false), } -export const DefaultGaussianDensityProps = PD.paramDefaultValues(GaussianDensityParams) +export const DefaultGaussianDensityProps = PD.getDefaultValues(GaussianDensityParams) export type GaussianDensityProps = typeof DefaultGaussianDensityProps function getConformation(unit: Unit) { diff --git a/src/mol-repr/index.ts b/src/mol-repr/index.ts index 6f9160fef..7b6beef01 100644 --- a/src/mol-repr/index.ts +++ b/src/mol-repr/index.ts @@ -42,7 +42,7 @@ export namespace Representation { for (let i = 0, il = reprList.length; i < il; ++i) { visualsOptions.push([ i.toString(), reprList[i].label ]) } - params['visuals'] = PD.MultiSelectParam<string>('Visuals', '', ['surface'], visualsOptions) + params['visuals'] = PD.MultiSelect<string>('Visuals', '', ['surface'], visualsOptions) if (!defaultProps.visuals) { defaultProps.visuals = reprList.map((r, i) => i.toString()) diff --git a/src/mol-repr/shape/index.ts b/src/mol-repr/shape/index.ts index a69e3da36..46fbeb495 100644 --- a/src/mol-repr/shape/index.ts +++ b/src/mol-repr/shape/index.ts @@ -24,9 +24,9 @@ export interface ShapeRepresentation<P extends RepresentationProps = {}> extends export const ShapeParams = { ...Mesh.Params, - colorTheme: PD.SelectParam<ColorThemeName>('Color Theme', '', 'shape-group', ColorThemeOptions) + colorTheme: PD.Select<ColorThemeName>('Color Theme', '', 'shape-group', ColorThemeOptions) } -export const DefaultShapeProps = PD.paramDefaultValues(ShapeParams) +export const DefaultShapeProps = PD.getDefaultValues(ShapeParams) export type ShapeProps = typeof DefaultShapeProps // TODO diff --git a/src/mol-repr/structure/complex-visual.ts b/src/mol-repr/structure/complex-visual.ts index 7c7d3af03..8a5a4611f 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -27,9 +27,9 @@ export interface ComplexVisual<P extends StructureProps> extends Visual<Structu const ComplexParams = { ...StructureParams, - unitKinds: PD.MultiSelectParam<UnitKind>('Unit Kind', '', ['atomic', 'spheres'], UnitKindOptions), + unitKinds: PD.MultiSelect<UnitKind>('Unit Kind', '', ['atomic', 'spheres'], UnitKindOptions), } -const DefaultComplexProps = PD.paramDefaultValues(ComplexParams) +const DefaultComplexProps = PD.getDefaultValues(ComplexParams) type ComplexProps = typeof DefaultComplexProps type ComplexRenderObject = MeshRenderObject | LinesRenderObject | PointsRenderObject | DirectVolumeRenderObject @@ -168,9 +168,9 @@ export function ComplexVisual<P extends ComplexMeshProps>(builder: ComplexVisual export const ComplexMeshParams = { ...StructureMeshParams, - unitKinds: PD.MultiSelectParam<UnitKind>('Unit Kind', '', [ 'atomic', 'spheres' ], UnitKindOptions), + unitKinds: PD.MultiSelect<UnitKind>('Unit Kind', '', [ 'atomic', 'spheres' ], UnitKindOptions), } -export const DefaultComplexMeshProps = PD.paramDefaultValues(ComplexMeshParams) +export const DefaultComplexMeshProps = PD.getDefaultValues(ComplexMeshParams) export type ComplexMeshProps = typeof DefaultComplexMeshProps export interface ComplexMeshVisualBuilder<P extends ComplexMeshProps> extends ComplexVisualBuilder<P, Mesh> { } diff --git a/src/mol-repr/structure/index.ts b/src/mol-repr/structure/index.ts index 1bf903225..a0fb183ab 100644 --- a/src/mol-repr/structure/index.ts +++ b/src/mol-repr/structure/index.ts @@ -21,38 +21,38 @@ export interface StructureRepresentation<P extends RepresentationProps = {}> ext export const StructureParams = { ...Geometry.Params, - colorTheme: PD.SelectParam<ColorThemeName>('Color Theme', '', 'polymer-index', ColorThemeOptions), - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + colorTheme: PD.Select<ColorThemeName>('Color Theme', '', 'polymer-index', ColorThemeOptions), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), } -export const DefaultStructureProps = PD.paramDefaultValues(StructureParams) +export const DefaultStructureProps = PD.getDefaultValues(StructureParams) export type StructureProps = typeof DefaultStructureProps export const StructureMeshParams = { ...Mesh.Params, ...StructureParams, } -export const DefaultStructureMeshProps = PD.paramDefaultValues(StructureMeshParams) +export const DefaultStructureMeshProps = PD.getDefaultValues(StructureMeshParams) export type StructureMeshProps = typeof DefaultStructureMeshProps export const StructurePointsParams = { ...Points.Params, ...StructureParams, } -export const DefaultStructurePointsProps = PD.paramDefaultValues(StructurePointsParams) +export const DefaultStructurePointsProps = PD.getDefaultValues(StructurePointsParams) export type StructurePointsProps = typeof DefaultStructurePointsProps export const StructureLinesParams = { ...Lines.Params, ...StructureParams, } -export const DefaultStructureLinesProps = PD.paramDefaultValues(StructureLinesParams) +export const DefaultStructureLinesProps = PD.getDefaultValues(StructureLinesParams) export type StructureLinesProps = typeof DefaultStructureLinesProps export const StructureDirectVolumeParams = { ...DirectVolume.Params, ...StructureParams, } -export const DefaultStructureDirectVolumeProps = PD.paramDefaultValues(StructureDirectVolumeParams) +export const DefaultStructureDirectVolumeProps = PD.getDefaultValues(StructureDirectVolumeParams) export type StructureDirectVolumeProps = typeof DefaultStructureDirectVolumeProps export { ComplexRepresentation } from './complex-representation' diff --git a/src/mol-repr/structure/representation/backbone.ts b/src/mol-repr/structure/representation/backbone.ts index 67443b92b..33731218d 100644 --- a/src/mol-repr/structure/representation/backbone.ts +++ b/src/mol-repr/structure/representation/backbone.ts @@ -13,7 +13,7 @@ import { Representation } from 'mol-repr'; export const BackboneParams = { ...PolymerBackboneParams } -export const DefaultBackboneProps = PD.paramDefaultValues(BackboneParams) +export const DefaultBackboneProps = PD.getDefaultValues(BackboneParams) export type BackboneProps = typeof DefaultBackboneProps export type BackboneRepresentation = StructureRepresentation<BackboneProps> diff --git a/src/mol-repr/structure/representation/ball-and-stick.ts b/src/mol-repr/structure/representation/ball-and-stick.ts index c74f4f714..7f94d0bf8 100644 --- a/src/mol-repr/structure/representation/ball-and-stick.ts +++ b/src/mol-repr/structure/representation/ball-and-stick.ts @@ -19,12 +19,12 @@ export const BallAndStickParams = { ...ElementSphereParams, ...IntraUnitLinkParams, ...InterUnitLinkParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 0.2, 0, 10, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 1, 0, 10, 0.1), - unitKinds: PD.MultiSelectParam<UnitKind>('Unit Kind', '', ['atomic'], UnitKindOptions), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 0.2, 0, 10, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 1, 0, 10, 0.1), + unitKinds: PD.MultiSelect<UnitKind>('Unit Kind', '', ['atomic'], UnitKindOptions), } -export const DefaultBallAndStickProps = PD.paramDefaultValues(BallAndStickParams) +export const DefaultBallAndStickProps = PD.getDefaultValues(BallAndStickParams) export type BallAndStickProps = typeof DefaultBallAndStickProps export type BallAndStickRepresentation = StructureRepresentation<BallAndStickProps> diff --git a/src/mol-repr/structure/representation/carbohydrate.ts b/src/mol-repr/structure/representation/carbohydrate.ts index d8cd83298..3a0c79e9a 100644 --- a/src/mol-repr/structure/representation/carbohydrate.ts +++ b/src/mol-repr/structure/representation/carbohydrate.ts @@ -15,11 +15,11 @@ import { Representation } from 'mol-repr'; export const CarbohydrateParams = { ...CarbohydrateSymbolParams, ...CarbohydrateLinkParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 0.1, 20), - sizeFactor: PD.NumberParam('Size Factor', '', 1, 0, 10, 0.1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 0.1, 20), + sizeFactor: PD.Numeric('Size Factor', '', 1, 0, 10, 0.1), } -export const DefaultCarbohydrateProps = PD.paramDefaultValues(CarbohydrateParams) +export const DefaultCarbohydrateProps = PD.getDefaultValues(CarbohydrateParams) export type CarbohydrateProps = typeof DefaultCarbohydrateProps export type CarbohydrateRepresentation = StructureRepresentation<CarbohydrateProps> diff --git a/src/mol-repr/structure/representation/cartoon.ts b/src/mol-repr/structure/representation/cartoon.ts index 1c2b9e8e0..dbf44633d 100644 --- a/src/mol-repr/structure/representation/cartoon.ts +++ b/src/mol-repr/structure/representation/cartoon.ts @@ -19,10 +19,10 @@ export const CartoonParams = { ...PolymerGapParams, ...NucleotideBlockParams, // ...PolymerDirectionParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 0.6, 0, 10, 0.1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 0.6, 0, 10, 0.1), } -export const DefaultCartoonProps = PD.paramDefaultValues(CartoonParams) +export const DefaultCartoonProps = PD.getDefaultValues(CartoonParams) export type CartoonProps = typeof DefaultCartoonProps export type CartoonRepresentation = StructureRepresentation<CartoonProps> diff --git a/src/mol-repr/structure/representation/distance-restraint.ts b/src/mol-repr/structure/representation/distance-restraint.ts index 7f5c182de..08ed87266 100644 --- a/src/mol-repr/structure/representation/distance-restraint.ts +++ b/src/mol-repr/structure/representation/distance-restraint.ts @@ -13,10 +13,10 @@ import { Representation } from 'mol-repr'; export const DistanceRestraintParams = { ...CrossLinkRestraintParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 0.25, 0, 0.05, 20), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 0.25, 0, 0.05, 20), } -export const DefaultDistanceRestraintProps = PD.paramDefaultValues(DistanceRestraintParams) +export const DefaultDistanceRestraintProps = PD.getDefaultValues(DistanceRestraintParams) export type DistanceRestraintProps = typeof DefaultDistanceRestraintProps export type DistanceRestraintRepresentation = StructureRepresentation<DistanceRestraintProps> diff --git a/src/mol-repr/structure/representation/molecular-surface.ts b/src/mol-repr/structure/representation/molecular-surface.ts index 7cf03191c..0e8fa626b 100644 --- a/src/mol-repr/structure/representation/molecular-surface.ts +++ b/src/mol-repr/structure/representation/molecular-surface.ts @@ -17,9 +17,9 @@ export const MolecularSurfaceParams = { ...GaussianSurfaceParams, ...GaussianWireframeParams, ...GaussianDensityVolumeParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), } -export const DefaultMolecularSurfaceProps = { ...PD.paramDefaultValues(MolecularSurfaceParams), visuals: [ '0' ] } +export const DefaultMolecularSurfaceProps = { ...PD.getDefaultValues(MolecularSurfaceParams), visuals: [ '0' ] } export type MolecularSurfaceProps = typeof DefaultMolecularSurfaceProps export type MolecularSurfaceRepresentation = StructureRepresentation<MolecularSurfaceProps> diff --git a/src/mol-repr/structure/representation/point.ts b/src/mol-repr/structure/representation/point.ts index 980e4c7d5..0e483ee9e 100644 --- a/src/mol-repr/structure/representation/point.ts +++ b/src/mol-repr/structure/representation/point.ts @@ -13,7 +13,7 @@ import { Representation } from 'mol-repr'; export const PointParams = { ...ElementPointParams, } -export const DefaultPointProps = PD.paramDefaultValues(PointParams) +export const DefaultPointProps = PD.getDefaultValues(PointParams) export type PointProps = typeof DefaultPointProps export type PointRepresentation = StructureRepresentation<PointProps> diff --git a/src/mol-repr/structure/representation/spacefill.ts b/src/mol-repr/structure/representation/spacefill.ts index d309a30c9..46a8a3e64 100644 --- a/src/mol-repr/structure/representation/spacefill.ts +++ b/src/mol-repr/structure/representation/spacefill.ts @@ -13,7 +13,7 @@ import { Representation } from 'mol-repr'; export const SpacefillParams = { ...ElementSphereParams } -export const DefaultSpacefillProps = PD.paramDefaultValues(SpacefillParams) +export const DefaultSpacefillProps = PD.getDefaultValues(SpacefillParams) export type SpacefillProps = typeof DefaultSpacefillProps export type SpacefillRepresentation = StructureRepresentation<SpacefillProps> diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index 269db19ba..bdb96e716 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -39,9 +39,9 @@ function sameGroupConformation(groupA: Unit.SymmetryGroup, groupB: Unit.Symmetry const UnitsParams = { ...StructureParams, - unitKinds: PD.MultiSelectParam<UnitKind>('Unit Kind', '', ['atomic', 'spheres'], UnitKindOptions), + unitKinds: PD.MultiSelect<UnitKind>('Unit Kind', '', ['atomic', 'spheres'], UnitKindOptions), } -const DefaultUnitsProps = PD.paramDefaultValues(UnitsParams) +const DefaultUnitsProps = PD.getDefaultValues(UnitsParams) type UnitsProps = typeof DefaultUnitsProps type UnitsRenderObject = MeshRenderObject | LinesRenderObject | PointsRenderObject | DirectVolumeRenderObject @@ -205,7 +205,7 @@ export const UnitsMeshParams = { ...StructureMeshParams, ...UnitsParams, } -export const DefaultUnitsMeshProps = PD.paramDefaultValues(UnitsMeshParams) +export const DefaultUnitsMeshProps = PD.getDefaultValues(UnitsMeshParams) export type UnitsMeshProps = typeof DefaultUnitsMeshProps export interface UnitsMeshVisualBuilder<P extends UnitsMeshProps> extends UnitsVisualBuilder<P, Mesh> { } @@ -228,7 +228,7 @@ export const UnitsPointsParams = { ...StructurePointsParams, ...UnitsParams, } -export const DefaultUnitsPointsProps = PD.paramDefaultValues(UnitsPointsParams) +export const DefaultUnitsPointsProps = PD.getDefaultValues(UnitsPointsParams) export type UnitsPointsProps = typeof DefaultUnitsPointsProps export interface UnitsPointVisualBuilder<P extends UnitsPointsProps> extends UnitsVisualBuilder<P, Points> { } @@ -251,7 +251,7 @@ export const UnitsLinesParams = { ...StructureLinesParams, ...UnitsParams, } -export const DefaultUnitsLinesProps = PD.paramDefaultValues(UnitsLinesParams) +export const DefaultUnitsLinesProps = PD.getDefaultValues(UnitsLinesParams) export type UnitsLinesProps = typeof DefaultUnitsLinesProps export interface UnitsLinesVisualBuilder<P extends UnitsLinesProps> extends UnitsVisualBuilder<P, Lines> { } @@ -274,7 +274,7 @@ export const UnitsDirectVolumeParams = { ...StructureDirectVolumeParams, ...UnitsParams, } -export const DefaultUnitsDirectVolumeProps = PD.paramDefaultValues(UnitsDirectVolumeParams) +export const DefaultUnitsDirectVolumeProps = PD.getDefaultValues(UnitsDirectVolumeParams) export type UnitsDirectVolumeProps = typeof DefaultUnitsDirectVolumeProps export interface UnitsDirectVolumeVisualBuilder<P extends UnitsDirectVolumeProps> extends UnitsVisualBuilder<P, DirectVolume> { } diff --git a/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts b/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts index 303a0b28a..5db9028b2 100644 --- a/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts +++ b/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts @@ -64,11 +64,11 @@ async function createCarbohydrateLinkCylinderMesh(ctx: VisualContext, structure: export const CarbohydrateLinkParams = { ...UnitsMeshParams, ...LinkCylinderParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), - detail: PD.NumberParam('Sphere Detail', '', 0, 0, 3, 1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 20, 0.1), + detail: PD.Numeric('Sphere Detail', '', 0, 0, 3, 1), } -export const DefaultCarbohydrateLinkProps = PD.paramDefaultValues(CarbohydrateLinkParams) +export const DefaultCarbohydrateLinkProps = PD.getDefaultValues(CarbohydrateLinkParams) export type CarbohydrateLinkProps = typeof DefaultCarbohydrateLinkProps export function CarbohydrateLinkVisual(): ComplexVisual<CarbohydrateLinkProps> { diff --git a/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts b/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts index 218017ff7..d4345c8bd 100644 --- a/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts +++ b/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts @@ -148,11 +148,11 @@ async function createCarbohydrateSymbolMesh(ctx: VisualContext, structure: Struc export const CarbohydrateSymbolParams = { ...ComplexMeshParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 10, 0.1), - detail: PD.NumberParam('Sphere Detail', '', 0, 0, 3, 1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 10, 0.1), + detail: PD.Numeric('Sphere Detail', '', 0, 0, 3, 1), } -export const DefaultCarbohydrateSymbolProps = PD.paramDefaultValues(CarbohydrateSymbolParams) +export const DefaultCarbohydrateSymbolProps = PD.getDefaultValues(CarbohydrateSymbolParams) export type CarbohydrateSymbolProps = typeof DefaultCarbohydrateSymbolProps export function CarbohydrateSymbolVisual(): ComplexVisual<CarbohydrateSymbolProps> { diff --git a/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts b/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts index 87374bfb9..0beec07c3 100644 --- a/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts +++ b/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts @@ -54,10 +54,10 @@ async function createCrossLinkRestraintCylinderMesh(ctx: VisualContext, structur export const CrossLinkRestraintParams = { ...ComplexMeshParams, ...LinkCylinderParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 20, 0.1), } -export const DefaultCrossLinkRestraintProps = PD.paramDefaultValues(CrossLinkRestraintParams) +export const DefaultCrossLinkRestraintProps = PD.getDefaultValues(CrossLinkRestraintParams) export type CrossLinkRestraintProps = typeof DefaultCrossLinkRestraintProps export function CrossLinkRestraintVisual(): ComplexVisual<CrossLinkRestraintProps> { diff --git a/src/mol-repr/structure/visual/element-point.ts b/src/mol-repr/structure/visual/element-point.ts index df0f81422..912c2f98d 100644 --- a/src/mol-repr/structure/visual/element-point.ts +++ b/src/mol-repr/structure/visual/element-point.ts @@ -18,11 +18,11 @@ import { VisualContext } from 'mol-repr'; export const ElementPointParams = { ...UnitsPointsParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 3, 0, 20, 0.1), - pointSizeAttenuation: PD.BooleanParam('Point Size Attenuation', '', false), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 3, 0, 20, 0.1), + pointSizeAttenuation: PD.Boolean('Point Size Attenuation', '', false), } -export const DefaultElementPointProps = PD.paramDefaultValues(ElementPointParams) +export const DefaultElementPointProps = PD.getDefaultValues(ElementPointParams) export type ElementPointProps = typeof DefaultElementPointProps // TODO size diff --git a/src/mol-repr/structure/visual/element-sphere.ts b/src/mol-repr/structure/visual/element-sphere.ts index dd75f1b36..73d25eb01 100644 --- a/src/mol-repr/structure/visual/element-sphere.ts +++ b/src/mol-repr/structure/visual/element-sphere.ts @@ -14,12 +14,12 @@ import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; export const ElementSphereParams = { ...UnitsMeshParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 0.2, 0, 10, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 1, 0, 10, 0.1), - detail: PD.NumberParam('Sphere Detail', '', 0, 0, 3, 1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 0.2, 0, 10, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 1, 0, 10, 0.1), + detail: PD.Numeric('Sphere Detail', '', 0, 0, 3, 1), } -export const DefaultElementSphereProps = PD.paramDefaultValues(ElementSphereParams) +export const DefaultElementSphereProps = PD.getDefaultValues(ElementSphereParams) export type ElementSphereProps = typeof DefaultElementSphereProps export function ElementSphereVisual(): UnitsVisual<ElementSphereProps> { diff --git a/src/mol-repr/structure/visual/gaussian-density-point.ts b/src/mol-repr/structure/visual/gaussian-density-point.ts index 6cb02e33a..19372420f 100644 --- a/src/mol-repr/structure/visual/gaussian-density-point.ts +++ b/src/mol-repr/structure/visual/gaussian-density-point.ts @@ -21,11 +21,11 @@ import { VisualContext } from 'mol-repr'; export const GaussianDensityPointParams = { ...UnitsPointsParams, ...GaussianDensityParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), - pointSizeAttenuation: PD.BooleanParam('Point Size Attenuation', '', false), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 20, 0.1), + pointSizeAttenuation: PD.Boolean('Point Size Attenuation', '', false), } -export const DefaultGaussianDensityPointProps = PD.paramDefaultValues(GaussianDensityPointParams) +export const DefaultGaussianDensityPointProps = PD.getDefaultValues(GaussianDensityPointParams) export type GaussianDensityPointProps = typeof DefaultGaussianDensityPointProps export async function createGaussianDensityPoint(ctx: VisualContext, unit: Unit, structure: Structure, props: GaussianDensityProps, points?: Points) { diff --git a/src/mol-repr/structure/visual/gaussian-density-volume.ts b/src/mol-repr/structure/visual/gaussian-density-volume.ts index 9117910c8..90cc0f72f 100644 --- a/src/mol-repr/structure/visual/gaussian-density-volume.ts +++ b/src/mol-repr/structure/visual/gaussian-density-volume.ts @@ -30,7 +30,7 @@ export const GaussianDensityVolumeParams = { ...UnitsDirectVolumeParams, ...GaussianDensityParams, } -export const DefaultGaussianDensityVolumeProps = PD.paramDefaultValues(GaussianDensityVolumeParams) +export const DefaultGaussianDensityVolumeProps = PD.getDefaultValues(GaussianDensityVolumeParams) export type GaussianDensityVolumeProps = typeof DefaultGaussianDensityVolumeProps export function GaussianDensityVolumeVisual(): UnitsVisual<GaussianDensityVolumeProps> { diff --git a/src/mol-repr/structure/visual/gaussian-surface-mesh.ts b/src/mol-repr/structure/visual/gaussian-surface-mesh.ts index 836999cda..e09ceaec1 100644 --- a/src/mol-repr/structure/visual/gaussian-surface-mesh.ts +++ b/src/mol-repr/structure/visual/gaussian-surface-mesh.ts @@ -37,7 +37,7 @@ export const GaussianSurfaceParams = { ...UnitsMeshParams, ...GaussianDensityParams, } -export const DefaultGaussianSurfaceProps = PD.paramDefaultValues(GaussianSurfaceParams) +export const DefaultGaussianSurfaceProps = PD.getDefaultValues(GaussianSurfaceParams) export type GaussianSurfaceProps = typeof DefaultGaussianSurfaceProps export function GaussianSurfaceVisual(): UnitsVisual<GaussianSurfaceProps> { diff --git a/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts b/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts index 928b54c8d..3f98da10b 100644 --- a/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts +++ b/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts @@ -35,11 +35,11 @@ async function createGaussianWireframe(ctx: VisualContext, unit: Unit, structure export const GaussianWireframeParams = { ...UnitsLinesParams, ...GaussianDensityParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 2, 0, 10, 0.1), - lineSizeAttenuation: PD.BooleanParam('Line Size Attenuation', '', false), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 2, 0, 10, 0.1), + lineSizeAttenuation: PD.Boolean('Line Size Attenuation', '', false), } -export const DefaultGaussianWireframeProps = PD.paramDefaultValues(GaussianWireframeParams) +export const DefaultGaussianWireframeProps = PD.getDefaultValues(GaussianWireframeParams) export type GaussianWireframeProps = typeof DefaultGaussianWireframeProps export function GaussianWireframeVisual(): UnitsVisual<GaussianWireframeProps> { diff --git a/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts b/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts index 85aaf11aa..71af78be0 100644 --- a/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts +++ b/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts @@ -53,11 +53,11 @@ async function createInterUnitLinkCylinderMesh(ctx: VisualContext, structure: St export const InterUnitLinkParams = { ...ComplexMeshParams, ...LinkCylinderParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 0.2, 0, 10, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 1, 0, 10, 0.1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 0.2, 0, 10, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 1, 0, 10, 0.1), } -export const DefaultInterUnitLinkProps = PD.paramDefaultValues(InterUnitLinkParams) +export const DefaultInterUnitLinkProps = PD.getDefaultValues(InterUnitLinkParams) export type InterUnitLinkProps = typeof DefaultInterUnitLinkProps export function InterUnitLinkVisual(): ComplexVisual<InterUnitLinkProps> { diff --git a/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts b/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts index 9c54f5b06..546a389e7 100644 --- a/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts +++ b/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts @@ -67,11 +67,11 @@ async function createIntraUnitLinkCylinderMesh(ctx: VisualContext, unit: Unit, s export const IntraUnitLinkParams = { ...UnitsMeshParams, ...LinkCylinderParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 0.2, 0, 10, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 1, 0, 10, 0.1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 0.2, 0, 10, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 1, 0, 10, 0.1), } -export const DefaultIntraUnitLinkProps = PD.paramDefaultValues(IntraUnitLinkParams) +export const DefaultIntraUnitLinkProps = PD.getDefaultValues(IntraUnitLinkParams) export type IntraUnitLinkProps = typeof DefaultIntraUnitLinkProps export function IntraUnitLinkVisual(): UnitsVisual<IntraUnitLinkProps> { diff --git a/src/mol-repr/structure/visual/nucleotide-block-mesh.ts b/src/mol-repr/structure/visual/nucleotide-block-mesh.ts index c5650f4a6..a378ee206 100644 --- a/src/mol-repr/structure/visual/nucleotide-block-mesh.ts +++ b/src/mol-repr/structure/visual/nucleotide-block-mesh.ts @@ -114,7 +114,7 @@ async function createNucleotideBlockMesh(ctx: VisualContext, unit: Unit, structu export const NucleotideBlockParams = { ...UnitsMeshParams } -export const DefaultNucleotideBlockProps = PD.paramDefaultValues(NucleotideBlockParams) +export const DefaultNucleotideBlockProps = PD.getDefaultValues(NucleotideBlockParams) export type NucleotideBlockProps = typeof DefaultNucleotideBlockProps export function NucleotideBlockVisual(): UnitsVisual<NucleotideBlockProps> { diff --git a/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts b/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts index 9d89e3010..74f2d8f59 100644 --- a/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts +++ b/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts @@ -21,11 +21,11 @@ import { addCylinder } from 'mol-geo/geometry/mesh/builder/cylinder'; import { VisualContext } from 'mol-repr'; export const PolymerBackboneCylinderParams = { - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 10, 0.1), - radialSegments: PD.NumberParam('Radial Segments', '', 16, 3, 56, 1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 10, 0.1), + radialSegments: PD.Numeric('Radial Segments', '', 16, 3, 56, 1), } -export const DefaultPolymerBackboneCylinderProps = PD.paramDefaultValues(PolymerBackboneCylinderParams) +export const DefaultPolymerBackboneCylinderProps = PD.getDefaultValues(PolymerBackboneCylinderParams) export type PolymerBackboneCylinderProps = typeof DefaultPolymerBackboneCylinderProps async function createPolymerBackboneCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, props: PolymerBackboneCylinderProps, mesh?: Mesh) { @@ -72,7 +72,7 @@ export const PolymerBackboneParams = { ...UnitsMeshParams, ...PolymerBackboneCylinderParams, } -export const DefaultPolymerBackboneProps = PD.paramDefaultValues(PolymerBackboneParams) +export const DefaultPolymerBackboneProps = PD.getDefaultValues(PolymerBackboneParams) export type PolymerBackboneProps = typeof DefaultPolymerBackboneProps export function PolymerBackboneVisual(): UnitsVisual<PolymerBackboneProps> { diff --git a/src/mol-repr/structure/visual/polymer-direction-wedge.ts b/src/mol-repr/structure/visual/polymer-direction-wedge.ts index 6ed09506b..89b48863b 100644 --- a/src/mol-repr/structure/visual/polymer-direction-wedge.ts +++ b/src/mol-repr/structure/visual/polymer-direction-wedge.ts @@ -30,10 +30,10 @@ const heightFactor = 6 const wedge = Wedge() export const PolymerDirectionWedgeParams = { - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 20, 0.1), } -export const DefaultPolymerDirectionWedgeProps = PD.paramDefaultValues(PolymerDirectionWedgeParams) +export const DefaultPolymerDirectionWedgeProps = PD.getDefaultValues(PolymerDirectionWedgeParams) export type PolymerDirectionWedgeProps = typeof DefaultPolymerDirectionWedgeProps async function createPolymerDirectionWedgeMesh(ctx: VisualContext, unit: Unit, structure: Structure, props: PolymerDirectionWedgeProps, mesh?: Mesh) { @@ -93,7 +93,7 @@ export const PolymerDirectionParams = { ...UnitsMeshParams, ...PolymerDirectionWedgeParams } -export const DefaultPolymerDirectionProps = PD.paramDefaultValues(PolymerDirectionParams) +export const DefaultPolymerDirectionProps = PD.getDefaultValues(PolymerDirectionParams) export type PolymerDirectionProps = typeof DefaultPolymerDirectionProps export function PolymerDirectionVisual(): UnitsVisual<PolymerDirectionProps> { diff --git a/src/mol-repr/structure/visual/polymer-gap-cylinder.ts b/src/mol-repr/structure/visual/polymer-gap-cylinder.ts index 5cf649eb0..56a83b2c1 100644 --- a/src/mol-repr/structure/visual/polymer-gap-cylinder.ts +++ b/src/mol-repr/structure/visual/polymer-gap-cylinder.ts @@ -23,12 +23,12 @@ import { VisualContext } from 'mol-repr'; const segmentCount = 10 export const PolymerGapCylinderParams = { - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 10, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 0.3, 0, 10, 0.1), - radialSegments: PD.NumberParam('Radial Segments', '', 16, 3, 56, 1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 10, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 0.3, 0, 10, 0.1), + radialSegments: PD.Numeric('Radial Segments', '', 16, 3, 56, 1), } -export const DefaultPolymerGapCylinderProps = PD.paramDefaultValues(PolymerGapCylinderParams) +export const DefaultPolymerGapCylinderProps = PD.getDefaultValues(PolymerGapCylinderParams) export type PolymerGapCylinderProps = typeof DefaultPolymerGapCylinderProps async function createPolymerGapCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, props: PolymerGapCylinderProps, mesh?: Mesh) { @@ -81,18 +81,18 @@ async function createPolymerGapCylinderMesh(ctx: VisualContext, unit: Unit, stru export const InterUnitLinkParams = { ...UnitsMeshParams, ...LinkCylinderParams, - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 0.3, 0, 10, 0.1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 20, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 0.3, 0, 10, 0.1), } -export const DefaultIntraUnitLinkProps = PD.paramDefaultValues(InterUnitLinkParams) +export const DefaultIntraUnitLinkProps = PD.getDefaultValues(InterUnitLinkParams) export type IntraUnitLinkProps = typeof DefaultIntraUnitLinkProps export const PolymerGapParams = { ...UnitsMeshParams, ...PolymerGapCylinderParams } -export const DefaultPolymerGapProps = PD.paramDefaultValues(PolymerGapParams) +export const DefaultPolymerGapProps = PD.getDefaultValues(PolymerGapParams) export type PolymerGapProps = typeof DefaultPolymerGapProps export function PolymerGapVisual(): UnitsVisual<PolymerGapProps> { diff --git a/src/mol-repr/structure/visual/polymer-trace-mesh.ts b/src/mol-repr/structure/visual/polymer-trace-mesh.ts index be8b995d7..934b81911 100644 --- a/src/mol-repr/structure/visual/polymer-trace-mesh.ts +++ b/src/mol-repr/structure/visual/polymer-trace-mesh.ts @@ -19,15 +19,15 @@ import { addTube } from 'mol-geo/geometry/mesh/builder/tube'; import { VisualContext } from 'mol-repr'; export const PolymerTraceMeshParams = { - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 0.3, 0, 10, 0.1), - linearSegments: PD.NumberParam('Linear Segments', '', 8, 1, 48, 1), - radialSegments: PD.NumberParam('Radial Segments', '', 16, 3, 56, 1), - aspectRatio: PD.NumberParam('Aspect Ratio', '', 5, 0.1, 5, 0.1), - arrowFactor: PD.NumberParam('Arrow Factor', '', 1.5, 0.1, 5, 0.1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 20, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 0.3, 0, 10, 0.1), + linearSegments: PD.Numeric('Linear Segments', '', 8, 1, 48, 1), + radialSegments: PD.Numeric('Radial Segments', '', 16, 3, 56, 1), + aspectRatio: PD.Numeric('Aspect Ratio', '', 5, 0.1, 5, 0.1), + arrowFactor: PD.Numeric('Arrow Factor', '', 1.5, 0.1, 5, 0.1), } -export const DefaultPolymerTraceMeshProps = PD.paramDefaultValues(PolymerTraceMeshParams) +export const DefaultPolymerTraceMeshProps = PD.getDefaultValues(PolymerTraceMeshParams) export type PolymerTraceMeshProps = typeof DefaultPolymerTraceMeshProps // TODO handle polymer ends properly @@ -93,7 +93,7 @@ export const PolymerTraceParams = { ...UnitsMeshParams, ...PolymerTraceMeshParams } -export const DefaultPolymerTraceProps = PD.paramDefaultValues(PolymerTraceParams) +export const DefaultPolymerTraceProps = PD.getDefaultValues(PolymerTraceParams) export type PolymerTraceProps = typeof DefaultPolymerTraceProps export function PolymerTraceVisual(): UnitsVisual<PolymerTraceProps> { diff --git a/src/mol-repr/structure/visual/util/link.ts b/src/mol-repr/structure/visual/util/link.ts index 7b8840c48..41932fa0f 100644 --- a/src/mol-repr/structure/visual/util/link.ts +++ b/src/mol-repr/structure/visual/util/link.ts @@ -17,15 +17,15 @@ import { LocationIterator } from 'mol-geo/util/location-iterator'; import { VisualContext } from 'mol-repr'; export const LinkCylinderParams = { - sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), - sizeFactor: PD.NumberParam('Size Factor', '', 1, 0, 10, 0.1), - linkScale: PD.RangeParam('Link Scale', '', 0.4, 0, 1, 0.1), - linkSpacing: PD.RangeParam('Link Spacing', '', 1, 0, 2, 0.01), - linkRadius: PD.RangeParam('Link Radius', '', 0.25, 0, 10, 0.05), - radialSegments: PD.NumberParam('Radial Segments', '', 16, 3, 56, 1), + sizeTheme: PD.Select<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.Numeric('Size Value', '', 1, 0, 20, 0.1), + sizeFactor: PD.Numeric('Size Factor', '', 1, 0, 10, 0.1), + linkScale: PD.Range('Link Scale', '', 0.4, 0, 1, 0.1), + linkSpacing: PD.Range('Link Spacing', '', 1, 0, 2, 0.01), + linkRadius: PD.Range('Link Radius', '', 0.25, 0, 10, 0.05), + radialSegments: PD.Numeric('Radial Segments', '', 16, 3, 56, 1), } -export const DefaultLinkCylinderProps = PD.paramDefaultValues(LinkCylinderParams) +export const DefaultLinkCylinderProps = PD.getDefaultValues(LinkCylinderParams) export type LinkCylinderProps = typeof DefaultLinkCylinderProps const tmpShiftV12 = Vec3.zero() diff --git a/src/mol-repr/volume/direct-volume.ts b/src/mol-repr/volume/direct-volume.ts index c8264335f..adc324e4e 100644 --- a/src/mol-repr/volume/direct-volume.ts +++ b/src/mol-repr/volume/direct-volume.ts @@ -187,7 +187,7 @@ export const DirectVolumeParams = { ...Geometry.Params, ...DirectVolume.Params } -export const DefaultDirectVolumeProps = PD.paramDefaultValues(DirectVolumeParams) +export const DefaultDirectVolumeProps = PD.getDefaultValues(DirectVolumeParams) export type DirectVolumeProps = typeof DefaultDirectVolumeProps export function DirectVolumeVisual(): VolumeVisual<DirectVolumeProps> { diff --git a/src/mol-repr/volume/index.ts b/src/mol-repr/volume/index.ts index 3ad9c37f4..a4b09a7d6 100644 --- a/src/mol-repr/volume/index.ts +++ b/src/mol-repr/volume/index.ts @@ -136,10 +136,10 @@ export interface VolumeRepresentation<P extends RepresentationProps = {}> extend export const VolumeParams = { ...Geometry.Params, - isoValueAbsolute: PD.RangeParam('Iso Value Absolute', '', 0.22, -1, 1, 0.01), - isoValueRelative: PD.RangeParam('Iso Value Relative', '', 2, -10, 10, 0.1), + isoValueAbsolute: PD.Range('Iso Value Absolute', '', 0.22, -1, 1, 0.01), + isoValueRelative: PD.Range('Iso Value Relative', '', 2, -10, 10, 0.1), } -export const DefaultVolumeProps = PD.paramDefaultValues(VolumeParams) +export const DefaultVolumeProps = PD.getDefaultValues(VolumeParams) export type VolumeProps = typeof DefaultVolumeProps export function VolumeRepresentation<P extends VolumeProps>(visualCtor: (volumeData: VolumeData) => VolumeVisual<P>): VolumeRepresentation<P> { diff --git a/src/mol-repr/volume/isosurface-mesh.ts b/src/mol-repr/volume/isosurface-mesh.ts index f569ec9c1..c09f89797 100644 --- a/src/mol-repr/volume/isosurface-mesh.ts +++ b/src/mol-repr/volume/isosurface-mesh.ts @@ -42,10 +42,10 @@ export async function createVolumeIsosurface(ctx: VisualContext, volume: VolumeD export const IsosurfaceParams = { ...Mesh.Params, - isoValueAbsolute: PD.RangeParam('Iso Value Absolute', '', 0.22, -1, 1, 0.01), - isoValueRelative: PD.RangeParam('Iso Value Relative', '', 2, -10, 10, 0.1), + isoValueAbsolute: PD.Range('Iso Value Absolute', '', 0.22, -1, 1, 0.01), + isoValueRelative: PD.Range('Iso Value Relative', '', 2, -10, 10, 0.1), } -export const DefaultIsosurfaceProps = PD.paramDefaultValues(IsosurfaceParams) +export const DefaultIsosurfaceProps = PD.getDefaultValues(IsosurfaceParams) export type IsosurfaceProps = typeof DefaultIsosurfaceProps export function IsosurfaceVisual(): VolumeVisual<IsosurfaceProps> { diff --git a/src/mol-state/transformer.ts b/src/mol-state/transformer.ts index 80998a0b4..ac38a55a8 100644 --- a/src/mol-state/transformer.ts +++ b/src/mol-state/transformer.ts @@ -20,7 +20,7 @@ export namespace Transformer { export type Id = string & { '@type': 'transformer-id' } export type Params<T extends Transformer<any, any, any>> = T extends Transformer<any, any, infer P> ? P : unknown; export type To<T extends Transformer<any, any, any>> = T extends Transformer<any, infer B, any> ? B : unknown; - export type ControlsFor<A extends StateObject, Props> = { [P in keyof Props]?: ((a: A, globalCtx: unknown) => PD.Param) } + export type ControlsFor<A extends StateObject, Props> = { [P in keyof Props]?: ((a: A, globalCtx: unknown) => PD.Any) } export interface ApplyParams<A extends StateObject = StateObject, P = unknown> { a: A, diff --git a/src/mol-util/param-definition.ts b/src/mol-util/param-definition.ts index 5d773abf0..0ebf49dd8 100644 --- a/src/mol-util/param-definition.ts +++ b/src/mol-util/param-definition.ts @@ -2,90 +2,90 @@ * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> + * @author David Sehnal <david.sehnal@gmail.com> */ -import { Color } from './color'; +import { Color as ColorData } from './color'; export namespace ParamDefinition { - export interface BaseParam<T> { + export interface Base<T> { label: string description: string defaultValue: T } - // TODO: is this really needed? - // export interface ValueParam<T> extends BaseParam<T> { - // type: 'value' - // } - // export function ValueParam<T>(label: string, description: string, defaultValue: T): ValueParam<T> { - // return { type: 'value', label, description, defaultValue } - // } + export interface GenericValue<T> extends Base<T> { + type: 'generic-value' + } + export function GenericValue<T>(label: string, description: string, defaultValue: T): GenericValue<T> { + return { type: 'generic-value', label, description, defaultValue } + } - export interface SelectParam<T extends string> extends BaseParam<T> { + export interface Select<T extends string> extends Base<T> { type: 'select' - /** array of (value, label) tupels */ + /** array of (value, label) tuples */ options: [T, string][] } - export function SelectParam<T extends string>(label: string, description: string, defaultValue: T, options: [T, string][]): SelectParam<T> { + export function Select<T extends string>(label: string, description: string, defaultValue: T, options: [T, string][]): Select<T> { return { type: 'select', label, description, defaultValue, options } } - export interface MultiSelectParam<E extends string, T = E[]> extends BaseParam<T> { + export interface MultiSelect<E extends string, T = E[]> extends Base<T> { type: 'multi-select' - /** array of (value, label) tupels */ + /** array of (value, label) tuples */ options: [E, string][] } - export function MultiSelectParam<E extends string, T = E[]>(label: string, description: string, defaultValue: T, options: [E, string][]): MultiSelectParam<E, T> { + export function MultiSelect<E extends string, T = E[]>(label: string, description: string, defaultValue: T, options: [E, string][]): MultiSelect<E, T> { return { type: 'multi-select', label, description, defaultValue, options } } - export interface BooleanParam extends BaseParam<boolean> { + export interface Boolean extends Base<boolean> { type: 'boolean' } - export function BooleanParam(label: string, description: string, defaultValue: boolean): BooleanParam { + export function Boolean(label: string, description: string, defaultValue: boolean): Boolean { return { type: 'boolean', label, description, defaultValue } } - export interface RangeParam extends BaseParam<number> { + export interface Range extends Base<number> { type: 'range' min: number max: number /** if an `integer` parse value with parseInt, otherwise use parseFloat */ step: number } - export function RangeParam(label: string, description: string, defaultValue: number, min: number, max: number, step: number): RangeParam { + export function Range(label: string, description: string, defaultValue: number, min: number, max: number, step: number): Range { return { type: 'range', label, description, defaultValue, min, max, step } } - export interface TextParam extends BaseParam<string> { + export interface Text extends Base<string> { type: 'text' } - export function TextParam(label: string, description: string, defaultValue: string): TextParam { + export function Text(label: string, description: string, defaultValue: string = ''): Text { return { type: 'text', label, description, defaultValue } } - export interface ColorParam extends BaseParam<Color> { + export interface Color extends Base<ColorData> { type: 'color' } - export function ColorParam(label: string, description: string, defaultValue: Color): ColorParam { + export function Color(label: string, description: string, defaultValue: ColorData): Color { return { type: 'color', label, description, defaultValue } } - export interface NumberParam extends BaseParam<number> { + export interface Numeric extends Base<number> { type: 'number' min: number max: number /** if an `integer` parse value with parseInt, otherwise use parseFloat */ step: number } - export function NumberParam(label: string, description: string, defaultValue: number, min: number, max: number, step: number): NumberParam { + export function Numeric(label: string, description: string, defaultValue: number, min: number, max: number, step: number): Numeric { return { type: 'number', label, description, defaultValue, min, max, step } } - export type Param = /* ValueParam<any> | */ SelectParam<any> | MultiSelectParam<any> | BooleanParam | RangeParam | TextParam | ColorParam | NumberParam - export type Params = { [k: string]: Param } + export type Any = /* ValueParam<any> | */ Select<any> | MultiSelect<any> | Boolean | Range | Text | Color | Numeric + export type Params = { [k: string]: Any } - export function paramDefaultValues<T extends Params>(params: T) { + export function getDefaultValues<T extends Params>(params: T) { const d: { [k: string]: any } = {} Object.keys(params).forEach(k => d[k] = params[k].defaultValue) return d as { [k in keyof T]: T[k]['defaultValue'] } -- GitLab