diff --git a/src/mol-plugin/ui/structure/selection.tsx b/src/mol-plugin/ui/structure/selection.tsx index f3d809faf478237269b5554a138cb0edd80c144f..9d9d3b63a3acb8eef5cb9b05f19fad52c4be8fe1 100644 --- a/src/mol-plugin/ui/structure/selection.tsx +++ b/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) diff --git a/src/mol-plugin/util/interactivity.ts b/src/mol-plugin/util/interactivity.ts index 1bb7bc1d280d4aac12c997636eb4759cded1bac1..e138d1167b1d380a370e1157509a6daf6a5cde4a 100644 --- a/src/mol-plugin/util/interactivity.ts +++ b/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>) { diff --git a/src/mol-plugin/util/structure-selection-helper.ts b/src/mol-plugin/util/structure-selection-helper.ts index e16e8f9b937253a6e697798cfe30f7259cfbaabe..112484db60e13f9420e0aeba92919cbfd63c79bc 100644 --- a/src/mol-plugin/util/structure-selection-helper.ts +++ b/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) } }