Skip to content
Snippets Groups Projects
Commit 1eb9d0ed authored by David Sehnal's avatar David Sehnal
Browse files

wip: param refactroing

parent 0c6dd1be
No related branches found
No related tags found
No related merge requests found
Showing
with 67 additions and 67 deletions
......@@ -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
}
......
......@@ -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
}
......
......@@ -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
}
......
......@@ -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
}
......
......@@ -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
}
......
......@@ -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
}
......
......@@ -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} />
......
......@@ -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> {
......
......@@ -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 }
......
......@@ -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> {
......
......@@ -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> {
......
......@@ -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> {
......
......@@ -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) {
......
......@@ -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())
......
......@@ -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
......
......@@ -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> { }
......
......@@ -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'
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment