From c5a99a7c128ab993805d7eba33324fd63ee6bde1 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Fri, 4 Oct 2019 17:07:08 -0700 Subject: [PATCH] improved lociApply for whole structures --- src/mol-model/structure/structure/element/loci.ts | 6 +++++- src/mol-repr/structure/complex-visual.ts | 15 ++++++++++++--- src/mol-repr/structure/units-visual.ts | 15 ++++++++++++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/mol-model/structure/structure/element/loci.ts b/src/mol-model/structure/structure/element/loci.ts index 3acf34f68..45268283f 100644 --- a/src/mol-model/structure/structure/element/loci.ts +++ b/src/mol-model/structure/structure/element/loci.ts @@ -54,7 +54,11 @@ export namespace Loci { } export function isEmpty(loci: Loci) { - return size(loci) === 0 ? true : false + return size(loci) === 0 + } + + export function isWholeStructure(loci: Loci) { + return size(loci) === loci.structure.elementCount } export function size(loci: Loci) { diff --git a/src/mol-repr/structure/complex-visual.ts b/src/mol-repr/structure/complex-visual.ts index 7366c99e9..bb51efc2c 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -7,7 +7,7 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { StructureParams, StructureMeshParams, StructureDirectVolumeParams } from './representation'; import { Visual, VisualContext } from '../visual'; -import { Structure } from '../../mol-model/structure'; +import { Structure, StructureElement } from '../../mol-model/structure'; import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; import { LocationIterator } from '../../mol-geo/util/location-iterator'; import { Theme, createEmptyTheme } from '../../mol-theme/theme'; @@ -164,8 +164,17 @@ export function ComplexVisual<G extends Geometry, P extends ComplexParams & Geom if (newGeometry) geometry = newGeometry } + function lociIsSuperset(loci: Loci) { + if (isEveryLoci(loci)) return true + if (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructure)) return true + if (StructureElement.Loci.is(loci) && Structure.areRootsEquivalent(loci.structure, currentStructure)) { + if (StructureElement.Loci.isWholeStructure(loci)) return true + } + return false + } + function lociApply(loci: Loci, apply: (interval: Interval) => boolean) { - if (isEveryLoci(loci) || (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructure))) { + if (lociIsSuperset(loci)) { return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount)) } else { return eachLocation(loci, currentStructure, apply) diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index b6b38d23d..c66892adb 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -1,11 +1,11 @@ /** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { ParamDefinition as PD } from '../../mol-util/param-definition'; -import { Structure, Unit } from '../../mol-model/structure'; +import { Structure, Unit, StructureElement } from '../../mol-model/structure'; import { RepresentationProps } from '../representation'; import { Visual, VisualContext } from '../visual'; import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; @@ -214,8 +214,17 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry : createEmptyGeometry(geometry) } + function lociIsSuperset(loci: Loci) { + if (isEveryLoci(loci)) return true + if (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructureGroup.structure)) return true + if (StructureElement.Loci.is(loci) && Structure.areRootsEquivalent(loci.structure, currentStructureGroup.structure)) { + if (StructureElement.Loci.isWholeStructure(loci)) return true + } + return false + } + function lociApply(loci: Loci, apply: (interval: Interval) => boolean) { - if (isEveryLoci(loci) || (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructureGroup.structure))) { + if (lociIsSuperset(loci)) { return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount)) } else { return eachLocation(loci, currentStructureGroup, apply) -- GitLab