Browse Source

fix handling of structure loci selection

Alexander Rose 5 years ago
parent
commit
58a49a8512

+ 9 - 1
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';
     }

+ 3 - 0
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)
             }