From 7d10971617e1ac3017ba7e1fb37e50c3a92bfc08 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Thu, 29 Dec 2022 11:42:59 -0800 Subject: [PATCH] avoid cloning of structure repr params --- .../structure/representation/ball-and-stick.ts | 2 +- .../structure/representation/carbohydrate.ts | 4 ++-- src/mol-repr/structure/representation/ellipsoid.ts | 4 ++-- .../structure/representation/gaussian-surface.ts | 4 ++-- .../structure/representation/gaussian-volume.ts | 7 +++---- src/mol-repr/structure/representation/label.ts | 4 ++-- src/mol-repr/structure/representation/line.ts | 6 +++--- .../structure/representation/molecular-surface.ts | 2 +- .../structure/representation/orientation.ts | 4 ++-- src/mol-repr/structure/representation/point.ts | 4 ++-- src/mol-repr/structure/representation/spacefill.ts | 13 +++++++++---- 11 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/mol-repr/structure/representation/ball-and-stick.ts b/src/mol-repr/structure/representation/ball-and-stick.ts index 4de9b6418..ce9df14b6 100644 --- a/src/mol-repr/structure/representation/ball-and-stick.ts +++ b/src/mol-repr/structure/representation/ball-and-stick.ts @@ -37,7 +37,7 @@ export const BallAndStickParams = { }; export type BallAndStickParams = typeof BallAndStickParams export function getBallAndStickParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(BallAndStickParams); + return BallAndStickParams; } export type BallAndStickRepresentation = StructureRepresentation<BallAndStickParams> diff --git a/src/mol-repr/structure/representation/carbohydrate.ts b/src/mol-repr/structure/representation/carbohydrate.ts index 2ea4f8e63..9d4d49e85 100644 --- a/src/mol-repr/structure/representation/carbohydrate.ts +++ b/src/mol-repr/structure/representation/carbohydrate.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -30,7 +30,7 @@ export const CarbohydrateParams = { }; export type CarbohydrateParams = typeof CarbohydrateParams export function getCarbohydrateParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(CarbohydrateParams); + return CarbohydrateParams; } export type CarbohydrateRepresentation = StructureRepresentation<CarbohydrateParams> diff --git a/src/mol-repr/structure/representation/ellipsoid.ts b/src/mol-repr/structure/representation/ellipsoid.ts index 165b834f3..fb35f59df 100644 --- a/src/mol-repr/structure/representation/ellipsoid.ts +++ b/src/mol-repr/structure/representation/ellipsoid.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -37,7 +37,7 @@ export const EllipsoidParams = { }; export type EllipsoidParams = typeof EllipsoidParams export function getEllipsoidParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(EllipsoidParams); + return EllipsoidParams; } export type EllipsoidRepresentation = StructureRepresentation<EllipsoidParams> diff --git a/src/mol-repr/structure/representation/gaussian-surface.ts b/src/mol-repr/structure/representation/gaussian-surface.ts index 4fa334354..b7cf518d3 100644 --- a/src/mol-repr/structure/representation/gaussian-surface.ts +++ b/src/mol-repr/structure/representation/gaussian-surface.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -28,7 +28,7 @@ export const GaussianSurfaceParams = { }; export type GaussianSurfaceParams = typeof GaussianSurfaceParams export function getGaussianSurfaceParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(GaussianSurfaceParams); + return GaussianSurfaceParams; } export type GaussianSurfaceRepresentation = StructureRepresentation<GaussianSurfaceParams> diff --git a/src/mol-repr/structure/representation/gaussian-volume.ts b/src/mol-repr/structure/representation/gaussian-volume.ts index 17e70940e..152caf340 100644 --- a/src/mol-repr/structure/representation/gaussian-volume.ts +++ b/src/mol-repr/structure/representation/gaussian-volume.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -18,13 +18,12 @@ const GaussianVolumeVisuals = { export const GaussianVolumeParams = { ...GaussianDensityVolumeParams, + jumpLength: PD.Numeric(4, { min: 0, max: 20, step: 0.1 }), visuals: PD.MultiSelect(['gaussian-volume'], PD.objectToOptions(GaussianVolumeVisuals)), }; export type GaussianVolumeParams = typeof GaussianVolumeParams export function getGaussianVolumeParams(ctx: ThemeRegistryContext, structure: Structure) { - const p = PD.clone(GaussianVolumeParams); - p.jumpLength = PD.Numeric(4, { min: 0, max: 20, step: 0.1 }); - return p; + return GaussianVolumeParams; } export type GaussianVolumeRepresentation = StructureRepresentation<GaussianVolumeParams> diff --git a/src/mol-repr/structure/representation/label.ts b/src/mol-repr/structure/representation/label.ts index 1d45b7210..c8f54dc2e 100644 --- a/src/mol-repr/structure/representation/label.ts +++ b/src/mol-repr/structure/representation/label.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -22,7 +22,7 @@ export const LabelParams = { }; export type LabelParams = typeof LabelParams export function getLabelParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(LabelParams); + return LabelParams; } export type LabelRepresentation = StructureRepresentation<LabelParams> diff --git a/src/mol-repr/structure/representation/line.ts b/src/mol-repr/structure/representation/line.ts index 65bed46df..f34eba0e6 100644 --- a/src/mol-repr/structure/representation/line.ts +++ b/src/mol-repr/structure/representation/line.ts @@ -16,6 +16,7 @@ import { Structure } from '../../../mol-model/structure'; import { getUnitKindsParam } from '../params'; import { ElementPointParams, ElementPointVisual } from '../visual/element-point'; import { ElementCrossParams, ElementCrossVisual } from '../visual/element-cross'; +import { Points } from '../../../mol-geo/geometry/points/points'; const LineVisuals = { 'intra-bond': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, IntraUnitBondLineParams>) => UnitsRepresentation('Intra-unit bond line', ctx, getParams, IntraUnitBondLineVisual), @@ -29,6 +30,7 @@ export const LineParams = { ...InterUnitBondLineParams, ...ElementPointParams, ...ElementCrossParams, + pointStyle: PD.Select('circle', PD.objectToOptions(Points.StyleTypes)), multipleBonds: PD.Select('offset', PD.arrayToOptions(['off', 'symmetric', 'offset'] as const)), includeParent: PD.Boolean(false), sizeFactor: PD.Numeric(2, { min: 0.01, max: 10, step: 0.01 }), @@ -37,9 +39,7 @@ export const LineParams = { }; export type LineParams = typeof LineParams export function getLineParams(ctx: ThemeRegistryContext, structure: Structure) { - const params = PD.clone(LineParams); - params.pointStyle.defaultValue = 'circle'; - return params; + return LineParams; } export type LineRepresentation = StructureRepresentation<LineParams> diff --git a/src/mol-repr/structure/representation/molecular-surface.ts b/src/mol-repr/structure/representation/molecular-surface.ts index e5d51cdb9..93786a7bd 100644 --- a/src/mol-repr/structure/representation/molecular-surface.ts +++ b/src/mol-repr/structure/representation/molecular-surface.ts @@ -28,7 +28,7 @@ export const MolecularSurfaceParams = { }; export type MolecularSurfaceParams = typeof MolecularSurfaceParams export function getMolecularSurfaceParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(MolecularSurfaceParams); + return MolecularSurfaceParams; } export type MolecularSurfaceRepresentation = StructureRepresentation<MolecularSurfaceParams> diff --git a/src/mol-repr/structure/representation/orientation.ts b/src/mol-repr/structure/representation/orientation.ts index 80b1a3aa0..8b09d6c88 100644 --- a/src/mol-repr/structure/representation/orientation.ts +++ b/src/mol-repr/structure/representation/orientation.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -24,7 +24,7 @@ export const OrientationParams = { }; export type OrientationParams = typeof OrientationParams export function getOrientationParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(OrientationParams); + return OrientationParams; } export type OrientationRepresentation = StructureRepresentation<OrientationParams> diff --git a/src/mol-repr/structure/representation/point.ts b/src/mol-repr/structure/representation/point.ts index 0bcddfe18..504cbbd02 100644 --- a/src/mol-repr/structure/representation/point.ts +++ b/src/mol-repr/structure/representation/point.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -21,7 +21,7 @@ export const PointParams = { }; export type PointParams = typeof PointParams export function getPointParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(PointParams); + return PointParams; } export type PointRepresentation = StructureRepresentation<PointParams> diff --git a/src/mol-repr/structure/representation/spacefill.ts b/src/mol-repr/structure/representation/spacefill.ts index f03d0cf2d..7a7da4953 100644 --- a/src/mol-repr/structure/representation/spacefill.ts +++ b/src/mol-repr/structure/representation/spacefill.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -22,12 +22,17 @@ export const SpacefillParams = { bumpFrequency: PD.Numeric(1, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory), }; export type SpacefillParams = typeof SpacefillParams + +let CoarseGrainedSpacefillParams: SpacefillParams; export function getSpacefillParams(ctx: ThemeRegistryContext, structure: Structure) { - const params = PD.clone(SpacefillParams); if (structure.isCoarseGrained) { - params.sizeFactor.defaultValue = 2; + if (!CoarseGrainedSpacefillParams) { + CoarseGrainedSpacefillParams = PD.clone(SpacefillParams); + CoarseGrainedSpacefillParams.sizeFactor.defaultValue = 2; + } + return CoarseGrainedSpacefillParams; } - return params; + return SpacefillParams; } export type SpacefillRepresentation = StructureRepresentation<SpacefillParams> -- GitLab