From e7defe5258ea865a40ac3cfa72fab31d68e88ddd Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Mon, 11 Mar 2019 13:07:28 -0700 Subject: [PATCH] fixed isoValue equality checking --- src/mol-model/volume/data.ts | 6 ++---- src/mol-repr/volume/isosurface.ts | 10 ++++------ src/mol-repr/volume/representation.ts | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/mol-model/volume/data.ts b/src/mol-model/volume/data.ts index 7046b9fa2..df2964b68 100644 --- a/src/mol-model/volume/data.ts +++ b/src/mol-model/volume/data.ts @@ -6,7 +6,6 @@ import { SpacegroupCell, Box3D } from 'mol-math/geometry' import { Tensor, Mat4, Vec3 } from 'mol-math/linear-algebra' -import { shallowEqual } from 'mol-util/object'; /** The basic unit cell that contains the data. */ interface VolumeData { @@ -48,9 +47,8 @@ namespace VolumeIsoValue { export type Relative = Readonly<{ kind: 'relative', relativeValue: number }> export type Absolute = Readonly<{ kind: 'absolute', absoluteValue: number }> - export function areSame(a: VolumeIsoValue, b: VolumeIsoValue) { - // TODO: this should compare values converted to absolute value - return shallowEqual(a, b); + export function areSame(a: VolumeIsoValue, b: VolumeIsoValue, stats: VolumeData['dataStats']) { + return toAbsolute(a, stats).absoluteValue === toAbsolute(b, stats).absoluteValue } export function absolute(value: number): Absolute { return { kind: 'absolute', absoluteValue: value }; } diff --git a/src/mol-repr/volume/isosurface.ts b/src/mol-repr/volume/isosurface.ts index 1fedbfc01..b29c7afe5 100644 --- a/src/mol-repr/volume/isosurface.ts +++ b/src/mol-repr/volume/isosurface.ts @@ -96,9 +96,8 @@ export function IsosurfaceMeshVisual(): VolumeVisual<IsosurfaceMeshParams> { createLocationIterator: (volume: VolumeData) => LocationIterator(1, 1, () => NullLocation), getLoci: () => EmptyLoci, eachLocation: () => false, - setUpdateState: (state: VisualUpdateState, newProps: PD.Values<IsosurfaceMeshParams>, currentProps: PD.Values<IsosurfaceMeshParams>) => { - // TODO: should convert to same type of isoValue 1st - if (!VolumeIsoValue.areSame(newProps.isoValue, currentProps.isoValue)) state.createGeometry = true + setUpdateState: (state: VisualUpdateState, volume: VolumeData, newProps: PD.Values<IsosurfaceMeshParams>, currentProps: PD.Values<IsosurfaceMeshParams>) => { + if (!VolumeIsoValue.areSame(newProps.isoValue, currentProps.isoValue, volume.dataStats)) state.createGeometry = true }, geometryUtils: Mesh.Utils }) @@ -133,9 +132,8 @@ export function IsosurfaceWireframeVisual(): VolumeVisual<IsosurfaceWireframePar createLocationIterator: (volume: VolumeData) => LocationIterator(1, 1, () => NullLocation), getLoci: () => EmptyLoci, eachLocation: () => false, - setUpdateState: (state: VisualUpdateState, newProps: PD.Values<IsosurfaceWireframeParams>, currentProps: PD.Values<IsosurfaceWireframeParams>) => { - // TODO: should convert to same type of isoValue 1st - if (!VolumeIsoValue.areSame(newProps.isoValue, currentProps.isoValue)) state.createGeometry = true + setUpdateState: (state: VisualUpdateState, volume: VolumeData, newProps: PD.Values<IsosurfaceWireframeParams>, currentProps: PD.Values<IsosurfaceWireframeParams>) => { + if (!VolumeIsoValue.areSame(newProps.isoValue, currentProps.isoValue, volume.dataStats)) state.createGeometry = true }, geometryUtils: Lines.Utils }) diff --git a/src/mol-repr/volume/representation.ts b/src/mol-repr/volume/representation.ts index 97324e213..9b2472a4c 100644 --- a/src/mol-repr/volume/representation.ts +++ b/src/mol-repr/volume/representation.ts @@ -44,7 +44,7 @@ interface VolumeVisualBuilder<P extends VolumeParams, G extends Geometry> { createLocationIterator(volume: VolumeData): LocationIterator getLoci(pickingId: PickingId, id: number): Loci eachLocation(loci: Loci, apply: (interval: Interval) => boolean): boolean - setUpdateState(state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme): void + setUpdateState(state: VisualUpdateState, volume: VolumeData, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme): void } interface VolumeVisualGeometryBuilder<P extends VolumeParams, G extends Geometry> extends VolumeVisualBuilder<P, G> { @@ -91,7 +91,7 @@ export function VolumeVisual<G extends Geometry, P extends VolumeParams & Geomet return } - setUpdateState(updateState, newProps, currentProps, newTheme, currentTheme) + setUpdateState(updateState, volume, newProps, currentProps, newTheme, currentTheme) if (!ColorTheme.areEqual(theme.color, currentTheme.color)) updateState.updateColor = true -- GitLab