Skip to content
Snippets Groups Projects
Commit 58a49a85 authored by Alexander Rose's avatar Alexander Rose
Browse files

fix handling of structure loci selection

parent 98bb9575
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @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 { UniqueArray } from '../../../mol-data/generic'
import { SymmetryOperator } from '../../../mol-math/geometry/symmetry-operator' import { SymmetryOperator } from '../../../mol-math/geometry/symmetry-operator'
import { Model, ElementIndex } from '../model' import { Model, ElementIndex } from '../model'
...@@ -345,6 +345,14 @@ namespace Structure { ...@@ -345,6 +345,14 @@ namespace Structure {
return { kind: 'structure-loci', 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 { export function isLoci(x: any): x is Loci {
return !!x && x.kind === 'structure-loci'; return !!x && x.kind === 'structure-loci';
} }
......
...@@ -97,6 +97,9 @@ namespace Interactivity { ...@@ -97,6 +97,9 @@ namespace Interactivity {
loci = Link.toStructureElementLoci(loci) loci = Link.toStructureElementLoci(loci)
} }
loci = Granularity[this.props.granularity](loci) loci = Granularity[this.props.granularity](loci)
if (Structure.isLoci(loci)) {
loci = Structure.toStructureElementLoci(loci)
}
if (StructureElement.isLoci(loci) && loci.structure.parent) { if (StructureElement.isLoci(loci) && loci.structure.parent) {
loci = StructureElement.Loci.remap(loci, loci.structure.parent) loci = StructureElement.Loci.remap(loci, loci.structure.parent)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment