message: ignore non StructureElement loci in StructureElementSelectionManager
diff: * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  + * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
  import { OrderedSet } from '../../mol-data/int';
  @@ -29,26 +30,38 @@ class StructureElementSelectionManager {
  return this.entries.get(ref)!;
  }
  - add(loci: StructureElement.Loci): Loci {
  + add(loci: Loci): Loci {
  + if (StructureElement.isLoci(loci)) {
  const entry = this.getEntry(loci.structure);
  - if (!entry) return EmptyLoci;
  + if (entry) {
  entry.selection = StructureElement.Loci.union(entry.selection, loci);
  return entry.selection;
  }
  + }
  + return EmptyLoci
  + }
  - remove(loci: StructureElement.Loci): Loci {
  + remove(loci: Loci): Loci {
  + if (StructureElement.isLoci(loci)) {
  const entry = this.getEntry(loci.structure);
  - if (!entry) return EmptyLoci;
  + if (entry) {
  entry.selection = StructureElement.Loci.subtract(entry.selection, loci);
  return entry.selection.elements.length === 0 ? EmptyLoci : entry.selection;
  }
  + }
  + return EmptyLoci
  + }
  - set(loci: StructureElement.Loci): Loci {
  + set(loci: Loci): Loci {
  + if (StructureElement.isLoci(loci)) {
  const entry = this.getEntry(loci.structure);
  - if (!entry) return EmptyLoci;
  + if (entry) {
  entry.selection = loci;
  return entry.selection.elements.length === 0 ? EmptyLoci : entry.selection;
  }
  + }
  + return EmptyLoci;
  + }
  clear() {
  const keys = this.entries.keys();
  @@ -69,13 +82,18 @@ class StructureElementSelectionManager {
  return entry.selection;
  }
  - has(loci: StructureElement.Loci) {
  + has(loci: Loci) {
  + if (StructureElement.isLoci(loci)) {
  const entry = this.getEntry(loci.structure);
  - if (!entry) return false;
  + if (entry) {
  return StructureElement.Loci.areIntersecting(loci, entry.selection);
  }
  + }
  + return false;
  + }
  - tryGetRange(loci: StructureElement.Loci): StructureElement.Loci | undefined {
  + tryGetRange(loci: Loci): StructureElement.Loci | undefined {
  + if (!StructureElement.isLoci(loci)) return;
  if (loci.elements.length !== 1) return;
  const entry = this.getEntry(loci.structure);
  if (!entry) return;
  @@ -110,12 +128,14 @@ class StructureElementSelectionManager {
  private prevHighlight: StructureElement.Loci | undefined = void 0;
  - accumulateInteractiveHighlight(loci: StructureElement.Loci) {
  + accumulateInteractiveHighlight(loci: Loci) {
  + if (StructureElement.isLoci(loci)) {
  if (this.prevHighlight) {
  this.prevHighlight = StructureElement.Loci.union(this.prevHighlight, loci);
  } else {
  this.prevHighlight = loci;
  }
  + }
  return this.prevHighlight;
  }
  