From 0c6dd1bedc1226fc2ed06c64610c84ad02ac479e Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Tue, 6 Nov 2018 13:36:01 +0100 Subject: [PATCH] wip: refactoring param definition --- src/apps/canvas/component/representation.tsx | 8 +- src/mol-app/component/parameter/boolean.tsx | 4 +- .../component/parameter/multi-select.tsx | 4 +- src/mol-app/component/parameter/number.tsx | 4 +- src/mol-app/component/parameter/range.tsx | 4 +- src/mol-app/component/parameter/select.tsx | 4 +- src/mol-app/component/parameter/text.tsx | 4 +- src/mol-app/component/parameters.tsx | 8 +- .../geometry/direct-volume/direct-volume.ts | 12 +-- src/mol-geo/geometry/geometry.ts | 20 ++-- src/mol-geo/geometry/lines/lines.ts | 12 +-- src/mol-geo/geometry/mesh/mesh.ts | 10 +- src/mol-geo/geometry/points/points.ts | 16 ++-- .../structure/unit/gaussian-density.ts | 14 +-- src/mol-repr/index.ts | 8 +- src/mol-repr/shape/index.ts | 6 +- src/mol-repr/structure/complex-visual.ts | 10 +- src/mol-repr/structure/index.ts | 16 ++-- .../structure/representation/backbone.ts | 4 +- .../representation/ball-and-stick.ts | 12 +-- .../structure/representation/carbohydrate.ts | 10 +- .../structure/representation/cartoon.ts | 8 +- .../representation/distance-restraint.ts | 8 +- .../representation/molecular-surface.ts | 6 +- .../structure/representation/point.ts | 4 +- .../structure/representation/spacefill.ts | 4 +- src/mol-repr/structure/units-visual.ts | 14 +-- .../visual/carbohydrate-link-cylinder.ts | 10 +- .../visual/carbohydrate-symbol-mesh.ts | 10 +- .../visual/cross-link-restraint-cylinder.ts | 8 +- .../structure/visual/element-point.ts | 10 +- .../structure/visual/element-sphere.ts | 12 +-- .../visual/gaussian-density-point.ts | 10 +- .../visual/gaussian-density-volume.ts | 4 +- .../structure/visual/gaussian-surface-mesh.ts | 4 +- .../visual/gaussian-surface-wireframe.ts | 10 +- .../visual/inter-unit-link-cylinder.ts | 10 +- .../visual/intra-unit-link-cylinder.ts | 10 +- .../structure/visual/nucleotide-block-mesh.ts | 4 +- .../visual/polymer-backbone-cylinder.ts | 12 +-- .../visual/polymer-direction-wedge.ts | 10 +- .../structure/visual/polymer-gap-cylinder.ts | 22 ++--- .../structure/visual/polymer-trace-mesh.ts | 20 ++-- src/mol-repr/structure/visual/util/link.ts | 18 ++-- src/mol-repr/volume/direct-volume.ts | 4 +- src/mol-repr/volume/index.ts | 8 +- src/mol-repr/volume/isosurface-mesh.ts | 8 +- src/mol-state/transformer.ts | 4 +- src/mol-util/param-definition.ts | 93 +++++++++++++++++++ src/mol-util/parameter.ts | 90 ------------------ 50 files changed, 314 insertions(+), 311 deletions(-) create mode 100644 src/mol-util/param-definition.ts delete mode 100644 src/mol-util/parameter.ts diff --git a/src/apps/canvas/component/representation.tsx b/src/apps/canvas/component/representation.tsx index bb68eed9c..8bbdf8bae 100644 --- a/src/apps/canvas/component/representation.tsx +++ b/src/apps/canvas/component/representation.tsx @@ -7,7 +7,7 @@ import * as React from 'react' import Canvas3D from 'mol-canvas3d/canvas3d'; import { App } from '../app'; -import { Params } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Representation } from 'mol-repr'; import { ParametersComponent } from 'mol-app/component/parameters'; import { ColorTheme } from 'mol-theme/color'; @@ -17,18 +17,18 @@ import { ColorThemeComponent } from 'mol-app/component/color-theme'; export interface RepresentationComponentProps { app: App canvas3d: Canvas3D - repr: Representation<Params> + repr: Representation<PD.Params> } export interface RepresentationComponentState { label: string - reprParams: Params + reprParams: PD.Params reprProps: Readonly<{}> } export class RepresentationComponent extends React.Component<RepresentationComponentProps, RepresentationComponentState> { - private stateFromRepr(repr: Representation<Params>) { + private stateFromRepr(repr: Representation<PD.Params>) { return { label: this.props.repr.label, reprParams: this.props.repr.params, diff --git a/src/mol-app/component/parameter/boolean.tsx b/src/mol-app/component/parameter/boolean.tsx index 5862efc1d..70c5c76df 100644 --- a/src/mol-app/component/parameter/boolean.tsx +++ b/src/mol-app/component/parameter/boolean.tsx @@ -5,10 +5,10 @@ */ import * as React from 'react' -import { BooleanParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface BooleanParamComponentProps { - param: BooleanParam + param: PD.BooleanParam 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 79e66af6b..d399f4f84 100644 --- a/src/mol-app/component/parameter/multi-select.tsx +++ b/src/mol-app/component/parameter/multi-select.tsx @@ -5,10 +5,10 @@ */ import * as React from 'react' -import { MultiSelectParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface MultiSelectParamComponentProps<T extends string> { - param: MultiSelectParam<T> + param: PD.MultiSelectParam<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 c693b7d91..cbf766ec9 100644 --- a/src/mol-app/component/parameter/number.tsx +++ b/src/mol-app/component/parameter/number.tsx @@ -5,10 +5,10 @@ */ import * as React from 'react' -import { NumberParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface NumberParamComponentProps { - param: NumberParam + param: PD.NumberParam 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 42d5450a1..7fe8d6d7f 100644 --- a/src/mol-app/component/parameter/range.tsx +++ b/src/mol-app/component/parameter/range.tsx @@ -5,10 +5,10 @@ */ import * as React from 'react' -import { RangeParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface RangeParamComponentProps { - param: RangeParam + param: PD.RangeParam 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 c0034953f..45374f177 100644 --- a/src/mol-app/component/parameter/select.tsx +++ b/src/mol-app/component/parameter/select.tsx @@ -5,10 +5,10 @@ */ import * as React from 'react' -import { SelectParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface SelectParamComponentProps<T extends string> { - param: SelectParam<T> + param: PD.SelectParam<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 507754f5f..d902e09bd 100644 --- a/src/mol-app/component/parameter/text.tsx +++ b/src/mol-app/component/parameter/text.tsx @@ -5,10 +5,10 @@ */ import * as React from 'react' -import { TextParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface TextParamComponentProps { - param: TextParam + param: PD.TextParam value: string onChange(v: string): void } diff --git a/src/mol-app/component/parameters.tsx b/src/mol-app/component/parameters.tsx index 0fc247b25..88b68e910 100644 --- a/src/mol-app/component/parameters.tsx +++ b/src/mol-app/component/parameters.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { Param, Params } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { BooleanParamComponent } from './parameter/boolean'; import { NumberParamComponent } from './parameter/number'; import { RangeParamComponent } from './parameter/range'; @@ -13,7 +13,7 @@ import { SelectParamComponent } from './parameter/select'; import { MultiSelectParamComponent } from './parameter/multi-select'; import { TextParamComponent } from './parameter/text'; -interface ParametersProps<P extends Params> { +interface ParametersProps<P extends PD.Params> { params: P values: { [k in keyof P]: P[k]['defaultValue'] } onChange<K extends keyof P>(k: K, v: P[K]['defaultValue']): void @@ -21,7 +21,7 @@ interface ParametersProps<P extends Params> { type ParametersState = {} -function getParamComponent<P extends Param>(p: Param, value: P['defaultValue'], onChange: (v: P['defaultValue']) => void) { +function getParamComponent<P extends PD.Param>(p: PD.Param, value: P['defaultValue'], onChange: (v: P['defaultValue']) => void) { switch (p.type) { case 'boolean': return <BooleanParamComponent param={p} value={value} onChange={onChange} /> @@ -39,7 +39,7 @@ function getParamComponent<P extends Param>(p: Param, value: P['defaultValue'], return '' } -export class ParametersComponent<P extends Params> extends React.Component<ParametersProps<P>, ParametersState> { +export class ParametersComponent<P extends PD.Params> extends React.Component<ParametersProps<P>, ParametersState> { onChange(k: string, value: any) { this.props.onChange(k, value) } diff --git a/src/mol-geo/geometry/direct-volume/direct-volume.ts b/src/mol-geo/geometry/direct-volume/direct-volume.ts index d0057084b..e50fd86a1 100644 --- a/src/mol-geo/geometry/direct-volume/direct-volume.ts +++ b/src/mol-geo/geometry/direct-volume/direct-volume.ts @@ -7,7 +7,7 @@ import { RuntimeContext } from 'mol-task' import { ValueCell } from 'mol-util' import { Sphere3D, Box3D } from 'mol-math/geometry' -import { paramDefaultValues, RangeParam, SelectParam, TextParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { DirectVolumeValues } from 'mol-gl/renderable/direct-volume'; import { Vec3, Mat4 } from 'mol-math/linear-algebra'; import { Box } from '../../primitive/box'; @@ -67,12 +67,12 @@ export namespace DirectVolume { export const Params = { ...Geometry.Params, - isoValueAbsolute: RangeParam('Iso Value Absolute', '', 0.22, -1, 1, 0.01), - isoValueRelative: RangeParam('Iso Value Relative', '', 2, -10, 10, 0.1), - renderMode: SelectParam('Render Mode', '', 'isosurface', RenderModeOptions), - controlPoints: TextParam('Control Points', '', '0.19:0.1, 0.2:0.5, 0.21:0.1, 0.4:0.3'), + 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'), } - export const DefaultProps = paramDefaultValues(Params) + export const DefaultProps = PD.paramDefaultValues(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 57df5ab48..72b6be162 100644 --- a/src/mol-geo/geometry/geometry.ts +++ b/src/mol-geo/geometry/geometry.ts @@ -15,7 +15,7 @@ import { LocationIterator } from '../util/location-iterator'; import { ColorType } from './color-data'; import { SizeType } from './size-data'; import { Lines } from './lines/lines'; -import { paramDefaultValues, RangeParam, BooleanParam, SelectParam, ColorParam } from 'mol-util/parameter' +import { ParamDefinition as PD } from 'mol-util/param-definition' import { DirectVolume } from './direct-volume/direct-volume'; // @@ -59,16 +59,16 @@ export namespace Geometry { // export const Params = { - alpha: RangeParam('Opacity', '', 1, 0, 1, 0.01), - visible: BooleanParam('Visible', '', true), - depthMask: BooleanParam('Depth Mask', '', true), - useFog: BooleanParam('Use Fog', '', false), - quality: SelectParam<VisualQuality>('Quality', '', 'auto', VisualQualityOptions), - colorTheme: SelectParam<ColorThemeName>('Color Theme', '', 'uniform', ColorThemeOptions), - colorList: SelectParam<ColorScaleName>('Color Scale', '', 'default', ColorScaleOptions), - colorValue: ColorParam('Color Value', '', Color(0xCCCCCC)), + 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)), } - export const DefaultProps = paramDefaultValues(Params) + export const DefaultProps = PD.paramDefaultValues(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 a6a7c83bd..8e23ce62f 100644 --- a/src/mol-geo/geometry/lines/lines.ts +++ b/src/mol-geo/geometry/lines/lines.ts @@ -18,7 +18,7 @@ import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { LinesValues } from 'mol-gl/renderable/lines'; import { Mesh } from '../mesh/mesh'; import { LinesBuilder } from './lines-builder'; -import { BooleanParam, SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; /** Wide line */ export interface Lines { @@ -93,12 +93,12 @@ export namespace Lines { export const Params = { ...Geometry.Params, - lineSizeAttenuation: BooleanParam('Line Size Attenuation', '', false), - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 10, 0.1), - sizeFactor: NumberParam('Size Factor', '', 1, 0, 10, 0.1), + 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), } - export const DefaultProps = paramDefaultValues(Params) + export const DefaultProps = PD.paramDefaultValues(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 14a204f9c..14325482d 100644 --- a/src/mol-geo/geometry/mesh/mesh.ts +++ b/src/mol-geo/geometry/mesh/mesh.ts @@ -16,7 +16,7 @@ import { TransformData } from '../transform-data'; import { LocationIterator } from '../../util/location-iterator'; import { createColors } from '../color-data'; import { ChunkedArray } from 'mol-data/util'; -import { BooleanParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface Mesh { readonly kind: 'mesh', @@ -339,11 +339,11 @@ export namespace Mesh { export const Params = { ...Geometry.Params, - doubleSided: BooleanParam('Double Sided', '', false), - flipSided: BooleanParam('Flip Sided', '', false), - flatShaded: BooleanParam('Flat Shaded', '', false), + doubleSided: PD.BooleanParam('Double Sided', '', false), + flipSided: PD.BooleanParam('Flip Sided', '', false), + flatShaded: PD.BooleanParam('Flat Shaded', '', false), } - export const DefaultProps = paramDefaultValues(Params) + export const DefaultProps = PD.paramDefaultValues(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 277528b60..9c33fb0c9 100644 --- a/src/mol-geo/geometry/points/points.ts +++ b/src/mol-geo/geometry/points/points.ts @@ -16,7 +16,7 @@ import { createSizes } from '../size-data'; import { TransformData } from '../transform-data'; import { LocationIterator } from '../../util/location-iterator'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; -import { BooleanParam, NumberParam, SelectParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; /** Point cloud */ export interface Points { @@ -55,14 +55,14 @@ export namespace Points { export const Params = { ...Geometry.Params, - pointSizeAttenuation: BooleanParam('Point Size Attenuation', '', false), - pointFilledCircle: BooleanParam('Point Filled Circle', '', false), - pointEdgeBleach: NumberParam('Point Edge Bleach', '', 0.2, 0, 1, 0.05), - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 20, 0.1), - sizeFactor: NumberParam('Size Factor', '', 1, 0, 10, 0.1), + 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), } - export const DefaultProps = paramDefaultValues(Params) + export const DefaultProps = PD.paramDefaultValues(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 66290495e..7a0ca0126 100644 --- a/src/mol-model/structure/structure/unit/gaussian-density.ts +++ b/src/mol-model/structure/structure/unit/gaussian-density.ts @@ -9,19 +9,19 @@ import { SizeTheme } from 'mol-theme/size'; import { GaussianDensity } from 'mol-math/geometry/gaussian-density'; import { Task, RuntimeContext } from 'mol-task'; import { DensityData } from 'mol-math/geometry'; -import { NumberParam, paramDefaultValues, BooleanParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { GaussianDensityTexture } from 'mol-math/geometry/gaussian-density/gpu'; import { Texture } from 'mol-gl/webgl/texture'; import { WebGLContext } from 'mol-gl/webgl/context'; export const GaussianDensityParams = { - resolution: NumberParam('Resolution', '', 1, 0.1, 10, 0.1), - radiusOffset: NumberParam('Radius Offset', '', 0, 0, 10, 0.1), - smoothness: NumberParam('Smoothness', '', 1.5, 0.5, 2.5, 0.1), - useGpu: BooleanParam('Use GPU', '', true), - ignoreCache: BooleanParam('Ignore Cache', '', false), + 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), } -export const DefaultGaussianDensityProps = paramDefaultValues(GaussianDensityParams) +export const DefaultGaussianDensityProps = PD.paramDefaultValues(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 a293cf595..6f9160fef 100644 --- a/src/mol-repr/index.ts +++ b/src/mol-repr/index.ts @@ -9,7 +9,7 @@ import { RenderObject } from 'mol-gl/render-object' import { PickingId } from '../mol-geo/geometry/picking'; import { Loci, isEmptyLoci, EmptyLoci } from 'mol-model/loci'; import { MarkerAction } from '../mol-geo/geometry/marker-data'; -import { Params, MultiSelectParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { WebGLContext } from 'mol-gl/webgl/context'; // import { ColorTheme } from 'mol-theme/color'; @@ -24,7 +24,7 @@ export interface RepresentationContext { export interface Representation<D, P extends RepresentationProps = {}> { readonly label: string - readonly params: Params + readonly params: PD.Params readonly renderObjects: ReadonlyArray<RenderObject> readonly props: Readonly<P> createOrUpdate: (ctx: RepresentationContext, props?: Partial<P>, data?: D) => Task<void> @@ -34,7 +34,7 @@ export interface Representation<D, P extends RepresentationProps = {}> { } export namespace Representation { - export function createMulti<D, P extends RepresentationProps = {}>(label: string, params: Params, defaultProps: P, reprList: Representation<D, P>[]): Representation<D, P> { + export function createMulti<D, P extends RepresentationProps = {}>(label: string, params: PD.Params, defaultProps: P, reprList: Representation<D, P>[]): Representation<D, P> { let currentProps: P let currentData: D @@ -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'] = MultiSelectParam<string>('Visuals', '', ['surface'], visualsOptions) + params['visuals'] = PD.MultiSelectParam<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 209f2b2aa..a69e3da36 100644 --- a/src/mol-repr/shape/index.ts +++ b/src/mol-repr/shape/index.ts @@ -12,7 +12,7 @@ import { ValueCell } from 'mol-util'; import { ColorThemeName, ColorThemeOptions } from 'mol-theme/color'; import { Shape } from 'mol-model/shape'; import { OrderedSet, Interval } from 'mol-data/int'; -import { paramDefaultValues, SelectParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { createIdentityTransform } from 'mol-geo/geometry/transform-data'; import { createRenderableState } from 'mol-geo/geometry/geometry'; @@ -24,9 +24,9 @@ export interface ShapeRepresentation<P extends RepresentationProps = {}> extends export const ShapeParams = { ...Mesh.Params, - colorTheme: SelectParam<ColorThemeName>('Color Theme', '', 'shape-group', ColorThemeOptions) + colorTheme: PD.SelectParam<ColorThemeName>('Color Theme', '', 'shape-group', ColorThemeOptions) } -export const DefaultShapeProps = paramDefaultValues(ShapeParams) +export const DefaultShapeProps = PD.paramDefaultValues(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 788562797..7c7d3af03 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -12,7 +12,7 @@ import { StructureProps, StructureMeshParams, StructureParams } from './index'; import { deepEqual, ValueCell } from 'mol-util'; import { Loci, isEveryLoci, EmptyLoci } from 'mol-model/loci'; import { Interval } from 'mol-data/int'; -import { MultiSelectParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { RenderableValues } from 'mol-gl/renderable/schema'; import { createSizes } from 'mol-geo/geometry/size-data'; import { Geometry, updateRenderableState } from 'mol-geo/geometry/geometry'; @@ -27,9 +27,9 @@ export interface ComplexVisual<P extends StructureProps> extends Visual<Structu const ComplexParams = { ...StructureParams, - unitKinds: MultiSelectParam<UnitKind>('Unit Kind', '', ['atomic', 'spheres'], UnitKindOptions), + unitKinds: PD.MultiSelectParam<UnitKind>('Unit Kind', '', ['atomic', 'spheres'], UnitKindOptions), } -const DefaultComplexProps = paramDefaultValues(ComplexParams) +const DefaultComplexProps = PD.paramDefaultValues(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: MultiSelectParam<UnitKind>('Unit Kind', '', [ 'atomic', 'spheres' ], UnitKindOptions), + unitKinds: PD.MultiSelectParam<UnitKind>('Unit Kind', '', [ 'atomic', 'spheres' ], UnitKindOptions), } -export const DefaultComplexMeshProps = paramDefaultValues(ComplexMeshParams) +export const DefaultComplexMeshProps = PD.paramDefaultValues(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 03a58d51a..1bf903225 100644 --- a/src/mol-repr/structure/index.ts +++ b/src/mol-repr/structure/index.ts @@ -9,7 +9,7 @@ import { Structure } from 'mol-model/structure'; import { ColorThemeName, ColorThemeOptions } from 'mol-theme/color'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { Representation, RepresentationProps } from '..'; -import { SelectParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Geometry } from 'mol-geo/geometry/geometry'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { Points } from 'mol-geo/geometry/points/points'; @@ -21,38 +21,38 @@ export interface StructureRepresentation<P extends RepresentationProps = {}> ext export const StructureParams = { ...Geometry.Params, - colorTheme: SelectParam<ColorThemeName>('Color Theme', '', 'polymer-index', ColorThemeOptions), - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + colorTheme: PD.SelectParam<ColorThemeName>('Color Theme', '', 'polymer-index', ColorThemeOptions), + sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), } -export const DefaultStructureProps = paramDefaultValues(StructureParams) +export const DefaultStructureProps = PD.paramDefaultValues(StructureParams) export type StructureProps = typeof DefaultStructureProps export const StructureMeshParams = { ...Mesh.Params, ...StructureParams, } -export const DefaultStructureMeshProps = paramDefaultValues(StructureMeshParams) +export const DefaultStructureMeshProps = PD.paramDefaultValues(StructureMeshParams) export type StructureMeshProps = typeof DefaultStructureMeshProps export const StructurePointsParams = { ...Points.Params, ...StructureParams, } -export const DefaultStructurePointsProps = paramDefaultValues(StructurePointsParams) +export const DefaultStructurePointsProps = PD.paramDefaultValues(StructurePointsParams) export type StructurePointsProps = typeof DefaultStructurePointsProps export const StructureLinesParams = { ...Lines.Params, ...StructureParams, } -export const DefaultStructureLinesProps = paramDefaultValues(StructureLinesParams) +export const DefaultStructureLinesProps = PD.paramDefaultValues(StructureLinesParams) export type StructureLinesProps = typeof DefaultStructureLinesProps export const StructureDirectVolumeParams = { ...DirectVolume.Params, ...StructureParams, } -export const DefaultStructureDirectVolumeProps = paramDefaultValues(StructureDirectVolumeParams) +export const DefaultStructureDirectVolumeProps = PD.paramDefaultValues(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 eea531a2e..67443b92b 100644 --- a/src/mol-repr/structure/representation/backbone.ts +++ b/src/mol-repr/structure/representation/backbone.ts @@ -5,7 +5,7 @@ */ import { PolymerBackboneVisual, PolymerBackboneParams } from '../visual/polymer-backbone-cylinder'; -import { paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { UnitsRepresentation } from '../units-representation'; import { StructureRepresentation } from '../index'; import { Representation } from 'mol-repr'; @@ -13,7 +13,7 @@ import { Representation } from 'mol-repr'; export const BackboneParams = { ...PolymerBackboneParams } -export const DefaultBackboneProps = paramDefaultValues(BackboneParams) +export const DefaultBackboneProps = PD.paramDefaultValues(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 f4271f3a8..c74f4f714 100644 --- a/src/mol-repr/structure/representation/ball-and-stick.ts +++ b/src/mol-repr/structure/representation/ball-and-stick.ts @@ -8,7 +8,7 @@ import { ElementSphereVisual, ElementSphereParams } from '../visual/element-sphe import { IntraUnitLinkVisual, IntraUnitLinkParams } from '../visual/intra-unit-link-cylinder'; import { InterUnitLinkVisual, InterUnitLinkParams } from '../visual/inter-unit-link-cylinder'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; -import { paramDefaultValues, SelectParam, NumberParam, MultiSelectParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { UnitKind, UnitKindOptions } from '../visual/util/common'; import { UnitsRepresentation } from '../units-representation'; import { ComplexRepresentation } from '../complex-representation'; @@ -19,12 +19,12 @@ export const BallAndStickParams = { ...ElementSphereParams, ...IntraUnitLinkParams, ...InterUnitLinkParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 0.2, 0, 10, 0.1), - sizeFactor: NumberParam('Size Factor', '', 1, 0, 10, 0.1), - unitKinds: MultiSelectParam<UnitKind>('Unit Kind', '', ['atomic'], UnitKindOptions), + 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), } -export const DefaultBallAndStickProps = paramDefaultValues(BallAndStickParams) +export const DefaultBallAndStickProps = PD.paramDefaultValues(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 941fda887..d8cd83298 100644 --- a/src/mol-repr/structure/representation/carbohydrate.ts +++ b/src/mol-repr/structure/representation/carbohydrate.ts @@ -7,7 +7,7 @@ import { CarbohydrateSymbolVisual, CarbohydrateSymbolParams } from '../visual/carbohydrate-symbol-mesh'; import { CarbohydrateLinkVisual, CarbohydrateLinkParams } from '../visual/carbohydrate-link-cylinder'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; -import { paramDefaultValues, SelectParam, NumberParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { ComplexRepresentation } from '../complex-representation'; import { StructureRepresentation } from '../index'; import { Representation } from 'mol-repr'; @@ -15,11 +15,11 @@ import { Representation } from 'mol-repr'; export const CarbohydrateParams = { ...CarbohydrateSymbolParams, ...CarbohydrateLinkParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 0.1, 20), - sizeFactor: NumberParam('Size Factor', '', 1, 0, 10, 0.1), + 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), } -export const DefaultCarbohydrateProps = paramDefaultValues(CarbohydrateParams) +export const DefaultCarbohydrateProps = PD.paramDefaultValues(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 6a4e48bb0..1c2b9e8e0 100644 --- a/src/mol-repr/structure/representation/cartoon.ts +++ b/src/mol-repr/structure/representation/cartoon.ts @@ -8,7 +8,7 @@ import { PolymerTraceVisual, PolymerTraceParams } from '../visual/polymer-trace import { PolymerGapVisual, PolymerGapParams } from '../visual/polymer-gap-cylinder'; import { NucleotideBlockVisual, NucleotideBlockParams } from '../visual/nucleotide-block-mesh'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; -import { paramDefaultValues, SelectParam, NumberParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { UnitsRepresentation } from '../units-representation'; import { StructureRepresentation } from '../index'; import { Representation } from 'mol-repr'; @@ -19,10 +19,10 @@ export const CartoonParams = { ...PolymerGapParams, ...NucleotideBlockParams, // ...PolymerDirectionParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 0.6, 0, 10, 0.1), + sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.NumberParam('Size Value', '', 0.6, 0, 10, 0.1), } -export const DefaultCartoonProps = paramDefaultValues(CartoonParams) +export const DefaultCartoonProps = PD.paramDefaultValues(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 28509b3fb..7f5c182de 100644 --- a/src/mol-repr/structure/representation/distance-restraint.ts +++ b/src/mol-repr/structure/representation/distance-restraint.ts @@ -6,17 +6,17 @@ import { CrossLinkRestraintVisual, CrossLinkRestraintParams } from '../visual/cross-link-restraint-cylinder'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; -import { paramDefaultValues, SelectParam, NumberParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { ComplexRepresentation } from '../complex-representation'; import { StructureRepresentation } from '../index'; import { Representation } from 'mol-repr'; export const DistanceRestraintParams = { ...CrossLinkRestraintParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 0.25, 0, 0.05, 20), + sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.NumberParam('Size Value', '', 0.25, 0, 0.05, 20), } -export const DefaultDistanceRestraintProps = paramDefaultValues(DistanceRestraintParams) +export const DefaultDistanceRestraintProps = PD.paramDefaultValues(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 eed341e26..7cf03191c 100644 --- a/src/mol-repr/structure/representation/molecular-surface.ts +++ b/src/mol-repr/structure/representation/molecular-surface.ts @@ -7,7 +7,7 @@ import { GaussianSurfaceVisual, GaussianSurfaceParams } from '../visual/gaussian-surface-mesh'; import { UnitsRepresentation } from '../units-representation'; import { GaussianWireframeVisual, GaussianWireframeParams } from '../visual/gaussian-surface-wireframe'; -import { paramDefaultValues, SelectParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { GaussianDensityVolumeParams, GaussianDensityVolumeVisual } from '../visual/gaussian-density-volume'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { StructureRepresentation } from '../index'; @@ -17,9 +17,9 @@ export const MolecularSurfaceParams = { ...GaussianSurfaceParams, ...GaussianWireframeParams, ...GaussianDensityVolumeParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), } -export const DefaultMolecularSurfaceProps = { ...paramDefaultValues(MolecularSurfaceParams), visuals: [ '0' ] } +export const DefaultMolecularSurfaceProps = { ...PD.paramDefaultValues(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 fc4637af4..980e4c7d5 100644 --- a/src/mol-repr/structure/representation/point.ts +++ b/src/mol-repr/structure/representation/point.ts @@ -6,14 +6,14 @@ import { ElementPointVisual, ElementPointParams } from '../visual/element-point'; import { UnitsRepresentation } from '../units-representation'; -import { paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { StructureRepresentation } from '../index'; import { Representation } from 'mol-repr'; export const PointParams = { ...ElementPointParams, } -export const DefaultPointProps = paramDefaultValues(PointParams) +export const DefaultPointProps = PD.paramDefaultValues(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 d5a19bcc1..d309a30c9 100644 --- a/src/mol-repr/structure/representation/spacefill.ts +++ b/src/mol-repr/structure/representation/spacefill.ts @@ -6,14 +6,14 @@ import { ElementSphereVisual, ElementSphereParams } from '../visual/element-sphere'; import { UnitsRepresentation } from '../units-representation'; -import { paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { StructureRepresentation } from '../index'; import { Representation } from 'mol-repr'; export const SpacefillParams = { ...ElementSphereParams } -export const DefaultSpacefillProps = paramDefaultValues(SpacefillParams) +export const DefaultSpacefillProps = PD.paramDefaultValues(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 7f8ef1969..269db19ba 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -12,7 +12,7 @@ import { MeshRenderObject, PointsRenderObject, LinesRenderObject, DirectVolumeRe import { createUnitsMeshRenderObject, createUnitsPointsRenderObject, createUnitsTransform, createUnitsLinesRenderObject, createUnitsDirectVolumeRenderObject, UnitKind, UnitKindOptions, includesUnitKind } from './visual/util/common'; import { deepEqual, ValueCell, UUID } from 'mol-util'; import { Interval } from 'mol-data/int'; -import { MultiSelectParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { RenderableValues } from 'mol-gl/renderable/schema'; import { Geometry, updateRenderableState } from 'mol-geo/geometry/geometry'; import { LocationIterator } from 'mol-geo/util/location-iterator'; @@ -39,9 +39,9 @@ function sameGroupConformation(groupA: Unit.SymmetryGroup, groupB: Unit.Symmetry const UnitsParams = { ...StructureParams, - unitKinds: MultiSelectParam<UnitKind>('Unit Kind', '', ['atomic', 'spheres'], UnitKindOptions), + unitKinds: PD.MultiSelectParam<UnitKind>('Unit Kind', '', ['atomic', 'spheres'], UnitKindOptions), } -const DefaultUnitsProps = paramDefaultValues(UnitsParams) +const DefaultUnitsProps = PD.paramDefaultValues(UnitsParams) type UnitsProps = typeof DefaultUnitsProps type UnitsRenderObject = MeshRenderObject | LinesRenderObject | PointsRenderObject | DirectVolumeRenderObject @@ -205,7 +205,7 @@ export const UnitsMeshParams = { ...StructureMeshParams, ...UnitsParams, } -export const DefaultUnitsMeshProps = paramDefaultValues(UnitsMeshParams) +export const DefaultUnitsMeshProps = PD.paramDefaultValues(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 = paramDefaultValues(UnitsPointsParams) +export const DefaultUnitsPointsProps = PD.paramDefaultValues(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 = paramDefaultValues(UnitsLinesParams) +export const DefaultUnitsLinesProps = PD.paramDefaultValues(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 = paramDefaultValues(UnitsDirectVolumeParams) +export const DefaultUnitsDirectVolumeProps = PD.paramDefaultValues(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 0b064012b..303a0b28a 100644 --- a/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts +++ b/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts @@ -14,7 +14,7 @@ import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { LinkType } from 'mol-model/structure/model/types'; import { BitFlags } from 'mol-util'; import { UnitsMeshParams } from '../units-visual'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { LocationIterator } from 'mol-geo/util/location-iterator'; import { PickingId } from 'mol-geo/geometry/picking'; @@ -64,11 +64,11 @@ async function createCarbohydrateLinkCylinderMesh(ctx: VisualContext, structure: export const CarbohydrateLinkParams = { ...UnitsMeshParams, ...LinkCylinderParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 20, 0.1), - detail: NumberParam('Sphere Detail', '', 0, 0, 3, 1), + 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), } -export const DefaultCarbohydrateLinkProps = paramDefaultValues(CarbohydrateLinkParams) +export const DefaultCarbohydrateLinkProps = PD.paramDefaultValues(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 ddbd3215d..218017ff7 100644 --- a/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts +++ b/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts @@ -17,7 +17,7 @@ import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { getSaccharideShape, SaccharideShapes } from 'mol-model/structure/structure/carbohydrates/constants'; import { addSphere } from 'mol-geo/geometry/mesh/builder/sphere'; import { ComplexMeshParams, ComplexMeshVisual } from '../complex-visual'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { ComplexVisual } from '../index'; import { VisualUpdateState } from '../../util'; import { LocationIterator } from 'mol-geo/util/location-iterator'; @@ -148,11 +148,11 @@ async function createCarbohydrateSymbolMesh(ctx: VisualContext, structure: Struc export const CarbohydrateSymbolParams = { ...ComplexMeshParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 10, 0.1), - detail: NumberParam('Sphere Detail', '', 0, 0, 3, 1), + 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), } -export const DefaultCarbohydrateSymbolProps = paramDefaultValues(CarbohydrateSymbolParams) +export const DefaultCarbohydrateSymbolProps = PD.paramDefaultValues(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 190565acb..87374bfb9 100644 --- a/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts +++ b/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts @@ -15,7 +15,7 @@ import { Interval } from 'mol-data/int'; import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-theme/size'; import { BitFlags } from 'mol-util'; import { LinkType } from 'mol-model/structure/model/types'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { LocationIterator } from 'mol-geo/util/location-iterator'; import { PickingId } from 'mol-geo/geometry/picking'; @@ -54,10 +54,10 @@ async function createCrossLinkRestraintCylinderMesh(ctx: VisualContext, structur export const CrossLinkRestraintParams = { ...ComplexMeshParams, ...LinkCylinderParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 20, 0.1), + sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), + sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), } -export const DefaultCrossLinkRestraintProps = paramDefaultValues(CrossLinkRestraintParams) +export const DefaultCrossLinkRestraintProps = PD.paramDefaultValues(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 c0b7ebb43..df0f81422 100644 --- a/src/mol-repr/structure/visual/element-point.ts +++ b/src/mol-repr/structure/visual/element-point.ts @@ -11,18 +11,18 @@ import { getElementLoci, StructureElementIterator, markElement } from './util/el import { Vec3 } from 'mol-math/linear-algebra'; import { SizeThemeOptions, SizeThemeName } from 'mol-theme/size'; import { UnitsPointsVisual, UnitsPointsParams } from '../units-visual'; -import { SelectParam, NumberParam, BooleanParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Points } from 'mol-geo/geometry/points/points'; import { PointsBuilder } from 'mol-geo/geometry/points/points-builder'; import { VisualContext } from 'mol-repr'; export const ElementPointParams = { ...UnitsPointsParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 3, 0, 20, 0.1), - pointSizeAttenuation: BooleanParam('Point Size Attenuation', '', false), + 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), } -export const DefaultElementPointProps = paramDefaultValues(ElementPointParams) +export const DefaultElementPointProps = PD.paramDefaultValues(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 abb930830..dd75f1b36 100644 --- a/src/mol-repr/structure/visual/element-sphere.ts +++ b/src/mol-repr/structure/visual/element-sphere.ts @@ -9,17 +9,17 @@ import { UnitsVisual } from '../index'; import { VisualUpdateState } from '../../util'; import { createElementSphereMesh, markElement, getElementLoci, StructureElementIterator } from './util/element'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; -import { NumberParam, paramDefaultValues, SelectParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; export const ElementSphereParams = { ...UnitsMeshParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 0.2, 0, 10, 0.1), - sizeFactor: NumberParam('Size Factor', '', 1, 0, 10, 0.1), - detail: NumberParam('Sphere Detail', '', 0, 0, 3, 1), + 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), } -export const DefaultElementSphereProps = paramDefaultValues(ElementSphereParams) +export const DefaultElementSphereProps = PD.paramDefaultValues(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 f14268e78..6cb02e33a 100644 --- a/src/mol-repr/structure/visual/gaussian-density-point.ts +++ b/src/mol-repr/structure/visual/gaussian-density-point.ts @@ -13,7 +13,7 @@ import { Vec3 } from 'mol-math/linear-algebra'; import { UnitsPointsVisual, UnitsPointsParams } from '../units-visual'; import { SizeThemeOptions, SizeThemeName } from 'mol-theme/size'; import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { paramDefaultValues, SelectParam, NumberParam, BooleanParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Points } from 'mol-geo/geometry/points/points'; import { PointsBuilder } from 'mol-geo/geometry/points/points-builder'; import { VisualContext } from 'mol-repr'; @@ -21,11 +21,11 @@ import { VisualContext } from 'mol-repr'; export const GaussianDensityPointParams = { ...UnitsPointsParams, ...GaussianDensityParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 20, 0.1), - pointSizeAttenuation: BooleanParam('Point Size Attenuation', '', false), + 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), } -export const DefaultGaussianDensityPointProps = paramDefaultValues(GaussianDensityPointParams) +export const DefaultGaussianDensityPointProps = PD.paramDefaultValues(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 e0b96b1f9..9117910c8 100644 --- a/src/mol-repr/structure/visual/gaussian-density-volume.ts +++ b/src/mol-repr/structure/visual/gaussian-density-volume.ts @@ -10,7 +10,7 @@ import { VisualUpdateState } from '../../util'; import { UnitsDirectVolumeVisual, UnitsDirectVolumeParams } from '../units-visual'; import { StructureElementIterator, getElementLoci, markElement } from './util/element'; import { GaussianDensityProps, GaussianDensityParams, computeUnitGaussianDensityTexture } from 'mol-model/structure/structure/unit/gaussian-density'; -import { paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { DirectVolume } from 'mol-geo/geometry/direct-volume/direct-volume'; import { VisualContext } from 'mol-repr'; @@ -30,7 +30,7 @@ export const GaussianDensityVolumeParams = { ...UnitsDirectVolumeParams, ...GaussianDensityParams, } -export const DefaultGaussianDensityVolumeProps = paramDefaultValues(GaussianDensityVolumeParams) +export const DefaultGaussianDensityVolumeProps = PD.paramDefaultValues(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 3e983cff2..836999cda 100644 --- a/src/mol-repr/structure/visual/gaussian-surface-mesh.ts +++ b/src/mol-repr/structure/visual/gaussian-surface-mesh.ts @@ -10,7 +10,7 @@ import { VisualUpdateState } from '../../util'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { StructureElementIterator, getElementLoci, markElement } from './util/element'; import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { computeMarchingCubesMesh } from 'mol-geo/util/marching-cubes/algorithm'; import { VisualContext } from 'mol-repr'; @@ -37,7 +37,7 @@ export const GaussianSurfaceParams = { ...UnitsMeshParams, ...GaussianDensityParams, } -export const DefaultGaussianSurfaceProps = paramDefaultValues(GaussianSurfaceParams) +export const DefaultGaussianSurfaceProps = PD.paramDefaultValues(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 1b3e30331..928b54c8d 100644 --- a/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts +++ b/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts @@ -10,7 +10,7 @@ import { VisualUpdateState } from '../../util'; import { UnitsLinesVisual, UnitsLinesParams } from '../units-visual'; import { StructureElementIterator, getElementLoci, markElement } from './util/element'; import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { paramDefaultValues, SelectParam, NumberParam, BooleanParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { Lines } from 'mol-geo/geometry/lines/lines'; import { computeMarchingCubesLines } from 'mol-geo/util/marching-cubes/algorithm'; @@ -35,11 +35,11 @@ async function createGaussianWireframe(ctx: VisualContext, unit: Unit, structure export const GaussianWireframeParams = { ...UnitsLinesParams, ...GaussianDensityParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 2, 0, 10, 0.1), - lineSizeAttenuation: BooleanParam('Line Size Attenuation', '', false), + 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), } -export const DefaultGaussianWireframeProps = paramDefaultValues(GaussianWireframeParams) +export const DefaultGaussianWireframeProps = PD.paramDefaultValues(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 76a51d680..85aaf11aa 100644 --- a/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts +++ b/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts @@ -14,7 +14,7 @@ import { ComplexMeshVisual, ComplexMeshParams } from '../complex-visual'; import { Interval } from 'mol-data/int'; import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { BitFlags } from 'mol-util'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { PickingId } from 'mol-geo/geometry/picking'; import { VisualContext } from 'mol-repr'; @@ -53,11 +53,11 @@ async function createInterUnitLinkCylinderMesh(ctx: VisualContext, structure: St export const InterUnitLinkParams = { ...ComplexMeshParams, ...LinkCylinderParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 0.2, 0, 10, 0.1), - sizeFactor: NumberParam('Size Factor', '', 1, 0, 10, 0.1), + 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), } -export const DefaultInterUnitLinkProps = paramDefaultValues(InterUnitLinkParams) +export const DefaultInterUnitLinkProps = PD.paramDefaultValues(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 b4239034c..9c54f5b06 100644 --- a/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts +++ b/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts @@ -15,7 +15,7 @@ import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { Interval } from 'mol-data/int'; import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { BitFlags } from 'mol-util'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { PickingId } from 'mol-geo/geometry/picking'; import { VisualContext } from 'mol-repr'; @@ -67,11 +67,11 @@ async function createIntraUnitLinkCylinderMesh(ctx: VisualContext, unit: Unit, s export const IntraUnitLinkParams = { ...UnitsMeshParams, ...LinkCylinderParams, - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 0.2, 0, 10, 0.1), - sizeFactor: NumberParam('Size Factor', '', 1, 0, 10, 0.1), + 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), } -export const DefaultIntraUnitLinkProps = paramDefaultValues(IntraUnitLinkParams) +export const DefaultIntraUnitLinkProps = PD.paramDefaultValues(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 9a2e83726..c5650f4a6 100644 --- a/src/mol-repr/structure/visual/nucleotide-block-mesh.ts +++ b/src/mol-repr/structure/visual/nucleotide-block-mesh.ts @@ -12,7 +12,7 @@ import { MoleculeType, isNucleic, isPurinBase, isPyrimidineBase } from 'mol-mode import { getElementIndexForAtomRole } from 'mol-model/structure/util'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { NucleotideLocationIterator, markNucleotideElement, getNucleotideElementLoci } from './util/nucleotide'; -import { paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Box } from 'mol-geo/primitive/box'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder'; @@ -114,7 +114,7 @@ async function createNucleotideBlockMesh(ctx: VisualContext, unit: Unit, structu export const NucleotideBlockParams = { ...UnitsMeshParams } -export const DefaultNucleotideBlockProps = paramDefaultValues(NucleotideBlockParams) +export const DefaultNucleotideBlockProps = PD.paramDefaultValues(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 6968ac9b5..9d89e3010 100644 --- a/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts +++ b/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts @@ -13,7 +13,7 @@ import { Vec3 } from 'mol-math/linear-algebra'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-theme/size'; import { OrderedSet } from 'mol-data/int'; -import { paramDefaultValues, NumberParam, SelectParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder'; import { CylinderProps } from 'mol-geo/primitive/cylinder'; @@ -21,11 +21,11 @@ import { addCylinder } from 'mol-geo/geometry/mesh/builder/cylinder'; import { VisualContext } from 'mol-repr'; export const PolymerBackboneCylinderParams = { - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 10, 0.1), - radialSegments: NumberParam('Radial Segments', '', 16, 3, 56, 1), + 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), } -export const DefaultPolymerBackboneCylinderProps = paramDefaultValues(PolymerBackboneCylinderParams) +export const DefaultPolymerBackboneCylinderProps = PD.paramDefaultValues(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 = paramDefaultValues(PolymerBackboneParams) +export const DefaultPolymerBackboneProps = PD.paramDefaultValues(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 461df57da..6ed09506b 100644 --- a/src/mol-repr/structure/visual/polymer-direction-wedge.ts +++ b/src/mol-repr/structure/visual/polymer-direction-wedge.ts @@ -11,7 +11,7 @@ import { Vec3, Mat4 } from 'mol-math/linear-algebra'; import { SecondaryStructureType, isNucleic } from 'mol-model/structure/model/types'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Wedge } from 'mol-geo/primitive/wedge'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder'; @@ -30,10 +30,10 @@ const heightFactor = 6 const wedge = Wedge() export const PolymerDirectionWedgeParams = { - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 20, 0.1), + sizeTheme: PD.SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), + sizeValue: PD.NumberParam('Size Value', '', 1, 0, 20, 0.1), } -export const DefaultPolymerDirectionWedgeProps = paramDefaultValues(PolymerDirectionWedgeParams) +export const DefaultPolymerDirectionWedgeProps = PD.paramDefaultValues(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 = paramDefaultValues(PolymerDirectionParams) +export const DefaultPolymerDirectionProps = PD.paramDefaultValues(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 c00559b24..5cf649eb0 100644 --- a/src/mol-repr/structure/visual/polymer-gap-cylinder.ts +++ b/src/mol-repr/structure/visual/polymer-gap-cylinder.ts @@ -11,7 +11,7 @@ import { PolymerGapIterator, PolymerGapLocationIterator, markPolymerGapElement, import { Vec3 } from 'mol-math/linear-algebra'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-theme/size'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { LinkCylinderParams } from './util/link'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder'; @@ -23,12 +23,12 @@ import { VisualContext } from 'mol-repr'; const segmentCount = 10 export const PolymerGapCylinderParams = { - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 10, 0.1), - sizeFactor: NumberParam('Size Factor', '', 0.3, 0, 10, 0.1), - radialSegments: NumberParam('Radial Segments', '', 16, 3, 56, 1), + 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), } -export const DefaultPolymerGapCylinderProps = paramDefaultValues(PolymerGapCylinderParams) +export const DefaultPolymerGapCylinderProps = PD.paramDefaultValues(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: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 20, 0.1), - sizeFactor: NumberParam('Size Factor', '', 0.3, 0, 10, 0.1), + 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), } -export const DefaultIntraUnitLinkProps = paramDefaultValues(InterUnitLinkParams) +export const DefaultIntraUnitLinkProps = PD.paramDefaultValues(InterUnitLinkParams) export type IntraUnitLinkProps = typeof DefaultIntraUnitLinkProps export const PolymerGapParams = { ...UnitsMeshParams, ...PolymerGapCylinderParams } -export const DefaultPolymerGapProps = paramDefaultValues(PolymerGapParams) +export const DefaultPolymerGapProps = PD.paramDefaultValues(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 941d9d651..be8b995d7 100644 --- a/src/mol-repr/structure/visual/polymer-trace-mesh.ts +++ b/src/mol-repr/structure/visual/polymer-trace-mesh.ts @@ -11,7 +11,7 @@ import { PolymerTraceIterator, createCurveSegmentState, interpolateCurveSegment, import { SecondaryStructureType, isNucleic } from 'mol-model/structure/model/types'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder'; import { addSheet } from 'mol-geo/geometry/mesh/builder/sheet'; @@ -19,15 +19,15 @@ import { addTube } from 'mol-geo/geometry/mesh/builder/tube'; import { VisualContext } from 'mol-repr'; export const PolymerTraceMeshParams = { - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 20, 0.1), - sizeFactor: NumberParam('Size Factor', '', 0.3, 0, 10, 0.1), - linearSegments: NumberParam('Linear Segments', '', 8, 1, 48, 1), - radialSegments: NumberParam('Radial Segments', '', 16, 3, 56, 1), - aspectRatio: NumberParam('Aspect Ratio', '', 5, 0.1, 5, 0.1), - arrowFactor: NumberParam('Arrow Factor', '', 1.5, 0.1, 5, 0.1), + 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), } -export const DefaultPolymerTraceMeshProps = paramDefaultValues(PolymerTraceMeshParams) +export const DefaultPolymerTraceMeshProps = PD.paramDefaultValues(PolymerTraceMeshParams) export type PolymerTraceMeshProps = typeof DefaultPolymerTraceMeshProps // TODO handle polymer ends properly @@ -93,7 +93,7 @@ export const PolymerTraceParams = { ...UnitsMeshParams, ...PolymerTraceMeshParams } -export const DefaultPolymerTraceProps = paramDefaultValues(PolymerTraceParams) +export const DefaultPolymerTraceProps = PD.paramDefaultValues(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 4f3931f48..7b8840c48 100644 --- a/src/mol-repr/structure/visual/util/link.ts +++ b/src/mol-repr/structure/visual/util/link.ts @@ -8,7 +8,7 @@ import { Vec3 } from 'mol-math/linear-algebra'; import { LinkType } from 'mol-model/structure/model/types'; import { SizeThemeName, SizeThemeOptions } from 'mol-theme/size'; import { Unit, StructureElement, Structure, Link } from 'mol-model/structure'; -import { SelectParam, RangeParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder'; import { CylinderProps } from 'mol-geo/primitive/cylinder'; @@ -17,15 +17,15 @@ import { LocationIterator } from 'mol-geo/util/location-iterator'; import { VisualContext } from 'mol-repr'; export const LinkCylinderParams = { - sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), - sizeValue: NumberParam('Size Value', '', 1, 0, 20, 0.1), - sizeFactor: NumberParam('Size Factor', '', 1, 0, 10, 0.1), - linkScale: RangeParam('Link Scale', '', 0.4, 0, 1, 0.1), - linkSpacing: RangeParam('Link Spacing', '', 1, 0, 2, 0.01), - linkRadius: RangeParam('Link Radius', '', 0.25, 0, 10, 0.05), - radialSegments: NumberParam('Radial Segments', '', 16, 3, 56, 1), + 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), } -export const DefaultLinkCylinderProps = paramDefaultValues(LinkCylinderParams) +export const DefaultLinkCylinderProps = PD.paramDefaultValues(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 ce412b099..c8264335f 100644 --- a/src/mol-repr/volume/direct-volume.ts +++ b/src/mol-repr/volume/direct-volume.ts @@ -9,7 +9,7 @@ import { RuntimeContext } from 'mol-task' import { VolumeVisual, VolumeRepresentation } from './index'; import { createDirectVolumeRenderObject } from 'mol-gl/render-object'; import { Loci, EmptyLoci } from 'mol-model/loci'; -import { paramDefaultValues } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Vec3, Mat4 } from 'mol-math/linear-algebra'; import { Box3D } from 'mol-math/geometry'; import { WebGLContext } from 'mol-gl/webgl/context'; @@ -187,7 +187,7 @@ export const DirectVolumeParams = { ...Geometry.Params, ...DirectVolume.Params } -export const DefaultDirectVolumeProps = paramDefaultValues(DirectVolumeParams) +export const DefaultDirectVolumeProps = PD.paramDefaultValues(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 f7d0ddded..3ad9c37f4 100644 --- a/src/mol-repr/volume/index.ts +++ b/src/mol-repr/volume/index.ts @@ -8,7 +8,7 @@ import { Task } from 'mol-task' import { RepresentationProps, Representation, Visual, RepresentationContext, VisualContext } from '..'; import { VolumeData, VolumeIsoValue } from 'mol-model/volume'; import { Loci, EmptyLoci, isEveryLoci } from 'mol-model/loci'; -import { paramDefaultValues, RangeParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Geometry, updateRenderableState } from 'mol-geo/geometry/geometry'; import { PickingId } from 'mol-geo/geometry/picking'; import { MarkerAction, applyMarkerAction } from 'mol-geo/geometry/marker-data'; @@ -136,10 +136,10 @@ export interface VolumeRepresentation<P extends RepresentationProps = {}> extend export const VolumeParams = { ...Geometry.Params, - isoValueAbsolute: RangeParam('Iso Value Absolute', '', 0.22, -1, 1, 0.01), - isoValueRelative: RangeParam('Iso Value Relative', '', 2, -10, 10, 0.1), + isoValueAbsolute: PD.RangeParam('Iso Value Absolute', '', 0.22, -1, 1, 0.01), + isoValueRelative: PD.RangeParam('Iso Value Relative', '', 2, -10, 10, 0.1), } -export const DefaultVolumeProps = paramDefaultValues(VolumeParams) +export const DefaultVolumeProps = PD.paramDefaultValues(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 1f81989e8..f569ec9c1 100644 --- a/src/mol-repr/volume/isosurface-mesh.ts +++ b/src/mol-repr/volume/isosurface-mesh.ts @@ -9,7 +9,7 @@ import { VolumeData } from 'mol-model/volume' import { VolumeVisual, VolumeRepresentation } from './index'; import { createMeshRenderObject } from 'mol-gl/render-object'; import { Loci, EmptyLoci } from 'mol-model/loci'; -import { paramDefaultValues, RangeParam } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { computeMarchingCubesMesh } from 'mol-geo/util/marching-cubes/algorithm'; import { LocationIterator } from 'mol-geo/util/location-iterator'; @@ -42,10 +42,10 @@ export async function createVolumeIsosurface(ctx: VisualContext, volume: VolumeD export const IsosurfaceParams = { ...Mesh.Params, - isoValueAbsolute: RangeParam('Iso Value Absolute', '', 0.22, -1, 1, 0.01), - isoValueRelative: RangeParam('Iso Value Relative', '', 2, -10, 10, 0.1), + isoValueAbsolute: PD.RangeParam('Iso Value Absolute', '', 0.22, -1, 1, 0.01), + isoValueRelative: PD.RangeParam('Iso Value Relative', '', 2, -10, 10, 0.1), } -export const DefaultIsosurfaceProps = paramDefaultValues(IsosurfaceParams) +export const DefaultIsosurfaceProps = PD.paramDefaultValues(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 6b9e0c7ab..80998a0b4 100644 --- a/src/mol-state/transformer.ts +++ b/src/mol-state/transformer.ts @@ -7,7 +7,7 @@ import { Task } from 'mol-task'; import { StateObject } from './object'; import { Transform } from './transform'; -import { Param } from 'mol-util/parameter'; +import { ParamDefinition as PD } from 'mol-util/param-definition'; export interface Transformer<A extends StateObject = StateObject, B extends StateObject = StateObject, P = unknown> { apply(params?: P, props?: Partial<Transform.Options>): Transform<A, B, P>, @@ -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) => Param) } + export type ControlsFor<A extends StateObject, Props> = { [P in keyof Props]?: ((a: A, globalCtx: unknown) => PD.Param) } 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 new file mode 100644 index 000000000..5d773abf0 --- /dev/null +++ b/src/mol-util/param-definition.ts @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author Alexander Rose <alexander.rose@weirdbyte.de> + */ + +import { Color } from './color'; + +export namespace ParamDefinition { + export interface BaseParam<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 SelectParam<T extends string> extends BaseParam<T> { + type: 'select' + /** array of (value, label) tupels */ + options: [T, string][] + } + export function SelectParam<T extends string>(label: string, description: string, defaultValue: T, options: [T, string][]): SelectParam<T> { + return { type: 'select', label, description, defaultValue, options } + } + + export interface MultiSelectParam<E extends string, T = E[]> extends BaseParam<T> { + type: 'multi-select' + /** array of (value, label) tupels */ + options: [E, string][] + } + export function MultiSelectParam<E extends string, T = E[]>(label: string, description: string, defaultValue: T, options: [E, string][]): MultiSelectParam<E, T> { + return { type: 'multi-select', label, description, defaultValue, options } + } + + export interface BooleanParam extends BaseParam<boolean> { + type: 'boolean' + } + export function BooleanParam(label: string, description: string, defaultValue: boolean): BooleanParam { + return { type: 'boolean', label, description, defaultValue } + } + + export interface RangeParam extends BaseParam<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 { + return { type: 'range', label, description, defaultValue, min, max, step } + } + + export interface TextParam extends BaseParam<string> { + type: 'text' + } + export function TextParam(label: string, description: string, defaultValue: string): TextParam { + return { type: 'text', label, description, defaultValue } + } + + export interface ColorParam extends BaseParam<Color> { + type: 'color' + } + export function ColorParam(label: string, description: string, defaultValue: Color): ColorParam { + return { type: 'color', label, description, defaultValue } + } + + export interface NumberParam extends BaseParam<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 { + 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 function paramDefaultValues<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'] } + } +} \ No newline at end of file diff --git a/src/mol-util/parameter.ts b/src/mol-util/parameter.ts deleted file mode 100644 index 5cfe46499..000000000 --- a/src/mol-util/parameter.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ - -import { Color } from './color'; - -export interface BaseParam<T> { - label: string - description: string - defaultValue: T -} - -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 SelectParam<T extends string> extends BaseParam<T> { - type: 'select' - /** array of (value, label) tupels */ - options: [T, string][] -} -export function SelectParam<T extends string>(label: string, description: string, defaultValue: T, options: [T, string][]): SelectParam<T> { - return { type: 'select', label, description, defaultValue, options } -} - -export interface MultiSelectParam<E extends string, T = E[]> extends BaseParam<T> { - type: 'multi-select' - /** array of (value, label) tupels */ - options: [E, string][] -} -export function MultiSelectParam<E extends string, T = E[]>(label: string, description: string, defaultValue: T, options: [E, string][]): MultiSelectParam<E, T> { - return { type: 'multi-select', label, description, defaultValue, options } -} - -export interface BooleanParam extends BaseParam<boolean> { - type: 'boolean' -} -export function BooleanParam(label: string, description: string, defaultValue: boolean): BooleanParam { - return { type: 'boolean', label, description, defaultValue } -} - -export interface RangeParam extends BaseParam<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 { - return { type: 'range', label, description, defaultValue, min, max, step } -} - -export interface TextParam extends BaseParam<string> { - type: 'text' -} -export function TextParam(label: string, description: string, defaultValue: string): TextParam { - return { type: 'text', label, description, defaultValue } -} - -export interface ColorParam extends BaseParam<Color> { - type: 'color' -} -export function ColorParam(label: string, description: string, defaultValue: Color): ColorParam { - return { type: 'color', label, description, defaultValue } -} - -export interface NumberParam extends BaseParam<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 { - 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 function paramDefaultValues<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'] } -} \ No newline at end of file -- GitLab