diff --git a/src/mol-model/structure/structure/structure.ts b/src/mol-model/structure/structure/structure.ts index 724bec9bce62069ea60f093cdcda3953d4b399e3..d91b0234676ebde0f89c8ad20a3fdcd8531c7663 100644 --- a/src/mol-model/structure/structure/structure.ts +++ b/src/mol-model/structure/structure/structure.ts @@ -5,7 +5,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { IntMap, SortedArray, Iterator, Segmentation } from '../../../mol-data/int' +import { IntMap, SortedArray, Iterator, Segmentation, Interval } from '../../../mol-data/int' import { UniqueArray } from '../../../mol-data/generic' import { SymmetryOperator } from '../../../mol-math/geometry/symmetry-operator' import { Model, ElementIndex } from '../model' @@ -345,6 +345,14 @@ namespace Structure { return { kind: 'structure-loci', structure }; } + export function toStructureElementLoci(loci: Loci): StructureElement.Loci { + const elements: StructureElement.Loci['elements'][0][] = [] + for (const unit of loci.structure.units) { + elements.push({ unit, indices: Interval.ofBounds(0, unit.elements.length) }) + } + return StructureElement.Loci(loci.structure, elements); + } + export function isLoci(x: any): x is Loci { return !!x && x.kind === 'structure-loci'; } diff --git a/src/mol-plugin/util/interactivity.ts b/src/mol-plugin/util/interactivity.ts index 61fff02d163329106e743c378161839bf6f3d84a..dac8ca4bcb38543830e3795a29e2c304a303798a 100644 --- a/src/mol-plugin/util/interactivity.ts +++ b/src/mol-plugin/util/interactivity.ts @@ -97,6 +97,9 @@ namespace Interactivity { loci = Link.toStructureElementLoci(loci) } loci = Granularity[this.props.granularity](loci) + if (Structure.isLoci(loci)) { + loci = Structure.toStructureElementLoci(loci) + } if (StructureElement.isLoci(loci) && loci.structure.parent) { loci = StructureElement.Loci.remap(loci, loci.structure.parent) }