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

don't apply granularity in StructureSelectionControls

parent 7868b229
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,7 @@ export class StructureSelectionControls<P, S extends StructureSelectionControlsS ...@@ -69,7 +69,7 @@ export class StructureSelectionControls<P, S extends StructureSelectionControlsS
set = (modifier: SelectionModifier, value: string) => { set = (modifier: SelectionModifier, value: string) => {
const query = StructureSelectionQueries[value as keyof typeof StructureSelectionQueries] 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) add = (value: string) => this.set('add', value)
......
...@@ -126,8 +126,8 @@ namespace Interactivity { ...@@ -126,8 +126,8 @@ namespace Interactivity {
export class LociHighlightManager extends LociMarkManager { export class LociHighlightManager extends LociMarkManager {
private prev: Loci = { loci: EmptyLoci, repr: void 0 }; private prev: Loci = { loci: EmptyLoci, repr: void 0 };
highlightOnly(current: Loci) { highlightOnly(current: Loci, applyGranularity = true) {
const normalized = this.normalizedLoci(current) const normalized = this.normalizedLoci(current, applyGranularity)
if (StructureElement.Loci.is(normalized.loci)) { if (StructureElement.Loci.is(normalized.loci)) {
const loci = normalized.loci; const loci = normalized.loci;
this.mark(this.prev, MarkerAction.RemoveHighlight); this.mark(this.prev, MarkerAction.RemoveHighlight);
...@@ -143,8 +143,8 @@ namespace Interactivity { ...@@ -143,8 +143,8 @@ namespace Interactivity {
} }
} }
highlightOnlyExtend(current: Loci) { highlightOnlyExtend(current: Loci, applyGranularity = true) {
const normalized = this.normalizedLoci(current) const normalized = this.normalizedLoci(current, applyGranularity)
if (StructureElement.Loci.is(normalized.loci)) { if (StructureElement.Loci.is(normalized.loci)) {
const loci = this.sel.tryGetRange(normalized.loci) || normalized.loci; const loci = this.sel.tryGetRange(normalized.loci) || normalized.loci;
this.mark(this.prev, MarkerAction.RemoveHighlight); this.mark(this.prev, MarkerAction.RemoveHighlight);
...@@ -158,8 +158,8 @@ namespace Interactivity { ...@@ -158,8 +158,8 @@ namespace Interactivity {
// //
export class LociSelectManager extends LociMarkManager { export class LociSelectManager extends LociMarkManager {
selectToggle(current: Loci<ModelLoci>) { selectToggle(current: Loci<ModelLoci>, applyGranularity = true) {
const normalized = this.normalizedLoci(current) const normalized = this.normalizedLoci(current, applyGranularity)
if (StructureElement.Loci.is(normalized.loci)) { if (StructureElement.Loci.is(normalized.loci)) {
this.toggleSel(normalized); this.toggleSel(normalized);
} else { } else {
...@@ -167,33 +167,33 @@ namespace Interactivity { ...@@ -167,33 +167,33 @@ namespace Interactivity {
} }
} }
selectExtend(current: Loci<ModelLoci>) { selectExtend(current: Loci<ModelLoci>, applyGranularity = true) {
const normalized = this.normalizedLoci(current) const normalized = this.normalizedLoci(current, applyGranularity)
if (StructureElement.Loci.is(normalized.loci)) { if (StructureElement.Loci.is(normalized.loci)) {
const loci = this.sel.tryGetRange(normalized.loci) || normalized.loci; const loci = this.sel.tryGetRange(normalized.loci) || normalized.loci;
this.toggleSel({ loci, repr: normalized.repr }); this.toggleSel({ loci, repr: normalized.repr });
} }
} }
select(current: Loci<ModelLoci>) { select(current: Loci<ModelLoci>, applyGranularity = true) {
const normalized = this.normalizedLoci(current) const normalized = this.normalizedLoci(current, applyGranularity)
if (StructureElement.Loci.is(normalized.loci)) { if (StructureElement.Loci.is(normalized.loci)) {
this.sel.add(normalized.loci); this.sel.add(normalized.loci);
} }
this.mark(normalized, MarkerAction.Select); this.mark(normalized, MarkerAction.Select);
} }
selectOnly(current: Loci<ModelLoci>) { selectOnly(current: Loci<ModelLoci>, applyGranularity = true) {
this.deselectAll() this.deselectAll()
const normalized = this.normalizedLoci(current) const normalized = this.normalizedLoci(current, applyGranularity)
if (StructureElement.Loci.is(normalized.loci)) { if (StructureElement.Loci.is(normalized.loci)) {
this.sel.set(normalized.loci); this.sel.set(normalized.loci);
} }
this.mark(normalized, MarkerAction.Select); this.mark(normalized, MarkerAction.Select);
} }
deselect(current: Loci<ModelLoci>) { deselect(current: Loci<ModelLoci>, applyGranularity = true) {
const normalized = this.normalizedLoci(current) const normalized = this.normalizedLoci(current, applyGranularity)
if (StructureElement.Loci.is(normalized.loci)) { if (StructureElement.Loci.is(normalized.loci)) {
this.sel.remove(normalized.loci); this.sel.remove(normalized.loci);
} }
...@@ -206,8 +206,7 @@ namespace Interactivity { ...@@ -206,8 +206,7 @@ namespace Interactivity {
} }
deselectAllOnEmpty(current: Loci<ModelLoci>) { deselectAllOnEmpty(current: Loci<ModelLoci>) {
const normalized = this.normalizedLoci(current) if (isEmptyLoci(current.loci)) this.deselectAll()
if (isEmptyLoci(normalized.loci)) this.deselectAll()
} }
private toggleSel(current: Loci<ModelLoci>) { private toggleSel(current: Loci<ModelLoci>) {
......
...@@ -276,21 +276,21 @@ export class StructureSelectionHelper { ...@@ -276,21 +276,21 @@ export class StructureSelectionHelper {
return this.plugin.state.dataState.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Structure)).map(s => s.obj!.data) 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) { switch (modifier) {
case 'add': case 'add':
this.plugin.interactivity.lociSelects.select({ loci }) this.plugin.interactivity.lociSelects.select({ loci }, applyGranularity)
break break
case 'remove': case 'remove':
this.plugin.interactivity.lociSelects.deselect({ loci }) this.plugin.interactivity.lociSelects.deselect({ loci }, applyGranularity)
break break
case 'only': case 'only':
this.plugin.interactivity.lociSelects.selectOnly({ loci }) this.plugin.interactivity.lociSelects.selectOnly({ loci }, applyGranularity)
break break
} }
} }
set(modifier: SelectionModifier, query: StructureQuery) { set(modifier: SelectionModifier, query: StructureQuery, applyGranularity = true) {
for (const s of this.structures) { for (const s of this.structures) {
const current = this.plugin.helpers.structureSelectionManager.get(s) const current = this.plugin.helpers.structureSelectionManager.get(s)
const currentSelection = Loci.isEmpty(current) const currentSelection = Loci.isEmpty(current)
...@@ -299,7 +299,7 @@ export class StructureSelectionHelper { ...@@ -299,7 +299,7 @@ export class StructureSelectionHelper {
const result = query(new QueryContext(s, { currentSelection })) const result = query(new QueryContext(s, { currentSelection }))
const loci = StructureSelection.toLociWithSourceUnits(result) const loci = StructureSelection.toLociWithSourceUnits(result)
this._set(modifier, loci) this._set(modifier, loci, applyGranularity)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment