Browse Source

don't apply granularity in StructureSelectionControls

Alexander Rose 5 years ago
parent
commit
1e9fa003db

+ 1 - 1
src/mol-plugin/ui/structure/selection.tsx

@@ -69,7 +69,7 @@ export class StructureSelectionControls<P, S extends StructureSelectionControlsS
 
     set = (modifier: SelectionModifier, value: string) => {
         const query = StructureSelectionQueries[value as keyof typeof StructureSelectionQueries]
-        this.plugin.helpers.structureSelection.set(modifier, query.query)
+        this.plugin.helpers.structureSelection.set(modifier, query.query, false)
     }
 
     add = (value: string) => this.set('add', value)

+ 15 - 16
src/mol-plugin/util/interactivity.ts

@@ -126,8 +126,8 @@ namespace Interactivity {
     export class LociHighlightManager extends LociMarkManager {
         private prev: Loci = { loci: EmptyLoci, repr: void 0 };
 
-        highlightOnly(current: Loci) {
-            const normalized = this.normalizedLoci(current)
+        highlightOnly(current: Loci, applyGranularity = true) {
+            const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 const loci = normalized.loci;
                 this.mark(this.prev, MarkerAction.RemoveHighlight);
@@ -143,8 +143,8 @@ namespace Interactivity {
             }
         }
 
-        highlightOnlyExtend(current: Loci) {
-            const normalized = this.normalizedLoci(current)
+        highlightOnlyExtend(current: Loci, applyGranularity = true) {
+            const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 const loci = this.sel.tryGetRange(normalized.loci) || normalized.loci;
                 this.mark(this.prev, MarkerAction.RemoveHighlight);
@@ -158,8 +158,8 @@ namespace Interactivity {
     //
 
     export class LociSelectManager extends LociMarkManager {
-        selectToggle(current: Loci<ModelLoci>) {
-            const normalized = this.normalizedLoci(current)
+        selectToggle(current: Loci<ModelLoci>, applyGranularity = true) {
+            const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 this.toggleSel(normalized);
             } else {
@@ -167,33 +167,33 @@ namespace Interactivity {
             }
         }
 
-        selectExtend(current: Loci<ModelLoci>) {
-            const normalized = this.normalizedLoci(current)
+        selectExtend(current: Loci<ModelLoci>, applyGranularity = true) {
+            const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 const loci = this.sel.tryGetRange(normalized.loci) || normalized.loci;
                 this.toggleSel({ loci, repr: normalized.repr });
             }
         }
 
-        select(current: Loci<ModelLoci>) {
-            const normalized = this.normalizedLoci(current)
+        select(current: Loci<ModelLoci>, applyGranularity = true) {
+            const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 this.sel.add(normalized.loci);
             }
             this.mark(normalized, MarkerAction.Select);
         }
 
-        selectOnly(current: Loci<ModelLoci>) {
+        selectOnly(current: Loci<ModelLoci>, applyGranularity = true) {
             this.deselectAll()
-            const normalized = this.normalizedLoci(current)
+            const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 this.sel.set(normalized.loci);
             }
             this.mark(normalized, MarkerAction.Select);
         }
 
-        deselect(current: Loci<ModelLoci>) {
-            const normalized = this.normalizedLoci(current)
+        deselect(current: Loci<ModelLoci>, applyGranularity = true) {
+            const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 this.sel.remove(normalized.loci);
             }
@@ -206,8 +206,7 @@ namespace Interactivity {
         }
 
         deselectAllOnEmpty(current: Loci<ModelLoci>) {
-            const normalized = this.normalizedLoci(current)
-            if (isEmptyLoci(normalized.loci)) this.deselectAll()
+            if (isEmptyLoci(current.loci)) this.deselectAll()
         }
 
         private toggleSel(current: Loci<ModelLoci>) {

+ 6 - 6
src/mol-plugin/util/structure-selection-helper.ts

@@ -276,21 +276,21 @@ export class StructureSelectionHelper {
         return this.plugin.state.dataState.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Structure)).map(s => s.obj!.data)
     }
 
-    private _set(modifier: SelectionModifier, loci: Loci) {
+    private _set(modifier: SelectionModifier, loci: Loci, applyGranularity = true) {
         switch (modifier) {
             case 'add':
-                this.plugin.interactivity.lociSelects.select({ loci })
+                this.plugin.interactivity.lociSelects.select({ loci }, applyGranularity)
                 break
             case 'remove':
-                this.plugin.interactivity.lociSelects.deselect({ loci })
+                this.plugin.interactivity.lociSelects.deselect({ loci }, applyGranularity)
                 break
             case 'only':
-                this.plugin.interactivity.lociSelects.selectOnly({ loci })
+                this.plugin.interactivity.lociSelects.selectOnly({ loci }, applyGranularity)
                 break
         }
     }
 
-    set(modifier: SelectionModifier, query: StructureQuery) {
+    set(modifier: SelectionModifier, query: StructureQuery, applyGranularity = true) {
         for (const s of this.structures) {
             const current = this.plugin.helpers.structureSelectionManager.get(s)
             const currentSelection = Loci.isEmpty(current)
@@ -299,7 +299,7 @@ export class StructureSelectionHelper {
 
             const result = query(new QueryContext(s, { currentSelection }))
             const loci = StructureSelection.toLociWithSourceUnits(result)
-            this._set(modifier, loci)
+            this._set(modifier, loci, applyGranularity)
         }
     }