Browse Source

fix whole structure selection/highlighting

Alexander Rose 5 years ago
parent
commit
6e1e463e1d

+ 3 - 3
src/mol-model/structure/structure/structure.ts

@@ -505,12 +505,12 @@ namespace Structure {
         return { kind: 'structure-loci', structure };
     }
 
-    export function toStructureElementLoci(loci: Loci): StructureElement.Loci {
+    export function toStructureElementLoci(structure: Structure): StructureElement.Loci {
         const elements: StructureElement.Loci['elements'][0][] = []
-        for (const unit of loci.structure.units) {
+        for (const unit of structure.units) {
             elements.push({ unit, indices: Interval.ofBounds(0, unit.elements.length) })
         }
-        return StructureElement.Loci(loci.structure, elements);
+        return StructureElement.Loci(structure, elements);
     }
 
     export function isLoci(x: any): x is Loci {

+ 1 - 1
src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts

@@ -149,7 +149,7 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W
                 } else if (Link.isLoci(current.loci)) {
                     loci = Link.toStructureElementLoci(current.loci);
                 } else if (Structure.isLoci(current.loci)) {
-                    loci = Structure.toStructureElementLoci(current.loci);
+                    loci = Structure.toStructureElementLoci(current.loci.structure);
                 } else {
                     return;
                 }

+ 1 - 1
src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts

@@ -262,7 +262,7 @@ export namespace VolumeStreaming {
             } else if (Link.isLoci(loci)) {
                 return Link.toStructureElementLoci(loci);
             } else if (Structure.isLoci(loci)) {
-                return Structure.toStructureElementLoci(loci);
+                return Structure.toStructureElementLoci(loci.structure);
             } else {
                 return EmptyLoci;
             }

+ 2 - 2
src/mol-plugin/util/interactivity.ts

@@ -56,7 +56,7 @@ namespace Interactivity {
         'element': (loci: ModelLoci) => loci,
         'residue': (loci: ModelLoci) => SE.Loci.is(loci) ? SE.Loci.extendToWholeResidues(loci, true) : loci,
         'chain': (loci: ModelLoci) => SE.Loci.is(loci) ? SE.Loci.extendToWholeChains(loci) : loci,
-        'structure': (loci: ModelLoci) => SE.Loci.is(loci) ? Structure.Loci(loci.structure) : loci
+        'structure': (loci: ModelLoci) => SE.Loci.is(loci) ? Structure.toStructureElementLoci(loci.structure) : loci
     }
     type Granularity = keyof typeof Granularity
     const GranularityOptions = Object.keys(Granularity).map(n => [n, capitalize(n)]) as [Granularity, string][]
@@ -99,7 +99,7 @@ namespace Interactivity {
             }
             if (Structure.isLoci(loci)) {
                 // convert to StructureElement.Loci
-                loci = Structure.toStructureElementLoci(loci)
+                loci = Structure.toStructureElementLoci(loci.structure)
             }
             if (StructureElement.Loci.is(loci)) {
                 // ensure the root structure is used