diff --git a/src/mol-model/structure/structure/element/loci.ts b/src/mol-model/structure/structure/element/loci.ts index 3acf34f68296cbd645377d09a64f488d095b4e4c..45268283f84cda07bbd94fb52dcc93b22f8014d2 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 7366c99e958d8a64e503c2571f25c9b9c9cebaa8..bb51efc2c655377dbbcb7abfcb1144135839451e 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 b6b38d23da8910887297109ffa2fd1c05df6d019..c66892adbaadcaafda89474371ab14594b1baaaa 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)